8000 Releases · casadi/casadi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Releases: casadi/casadi

3.6.3

18 May 06:44
Compare
Choose a tag to compare

Install

Grab a binary from the table:

WindowsLinuxMac classic (High Sierra or above)Mac M1
Matlab R2018b or later R2018b or later R2018b or later R2020b or later (normal Matlab)
R2018b or later (Open Beta)
Octave 6.2.0 or later 6.2.0 or later 6.2.0 or later 6.2.0 or later
Python pip install casadi (needs pip -V>=8.1)

For Matlab/Octave, unzip in your home directory and adapt the path:


addpath('<yourpath>/casadi-3.6.3-windows64-matlab2018b')

Check your installation:

Matlab/OctavePython

import casadi.*
x = MX.sym('x')
disp(jacobian(sin(x),x))


from casadi import *
x = MX.sym("x")
print(jacobian(sin(x),x))

Get started with the example pack. Onboarding pointers have been gathered by the community at our wiki.

Troubleshooting

  • KNITRO on linux crashes with a segmentation fault without LD_PRELOAD=<knitro_lin_path>/libiomp5.so.
  • Callbacks with one argument are broken in Matlab CasADi

Release notes

Symbolic expressions

  • Added SX/MX/DM operations #1595:
    • hypot(x,y) = sqrt(x*x+y*y)
    • log1p(x) = log(1+x)
    • expm1(x) = exp(x-1)
  • Added operation remainder with the semantics of the C operation
  • breaking AD rule of fmin/fmax` is now symmetric:
    jacobian(fmin(x,y),vertcat(x,y)) used to be [1 0] for x==y. Now yields [0.5 0.5].
  • Added AD rules for mmin/mmax
  • Added logsumexp which behaves like log(sum(exp(x))) but is numerically more accurate (and no overflow issues).
  • breaking vertcat/vcat,horzcat/hcat, etc now return a DM type instead of a Sparsity type #2549
  • breaking CasADi-Matlab mod has been renamed to rem, because its numerical behaviour is like the builtin-Matlab rem. The builtin-Matlab mod has no CasADi counterpart. CasADi-Python mod has been removed, because its numerical behaviour is not like numpy.mod. #2767. numpy.mod has no counterpart in CasADi; only fmod is equivalent.
  • DAE index reduction support (Pantelides structural algorithm) See https://github.com/casadi/casadi/blob/3.6.0/docs/examples/python/dae_reduced_index.py
  • Fixed flaw in codegen with MX if_else

Common subexpression elimination

  • Added Common Subexpression Elimination #1540 for MX and SX.
    CasADi can now efficiently eliminate redundant computation by inspecting an expression graph and removing redundant nodes.

Before, CasADi internals would avoid introducing redundant nodes during operations on a given expression, but the user was responsible to avoid duplication when constructing that expression.

There is a function cse() that you may apply to expressions:

x = MX.sym('x')

# User responsibility
sx = sin(x)
y = sqrt(sx)+sx # MX(@1=sin(x), (sqrt(@1)+@1))

# cse
y = sqrt(sin(x))+sin(x) # MX((sqrt(sin(x))+sin(x)))
y = cse(y) # MX(@1=sin(x), (sqrt(@1)+@1))

There is a boolean option cse that may be used when constructing a Function:

x = MX.sym('x')

f = Function('f',[x],[sqrt(sin(x))+sin(x)],{"cse":True})
f.disp(True)
f:(i0)->(o0) MXFunction
Algorithm:
@0 = input[0][0]
@0 = sin(@0)
@1 = sqrt(@0)
@1 = (@1+@0)
output[0][0] = @1

The technique scales favorably for large graphs.

Triangular solve triangular solve nodes in MX

MX how has atomic support for solving upper and lower triangular linear systems without allocating any linear solver instance. The operation handles the case with unity diagonal separately for efficiency and supports C code generation. To use the feature, call casadi.solve(A, b) (Python or MATLAB/Octave)

# Python
import casadi
A = casadi.MX.sym('A', casadi.Sparsity.upper(2))
b = casadi.MX.sym('b', 2)
x = casadi.solve(A, b)
// C++
casadi::MX A = casadi::MX::sym("A", casadi::Sparsity::upper(2));
casadi::MX b = casadi::MX::sym("b", 2);
casadi::MX x = solve(A, b);  // for argument-dependent lookup, alternatively casadi::MX::solve(A, b) for static function

Cf. #2688.

Function

  • breaking SX/MX Function construction with free variables (i.e. symbols used in the output expressions that are not declared as inputs) now fails immediately unless the allow_free option is used.
  • breaking SX/MX Function construction now fails if there are duplicates in input names or output names, unless the allow_duplicate_io_names option is used #2604.
  • breaking Serialization: files saved with CasADi 3.5.5 will load in CasADi 3.6.0 (unittested), except for Functions that include a 'mumps' linear solver since serialization of this solver was deficient, and except for Functions that include an Integrator.
  • breaking custom_jacobian semantics changed. The Function must now return individual blocks (Jacobian of an output w.r.t. to an input)
  • breaking Changed API part for Jacobian sparsity (relevant for advanced use through external or Callback)
bool has_jac_sparsity(casadi_int oind, casadi_int iind) const override;
Sparsity get_jac_sparsity(casadi_int oind, casadi_int iind, bool symmetric) const override;
  • Function.find_function Can be used to retrieve Functions in a hierarchy.
  • Avoid truncation in printing #2452
  • breaking: Function outputs that are not used (passed a null pointer internally) will be logged (dump_in option ) as nan instead of earlier 0. E.g. Ipopt nlp_grad_f has two outputs, f and grad_f_x. The f output is not used internally, so will be logged as nan.

Code-generation

  • Function objects with an external call can now be codegenerated.
  • mmin/mmax now support codegeneration

Solvers/plugins

  • nlpsol/Opti.solver can now take an option 'detect_simple_bounds' (default False) that will promote general constraints to simple bounds (lbx/ubx).
  • Added SPRAL linear solver for Ipopt
  • Added QP solvers HPIPM, Proxqp, Highs
  • CPLEX interface will dynamically load libcplex<CPLEX_VERSION>, where CPLEX_VERSION is read from environmental variables. Same strategy for Gurobi.
  • SqpMethod Eigen-reflect/eigen-clip incorrect #2896

Generalized integrator support

The Integrator class, which solves initial-value problems in ODEs and DAEs has been thoroughly refactored. Changes include:

  • The integrator class now has a much more mature support for returning the IVP solution at multiple time points. It can now be obtained by providing a time grid to the integrator constructor. Unlike before, this support should now work in combination with forward/adjoint sensitivity analysis (to any order) and sparsity pattern calculations. Cf. #2823.
  • The integrator class now includes support for a piecewise constant control (u). The interface will keep track of changes to u and avoid integrating past such changes; for the Sundials (CVODES/IDAS) interfaces by setting a "stop time", for fixed step integrators by aligning the integration points with the grid points. Cf. #3025. Development versions of CasADi included support for this in a dedicated class, called Simulator, but this class has now been removed (breaking) and the functionality has been ported to the Integrator class.
    If you had code looking like cs.integrator('sim_function', 'cvodes', dae, tgrid, opts), you may replace it by cs.integrator('sim_function', 'cvodes', dae, 0, tgrid[1:], opts).
  • The Integrator class now much better exploits the problem structure in the sensitivity calculations, especially adjoint (and forward-over-adjoint, adjoint-over-adjoint) sensitivity calculations. Cf. #2823, #3047. The sensitivity analysis relies to a much less extent on sym...
Read more

3.6.2

25 Apr 07:06
Compare
Choose a tag to compare

Install

Grab a binary from the table:

WindowsLinuxMac classic (High Sierra or above)Mac M1
Matlab R2018b or later R2018b or later R2018b or later R2020b or later (normal Matlab)
R2018b or later (Open Beta)
Octave 6.2.0 or later 6.2.0 or later 6.2.0 or later 6.2.0 or later
Python pip install casadi (needs pip -V>=8.1)

For Matlab/Octave, unzip in your home directory and adapt the path:


addpath('<yourpath>/casadi-3.6.2-windows64-matlab2018b')

Check your installation:

Matlab/OctavePython

import casadi.*
x = MX.sym('x')
disp(jacobian(sin(x),x))


from casadi import *
x = MX.sym("x")
print(jacobian(sin(x),x))

Get started with the example pack. Onboarding pointers have been gathered by the community at our wiki.

Troubleshooting

  • KNITRO on linux crashes with a segmentation fault without LD_PRELOAD=<knitro_lin_path>/libiomp5.so.
  • Callbacks with one argument are broken in Matlab CasADi

Release notes

Symbolic expressions

  • Added SX/MX/DM operations #1595:
    • hypot(x,y) = sqrt(x*x+y*y)
    • log1p(x) = log(1+x)
    • expm1(x) = exp(x-1)
  • Added operation remainder with the semantics of the C operation
  • breaking AD rule of fmin/fmax` is now symmetric:
    jacobian(fmin(x,y),vertcat(x,y)) used to be [1 0] for x==y. Now yields [0.5 0.5].
  • Added AD rules for mmin/mmax
  • Added logsumexp which behaves like log(sum(exp(x))) but is numerically more accurate (and no overflow issues).
  • breaking vertcat/vcat,horzcat/hcat, etc now return a DM type instead of a Sparsity type #2549
  • breaking CasADi-Matlab mod has been renamed to rem, because its numerical behaviour is like the builtin-Matlab rem. The builtin-Matlab mod has no CasADi counterpart. CasADi-Python mod has been removed, because its numerical behaviour is not like numpy.mod. #2767. numpy.mod has no counterpart in CasADi; only fmod is equivalent.
  • DAE index reduction support (Pantelides structural algorithm) See https://github.com/casadi/casadi/blob/3.6.0/docs/examples/python/dae_reduced_index.py
  • Fixed flaw in codegen with MX if_else

