Skip to main content
v2026.11,986 entries · CC-BY 4.0

CasADi: What It Is, What It Does, How to Cite It

What CasADi is, how SX, MX and Opti differ, which solvers it interfaces, and how to cite and report it for reproducible research.

Written and maintained by CASRAI Editorial Board

Published

On this page

CasADi is an open-source software framework for nonlinear optimization and algorithmic (automatic) differentiation, used to implement numerical optimal control, including offline and nonlinear model predictive control (NMPC). It builds symbolic expression graphs, differentiates them in forward and reverse mode, and passes the resulting problems to external solvers such as IPOPT. It is licensed under LGPL-3.0, and its authors ask users to cite a 2019 Mathematical Programming Computation paper.

Definition and scope

The project home page describes CasADi as an open-source tool for nonlinear optimization and algorithmic differentiation, and says it supports rapid implementation of numerical optimal control. The GitHub repository describes it as a symbolic framework for numeric optimization that performs automatic differentiation in forward and reverse modes on sparse matrix-valued computational graphs, with self-contained C code generation and interfaces to SUNDIALS and IPOPT. Languages named in the repository are C++, Python, Matlab/Octave, Julia and JavaScript.

In practice this means CasADi sits between a researcher’s mathematical model and a numerical solver. The researcher writes the model (dynamics, cost, constraints) once using symbolic variables; CasADi supplies the derivatives the solver needs (gradients, sparse Jacobians, Hessians) and hands the problem to a solver. It is relevant wherever an optimization problem is built from differential equations, which is why it appears in control theory and robotics work, and in model-based studies such as musculoskeletal simulation, where optimal control formulations are common. Those applications are examples of fit, not claims made by the project about specific users.

How CasADi is used in practice

Algorithmic differentiation on expression graphs

According to the project site, CasADi’s forward and reverse algorithmic differentiation operate on expression graphs to calculate gradients, sparse Jacobians and Hessians. The graphs can be evaluated in CasADi’s own virtual machine or exported as standalone C code. Because derivatives come from the graph itself, the user does not hand-derive or finite-difference them.

Initial value problems and sensitivities

CasADi can solve initial value problems for ordinary and differential-algebraic equations (ODEs and DAEs). The project site lists explicit and implicit Runge-Kutta integrators and interfaces to the SUNDIALS integrators IDAS and CVODES, with sensitivities obtained through sensitivity equations to arbitrary order.

Nonlinear and quadratic programs

For optimization, the project site states that CasADi supports nonlinear programs (NLPs) and mixed-integer nonlinear programs (MINLPs) through sequential quadratic programming and solver interfaces, and quadratic programs (QPs) and mixed-integer QPs. Optimal control building blocks include single shooting. The data table below lists the NLP and QP solvers the project site names as interfaced; CasADi does not replace them, it formulates the problem and supplies derivatives. For the broader problem class, see the mixed-integer programming guide; for convex modelling in Python, compare CVXPY.

The Opti stack

The CasADi user guide (version 3.8.2 when read on 2026-11-12) presents the Opti stack as a higher-level interface to the optimization machinery, and says it can be learned stand-alone. The guide’s worked example minimizes x2 + 100z2 subject to z + (1 − x)2 − y = 0, solved with nlpsol and IPOPT from the starting point [2.5, 3.0, 0.75], reaching approximately x = 0, y = 1, z = 0.

Code generation

A CasADi Function can be exported with Function.generate('gen.c'), producing self-contained C code. The user guide lists options for generating a main function, a MEX interface and a header. The guide gives a rule of thumb that the generated code, compiled with optimization flags, is roughly 4 to 10 times faster than evaluation in CasADi’s virtual machines.

SX, MX and Opti: choosing a symbolic type

CasADi has two symbolic types, and the user guide distinguishes them clearly. This comparison is compiled from that guide.

Item What the user guide says Consequence
SX Scalar symbolic expressions with low per-operation overhead. Every scalar operation is its own node. For 3*x + y on a 2×2 matrix x, the guide counts 8 SX operations.
MX Matrix-valued expression graphs that allow function calls with multiple inputs and outputs to appear as single operations. The same 3*x + y expression is 2 MX operations in the guide’s count.
Mixing SX and MX cannot be mixed in one expression. An MX graph can, however, call an SX Function, so the two can be combined at function level.
Opti stack A higher-level interface to the optimization functionality (guide Chapter 9). Can be learned without first mastering SX and MX.

The guide does not prescribe one type for every problem, so any rule beyond these statements is an editorial reading: the operation counts above explain why MX is described as suited to larger, structured graphs and SX to scalar-heavy ones, but a team should test its own model.

Platforms, installation and documentation

