Grab a binary from the table (for MATLAB, use the newest compatible version below):
|Matlab||R2014b or later,
R2013a or R2013b
|R2014b or later,
|R2015a or later,
|Octave||4.2.1 (32bit / 64bit)||4.2.1||4.2.1|
|Python||Py27 (32bit1,2 / 64bit2),
Py35 (32bit2 / 64bit2),
Py36 (32bit2 / 64bit2)
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:
addpath('.../casadi-matlabR2014a-v3.3.0') import casadi.* x = MX.sym('x') disp(jacobian(sin(x),x))
from sys import path path.append(r".../casadi-py27-v3.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.
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
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 built-in derivative support, you can disable it by setting the options
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
backward. There is also an experimental discontinuity avoiding scheme (suitable if the function is differentiated near nonsmooth points that can be enable by setting
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 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).
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.
y'/Anow work in Matlab/Octave
- Matrix power works
- First major release with Opti
shellcompiler now works on Windows, allowing to do
jitusing Visual Studio
- Added introspection methods
instruction_*that work for SX/MX Functions. See
accessing_mx_algorithmexample to see how you can walk an MX
- Experimental feature to export SX/MX functions to pure-Matlab code.
DM::randcreates a matrix with random numbers.
DM::rngcontrols the seeding of the random number generator.
- Python interface no longer searches for/links to Python libraries (on Linux, OSX)
- Python interface no longer depends on Numpy at compile-time; CasADi works for any numpy version now
- Python binaries and wheels have come a step closer to true
CasADi should now run on CentOS 5.
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)->(r) 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:
f.str(). If you want to print the algorithm, pass an optional argument "True", i.e.
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.
inv()is now more efficient for large
DMmatrices, and is evaluatable for
The old variant is still available for
inv_minor, and for
- Linear solver-related defaults are now set to
csparseas opposed to
- In Matlab, when the CasADi result is a
vector<bool>, this gets mapped to a logical matrix. E.g.
which_dependsis affected by this change.
- The sum-of-squares operator is now called
- The API of the
Linsolclass has changed.