Common subexpression elimination

  • Added Common Subexpression Elimination #1540 for MX and SX.
    CasADi can now efficiently eliminate redundant computation by inspecting an expression graph and removing redundant nodes.

Before, CasADi internals would avoid introducing redundant nodes during operations on a given expression, but the user was responsible to avoid duplication when constructing that expression.

There is a function cse() that you may apply to expressions:

x = MX.sym('x')

# User responsibility
sx = sin(x)
y = sqrt(sx)+sx # MX(@1=sin(x), (sqrt(@1)+@1))

# cse
y = sqrt(sin(x))+sin(x) # MX((sqrt(sin(x))+sin(x)))
y = cse(y) # MX(@1=sin(x), (sqrt(@1)+@1))

There is a boolean option cse that may be used when constructing a Function:

x = MX.sym('x')

f = Function('f',[x],[sqrt(sin(x))+sin(x)],{"cse":True})
f.disp(True)
f:(i0)->(o0) MXFunction
Algorithm:
@0 = input[0][0]
@0 = sin(@0)
@1 = sqrt(@0)
@1 = (@1+@0)
output[0][0] = @1

The technique scales favorably for large graphs.

Triangular solve triangular solve nodes in MX

MX how has atomic support for solving upper and lower triangular linear systems without allocating any linear solver instance. The operation handles the case with unity diagonal separately for efficiency and supports C code generation. To use the feature, call casadi.solve(A, b) (Python or MATLAB/Octave)

# Python
import casadi
A = casadi.MX.sym('A', casadi.Sparsity.upper(2))
b = casadi.MX.sym('b', 2)
x = casadi.solve(A, b)
// C++
casadi::MX A = casadi::MX::sym("A", casadi::Sparsity::upper(2));
casadi::MX b = casadi::MX::sym("b", 2);
casadi::MX x = solve(A, b);  // for argument-dependent lookup, alternatively casadi::MX::solve(A, b) for static function

Cf. #2688.

Function

  • breaking SX/MX Function construction with free variables (i.e. symbols used in the output expressions that are not declared as inputs) now fails immediately unless the allow_free option is used.
  • breaking SX/MX Function construction now fails if there are duplicates in input names or output names, unless the allow_duplicate_io_names option is used #2604.
  • breaking Serialization: files saved with CasADi 3.5.5 will load in CasADi 3.6.0 (unittested), except for Functions that include a 'mumps' linear solver since serialization of this solver was deficient, and except for Functions that include an Integrator.
  • breaking custom_jacobian semantics changed. The Function must now return individual blocks (Jacobian of an output w.r.t. to an input)
  • breaking Changed API part for Jacobian sparsity (relevant for advanced use through external or Callback)
bool has_jac_sparsity(casadi_int oind, casadi_int iind) const override;
Sparsity get_jac_sparsity(casadi_int oind, casadi_int iind, bool symmetric) const override;
  • Function.find_function Can be used to retrieve Functions in a hierarchy.
  • Avoid truncation in printing #2452
  • breaking: Function outputs that are not used (passed a null pointer internally) will be logged (dump_in option ) as nan instead of earlier 0. E.g. Ipopt nlp_grad_f has two outputs, f and grad_f_x. The f output is not used internally, so will be logged as nan.

Code-generation

  • Function objects with an external call can now be codegenerated.
  • mmin/mmax now support codegeneration

Solvers/plugins

  • nlpsol/Opti.solver can now take an option 'detect_simple_bounds' (default False) that will promote general constraints to simple bounds (lbx/ubx).
  • Added SPRAL linear solver for Ipopt
  • Added QP solvers HPIPM, Proxqp, Highs
  • CPLEX interface will dynamically load libcplex<CPLEX_VERSION>, where CPLEX_VERSION is read from environmental variables. Same strategy for Gurobi.
  • SqpMethod Eigen-reflect/eigen-clip incorrect #2896

Generalized integrator support