The GitHub repository points to install.casadi.org for installation instructions. The user guide states that CasADi runs on Linux, OS X and Windows, that the Python API is the best documented, and that Octave version 4.0.2 or later has been tested. A researcher who plans to share code should therefore state the interface used (for example Python or Matlab) as well as the CasADi version, because the examples and API coverage in the guide are not equally detailed across languages.

Reading the user guide’s worked example

The guide’s introductory problem has three decision variables (x, y, z), a nonlinear cost, and one equality constraint. Formulating it needs only symbolic variables, an objective expression and a constraint expression; CasADi then derives the gradient and Jacobian information IPOPT needs, so the user supplies no derivative code. The guide reports the solution as approximately x = 0, y = 1, z = 0 from the stated starting point. For a nonlinear problem, a different starting point can in general lead a solver to a different result, which is why recording the starting point belongs in a methods section.

  • Algorithmic (automatic) differentiation: exact derivatives computed from the program or graph rather than by symbolic algebra on paper or numerical finite differences. CasADi implements forward and reverse modes.
  • Numerical optimal control: turning a continuous-time control problem into a finite-dimensional NLP. CasADi provides building blocks, including single shooting, and a framework for assembling the rest.
  • Model predictive control: the project site names offline and nonlinear MPC among the supported uses.
  • Algebraic modelling languages: tools such as AMPL, GAMS, JuMP and Pyomo. Secondary summaries of the CasADi paper say it offers more flexibility than these; check the paper itself before repeating that comparison in your own work.

Where it matters in research practice

Citation

The project asks users to cite: Joel A E Andersson, Joris Gillis, Greg Horn, James B Rawlings and Moritz Diehl, “CasADi: A software framework for nonlinear optimization and optimal control,” Mathematical Programming Computation 11(1):1–36, Springer, 2019, DOI 10.1007/s12532-018-0139-4 (publications page, read 2026-11-12). Software citation is a recognised part of research output; see formal methods for a related reproducibility context.

Licensing

The GitHub repository states the licence is LGPL-3.0. That is the licence fact only; whether a particular institutional or commercial use is compatible is a question for the institution’s technology-transfer or legal office.

Reproducibility checklist

The following is an editorial checklist derived from the sources above (the citation request, and the fact that results depend on the CasADi release and the chosen solver):

  1. Record the CasADi version (the user guide read for this page documents 3.8.2).
  2. Record which NLP or QP solver was called, and its version, since CasADi interfaces solvers rather than being one itself.
  3. Record the starting point and solver options used, as in the user guide’s IPOPT example, where the starting point is stated.
  4. Cite the 2019 paper by DOI.
  5. Share the model script; if generated C code was used, state that it came from Function.generate.

Common misunderstandings

  • “CasADi is a solver.” It interfaces solvers such as IPOPT, BONMIN, WORHP, KNITRO, SNOPT, CPLEX, GUROBI and qpOASES; it supplies the problem formulation and derivatives.
  • “It is only for Python.” The repository names C++, Python, Matlab/Octave, Julia and JavaScript; the user guide notes the Python API is the best documented.
  • “SX and MX are interchangeable.” They cannot be mixed in one expression, though an MX graph can call an SX Function.
  • “It only solves optimal control.” The project site describes general nonlinear optimization and algorithmic differentiation, with optimal control as a headline use.

Frequently asked questions

What is CasADi used for?

Nonlinear optimization and algorithmic differentiation, in particular implementing numerical optimal control and nonlinear model predictive control (project site, read 2026-11-12).

Which languages does CasADi support?

C++, Python, Matlab/Octave, Julia and JavaScript are named in the GitHub repository. The user guide says it runs on Linux, OS X and Windows.

Is CasADi free?

It is open source under LGPL-3.0 per the GitHub repository. The solvers it interfaces have their own licences.

How do I cite CasADi?

Cite Andersson et al. (2019), Mathematical Programming Computation 11(1):1–36, DOI 10.1007/s12532-018-0139-4.

Sources

Data: Solvers interfaced by CasADi, by problem class

Compiled from the interfaced-solver lists on the CasADi project home page: which external NLP and QP solvers CasADi can call. Names and class labels follow the project's own lists.

Solvers interfaced by CasADi, by problem class
SolverProblem class listed by the project
IPOPTNonlinear program (NLP) solver
BONMINNonlinear program (NLP) solver
BlockSQPNonlinear program (NLP) solver
WORHPNonlinear program (NLP) solver
KNITRONonlinear program (NLP) solver
SNOPTNonlinear program (NLP) solver
SLEQPNonlinear program (NLP) solver
AlpaqaNonlinear program (NLP) solver
CPLEXQuadratic program (QP) solver
GUROBIQuadratic program (QP) solver
HPIPMQuadratic program (QP) solver
OOQPQuadratic program (QP) solver
qpOASESQuadratic program (QP) solver
HiGHSQuadratic program (QP) solver

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about CasADi: What It Is, What It Does, How to Cite It

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →