CasADi is a symbolic framework for numeric optimization implementing automatic differentiation in forward and reverse modes on sparse matrix-valued computational graphs. It supports self-contained C-code generation and interfaces state-of-the-art codes such as SUNDIALS, IPOPT etc. It can be used from C++, Python or Matlab/Octave.
LGPL-3.0 License
Bot releases are hidden (Show)
Published by jgillis over 6 years ago
Published by jgillis over 6 years ago
Published by jgillis over 6 years ago
Published by jgillis over 6 years ago
Published by jgillis over 6 years ago
Published by jgillis over 6 years ago
Published by jgillis over 6 years ago
Published by jgillis over 6 years ago
Grab 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 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:
New: install with pip install casadi
(you must have pip --version
>= 8.1!)
Get started with the example pack.
Getting error "CasADi is not running from its package context." in Python? Check that you have casadi-py27-np1.9.1-v3.2.3/casadi/casadi.py
. If you have casadi-py27-np1.9.1-v3.2.3/casadi.py
instead, that's not good; add an extra casadi
folder.
expm
(requires slicot)interpolant
with 'bspline' solver.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:
if_else
and conditional
operations are now non-short-circuiting by default for both SX and MX. This means that if_else(c,x,y)
is now equivalent to if_else(c,x,y,False)
and not if_else(c,x,y,True)
as before. Also note that if_else(c,x,y,True)
is only supported for MX. Cf. #1968.Function::jacobian
, Function::derivative
and Function::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)
or Jv = jtimes(f,x,v)
or [H,g] = hessian(f,x)
) or use Function::factory
(*). To allow a smooth transition, Function::jacobian
and Function::hessian
will be available as Function::jacobian_old
and Function::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
-Wall -Werror
. Cf. #1741.e.g.
-DWITH_IPOPT=ON`. Cf.CMAKE_INSTALL_PREFIX
location by default, but this can be changed by explicitly setting the CMake variables BIN_PREFIX
, CMAKE_PREFIX
, INCLUDE_PREFIX
, LIB_PREFIX
, MATLAB_PREFIX
and PYTHON_PREFIX
. A flat installation directory (without subdirectories) can be obtained by setting the WITH_SELFCONTAINED
option. This is the default behavior on Windows. Cf. #1991, #1990
Python 2.6 (#1976), Python 3.6 (#1987) and Octave 4.2 (#2002, #2000) are now supported.
Published by jgillis over 6 years ago
Published by jgillis over 6 years ago
Published by jgillis over 6 years ago
Grab 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 (32bit1,2 / 64bit2), Py35 (32bit2 / 64bit2), Py36 (32bit2 / 64bit2) | 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:
New: install with pip install casadi
Get started with the example pack.
Getting error "CasADi is not running from its package context." in Python? Check that you have casadi-py27-v3.3.0/casadi/casadi.py
. If you have casadi-py27-v3.3.0/casadi.py
instead, that's not good; add an extra casadi
folder.
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 built-in 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 step-size selection based on estimates of truncation errors and roundoff errors. You can change this to a (cheaper, but less accurate) one-sided 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
.
Two sparse direct linear solvers have been added to CasADi's runtime core: One based on an up-looking QR factorization, calculated using Householder reflections, and one sparse direct LDL method (square-root 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).
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.
A\y
and y'/A
now work in Matlab/Octaveshell
compiler now works on Windows, allowing to do jit
using Visual Studioinstruction_*
that work for SX/MX Functions. See accessing_mx_algorithm
example to see how you can walk an MX graph
.DM::rand
creates a matrix with random numbers. DM::rng
controls the seeding of the random number generator.manylinux
.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 non-scalar, 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)
.
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.
inv()
is now more efficient for large SX
/DM
matrices, and is evaluatable for MX
(cparse
by default).SX
/MX
as inv_minor
, and for MX
as inv_node
.csparse
as opposed to symbolicqr
vector<bool>
, this gets mapped to a logical matrix. E.g. which_depends
is affected by this change.sumsqr
instead of sum_square
.Linsol
class has changed.