The Integrator class, which solves initial-value problems in ODEs and DAEs has been thoroughly refactored. Changes include:

  • The integrator class now has a much more mature support for returning the IVP solution at multiple time points. It can now be obtained by providing a time grid to the integrator constructor. Unlike before, this support should now work in combination with forward/adjoint sensitivity analysis (to any order) and sparsity pattern calculations. Cf. #2823.
  • The integrator class now includes support for a piecewise constant control (u). The interface will keep track of changes to u and avoid integrating past such changes; for the Sundials (CVODES/IDAS) interfaces by setting a "stop time", for fixed step integrators by aligning the integration points with the grid points. Cf. #3025. Development versions of CasADi included support for this in a dedicated class, called Simulator, but this class has now been removed and the functionality has been ported to the Integrator class.
  • The Integrator class now much better exploits the problem structure in the sensitivity calculations, especially adjoint (and forward-over-adjoint, adjoint-over-adjoint) sensitivity calculations. Cf. #2823, #3047. The sensitivity analysis relies to a much less extent on symbolic reformulations and instead uses calls to the Function class for derivative calculations - this makes the class now more efficient for use with non-symbolic DAEs, including FMUs or other exter...
Read more

nightly-main

19 Apr 08:08
6c82f59
Compare
Choose a tag to compare
nightly-main Pre-release
Pre-release
Post release action

3.6.1

18 Apr 21:56
Compare
Choose a tag to compare

Install

Grab a binary from the table:

WindowsLinuxMac classic (High Sierra or above)Mac M1
Matlab R2018b or later R2018b or later R2018b or later R2020b or later (normal Matlab)
R2018b or later (Open Beta)
Octave 6.2.0 or later 6.2.0 or later 6.2.0 or later 6.2.0 or later
Python pip install casadi (needs pip -V>=8.1)

For Matlab/Octave, unzip in your home directory and adapt the path:


addpath('<yourpath>/casadi-3.6.1-windows64-matlab2018b')

Check your installation:

Matlab/OctavePython

import casadi.*
x = MX.sym('x')
disp(jacobian(sin(x),x))


from casadi import *
x = MX.sym("x")
print(jacobian(sin(x),x))

Get started with the example pack. Onboarding pointers have been gathered by the community at our wiki.

Troubleshooting

  • KNITRO on linux crashes with a segmentation fault without LD_PRELOAD=<knitro_lin_path>/libiomp5.so.
  • Callbacks with one argument are broken in Matlab CasADi

Release notes

