Install CasADi? Pick a version from below...
... or try out CasADi live in your browser (Python, Octave/Matlab).
CasADi v3.5.0
latest released October 2, 2019Grab a binary from the table (for MATLAB, use the newest compatible version below):
Windows  Linux  Mac  

Matlab  R2016a or later, R2014b, R2014a, R2013a or R2013b 
R2014b or later, R2014a 
R2015a or later, R2014b, R2014a 
Octave  4.4.1 (32bit / 64bit), 4.4.0 (32bit / 64bit), 5.1.0 (32bit / 64bit) 
4.4.1, 4.2.2, 5.1.0 
5.1.0 
Python  Py27 (32bit^{} / 64bit^{}), Py35 (32bit^{} / 64bit^{}), Py36 (32bit^{} / 64bit^{}), Py37 (32bit^{} / 64bit^{}) 
Py27, Py35, Py36, Py37 
Py27, Py35, Py36, Py37 
or just pip install casadi (needs pip V >=8.1) 
(^{*}) Check your Python console if you need 32bit or 64bit  bitness should be printed at startup.
Unzip in your home directory and adapt the path:
Matlab/Octave  Python 



Get started with the example pack.
CasADi Functions
 CasADi Functions can be serialized now (#308).
f.save('f.casadi') % Dump any CasADi Function to a file
f = Function.load('f.casadi') % Loads back in
This enables easy sharing of models/solver isntances beteen Matlab/Python/C++ crossplatform, and enables a form of parallelization.
 You can now evaluate CasADi Functions from C without requiring codegeneration. This makes it possible to embed CasADi computations in Fortran, Julia, FMI, ...
 All CasADi Functions support timing information now (
print_time
, default true for QP and NLP solvers). Userecord_time
to make timings available throughf.stats()
without printing them. map
with reduce arguments now has an efficient implementation (no copying/repmat) Lowoverhead Callback eval support was changed to
eval_buffer
FunctionInternal::finalize
no longer takes options dict. Options
always_inline
andnever_inline
were added  Options
is_diff_in
andis_diff_out
were added
CasADi expressions
 breaking:
IM
type is removed from public API (was used to represent integer sparse matrices). UseDM
instead.  breaking:
linspace(0,1,3)
andlinspace(0.0,1,3)
now both return[0 0.5 1]
instead of[0 0 1]
for the former MX
supports slicing withMX
now (symbolic indexing). Issue #2364:
 breaking:
veccat
of an empty list now returns0by1
instead of0by0
. jtimes
output dimensions have changed when any of the arguments is empty. NLP function object's 'lam_p' is now
0by1
in case of missing parameters.
 breaking:
Interpolation functionality
 Support for parametric (=changeable only, but not differentiable) grid and/or coefficients for linear/spline interpolation
 for
interpolant
, new constructors where added that takes dimensions instead of concrete vectors
 for
 Support for symbolic (differentiable) grid and coefficients for linear interpolation (set
inline
option to true).
Python specific
 Overheadless CasADi Function evaluation API added through Python memoryviews
 Similar functionality in Callbacks
Matlab/Octave specific
 breaking:
a(:)=b
now behaves like Matlab builtin matrices whena
is a CasADi matrix. Before, only the first column ofa
would be touched by this statement. (#2363)  breaking: Fixed bug where
MX
constructor treated a numeric row vector as column vector. Nowsize(MX(ones(1,4)))
returns(1,4)
as expected. (#2366)  Can now use spy directly on
DM
,MX
,SX
Opti
 Opti supports conic problems now:
Opti('conic')
 One can now easily obtain a parametric solution as a CasADi Function from an Opti instance:
opti = Opti()
x = opti.variable()
y = opti.variable()
p = opti.parameter()
opti.minimize(y**2+sin(xyp)**2)
opti.subject_to(x+y>=1)
opti.solver(nlpsolver,nlpsolver_options)
F = opti.to_function("F",[x,p,opti.lam_g],[x,y])
r = F(0,0.1,0)
 Using Opti together with
max_iter
is more natural now: usesolve_limited()
to avoid exceptions to be raised when iterations or time runs out. No need to try/catch.
Codegeneration
 breaking:
external
now looks for a.dylib
file, not.so
 breaking: Codegen API has changes related to threadlocal memory:
void* mem
changed toint mem
alloc_mem
,init_mem
,free_mem
have been purged.checkout
andrelease
replace them.
int mem = checkout();
eval(arg, res, iw, w, mem);
release(mem);
 Codegen 'CODEGEN_PREFIX' has been renamed to 'CASADI_CODEGEN_PREFIX'
 QP solvers (QRQP, OSQP) and SqpMethod codegenerate now. This means that embedded MPC with CasADi is now more practical.
 RungeKutta and Collocation Integrator objects can be inlined into codegeneratable MX Function with the 'simplify' option.
Solvers
 breaking: NLP solvers 
bound_consistency
, an option to postprocess the primal and dual solution by projecting it on the bounds, introduced in 3.4, was changed to defaultoff
 Sundials was patched to support multithreading
 WORHP was bumped to v1.13
 SNOPT was bumped to v7.7
 SuperSCS (conic solver) was added
 OSQP (QP solver) was added
CBC (LP solver) was added
breaking: SQP Method
regularize_margin
option was addedregularize
(bool) option was removed. To get the effect ofregularize=true
, specifyconvexify_strategy='regularize'
. Other strategies include clipping eigenvalues. line search was reverted from a custom designed thing, to standard textbook L1
CPLEX and Gurobi got support for sos constraints
Conic/qpsol interface extended for semidefinite programming and SOCP
 Solvers supporting SOCP:
Gurobi
,SuperSCS
,CPLEX
 Solvers supporting SOCP:
breaking: Newton Rootfinder now supports a
line_search
option (default true)Rootfinder now throws an exception by default ('error_on_fail' option true) when failing to converge
Convenience tools
 Debugging facilities:
 Function options
print_in
/print_in
print inputs/outputs when numerically evaluating a function  Function option
dump_in
/dump_out
dumps to the file system  Function option
dump
dumps the function itself (loadable withFunction.load
)
 Function options
DM.from_file
andDM.to_file
with aMatrixMarket
andtxt
support Helping interaction with codegen with
main=true
:Function.generate_in
/Function.nz_from_in
/Function.nz_to_in
to help creating input text files. Function.convert_in
/Function.convert_out
to switch between list and dictionary arguments/results
CasADi v3.4.5
released August 7, 2018Grab a binary from the table (for MATLAB, use the newest compatible version below):
Windows  Linux  Mac  

Matlab  R2016a or later, R2014b, R2014a, R2013a or R2013b 
R2014b or later, R2014a 
R2015a or later, R2014b, R2014a 
Octave  4.4.1 (32bit / 64bit), 4.4.0 (32bit / 64bit) 
4.4.1, 4.2.2 
4.4.0 
Python  Py27 (32bit^{*} / 64bit^{*}), Py35 (32bit^{*} / 64bit^{*}), Py36 (32bit^{*} / 64bit^{*}), Py37 (32bit^{*} / 64bit^{*}) 
Py27, Py35, Py36, Py37 
Py27, Py35, Py36, Py37 
or just pip install casadi (needs pip V >=8.1) 
(^{*}) Check your Python console if you need 32bit or 64bit  bitness should be printed at startup.
Unzip in your home directory and adapt the path:
Matlab/Octave  Python 



Get started with the example pack.
Credit where credit is due: Proper attribution of linear solver routines, reimplementation of code generation for linear solvers #2158, #2134
CasADi 3.3 introduced support for two sparse direct linear solvers relying based on sparse direct QR factorization and sparse direct LDL factorization, respectively. In the release notes and in the code, it was not made clear enough that part of these routines could be considered derivative works of CSparse and LDL, respectively, both under copyright of Tim Davis. In the current release, routines derived from CSparse and LDL are clearly marked as such and to be considered derivative work under LGPL. All these routines reside inside the casadi::Sparsity
class.
Since CasADi, CSparse and LDL all have the same opensource license (LGPL), this will not introduce any additional restrictions for users.
Since C code generated from CasADi is not LGPL (allowing CasADi users to use the generated code freely), all CSparse and LDL derived routines have been removed or replaced in CasADi's C runtime. This means that code generation for CasADi's 'qr' and 'ldl' is now possible without any additional license restrictions. A number of bugs have also been resolved.
Parametric sensitivity for NLP solvers #724
CasADi 3.4 introduces differentiability for NLP solver instances in CasADi. Derivatives can be calculated efficiently with either forward or reverse mode algorithmic differentiation. We will detail this functionality in future publications, but in the meantime, feel free to reach out to Joel if you have questions about the functionality. The implementation is based on using derivative propagation rules to the implicit function theorem, applied to the nonlinear KKT system. It is part of the NLP solver base class and should in principle work with any NLP solver, although the factorization and solution of the KKT system (based on the sparse QR above) is likely to be a speed bottle neck in applications. The derivative calculations also depend on accurate Lagrange multipliers to be available, in particular with the correct signs for all multipliers. Functions for calculating parametric sensitivities for a particular system can be C code generated.
A primaldual active set method for quadratic programming
The parametric sensitivity analysis for NLP solvers, detailed above, is only as good as the multipliers you provide to it. Multipliers from an interior point method such as IPOPT are usually not accurate enough to be used for the parametric sensitivity analysis, which in particular relies on knowledge of the active set. For this reason, we have started work on a primaldual active set method for quadratic programming. The method relies on the same factorization of the linearized KKT system as the parametric sensitivity analysis and will support C code generation. The solver is available as the "activeset" plugin in CasADi. The method is still workinprogress and in particular performs poorly if the Hessian matrix is not strictly positive definite.
Changes in Opti
describe
methods in Matlab now follows index1 based convention. Added
show_infeasibilities
to help debugging infeasible problems.  Added
opti.lbg,opti.ubg
Changes in existing functionality
 Some CasADi operations failed when the product of rows and columns of a matrix was larger then
2^311
. This limit has been raised to2^631
by changing CasADi integer types tocasadi_int
(long long
). The change is hidden for Python/Octave/Matlab users, but C++ users may be affected.  Fixed various bottlenecks in large scale MX Function initialization
 Nonzero location reports for NaN/Inf now follow index1 based convention in Matlab interface.
Added functionality
 SX Functions can be serialized/pickled/saved now.
 Added
forloop equivalents
to the users guide  New backend for parallel maps: "thread" target, shipped in the binaries.
 Uniform 'success' flag in
solver.stats()
fornlpsol
/conic
 Added
evalf
function to numerically evaluate an SX/MX matrix that does not depend on any symbols  Added
diff
andcumsum
(follows the Matlab convention)  Added a rootfinder plugin ('fast_newton') that can codegenerate
 Added binary search for Linear/BSpline Interpolant. Used by default for grid dimensions (>=100)
Binaries
 Binaries now come with a large set of plugins enabled
 Binaries ship with "thread" parallelization
 Binaries are hosted on Github instead of Sourceforge
Misc
 Default build mode is
Release
mode once again (as was always intended)  CasADi passes with
Werror
forgcc6
andgcc7
Getting error "CasADi is not running from its package context." in Python? Check that you have casadipy27v3.4.5/casadi/casadi.py
. If you have casadipy27v3.4.5/casadi.py
instead, that's not good; add an extra casadi
folder.
Got stuck while installing? You may also try out CasADi without installing, right in your browser (pick Python or Octave/Matlab).
CasADi v3.3.0
released November 14, 2017Grab a binary from the table (for MATLAB, use the newest compatible version below):
Windows  Linux  Mac  

Matlab  R2014b or later, R2014a, R2013a or R2013b 
R2014b or later, R2014a 
R2015a or later, R2014b, R2014a 
Octave  4.2.1 (32bit / 64bit)  4.2.1  4.2.1 
Python  Py27 (32bit^{1,2} / 64bit^{2}), Py35 (32bit^{2} / 64bit^{2}), Py36 (32bit^{2} / 64bit^{2}) 
Py27, Py35, Py36 
Py27, Py35, Py36 
^{1} Use this when you have Python(x,y). ^{2} Check your Python console if you need 32bit or 64bit  bitness should be printed at startup.
Or see the download page for more options.
Unzip in your home directory and adapt the path:
Matlab/Octave  Python 

addpath('.../casadimatlabR2014av3.3.0') import casadi.* x = MX.sym('x') disp(jacobian(sin(x),x)) 
from sys import path path.append(r".../casadipy27v3.3.0") from casadi import * x = MX.sym("x") print(jacobian(sin(x),x)) 
New: install with pip install casadi
Get started with the example pack.
New and improved features
Support for finite differences
CasADi is now able to calculate derivatives using finite differences approximations. To enable this feature, set the "enable_fd" option to true for a function object. If the function object has builtin derivative support, you can disable it by setting the options enable_forward
, enable_reverse
and enable_jacobian
to false.
The default algorithm is a central difference scheme with automatic stepsize selection based on estimates of truncation errors and roundoff errors. You can change this to a (cheaper, but less accurate) onesided scheme by setting fd_method
to forward
or backward
. There is also an experimental discontinuity avoiding scheme (suitable if the function is differentiated near nonsmooth points that can be enable by setting fd_method
to smoothing
.
New linear solvers with support for C code generation
Two sparse direct linear solvers have been added to CasADi's runtime core: One based on an uplooking QR factorization, calculated using Householder reflections, and one sparse direct LDL method (squareroot free variant of Cholesky). These solvers are available for both SX and MX, for MX as the linear solver plugins "qr" and "ldl", for MX as the methods "SX::qr_sparse" and "SX::ldl". They also support for C code generation (with the exception of LDL in MX).
Faster symbolic processing of MX graphs
A speed bottleneck, related to the topological sorting of large MX graphs has been identified and resolved. The complexity of the sorting algorithms is now linear in all cases.
Other improvements
A\y
andy'/A
now work in Matlab/Octave Matrix power works
 First major release with Opti
shell
compiler now works on Windows, allowing to dojit
using Visual Studio Added introspection methods
instruction_*
that work for SX/MX Functions. Seeaccessing_mx_algorithm
example to see how you can walk an MXgraph
.  Experimental feature to export SX/MX functions to pureMatlab code.
DM::rand
creates a matrix with random numbers.DM::rng
controls the seeding of the random number generator.
Distribution/build system
 Python interface no longer searches for/links to Python libraries (on Linux, OSX)
 Python interface no longer depends on Numpy at compiletime; CasADi works for any numpy version now
 Python binaries and wheels have come a step closer to true
manylinux
. CasADi should now run on CentOS 5.
API changes
Refactored printing of function objects
The default printout of Function instances is now shorter and consistent across different Function derived classes (SX/MX functions, NLP solvers, integrators, etc.). The new syntax is:
from casadi import *
x = SX.sym('x')
y = SX.sym('x',2)
f = Function('f', [x,y],[sin(x)+y], ['x', 'y'], ['r'])
print(f) # f:(x,y[2])>(r[2]) SXFunction
f.disp() # Equivalent syntax (MATLAB style)
f.disp(True) # Print algorithm
I.e. you get a list of inputs, with dimension if nonscalar, and a name of the internal class (here SXFunction).
You can also get the name as a string: str(f)
or f.str()
. If you want to print the algorithm, pass an optional argument "True", i.e. f.str(True)
or f.disp(True)
.
Changes to the codegen C API
The C API has seen continued improvements, in particular regarding the handling of external functions with memory allocation. See the user guide for the latest API.
Other changes
inv()
is now more efficient for largeSX
/DM
matrices, and is evaluatable forMX
(cparse
by default). The old variant is still available forSX
/MX
asinv_minor
, and forMX
asinv_node
. Linear solverrelated defaults are now set to
csparse
as opposed tosymbolicqr
 In Matlab, when the CasADi result is a
vector<bool>
, this gets mapped to a logical matrix. E.g.which_depends
is affected by this change.  The sumofsquares operator is now called
sumsqr
instead ofsum_square
.  The API of the
Linsol
class has changed.
casadipy27v3.3.0/casadi/casadi.py
. If you have casadipy27v3.3.0/casadi.py
instead, that's not good; add an extra casadi
folder.
CasADi v3.2.3
released September 11, 2017Grab a binary from the table (for MATLAB, use the newest compatible version below):
Windows 64 bit  Linux (14.04+)  Mac  

Matlab  R2014b or later  R2014b or later  R2015a or later 
R2014a  R2014a  R2014b  
R2013a or R2013b  R2014a  
Octave  4.2.1 32bit or 64bit  4.2.1  4.2.1 
Python  Py27 (py 32bit. In general: check your Python console. Bitness should be printed at startup.") or py 64bit )  Py27  Py27 
Py35 (py 32bit or py 64bit )  Py35  Py35  
Py36 (py 32bit or py 64bit )  Py36  Py36 
or see download page for more options/versions ...
Unzip in your home directory and adapt the path:
Matlab/Octave  Python 

addpath('.../casadimatlabR2014av3.2.3') import casadi.* x = MX.sym('x') disp(jacobian(sin(x),x)) 
from sys import path path.append(r".../casadipy27np1.9.1v3.2.3") from casadi import * x = MX.sym("x") print(jacobian(sin(x),x)) 
New: install with pip install casadi
(you must have pip version
>= 8.1!)
New features
 Introduced differentiable exponential matrix node
expm
(requires slicot)  Introduced differentiable Ndimensional lookup tables:
interpolant
with 'bspline' solver.
Bugs in the SUNDIALS interface fixed
CasADi 3.1 included a refactored support for ODE/DAE sensitivity analysis. While more efficient, this also exposed some bugs that have now been fixed in the CasADi 3.2 release, including: * A bug affecting second order sensitivity analysis using CVODES was fixed. Cf. #1924. * Segfault in IDAS Cf. #1911.
API changes
 The
if_else
andconditional
operations are now nonshortcircuiting by default for both SX and MX. This means thatif_else(c,x,y)
is now equivalent toif_else(c,x,y,False)
and notif_else(c,x,y,True)
as before. Also note thatif_else(c,x,y,True)
is only supported for MX. Cf. #1968.  The functions
Function::jacobian
,Function::derivative
andFunction::hessian
, which have had an internal character since CasADi 3.0, have been deprecated and will be removed in their current forms in the next release. The user is encouraged to work with expressions (e.g.J = jacobian(f,x)
orJv = jtimes(f,x,v)
or[H,g] = hessian(f,x)
) or useFunction::factory
(*). To allow a smooth transition,Function::jacobian
andFunction::hessian
will be available asFunction::jacobian_old
andFunction::hessian_old
in this and next release. Cf. #1777.
(*) example in Matlab:
x = MX.sym('x')
y = x^2;
f = Function('f',{x},{y})
%J = f.jacobian(0,0) replacement:
J = Function('J',{x},{jacobian(y,x), y}) % alternative 1
J = f.factory('J',{'i0'},{'jac:o0:i0','o0'}) % alternative 2
%H = f.hessian(0,0) replacement:
[H,g] = hessian(y,x);
H = Function('H',{x},{H,g}) % alternative 1
H = f.factory('H',{'i0'},{'hess:o0:i0:i0','grad:o0:i0'}) % alternative 2
Improvements to C code generation
 The generated code now follows stricter coding standards. It should now be possible to compile the code with the GCC flags
Wall Werror
. Cf. #1741.
Changes to the build system
 The build system has been refactored and CasADi/C++ can be conveniently compiled with Visual Studio C++ on Windows. The installation now also includes CMake configure files, which makes it convenient to locate and use a CasADi installation in C++ code. Cf. #1982.
 The logic for source builds have changed. Before, the build system would try to locate thirdparty packages on the system and compile and install the thirdparty interfaces if this was successful. Now, the logic is that thirdparty packages are not installed unless the user specifically indicates this
e.g.
DWITH_IPOPT=ON`. Cf. #1989, #1988.  The default installation directories for the SWIG interfaces (for Python, Octave and MATLAB) has changed. It is now installed as subdirectories of the
CMAKE_INSTALL_PREFIX
location by default, but this can be changed by explicitly setting the CMake variablesBIN_PREFIX
,CMAKE_PREFIX
,INCLUDE_PREFIX
,LIB_PREFIX
,MATLAB_PREFIX
andPYTHON_PREFIX
. A flat installation directory (without subdirectories) can be obtained by setting theWITH_SELFCONTAINED
option. This is the default behavior on Windows. Cf. #1991, #1990
Changes to precompiled binaries
Python 2.6 (#1976), Python 3.6 (#1987) and Octave 4.2 (#2002, #2000) are now supported.
Get started with the example pack.
Getting error "CasADi is not running from its package context." in Python? Check that you have casadipy27np1.9.1v3.2.3/casadi/casadi.py
. If you have casadipy27np1.9.1v3.2.3/casadi.py
instead, that's not good; add an extra casadi
folder.
Extra links for the adventurous: more versions, nightly builds, source build instructions