Symbolic expressions

  • Added SX/MX/DM operations #1595:
    • hypot(x,y) = sqrt(x*x+y*y)
    • log1p(x) = log(1+x)
    • expm1(x) = exp(x-1)
  • Added operation remainder with the semantics of the C operation
  • breaking AD rule of fmin/fmax` is now symmetric:
    jacobian(fmin(x,y),vertcat(x,y)) used to be [1 0] for x==y. Now yields [0.5 0.5].
  • Added AD rules for mmin/mmax
  • Added logsumexp which behaves like log(sum(exp(x))) but is numerically more accurate (and no overflow issues).
  • breaking vertcat/vcat,horzcat/hcat, etc now return a DM type instead of a Sparsity type #2549
  • breaking CasADi-Matlab mod has been renamed to rem, because its numerical behaviour is like the builtin-Matlab rem. The builtin-Matlab mod has no CasADi counterpart. CasADi-Python mod has been removed, because its numerical behaviour is not like numpy.mod. #2767. numpy.mod has no counterpart in CasADi; only fmod is equivalent.
  • DAE index reduction support (Pantelides structural algorithm) See https://github.com/casadi/casadi/blob/3.6.0/docs/examples/python/dae_reduced_index.py
  • Fixed flaw in codegen with MX if_else

Common subexpression elimination

  • Added Common Subexpression Elimination #1540 for MX and SX.
    CasADi can now efficiently eliminate redundant computation by inspecting an expression graph and removing redundant nodes.

Before, CasADi internals would avoid introducing redundant nodes during operations on a given expression, but the user was responsible to avoid duplication when constructing that expression.

There is a function cse() that you may apply to expressions:

x = MX.sym('x')

# User responsibility
sx = sin(x)
y = sqrt(sx)+sx # MX(@1=sin(x), (sqrt(@1)+@1))

# cse
y = sqrt(sin(x))+sin(x) # MX((sqrt(sin(x))+sin(x)))
y = cse(y) # MX(@1=sin(x), (sqrt(@1)+@1))

There is a boolean option cse that may be used when constructing a Function:

x = MX.sym('x')

f = Function('f',[x],[sqrt(sin(x))+sin(x)],{"cse":True})
f.disp(True)
f:(i0)->(o0) MXFunction
Algorithm:
@0 = input[0][0]
@0 = sin(@0)
@1 = sqrt(@0)
@1 = (@1+@0)
output[0][0] = @1

The technique scales favorably for large graphs.

Triangular solve triangular solve nodes in MX

MX how has atomic support for solving upper and lower triangular linear systems without allocating any linear solver instance. The operation handles the case with unity diagonal separately for efficiency and supports C code generation. To use the feature, call casadi.solve(A, b) (Python or MATLAB/Octave)

# Python
import casadi
A = casadi.MX.sym('A', casadi.Sparsity.upper(2))
b = casadi.MX.sym('b', 2)
x = casadi.solve(A, b)
// C++
casadi::MX A = casadi::MX::sym("A", casadi::Sparsity::upper(2));
casadi::MX b = casadi::MX::sym("b", 2);
casadi::MX x = solve(A, b);  // for argument-dependent lookup, alternatively casadi::MX::solve(A, b) for static function

Cf. #2688.

Function

  • breaking SX/MX Function construction with free variables (i.e. symbols used in the output expressions that are not declared as inputs) now fails immediately unless the allow_free option is used.
  • breaking SX/MX Function construction now fails if there are duplicates in input names or output names, unless the allow_duplicate_io_names option is used #2604.
  • breaking Serialization: files saved with CasADi 3.5.5 will load in CasADi 3.6.0 (unittested), except for Functions that include a 'mumps' linear solver since serialization of this solver was deficient, and except for Functions that include an Integrator.
  • breaking custom_jacobian semantics changed. The Function must now return individual blocks (Jacobian of an output w.r.t. to an input)
  • breaking Changed API part for Jacobian sparsity (relevant for advanced use through external or Callback)
bool has_jac_sparsity(casadi_int oind, casadi_int iind) const override;
Sparsity get_jac_sparsity(casadi_int oind, casadi_int iind, bool symmetric) const override;
  • Function.find_function Can be used to retrieve Functions in a hierarchy.
  • Avoid truncation in printing #2452
  • breaking: Function outputs that are not used (passed a null pointer internally) will be logged (dump_in option ) as nan instead of earlier 0. E.g. Ipopt nlp_grad_f has two outputs, f and grad_f_x. The f output is not used internally, so will be logged as nan.

Code-generation

  • Function objects with an external call can now be codegenerated.
  • mmin/mmax now support codegeneration

Solvers/plugins

  • nlpsol/Opti.solver can now take an option 'detect_simple_bounds' (default False) that will promote general constraints to simple bounds (lbx/ubx).
  • Added SPRAL linear solver for Ipopt
  • Added QP solvers HPIPM, Proxqp, Highs
  • CPLEX interface will dynamically load libcplex<CPLEX_VERSION>, where CPLEX_VERSION is read from environmental variables. Same strategy for Gurobi.
  • SqpMethod Eigen-reflect/eigen-clip incorrect #2896

Generalized integrator support

The Integrator class, which solves initial-value problems in ODEs and DAEs has been thoroughly refactored. Changes include:

  • The integrator class now has a much more mature support for returning the IVP solution at multiple time points. It can now be obtained by providing a time grid to the integrator constructor. Unlike before, this support should now work in combination with forward/adjoint sensitivity analysis (to any order) and sparsity pattern calculations. Cf. #2823.
  • The integrator class now includes support for a piecewise constant control (u). The interface will keep track of changes to u and avoid integrating past such changes; for the Sundials (CVODES/IDAS) interfaces by setting a "stop time", for fixed step integrators by aligning the integration points with the grid points. Cf. #3025. Development versions of CasADi included support for this in a dedicated class, called Simulator, but this class has now been removed and the functionality has been ported to the Integrator class.
  • The Integrator class now much better exploits the problem structure in the sensitivity calculations, especially adjoint (and forward-over-adjoint, adjoint-over-adjoint) sensitivity calculations. Cf. #2823, #3047. The sensitivity analysis relies to a much less extent on symbolic reformulations and instead uses calls to the Function class for derivative calculations - this makes the class now more efficient for use with non-symbolic DAEs, including FMUs or other exter...
Read more

3.6.0

04 Apr 23:31
Compare
Choose a tag to compare

Install

Grab a binary from the table:

WindowsLinuxMac classic (High Sierra or above)Mac M1
Matlab R2018b or later R2018b or later R2018b or later R2018b or later
Octave 6.2.0 or later 6.2.0 or later 6.2.0 or later 6.2.0 or later
Python pip install casadi (needs pip -V>=8.1)

For Matlab/Octave, unzip in your home directory and adapt the path:


addpath('<yourpath>/casadi-3.6.0-windows64-matlab2018b')

Check your installation:

Matlab/OctavePython

import casadi.*
x = MX.sym('x')
disp(jacobian(sin(x),x))


from casadi import *
x = MX.sym("x")
print(jacobian(sin(x),x))

Get started with the example pack. Onboarding pointers have been gathered by the community at our wiki.

Troubleshooting

  • KNITRO on linux crashes with a segmentation fault without LD_PRELOAD=<knitro_lin_path>/libiomp5.so.
  • Callbacks with one argument are broken in Matlab CasADi

Release notes

Symbolic expressions

  • Added SX/MX/DM operations #1595:
    • hypot(x,y) = sqrt(x*x+y*y)
    • log1p(x) = log(1+x)
    • expm1(x) = exp(x-1)
  • Added operation remainder with the semantics of the C operation
  • breaking AD rule of fmin/fmax` is now symmetric:
    jacobian(fmin(x,y),vertcat(x,y)) used to be [1 0] for x==y. Now yields [0.5 0.5].
  • Added AD rules for mmin/mmax
  • Added logsumexp which behaves like log(sum(exp(x))) but is numerically more accurate (and no overflow issues).
  • breaking vertcat/vcat,horzcat/hcat, etc now return a DM type instead of a Sparsity type #2549
  • breaking CasADi-Matlab mod has been renamed to rem, because its numerical behaviour is like the builtin-Matlab rem. The builtin-Matlab mod has no CasADi counterpart. CasADi-Python mod has been removed, because its numerical behaviour is not like numpy.mod. #2767. numpy.mod has no counterpart in CasADi; only fmod is equivalent.
  • DAE index reduction support (Pantelides structural algorithm) See https://github.com/casadi/casadi/blob/3.6.0/docs/examples/python/dae_reduced_index.py
  • Fixed flaw in codegen with MX if_else

Common subexpression elimination

  • Added Common Subexpression Elimination #1540 for MX and SX.
    CasADi can now efficiently eliminate redundant computation by inspecting an expression graph and removing redundant nodes.

Before, CasADi internals would avoid introducing redundant nodes during operations on a given expression, but the user was responsible to avoid duplication when constructing that expression.

There is a function cse() that you may apply to expressions:

x = MX.sym('x')

# User responsibility
sx = sin(x)
y = sqrt(sx)+sx # MX(@1=sin(x), (sqrt(@1)+@1))

# cse
y = sqrt(sin(x))+sin(x) # MX((sqrt(sin(x))+sin(x)))
y = cse(y) # MX(@1=sin(x), (sqrt(@1)+@1))

There is a boolean option cse that may be used when constructing a Function:

x = MX.sym('x')

f = Function('f',[x],[sqrt(sin(x))+sin(x)],{"cse":True})
f.disp(True)
f:(i0)->(o0) MXFunction
Algorithm:
@0 = input[0][0]
@0 = sin(@0)
@1 = sqrt(@0)
@1 = (@1+@0)
output[0][0] = @1

The technique scales favorably for large graphs.

Triangular solve triangular solve nodes in MX

MX how has atomic support for solving upper and lower triangular linear systems without allocating any linear solver instance. The operation handles the case with unity diagonal separately for efficiency and supports C code generation. To use the feature, call casadi.solve(A, b) (Python or MATLAB/Octave)

# Python
import casadi
A = casadi.MX.sym('A', casadi.Sparsity.upper(2))
b = casadi.MX.sym('b', 2)
x = casadi.solve(A, b)
// C++
casadi::MX A = casadi::MX::sym("A", casadi::Sparsity::upper(2));
casadi::MX b = casadi::MX::sym("b", 2);
casadi::MX x = solve(A, b);  // for argument-dependent lookup, alternatively casadi::MX::solve(A, b) for static function

Cf. #2688.

Function

  • breaking SX/MX Function construction with free variables (i.e. symbols used in the output expressions that are not declared as inputs) now fails immediately unless the allow_free option is used.
  • breaking SX/MX Function construction now fails if there are duplicates in input names or output names, unless the allow_duplicate_io_names option is used #2604.
  • breaking Serialization: files saved with CasADi 3.5.5 will load in CasADi 3.6.0 (unittested), except for Functions that include a 'mumps' linear solver since serialization of this solver was deficient, and except for Functions that include an Integrator.
  • breaking custom_jacobian semantics changed. The Function must now return individual blocks (Jacobian of an output w.r.t. to an input)
  • breaking Changed API part for Jacobian sparsity (relevant for advanced use through external or Callback)
bool has_jac_sparsity(casadi_int oind, casadi_int iind) const override;
Sparsity get_jac_sparsity(casadi_int oind, casadi_int iind, bool symmetric) const override;
  • Function.find_function Can be used to retrieve Functions in a hierarchy.
  • Avoid truncation in printing #2452

Code-generation

  • Function objects with an external call can now be codegenerated.
  • mmin/mmax now support codegeneration

Solvers/plugins

  • nlpsol/Opti.solver can now take an option 'detect_simple_bounds' (default False) that will promote general constraints to simple bounds (lbx/ubx).
  • Added SPRAL linear solver for Ipopt
  • Added QP solvers HPIPM, Proxqp, Highs
  • CPLEX interface will dynamically load libcplex<CPLEX_VERSION>, where CPLEX_VERSION is read from environmental variables. Same strategy for Gurobi.
  • SqpMethod Eigen-reflect/eigen-clip incorrect #2896

Generalized integrator support

The Integrator class, which solves initial-value problems in ODEs and DAEs has been thoroughly refactored. Changes include:

  • The integ 10000 rator class now has a much more mature support for returning the IVP solution at multiple time points. It can now be obtained by providing a time grid to the integrator constructor. Unlike before, this support should now work in combination with forward/adjoint sensitivity analysis (to any order) and sparsity pattern calculations. Cf. #2823.
  • The integrator class now includes support for a piecewise constant control (u). The interface will keep track of changes to u and avoid integrating past such changes; for the Sundials (CVODES/IDAS) interfaces by setting a "stop time", for fixed step integrators by aligning the integration points with the grid points. Cf. #3025. Development versions of CasADi included support for this in a dedicated class, called Simulator, but this class has now been removed and the functionality has been ported to the Integrator class.
  • The Integrator class now much better exploits the problem structure in the sensitivity calculations, especially adjoint (and forward-over-adjoint, adjoint-over-adjoint) sensitivity calculations. Cf. #2823, #3047. The sensitivity analysis relies to a much less extent on symbolic reformulations and instead uses calls to the Function class for derivative calculations - this makes the class now more efficient for use with non-symbolic DAEs, including FMUs or other external models.
  • breaking The options t0, tf, output_t0 and grid have been deprecated and will result in a warning if used. Instead, the user can provide equivalent information via the integrator constructor, cf. previous point.
  • The backward states are no longer part of the DAE formulation. They are now derived from a user specified number of sensitivity equations (nadj). This is a slight restriction in the possible problem formulations, but on the other hand allows for a much better exploit...
Read more

nightly-clang

07 Mar 11:51
2baf7f2
Compare
Choose a tag to compare
nightly-clang Pre-release
Pre-release
Skip a particular unittest for proxqp

nightly-ge8

21 Nov 20:58
Compare
Choose a tag to compare
nightly-ge8 Pre-release
Pre-release
split release files

nightly-fmu

25 Mar 00:16
Compare
Choose a tag to compare
nightly-fmu Pre-release
Pre-release
split release files

3.5.5

05 Sep 12:28
Compare
Choose a tag to compare

Install

Grab a binary from the table (for MATLAB, use the newest compatible version below):

WindowsLinuxMac (High Sierra or above)
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),
5.2.0 (32bit / 64bit),
6.1.0 (32bit / 64bit)
4.4.1,
5.1.0,
5.2.0,
6.1.0
5.2.0,
6.1.0(Mojave or higher)
Python Py27 (32bit* / 64bit*),
Py35 (32bit* / 64bit*),
Py36 (32bit* / 64bit*),
Py37 (32bit* / 64bit*),
Py38 (32bit* / 64bit*)
Py39 (32bit* / 64bit*)
Py27,
Py35,
Py36,
Py37,
Py38,
Py39
Py27,
Py35,
Py36,
Py37,
Py38,
Py39
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/OctavePython

addpath('<yourpath>/casadi-matlabR2014a-v3.5.5')
import casadi.*
x = MX.sym('x')
disp(jacobian(sin(x),x))


from sys import path
path.append(r"<yourpath>/casadi-py27-v3.5.5")
from casadi import *
x = MX.sym("x")
print(jacobian(sin(x),x))

Get started with the example pack.

Troubleshooting

Release notes

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++ cross-platform, and enables a form of parallelization.

  • You can now evaluate CasADi Functions from C without requiring code-generation. 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). Use record_time to make timings available through f.stats() without printing them.
  • map with reduce arguments now has an efficient implementation (no copying/repmat)
  • Low-overhead Callback eval support was changed to eval_buffer
  • FunctionInternal::finalize no longer takes options dict.
  • Options always_inline and never_inline were added
  • Options is_diff_in and is_diff_out were added
  • (3.5.2) Ctrl-C interrupts are now disabled in multi-threaded Maps since they could result in crashes
  • (3.5.2) Sparsity of Callbacks can be set with has_jacobian_sparsity/get_jacobian_sparsity
  • (3.5.2) Jitted functions can now be serialized
  • (3.5.2) BSpline constructor takes an inline option yielding a fully differentiable (but not very scalable) BSpline operation for MX
  • (3.5.5) Fixed performance deficiency in inline BSline derivatives

CasADi expressions

  • breaking: IM type is removed from public API (was used to represent integer sparse matrices). Use DM instead.
  • breaking: linspace(0,1,3) and linspace(0.0,1,3) now both return [0 0.5 1] instead of [0 0 1] for the former
  • MX supports slicing with MX now (symbolic indexing).
  • Issue #2364:
    • breaking: veccat of an empty list now returns 0-by-1 instead of 0-by-0.
    • jtimes output dimensions have changed when any of the arguments is empty.
    • NLP function object's 'lam_p' is now 0-by-1 in case of missing parameters.
  • (3.5.2) Fixed long-standing bug in cosh derivative
  • (3.5.2) An MX operation convexify was added
  • (3.5.2) An inefficiency in MX multiplication sparsity was detected and fixed by Mirk...
Read more

3.5.4

03 Sep 13:06
Compare
Choose a tag to compare

Install

Grab a binary from the table (for MATLAB, use the newest compatible version below):

WindowsLinuxMac (High Sierra or above)
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),
5.2.0 (32bit / 64bit)
4.4.1,
4.2.2,
5.1.0,
5.2.0
5.2.0
Python Py27 (32bit* / 64bit*),
Py35 (32bit* / 64bit*),
Py36 (32bit* / 64bit*),
Py37 (32bit* / 64bit*),
Py38 (32bit* / 64bit*)
Py27,
Py35,
Py36,
Py37,
Py38
Py27,
Py35,
Py36,
Py37,
Py38
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/OctavePython

addpath('<yourpath>/casadi-matlabR2014a-v3.5.4')
import casadi.*
x = MX.sym('x')
disp(jacobian(sin(x),x))


from sys import path
path.append(r"<yourpath>/casadi-py27-v3.5.4")
from casadi import *
x = MX.sym("x")
print(jacobian(sin(x),x))

Get started with the example pack.

Troubleshooting

Release notes

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++ cross-platform, and enables a form of parallelization.

  • You can now evaluate CasADi Functions from C without requiring code-generation. 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). Use record_time to make timings available through f.stats() without printing them.
  • map with reduce arguments now has an efficient implementation (no copying/repmat)
  • Low-overhead Callback eval support was changed to eval_buffer
  • FunctionInternal::finalize no longer takes options dict.
  • Options always_inline and never_inline were added
  • Options is_diff_in and is_diff_out were added
  • (3.5.2) Ctrl-C interrupts are now disabled in multi-threaded Maps since they could result in crashes
  • (3.5.2) Sparsity of Callbacks can be set with has_jacobian_sparsity/get_jacobian_sparsity
  • (3.5.2) Jitted functions can now be serialized
  • (3.5.2) BSpline constructor takes an inline option yielding a fully differentiable (but not very scalable) BSpline operation for MX

CasADi expressions

  • breaking: IM type is removed from public API (was used to represent integer sparse matrices). Use DM instead.
  • breaking: linspace(0,1,3) and linspace(0.0,1,3) now both return [0 0.5 1] instead of [0 0 1] for the former
  • MX supports slicing with MX now (symbolic indexing).
  • Issue #2364:
    • breaking: veccat of an empty list now returns 0-by-1 instead of 0-by-0.
    • jtimes output dimensions have changed when any of the arguments is empty.
    • NLP function object's 'lam_p' is now 0-by-1 in case of missing parameters.
  • (3.5.2) Fixed long-standing bug in cosh derivative
  • (3.5.2) An MX operation convexify was added
  • (3.5.2) An inefficiency in MX multiplication sparsity was detected and fixed by Mirko Hahn

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
  • Support for symbolic (differentiable) grid and coefficients for linear interpolation (set inline option to true).

Python specific

  • Overhead-less CasADi Function evaluation API added through Python memoryviews
  • Similar functionality in Callbacks
  • (3.5.2) fix numpy compatibility (numpy 1.19)
  • (3.5.3) fix the numpy fix

Matlab/Octave specific

  • breaking: a(:)=b now behaves like Matlab builtin matrices when a is a CasADi matrix. Before, only the first column of a would be touched by this statement. ([#2363](https://githu...
Read more
0