CasADi Python API

1. Expression tools

acos(*args)

Arc cosine: x -> acos(x)

acos(float x) -> float acos(DM x) -> DM acos(SX x) -> SX acos(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_p8

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L374

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L374-L376

acosh(*args)

Inverse hyperbolic cosine: x -> acosh(x)

acosh(float x) -> float acosh(DM x) -> DM acosh(SX x) -> SX acosh(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pe

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L446

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L446-L448

adj(*args)

Matrix adjoint.

adj(DM A) -> DM adj(SX A) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_18p

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L502

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L502-L504

asin(*args)

Arc sine: x -> asin(x)

asin(float x) -> float asin(DM x) -> DM asin(SX x) -> SX asin(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_p7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L362

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L362-L364

asinh(*args)

Inverse hyperbolic sin: x -> asinh(x)

asinh(float x) -> float asinh(DM x) -> DM asinh(SX x) -> SX asinh(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pd

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L434

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L434-L436

atan(*args)

Arc tangent: x -> atan(x)

atan(float x) -> float atan(DM x) -> DM atan(SX x) -> SX atan(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_p6

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L350

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L350-L352

atan2(*args)

Two argument arc tangent: (x,y) -> atan2(x,y)

atan2(float x, float y) -> float atan2(DM x, DM y) -> DM atan2(SX x, SX y) -> SX atan2(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pr

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L610

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L610-L612

atanh(*args)

Inverse hyperbolic tangent: x -> atanh(x)

atanh(float x) -> float atanh(DM x) -> DM atanh(SX x) -> SX atanh(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pc

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L422

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L422-L424

bilin(*args)

Calculate bilinear form x^T A y.

bilin(DM A, DM x, DM y) -> DM bilin(SX A, SX x, SX y) -> SX bilin(MX A, MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1bo

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L404

blockcat(*args)

Construct a matrix from 4 blocks.

blockcat([[DM]] v) -> DM blockcat([[SX]] v) -> SX blockcat([[MX]] v) -> MX blockcat(Sparsity A, Sparsity B, Sparsity C, Sparsity D) -> Sparsity blockcat(DM A, DM B, DM C, DM D) -> DM blockcat(SX A, SX B, SX C, SX D) -> SX blockcat(MX A, MX B, MX C, MX D) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_3m

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L197

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L197-L199

ceil(*args)

Round up to nearest integer: x -> ceil(x)

ceil(float x) -> float ceil(DM x) -> DM ceil(SX x) -> SX ceil(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pl

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L530

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L530-L532

chol(*args)

Obtain a Cholesky factorisation of a matrix.

chol(DM A) -> DM chol(SX A) -> SX

Performs and LDL transformation [L,D] = ldl(A) and returns diag(sqrt(D))*L’

Extra doc: https://github.com/casadi/casadi/wiki/L_18v

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L560

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L560-L562

cofactor(*args)

Get the (i,j) cofactor matrix.

cofactor(DM x, int i, int j) -> DM cofactor(SX x, int i, int j) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_18r

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L516

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L516-L518

conditional(*args)

Create a switch.

conditional(DM ind, [DM] x, DM x_default, bool short_circuit) -> DM conditional(SX ind, [SX] x, SX x_default, bool short_circuit) -> SX conditional(MX ind, [MX] x, MX x_default, bool short_circuit) -> MX

If the condition

ind: evaluates to the integer k, where 0<=k<f.size(), then x[k] will be

returned, otherwise

x_default: will be returned.

Extra doc: https://github.com/casadi/casadi/wiki/L_1cj

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L642

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L642-L645

constpow(*args)

Elementwise power with const power

constpow(float x, float y) -> float constpow(DM x, DM y) -> DM constpow(SX x, SX y) -> SX constpow(MX x, MX y) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L682

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L682-L684

copysign(*args)

Copy sign

copysign(float x, float y) -> float copysign(DM x, DM y) -> DM copysign(SX x, SX y) -> SX copysign(MX x, MX y) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L672

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L672-L674

cos(*args)

Cosine: x -> cos(x)

cos(float x) -> float cos(DM x) -> DM cos(SX x) -> SX cos(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_p4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L326

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L326-L328

cosh(*args)

Hyperbolic cosine: x -> cosh(x)

cosh(float x) -> float cosh(DM x) -> DM cosh(SX x) -> SX cosh(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L410

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L410-L412

cross(*args)

Matlab’s cross command.

cross(DM a, DM b, int dim) -> DM cross(SX a, SX b, int dim) -> SX cross(MX a, MX b, int dim) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1bu

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L462

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L462-L464

cumsum(*args)

cumulative sum

cumsum(DM A, int axis) -> DM cumsum(SX A, int axis) -> SX cumsum(MX A, int axis) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1lm

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L852

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L852-L860

densify(*args)

Make the matrix dense and assign nonzeros to a value.

densify(DM x) -> DM densify(SX x) -> SX densify(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1cg

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L612

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L612-L614

depends_on(*args)

Check if expression depends on the argument.

depends_on(DM f, DM arg) -> bool depends_on(SX f, SX arg) -> bool depends_on(MX f, MX arg) -> bool

The argument must be symbolic

Extra doc: https://github.com/casadi/casadi/wiki/L_1ck

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L652

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L652-L654

det(*args)

Matrix determinant (experimental)

det(DM A) -> DM det(SX A) -> SX det(MX A) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1bx

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L483

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L483-L483

diag(*args)

Get the diagonal of a matrix or construct a diagonal.

diag(DM A) -> DM diag(SX A) -> SX diag(MX A) -> MX

When the input is square, the diagonal elements are returned. If the input is vector-like, a diagonal matrix is constructed with it.

Extra doc: https://github.com/casadi/casadi/wiki/L_1cd

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L591

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L591-L593

diagsplit(*args)

split diagonally, retaining fixed-sized matrices

diagsplit(Sparsity x, int incr) -> [Sparsity] diagsplit(DM x, int incr) -> [DM] diagsplit(SX x, int incr) -> [SX] diagsplit(MX x, int incr) -> [MX] diagsplit(Sparsity x, [int] output_offset) -> [Sparsity] diagsplit(DM x, [int] output_offset) -> [DM] diagsplit(SX x, [int] output_offset) -> [SX] diagsplit(MX x, [int] output_offset) -> [MX] diagsplit(Sparsity x, int incr1, int incr2) -> [Sparsity] diagsplit(Sparsity x, [int] output_offset1, [int] output_offset2) -> [Sparsity] diagsplit(DM x, int incr1, int incr2) -> [DM] diagsplit(DM x, [int] output_offset1, [int] output_offset2) -> [DM] diagsplit(SX x, int incr1, int incr2) -> [SX] diagsplit(SX x, [int] output_offset1, [int] output_offset2) -> [SX] diagsplit(MX x, int incr1, int incr2) -> [MX] diagsplit(MX x, [int] output_offset1, [int] output_offset2) -> [MX]

incr1: Row dimension of each matrix

incr2: Column dimension of each matrix

diagsplit(diagsplit(x, …)) = x

Extra doc: https://github.com/casadi/casadi/wiki/L_3t

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L287

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L287-L289

diff(*args)

diff

diff(DM A, int n, int axis) -> DM diff(SX A, int n, int axis) -> SX diff(MX A, int n, int axis) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1ln

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L874

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L874-L881

dot(*args)

Inner product of two matrices.

dot(DM x, DM y) -> DM dot(SX x, SX y) -> SX dot(MX x, MX y) -> MX

with x and y matrices of the same dimension

Extra doc: https://github.com/casadi/casadi/wiki/L_1ca

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L560

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L560-L562

eig_symbolic(*args)

Attempts to find the eigenvalues of a symbolic matrix.

eig_symbolic(DM m) -> DM eig_symbolic(SX m) -> SX

This will only work for up to 3x3 matrices

Extra doc: https://github.com/casadi/casadi/wiki/L_199

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L831

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L831-L833

einstein(*args)

Computes an einstein dense tensor contraction.

einstein(DM A, DM B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> DM einstein(SX A, SX B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> SX einstein(MX A, MX B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> MX einstein(DM A, DM B, DM C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> DM einstein(SX A, SX B, SX C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> SX einstein(MX A, MX B, MX C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> MX

Computes the product: C_c = A_a + B_b where a b c are index/einstein

notation in an encoded form

For example, an matrix-matrix product may be written as: C_ij = A_ik B_kj

The encoded form uses strictly negative numbers to indicate labels. For the

above example, we would have: a {-1, -3} b {-3, -2} c {-1 -2}

Extra doc: https://github.com/casadi/casadi/wiki/L_r5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L520

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L647-L653

eq(*args)

Logical equal to: (x,y) -> x == y.

eq(float x, float y) -> float eq(DM x, DM y) -> DM eq(SX x, SX y) -> SX eq(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_ov

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L191

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L191-L193

erf(*args)

Error function: x -> erf(x)

erf(float x) -> float erf(DM x) -> DM erf(SX x) -> SX erf(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pm

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L542

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L542-L544

erfinv(*args)

Inverse error function: x -> erfinv(x)

erfinv(float x) -> float erfinv(DM x) -> DM erfinv(SX x) -> SX erfinv(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pn

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L554

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L554-L556

evalf(*args)

Evaluates the expression numerically.

evalf(DM x) -> DM evalf(SX x) -> DM evalf(MX x) -> DM

An error is raised when the expression contains symbols

Extra doc: https://github.com/casadi/casadi/wiki/L_rf

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L798

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L798-L800

exp(*args)

Elementwise exponential: x -> exp(x)

exp(float x) -> float exp(DM x) -> DM exp(SX x) -> SX exp(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pf

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L458

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L458-L460

expand(*args)

Expand the expression as a weighted sum (with constant weights)

expand(DM ex) -> (DM OUTPUT1, DM OUTPUT2) expand(SX ex) -> (SX OUTPUT1, SX OUTPUT2)

Extra doc: https://github.com/casadi/casadi/wiki/L_192

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L618

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L618-L621

expm(*args)

Calculate Matrix exponential.

expm(DM A) -> DM expm(SX A) -> SX expm(MX A) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_23w

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L785

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L785-L787

expm_const(*args)

Calculate Matrix exponential.

expm_const(DM A, DM t) -> DM expm_const(SX A, SX t) -> SX expm_const(MX A, MX t) -> MX

Computes expm(A*t) with A constant

A[in]: Square matrix

t[in]: Scalar

Extra doc: https://github.com/casadi/casadi/wiki/L_23v

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L777

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L777-L779

find(*args)

find nonzeros

find(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1le

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L547

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L547-L553

floor(*args)

Round down to nearest integer: x -> floor(x)

floor(float x) -> float floor(DM x) -> DM floor(SX x) -> SX floor(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pk

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L518

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L518-L520

fmax(*args)

Largest of two values: (x,y) -> max(x,y)

fmax(float x, float y) -> float fmax(DM x, DM y) -> DM fmax(SX x, SX y) -> SX fmax(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pu

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L646

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L646-L648

fmin(*args)

Smallest of two values: (x,y) -> min(x,y)

fmin(float x, float y) -> float fmin(DM x, DM y) -> DM fmin(SX x, SX y) -> SX fmin(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pt

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L634

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L634-L636

gauss_quadrature(*args)

Integrate f from a to b using Gaussian quadrature with n points.

gauss_quadrature(DM f, DM x, DM a, DM b, int order) -> DM gauss_quadrature(SX f, SX x, SX a, SX b, int order) -> SX gauss_quadrature(DM f, DM x, DM a, DM b, int order, DM w) -> DM gauss_quadrature(SX f, SX x, SX a, SX b, int order, SX w) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_196

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L730

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L730-L734

ge(*args)

Logical greater or equal to: (x,y) -> x <= y.

ge(float x, float y) -> float ge(DM x, DM y) -> DM ge(SX x, SX y) -> SX ge(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_ou

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L176

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L176-L178

gradient(*args)

Calculate the gradient of an expression.

gradient(DM ex, DM arg) -> DM gradient(SX ex, SX arg) -> SX gradient(MX ex, MX arg) -> MX

ex[in]: Scalar expression to take the gradient of

arg[in]: Vector expression of symbols

opts[in]: Options

Dense column vector

Extra doc: https://github.com/casadi/casadi/wiki/L_23x

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L807

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L807-L809

graph_substitute(*args)

Substitute multiple expressions in graph.

graph_substitute(MX ex, [MX] v, [MX] vdef) -> MX graph_substitute([MX] ex, [MX] v, [MX] vdef) -> [MX]

Substitute variable var with expression expr in multiple expressions,

preserving nodes

Extra doc: https://github.com/casadi/casadi/wiki/L_ra

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L716

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L716-L720

gt(*args)

Logical greater than: (x,y) -> x > y.

gt(float x, float y) -> float gt(DM x, DM y) -> DM gt(SX x, SX y) -> SX gt(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_ot

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L161

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L161-L163

heaviside(*args)

Heaviside function.

heaviside(DM x) -> DM heaviside(SX x) -> SX

[ begin {cases} H(x) = 0 & x<0 \ H(x) = 1/2 & x=0 \ H(x) = 1 & x>0 \ end {cases} ]

Extra doc: https://github.com/casadi/casadi/wiki/L_195

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L666

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L666-L668

hessian(*args)

Hessian and (optionally) gradient.

hessian(DM ex, DM arg, dict opts) -> (DM , DM OUTPUT1) hessian(SX ex, SX arg, dict opts) -> (SX , SX OUTPUT1) hessian(MX ex, MX arg, dict opts) -> (MX , MX OUTPUT1)

Extra doc: https://github.com/casadi/casadi/wiki/L_23z

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L860

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L860-L863

horzsplit(*args)

split horizontally, retaining fixed-sized groups of columns

horzsplit(Sparsity v, int incr) -> [Sparsity] horzsplit(DM v, int incr) -> [DM] horzsplit(SX v, int incr) -> [SX] horzsplit(MX v, int incr) -> [MX] horzsplit(Sparsity v, [int] offset) -> [Sparsity] horzsplit(DM v, [int] offset) -> [DM] horzsplit(SX v, [int] offset) -> [SX] horzsplit(MX v, [int] offset) -> [MX]

incr: Size of each group of columns

horzcat(horzsplit(x, …)) = x

Extra doc: https://github.com/casadi/casadi/wiki/L_3h

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L130

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L130-L132

if_else(*args)

Ternary if_else: x ? y : z.

if_else(DM cond, DM if_true, DM if_false, bool short_circuit) -> DM if_else(SX cond, SX if_true, SX if_false, bool short_circuit) -> SX if_else(MX cond, MX if_true, MX if_false, bool short_circuit) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_113

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sx_elem.hpp#L265

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sx_elem.hpp#L265-L267

interp1d(*args)

Performs 1d linear interpolation.

interp1d([float] x, DM v, [float] xq, str mode, bool equidistant) -> DM interp1d([float] x, SX v, [float] xq, str mode, bool equidistant) -> SX interp1d([float] x, MX v, [float] xq, str mode, bool equidistant) -> MX

The data-points to be interpolated are given as (x[i], v[i]). xq[j] is

used as interplating value

Extra doc: https://github.com/casadi/casadi/wiki/L_1bh

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L311

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L311-L314

inv(*args)

Element-wise inverse.

inv(DM A) -> DM inv(SX A) -> SX inv(MX A) -> MX inv(DM A, str lsolver, dict opts) -> DM inv(SX A, str lsolver, dict opts) -> SX inv(MX A, str lsolver, dict opts) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_10y

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sx_elem.hpp#L222

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sx_elem.cpp#L160-L166

inv_minor(*args)

Matrix inverse (experimental)

inv_minor(DM A) -> DM inv_minor(SX A) -> SX inv_minor(MX A) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1by

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L488

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L488-L488

inv_node(*args)

Inverse node.

inv_node(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_re

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L789

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L789-L791

inv_skew(*args)

Generate the 3-vector progenitor of a skew symmetric matrix.

inv_skew(DM a) -> DM inv_skew(SX a) -> SX inv_skew(MX a) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1bw

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L476

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L476-L478

is_equal(*args)

Check if two nodes are equivalent up to a given depth.

is_equal(float x, float y, int depth) -> bool is_equal(DM x, DM y, int depth) -> bool is_equal(SX x, SX y, int depth) -> bool is_equal(MX x, MX y, int depth) -> bool

Depth=0 checks if the expressions are identical, i.e. points to the same node.

a = x*x b = x*x

is_equal(a,b,0) will return false, but a.is_equal(a,b,1) will return true

Extra doc: https://github.com/casadi/casadi/wiki/L_pv

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L665

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L665-L667

is_linear(*args)

Is expr linear in var?

is_linear(DM expr, DM var) -> bool is_linear(SX expr, SX var) -> bool is_linear(MX expr, MX var) -> bool

False negatives are possible (an expression may not be recognised as linear

while it really is), false positives not.

Extra doc: https://github.com/casadi/casadi/wiki/L_1d0

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L881

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L881-L883

is_quadratic(*args)

Is expr quadratic in var?

is_quadratic(DM expr, DM var) -> bool is_quadratic(SX expr, SX var) -> bool is_quadratic(MX expr, MX var) -> bool

False negatives are possible (an expression may not be recognised as

quadratic while it really is), false positives not.

Extra doc: https://github.com/casadi/casadi/wiki/L_1d1

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L892

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L892-L894

jacobian(*args)

Calculate Jacobian.

jacobian(DM ex, DM arg, dict opts) -> DM jacobian(SX ex, SX arg, dict opts) -> SX jacobian(MX ex, MX arg, dict opts) -> MX

Sparse matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_1cv

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L794

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L794-L797

jtimes(*args)

Calculate the Jacobian and multiply by a vector from the right.

jtimes(DM ex, DM arg, DM v, bool tr) -> DM jtimes(SX ex, SX arg, SX v, bool tr) -> SX jtimes(MX ex, MX arg, MX v, bool tr) -> MX

This is equivalent to mul(jacobian(ex, arg), v) or mul(jacobian(ex, arg).T, v) for tr set to false and true respectively. If contrast to these

expressions, it will use directional derivatives which is typically (but not necessarily) more efficient if the complete Jacobian is not needed and v has few rows.

Extra doc: https://github.com/casadi/casadi/wiki/L_1cw

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L827

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L827-L830

kron(*args)

Kronecker tensor product.

kron(Sparsity a, Sparsity b) -> Sparsity kron(DM a, DM b) -> DM kron(SX a, SX b) -> SX kron(MX a, MX b) -> MX

Creates a block matrix in which each element (i, j) is a_ij*b

Extra doc: https://github.com/casadi/casadi/wiki/L_47

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L407

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L407-L409

ldivide(float x, float y) float
ldivide(DM x, DM y) DM
ldivide(SX x, SX y) SX
ldivide(MX x, MX y) MX
ldl(*args)

Sparse LDL^T factorization.

ldl(DM A, bool amd) -> (DM OUTPUT1, DM OUTPUT2, [int] OUTPUT3) ldl(SX A, bool amd) -> (SX OUTPUT1, SX OUTPUT2, [int] OUTPUT3)

Returns D and the strictly upper triangular entries of L^T I.e. ones on the

diagonal are ignored. Only guarenteed to work for positive

definite matrices.

Extra doc: https://github.com/casadi/casadi/wiki/L_18w

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L571

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L571-L574

ldl_solve(*args)

Solve using a sparse LDL^T factorization.

ldl_solve(DM b, DM D, DM LT, [int] p) -> DM ldl_solve(SX b, SX D, SX LT, [int] p) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_18x

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L580

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L580-L583

le(*args)

Logical less or equal to: (x,y) -> x <= y.

le(float x, float y) -> float le(DM x, DM y) -> DM le(SX x, SX y) -> SX le(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_os

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L146

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L146-L148

linear_coeff(*args)

Recognizes linear form in vector expression.

linear_coeff(DM ex, DM arg, bool check) -> (DM OUTPUT1, DM OUTPUT2) linear_coeff(SX ex, SX arg, bool check) -> (SX OUTPUT1, SX OUTPUT2) linear_coeff(MX ex, MX arg, bool check) -> (MX OUTPUT1, MX OUTPUT2)

A x + b

check[in]: When true (default)m, A is checked to be independent of x. Provided to

deal with false positive dependency checks.

Extra doc: https://github.com/casadi/casadi/wiki/L_1d3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L919

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L919-L922

linearize(*args)

Linearize an expression.

linearize(DM f, DM x, DM x0) -> DM linearize(SX f, SX x, SX x0) -> SX linearize(MX f, MX x, MX x0) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1cs

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L735

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L735-L738

linspace(*args)

Matlab’s linspace.

linspace(DM a, DM b, int nsteps) -> DM linspace(SX a, SX b, int nsteps) -> SX linspace(MX a, MX b, int nsteps) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L772

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L772-L783

log(*args)

Natural logarithm: x -> log(x)

log(float x) -> float log(DM x) -> DM log(SX x) -> SX log(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pg

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L470

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L470-L472

log10(*args)

Base-10 logarithm: x -> log10(x)

log10(float x) -> float log10(DM x) -> DM log10(SX x) -> SX log10(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_ph

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L482

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L482-L484

lt(*args)

Logical less than: (x,y) -> x < y.

lt(float x, float y) -> float lt(DM x, DM y) -> DM lt(SX x, SX y) -> SX lt(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_or

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L131

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L131-L133

mac(*args)

Multiply-accumulate operation.

mac(Sparsity X, Sparsity Y, Sparsity Z) -> Sparsity mac(DM X, DM Y, DM Z) -> DM mac(SX X, SX Y, SX Z) -> SX mac(MX X, MX Y, MX Z) -> MX

Matrix product of two matrices (x and y), adding the result to a third

matrix z. The result has the same sparsity pattern as C meaning that other entries of (x*y) are ignored. The operation is equivalent to:

z+mtimes(x,y).project(z.sparsity()).

Extra doc: https://github.com/casadi/casadi/wiki/L_3x

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L321

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L321-L323

matrix_expand(*args)

Expand MX graph to SXFunction call.

matrix_expand(MX e, [MX] boundary, dict options) -> MX matrix_expand([MX] e, [MX] boundary, dict options) -> [MX]

Expand the given expression e, optionally supplying expressions contained in it at which expansion should stop.

Extra doc: https://github.com/casadi/casadi/wiki/L_rc

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L741

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L741-L745

minor(*args)

Get the (i,j) minor matrix.

minor(DM x, int i, int j) -> DM minor(SX x, int i, int j) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_18q

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L509

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L509-L511

minus(*args)

Subtraction: (x,y) -> x - y.

minus(float x, float y) -> float minus(DM x, DM y) -> DM minus(SX x, SX y) -> SX minus(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_oo

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L83

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L83-L85

mldivide(*args)

Matrix divide (cf. backslash ‘' in MATLAB)

mldivide(DM x, DM y) -> DM mldivide(SX x, SX y) -> SX mldivide(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1bm

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L383

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L383-L385

mmax(*args)

Largest element in a matrix.

mmax(DM x) -> DM mmax(SX x) -> SX mmax(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1d9

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L983

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L983-L985

mmin(*args)

Smallest element in a matrix.

mmin(DM x) -> DM mmin(SX x) -> SX mmin(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1d8

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L974

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L974-L976

mod(*args)

Remainder after division: (x,y) -> mod(x,y)

mod(float x, float y) -> float mod(DM x, DM y) -> DM mod(SX x, SX y) -> SX mod(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pq

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L595

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L595-L597

mpower(*args)

Matrix power x^n.

mpower(DM x, DM n) -> DM mpower(SX x, SX n) -> SX mpower(MX x, MX n) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1bi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L319

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L319-L321

mrdivide(*args)

Matrix divide (cf. slash ‘/’ in MATLAB)

mrdivide(DM x, DM y) -> DM mrdivide(SX x, SX y) -> SX mrdivide(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1bl

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L376

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L376-L378

mtaylor(*args)

multivariate Taylor series expansion

mtaylor(DM ex, DM x, DM a, int order) -> DM mtaylor(SX ex, SX x, SX a, int order) -> SX mtaylor(DM ex, DM x, DM a, int order, [int] order_contributions) -> DM mtaylor(SX ex, SX x, SX a, int order, [int] order_contributions) -> SX

Do Taylor expansions until the aggregated order of a term is equal to

‘order’. The aggregated order of $x^n y^m$ equals $n+m$.

The argument order_contributions can denote how match each variable

contributes to the aggregated order. If x=[x, y] and

order_contributions=[1, 2], then the aggregated order of $x^n y^m$ equals $1n+2m$.

Example usage

>>> taylor(sin(x+y),[x, y],[a, b], 1)

$ sin(b+a)+cos(b+a)(x-a)+cos(b+a)(y-b) $

>>> taylor(sin(x+y),[x, y],[0, 0], 4)

$ y+x-(x^3+3y x^2+3 y^2 x+y^3)/6 $

>>> taylor(sin(x+y),[x, y],[0, 0], 4,[1, 2])

$ (-3 x^2 y-x^3)/6+y+x $

Extra doc: https://github.com/casadi/casadi/wiki/L_23s

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L799

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L799-L803

mtimes(*args)

Matrix product of n matrices.

mtimes([Sparsity] args) -> Sparsity mtimes([DM] args) -> DM mtimes([SX] args) -> SX mtimes([MX] args) -> MX mtimes(Sparsity x, Sparsity y) -> Sparsity mtimes(DM x, DM y) -> DM mtimes(SX x, SX y) -> SX mtimes(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_3w

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L308

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L308-L310

n_nodes(DM A) int
n_nodes(SX A) int
n_nodes(MX A) int
ne(*args)

Logical not equal to: (x,y) -> x != y.

ne(float x, float y) -> float ne(DM x, DM y) -> DM ne(SX x, SX y) -> SX ne(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_ow

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L206

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L206-L208

norm_0_mul(Sparsity x, Sparsity y) int
norm_0_mul(DM x, DM y) int
norm_0_mul(SX x, SX y) int
norm_0_mul(MX x, MX y) int
norm_1(*args)

1-norm

norm_1(DM x) -> DM norm_1(SX x) -> SX norm_1(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1c6

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L534

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L534-L534

norm_2(*args)

2-norm

norm_2(DM x) -> DM norm_2(SX x) -> SX norm_2(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1c5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L529

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L529-L529

norm_fro(*args)

Frobenius norm.

norm_fro(DM x) -> DM norm_fro(SX x) -> SX norm_fro(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1c4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L524

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L524-L524

norm_inf(*args)

Infinity-norm.

norm_inf(DM x) -> DM norm_inf(SX x) -> SX norm_inf(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1c7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L539

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L539-L539

norm_inf_mul(*args)

Inf-norm of a Matrix-Matrix product.

norm_inf_mul(DM x, DM y) -> DM norm_inf_mul(SX x, SX y) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_190

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L603

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L603-L605

nullspace(*args)

Computes the nullspace of a matrix A.

nullspace(DM A) -> DM nullspace(SX A) -> SX nullspace(MX A) -> MX

Finds Z m-by-(m-n) such that AZ = 0 with A n-by-m with m > n

Assumes A is full rank

Inspired by Numerical Methods in Scientific Computing by Ake Bjorck

Extra doc: https://github.com/casadi/casadi/wiki/L_1cb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L574

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L574-L576

pinv(*args)

Computes the Moore-Penrose pseudo-inverse.

pinv(DM A) -> DM pinv(SX A) -> SX pinv(MX A) -> MX pinv(DM A, str lsolver, dict opts) -> DM pinv(SX A, str lsolver, dict opts) -> SX pinv(MX A, str lsolver, dict opts) -> MX

If the matrix A is fat (size1>size2), mul(A, pinv(A)) is unity. If the

matrix A is slender (size2<size1), mul(pinv(A), A) is unity.

Extra doc: https://github.com/casadi/casadi/wiki/L_1cu

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L762

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L762-L765

plus(float x, float y) float
plus(DM x, DM y) DM
plus(SX x, SX y) SX
plus(MX x, MX y) MX
poly_coeff(*args)

extracts polynomial coefficients from an expression

poly_coeff(DM ex, DM x) -> DM poly_coeff(SX ex, SX x) -> SX

ex: Scalar expression that represents a polynomial

x: Scalar symbol that the polynomial is build up with

Extra doc: https://github.com/casadi/casadi/wiki/L_197

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L811

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L811-L814

poly_roots(*args)

Attempts to find the roots of a polynomial.

poly_roots(DM p) -> DM poly_roots(SX p) -> SX

This will only work for polynomials up to order 3 It is assumed that the roots are real.

Extra doc: https://github.com/casadi/casadi/wiki/L_198

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L822

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L822-L824

polyval(*args)

Evaluate a polynomial with coefficients p in x.

polyval(DM p, DM x) -> DM polyval(SX p, SX x) -> SX polyval(MX p, MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1cc

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L581

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L581-L583

power(float x, float n) float
power(DM x, DM n) DM
power(SX x, SX n) SX
power(MX x, MX n) MX
print_operator(*args)

Get a string representation for a binary MatType, using custom

print_operator(DM xb, [str] args) -> str print_operator(SX xb, [str] args) -> str print_operator(MX xb, [str] args) -> str

arguments.

Extra doc: https://github.com/casadi/casadi/wiki/L_1d4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L938

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L938-L940

project(*args)

Create a new matrix with a given sparsity pattern but with the.

project(DM A, Sparsity sp, bool intersect) -> DM project(SX A, Sparsity sp, bool intersect) -> SX project(MX A, Sparsity sp, bool intersect) -> MX

nonzeros taken from an existing matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_1ch

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L621

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L621-L624

pw_const(*args)

Create a piecewise constant function.

pw_const(DM t, DM tval, DM val) -> DM pw_const(SX t, SX tval, SX val) -> SX

Create a piecewise constant function with n=val.size() intervals

Inputs:

t: a scalar variable (e.g. time)

tval: vector with the discrete values of t at the interval transitions

(length n-1)

val: vector with the value of the function for each interval (length n)

Extra doc: https://github.com/casadi/casadi/wiki/L_193

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L633

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L633-L637

pw_lin(*args)

t a scalar variable (e.g. time)

pw_lin(DM t, DM tval, DM val) -> DM pw_lin(SX t, SX tval, SX val) -> SX

Create a piecewise linear function

Create a piecewise linear function:

Inputs:

tval vector with the the discrete values of t (monotonically increasing)

val vector with the corresponding function values (same length as tval)

Extra doc: https://github.com/casadi/casadi/wiki/L_194

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L650

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L650-L653

qr(*args)

QR factorization using the modified Gram-Schmidt algorithm.

qr(DM A) -> (DM OUTPUT1, DM OUTPUT2) qr(SX A) -> (SX OUTPUT1, SX OUTPUT2)

More stable than the classical Gram-Schmidt, but may break down if the

rows of A are nearly linearly dependent See J. Demmel: Applied

Numerical Linear

Algebra (algorithm 3.1.). Note that in SWIG, Q and R

are returned by value.

Extra doc: https://github.com/casadi/casadi/wiki/L_18s

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L528

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L528-L530

qr_solve(*args)

Solve using a sparse QR factorization.

qr_solve(DM b, DM v, DM r, DM beta, [int] prinv, [int] pc, bool tr) -> DM qr_solve(SX b, SX v, SX r, SX beta, [int] prinv, [int] pc, bool tr) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_18u

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L547

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L547-L552

qr_sparse(*args)

Sparse direct QR factorization.

qr_sparse(DM A, bool amd) -> (DM OUTPUT1, DM OUTPUT2, DM OUTPUT3, [int] OUTPUT4, [int] OUTPUT5) qr_sparse(SX A, bool amd) -> (SX OUTPUT1, SX OUTPUT2, SX OUTPUT3, [int] OUTPUT4, [int] OUTPUT5)

See T. Davis: Direct Methods for Sparse Linear Systems

Extra doc: https://github.com/casadi/casadi/wiki/L_18t

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L537

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L537-L541

quadratic_coeff(*args)

Recognizes quadratic form in scalar expression.

quadratic_coeff(DM ex, DM arg, bool check) -> (DM OUTPUT1, DM OUTPUT2, DM OUTPUT3) quadratic_coeff(SX ex, SX arg, bool check) -> (SX OUTPUT1, SX OUTPUT2, SX OUTPUT3) quadratic_coeff(MX ex, MX arg, bool check) -> (MX OUTPUT1, MX OUTPUT2, MX OUTPUT3)

1/2*x’ A x + b’ x + c

e = 0.5*bilin(A,x,x)+dot(b,x)+c

check[in]: When true (default), A is checked to be independent of x. Provided to deal with false positive dependency checks.

Extra doc: https://github.com/casadi/casadi/wiki/L_1d2

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L906

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L906-L909

ramp(*args)

ramp function

ramp(DM x) -> DM ramp(SX x) -> SX

[ begin {cases} R(x) = 0 & x <= 1 \ R(x) = x & x > 1

\ end {cases} ]

Also called: slope function

Extra doc: https://github.com/casadi/casadi/wiki/L_23p

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L715

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L715-L717

rank1(*args)

Make a rank-1 update to a matrix A.

rank1(DM A, DM alpha, DM x, DM y) -> DM rank1(SX A, SX alpha, SX x, SX y) -> SX rank1(MX A, MX alpha, MX x, MX y) -> MX

Calculates A + 1/2 * alpha * x*y’

Extra doc: https://github.com/casadi/casadi/wiki/L_1bp

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L417

rdivide(*args)

Elementwise division: (x,y) -> x ./ y.

rdivide(float x, float y) -> float rdivide(DM x, DM y) -> DM rdivide(SX x, SX y) -> SX rdivide(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_oq

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L115

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L115-L117

rectangle(*args)

rectangle function

rectangle(DM x) -> DM rectangle(SX x) -> SX

[ begin {cases} Pi(x) = 1 & |x| < 1/2 \ Pi(x) =

1/2

& |x| = 1/2 \ Pi(x) = 0 & |x| > 1/2 \ end {cases} ]

Also called: gate function, block function, band function, pulse function, window function

Extra doc: https://github.com/casadi/casadi/wiki/L_23n

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L683

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L683-L685

repmat(*args)

Repeat matrix A n times vertically and m times horizontally.

repmat(Sparsity A, int n, int m) -> Sparsity repmat(Sparsity A, (int,int) rc) -> Sparsity repmat(DM A, int n, int m) -> DM repmat(DM A, (int,int) rc) -> DM repmat(SX A, int n, int m) -> SX repmat(SX A, (int,int) rc) -> SX repmat(MX A, int n, int m) -> MX repmat(MX A, (int,int) rc) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_49

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L421

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L421-L423

repsum(*args)

Given a repeated matrix, computes the sum of repeated parts.

repsum(DM A, int n, int m) -> DM repsum(SX A, int n, int m) -> SX repsum(MX A, int n, int m) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1d7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L966

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L966-L968

reshape(*args)

Reshape the matrix.

reshape(Sparsity a, (int,int) rc) -> Sparsity reshape(Sparsity a, Sparsity sp) -> Sparsity reshape(DM a, (int,int) rc) -> DM reshape(DM a, Sparsity sp) -> DM reshape(SX a, (int,int) rc) -> SX reshape(SX a, Sparsity sp) -> SX reshape(MX a, (int,int) rc) -> MX reshape(MX a, Sparsity sp) -> MX reshape(Sparsity a, int nrow, int ncol) -> Sparsity reshape(DM a, int nrow, int ncol) -> DM reshape(SX a, int nrow, int ncol) -> SX reshape(MX a, int nrow, int ncol) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_42

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L370

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L370-L372

shared(*args)

Get a shared (owning) reference.

shared([DM] ex, str v_prefix, str v_suffix) -> ([DM] OUTPUT1, [DM] OUTPUT2, [DM] OUTPUT3) shared([SX] ex, str v_prefix, str v_suffix) -> ([SX] OUTPUT1, [SX] OUTPUT2, [SX] OUTPUT3) shared([MX] ex, str v_prefix, str v_suffix) -> ([MX] OUTPUT1, [MX] OUTPUT2, [MX] OUTPUT3)

Extra doc: https://github.com/casadi/casadi/wiki/L_b0

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/shared_object.hpp#L198

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/shared_object.cpp#L142-L148

sign(*args)

Sign function:

sign(float x) -> float sign(DM x) -> DM sign(SX x) -> SX sign(MX x) -> MX

sign(x) := -1 for x<0 sign(x) := 1 for x>0, sign(0) := 0 sign(NaN) := NaN

Extra doc: https://github.com/casadi/casadi/wiki/L_po

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L571

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L571-L573

simplify(*args)

Simplify an expression.

simplify(float x) -> float simplify(DM x) -> DM simplify(SX x) -> SX simplify(MX x) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L930

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L930-L932

sin(*args)

Sine: x -> sin(x)

sin(float x) -> float sin(DM x) -> DM sin(SX x) -> SX sin(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_p3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L314

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L314-L316

sinh(*args)

Hyperbolic sin: x -> sinh(x)

sinh(float x) -> float sinh(DM x) -> DM sinh(SX x) -> SX sinh(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_pa

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L398

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L398-L400

skew(*args)

Generate a skew symmetric matrix from a 3-vector.

skew(DM a) -> DM skew(SX a) -> SX skew(MX a) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1bv

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L469

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L469-L471

soc(*args)

Construct second-order-convex.

soc(DM x, DM y) -> DM soc(SX x, SX y) -> SX soc(MX x, MX y) -> MX

x: vector expression of size n

y: scalar expression

soc(x,y) computes [y*eye(n) x; x’ y]

soc(x,y) positive semi definite <=> || x ||_2 <= y

Extra doc: https://github.com/casadi/casadi/wiki/L_1bj

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L334

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L334-L336

solve(*args)

Crunch the numbers; solve the problem.

solve(DM A, DM b) -> DM solve(SX A, SX b) -> SX solve(MX A, MX b) -> MX solve(DM A, DM b, str lsolver, dict opts) -> DM solve(SX A, SX b, str lsolver, dict opts) -> SX solve(MX A, MX b, str lsolver, dict opts) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/optistack.hpp#L204

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/optistack.cpp#L155-L161

sparsify(*args)

Make a matrix sparse by removing numerical zeros.

sparsify(DM A, float tol) -> DM sparsify(SX A, float tol) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_191

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L611

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L611-L613

sprank(Sparsity A) int
sprank(DM A) int
sprank(SX A) int
sprank(MX A) int
sqrt(*args)

Square root: x -> sqrt(x)

sqrt(float x) -> float sqrt(DM x) -> DM sqrt(SX x) -> SX sqrt(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_p1

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L290

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L290-L292

substitute(*args)

Substitute variable var with expression expr in multiple expressions.

substitute(DM ex, DM v, DM vdef) -> DM substitute([DM] ex, [DM] v, [DM] vdef) -> [DM] substitute(SX ex, SX v, SX vdef) -> SX substitute([SX] ex, [SX] v, [SX] vdef) -> [SX] substitute(MX ex, MX v, MX vdef) -> MX substitute([MX] ex, [MX] v, [MX] vdef) -> [MX]

Extra doc: https://github.com/casadi/casadi/wiki/L_1cm

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L668

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L668-L671

substitute_inplace(*args)

Inplace substitution with piggyback expressions.

substitute_inplace([DM] v, bool reverse) -> ([DM] INOUT1, [DM] INOUT2) substitute_inplace([SX] v, bool reverse) -> ([SX] INOUT1, [SX] INOUT2) substitute_inplace([MX] v, bool reverse) -> ([MX] INOUT1, [MX] INOUT2)

Substitute variables v out of the expressions vdef sequentially, as well as

out of a number of other expressions piggyback

Extra doc: https://github.com/casadi/casadi/wiki/L_1cn

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L680

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L680-L684

sum1(*args)

Return a row-wise summation of elements.

sum1(Sparsity x) -> Sparsity sum1(DM x) -> DM sum1(SX x) -> SX sum1(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_4p

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L542

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L542-L542

sum2(*args)

Return a column-wise summation of elements.

sum2(Sparsity x) -> Sparsity sum2(DM x) -> DM sum2(SX x) -> SX sum2(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_4q

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L547

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L547-L547

sumsqr(*args)

Calculate sum of squares: sum_ij X_ij^2.

sumsqr(DM X) -> DM sumsqr(SX X) -> SX sumsqr(MX X) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1bq

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L424

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L424-L426

symvar(*args)

Get symbols present in expression.

symvar(DM x) -> [DM] symvar(SX x) -> [SX] symvar(MX x) -> [MX]

Returned vector is ordered according to the order of variable()/parameter()

calls used to create the variables

Extra doc: https://github.com/casadi/casadi/wiki/L_1u

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/optistack.hpp#L497

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/optistack.cpp#L440-L446

tan(*args)

Tangent: x -> tan(x)

tan(float x) -> float tan(DM x) -> DM tan(SX x) -> SX tan(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_p5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L338

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L338-L340

tangent(*args)

Calculate the tangent of an expression.

tangent(DM ex, DM arg) -> DM tangent(SX ex, SX arg) -> SX tangent(MX ex, MX arg) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_23y

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L814

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L814-L816

tanh(*args)

Hyperbolic tangent: x -> tanh(x)

tanh(float x) -> float tanh(DM x) -> DM tanh(SX x) -> SX tanh(MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_p9

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L386

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L386-L388

taylor(*args)

univariate Taylor series expansion

taylor(DM ex, DM x, DM a, int order) -> DM taylor(SX ex, SX x, SX a, int order) -> SX

Calculate the Taylor expansion of expression ‘ex’ up to order ‘order’ with respect to variable ‘x’ around the point ‘a’

$(x)=f(a)+f’(a)(x-a)+f’’(a)frac

{(x-a)^2}{2!}+f’’’(a)frac{(x-a)^3}{3!}+ldots$

Example usage:

>>> taylor(sin(x), x)
>>   x

Extra doc: https://github.com/casadi/casadi/wiki/L_23q

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L756

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L756-L758

times(*args)

Elementwise multiplication: (x,y) -> x .* y.

times(float x, float y) -> float times(DM x, DM y) -> DM times(SX x, SX y) -> SX times(MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_op

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L99

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L99-L101

trace(*args)

Matrix trace.

trace(DM a) -> DM trace(SX a) -> SX trace(MX a) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1c1

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L509

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L509-L509

transpose(*args)

Transpose.

transpose(Sparsity X) -> Sparsity transpose(DM X) -> DM transpose(SX X) -> SX transpose(MX X) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_3y

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L328

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L328-L330

triangle(*args)

triangle function

triangle(DM x) -> DM triangle(SX x) -> SX

[ begin {cases} Lambda(x) = 0 & |x| >= 1 \ Lambda(x)

= 1-|x| & |x| < 1 end {cases} ]

Extra doc: https://github.com/casadi/casadi/wiki/L_23o

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L698

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L698-L700

tril(*args)

Get the lower triangular part of a matrix.

tril(Sparsity a, bool includeDiagonal) -> Sparsity tril(DM a, bool includeDiagonal) -> DM tril(SX a, bool includeDiagonal) -> SX tril(MX a, bool includeDiagonal) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_46

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L398

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L398-L400

tril2symm(*args)

Convert a lower triangular matrix to a symmetric one.

tril2symm(DM a) -> DM tril2symm(SX a) -> SX tril2symm(MX a) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1c2

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L514

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L514-L514

triu(*args)

Get the upper triangular part of a matrix.

triu(Sparsity a, bool includeDiagonal) -> Sparsity triu(DM a, bool includeDiagonal) -> DM triu(SX a, bool includeDiagonal) -> SX triu(MX a, bool includeDiagonal) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_45

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L391

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L391-L393

triu2symm(*args)

Convert a upper triangular matrix to a symmetric one.

triu2symm(DM a) -> DM triu2symm(SX a) -> SX triu2symm(MX a) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1c3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L519

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L519-L519

unite(*args)

Unite two matrices no overlapping sparsity.

unite(DM A, DM B) -> DM unite(SX A, SX B) -> SX unite(MX A, MX B) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1ce

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L598

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L598-L600

vec(*args)

make a vector

vec(Sparsity a) -> Sparsity vec(DM a) -> DM vec(SX a) -> SX vec(MX a) -> MX

Reshapes/vectorizes the matrix such that the shape becomes (expr.numel(), 1). Columns are stacked on top of each other. Same as reshape(expr, expr.numel(), 1)

a c b d

turns into

a b c d

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L349

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L349-L351

which_depends(*args)

Find out which variables enter with some order.

which_depends(DM expr, DM var, int order, bool tr) -> [bool] which_depends(SX expr, SX var, int order, bool tr) -> [bool] which_depends(MX expr, MX var, int order, bool tr) -> [bool]

Extra doc: https://github.com/casadi/casadi/wiki/L_1cz

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L869

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L869-L872

2. Classes

2.1. DM

class DM(*args)
assign(self, DM rhs)
static binary(int op, DM x, DM y) DM
clear(self)
dep(self, int ch) DM
static deserialize(std::istream & stream) DM
static deserialize(casadi::DeserializingStream & s) DM
static deserialize(str s) DM
disp(*args)

Print a representation of the object.

disp(self, bool more)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L875

element_hash(self) int
elements(*args)

Get all elements.

elements(self) -> [float]

Extra doc: https://github.com/casadi/casadi/wiki/L_1a3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1133

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1133-L1133

enlarge(*args)

Enlarge matrix.

enlarge(self, int nrow, int ncol, [int] rr, [int] cc, bool ind1)

Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros

Extra doc: https://github.com/casadi/casadi/wiki/L_19i

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L950

erase(*args)

Erase a submatrix (leaving structural zeros in its place)

erase(self, [int] rr, bool ind1) erase(self, [int] rr, [int] cc, bool ind1)

Erase elements of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19g

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L935

erase(self, [int] rr, bool ind1)

Erase a submatrix (leaving structural zeros in its place)

Erase elements of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19g

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L935

erase(self, [int] rr, [int] cc, bool ind1)

Erase a submatrix (leaving structural zeros in its place)

Erase rows and/or columns of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19f

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L927

export_code(self, str lang, dict options)
static eye(int n) DM
static from_file(str filename, str format_hint) DM
full(self) PyObject *
get(self, bool ind1, Sparsity sp) DM
get(self, bool ind1, Slice rr) DM
get(self, bool ind1, IM rr) DM
get(self, bool ind1, Slice rr, Slice cc) DM
get(self, bool ind1, Slice rr, IM cc) DM
get(self, bool ind1, IM rr, Slice cc) DM
get(self, bool ind1, IM rr, IM cc) DM
static get_free(Function f) [DM]
static get_input(Function f) [DM]
static get_max_depth() int
get_nz(self, bool ind1, Slice k) DM
get_nz(self, bool ind1, IM k) DM
has_duplicates(self) bool
has_nz(*args)

Returns true if the matrix has a non-zero at location rr, cc.

has_nz(self, int rr, int cc) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L219

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L219-L219

has_zeros(*args)

Check if the matrix has any zero entries which are not structural

has_zeros(self) -> bool

zeros.

Extra doc: https://github.com/casadi/casadi/wiki/L_1a1

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1123

static inf(*args)

create a matrix with all inf

inf(int nrow, int ncol) -> DM inf((int,int) rc) -> DM inf(Sparsity sp) -> DM

Extra doc: https://github.com/casadi/casadi/wiki/L_19k

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1003

inf(int nrow, int ncol)

create a matrix with all inf

Extra doc: https://github.com/casadi/casadi/wiki/L_19k

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1002

inf((int,int) rc)

create a matrix with all inf

Extra doc: https://github.com/casadi/casadi/wiki/L_19k

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1003

inf(Sparsity sp)

create a matrix with all inf

Extra doc: https://github.com/casadi/casadi/wiki/L_19k

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1001

info(self) dict
is_commutative(self) bool
is_constant(*args)

Check if the matrix is constant (note that false negative answers are

is_constant(self) -> bool

possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19v

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1083

is_eye(*args)

check if the matrix is an identity matrix (note that false negative

is_eye(self) -> bool

answers

are possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_1a0

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1112

is_integer(*args)

Check if the matrix is integer-valued.

is_integer(self) -> bool

(note that false negative answers are possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19w

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1090

is_leaf(self) bool
is_minus_one(*args)

check if the matrix is -1 (note that false negative answers are

is_minus_one(self) -> bool

possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19z

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1105

is_one(*args)

check if the matrix is 1 (note that false negative answers are

is_one(self) -> bool

possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19y

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1100

is_op(self, int op) bool
is_regular(self) bool
is_smooth(self) bool
is_symbolic(self) bool
is_valid_input(self) bool
is_zero(*args)

check if the matrix is 0 (note that false negative answers are

is_zero(self) -> bool

possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19x

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1095

static matrix_matrix(int op, DM x, DM y) DM
static matrix_scalar(int op, DM x, DM y) DM
n_dep(self) int
name(self) str
static nan(*args)

create a matrix with all nan

nan(int nrow, int ncol) -> DM nan((int,int) rc) -> DM nan(Sparsity sp) -> DM

Extra doc: https://github.com/casadi/casadi/wiki/L_19l

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1012

nan(int nrow, int ncol)

create a matrix with all nan

Extra doc: https://github.com/casadi/casadi/wiki/L_19l

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1011

nan((int,int) rc)

create a matrix with all nan

Extra doc: https://github.com/casadi/casadi/wiki/L_19l

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1012

nan(Sparsity sp)

create a matrix with all nan

Extra doc: https://github.com/casadi/casadi/wiki/L_19l

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1010

nonzeros(*args)

Get all nonzeros.

nonzeros(self) -> [float]

Extra doc: https://github.com/casadi/casadi/wiki/L_1a4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1140

op(self) int
print_dense(*args)

Print dense matrix-stype.

print_dense(self, bool truncate)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L887

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L671-L673

print_scalar(*args)

Print scalar.

print_scalar(self)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L881

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L594-L618

print_sparse(*args)

Print sparse matrix style.

print_sparse(self, bool truncate)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L890

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L676-L678

print_split(*args)

Get strings corresponding to the nonzeros and the interdependencies.

print_split(self) -> ([str] OUTPUT, [str] OUTPUT)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L871

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L681-L685

print_vector(*args)

Print vector-style.

print_vector(self, bool truncate)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L884

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L621-L623

printme(self, DM y) DM
static rand(*args)

Create a matrix with uniformly distributed random numbers.

rand(int nrow, int ncol) -> DM rand((int,int) rc) -> DM rand(Sparsity sp) -> DM

Extra doc: https://github.com/casadi/casadi/wiki/L_1ab

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201-L1203

rand(Sparsity sp)
rand(int nrow, int ncol)

Create a matrix with uniformly distributed random numbers.

Extra doc: https://github.com/casadi/casadi/wiki/L_1ab

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1195

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1195-L1198

rand((int,int) rc)

Create a matrix with uniformly distributed random numbers.

Extra doc: https://github.com/casadi/casadi/wiki/L_1ab

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201-L1203

remove(*args)

Remove columns and rows.

remove(self, [int] rr, [int] cc)

Remove/delete rows and/or columns of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19h

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L942

reserve(self, int nnz)
reserve(self, int nnz, int ncol) None
reset_input(self)
resize(self, int nrow, int ncol)
static rng(int seed)
static scalar_matrix(int op, DM x, DM y) DM
serialize(*args)

Serialize an object.

serialize(self) -> str serialize(self, casadi::SerializingStream & s)

Extra doc: https://github.com/casadi/casadi/wiki/L_1ah

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1250

serialize(self)

Serialize.

Extra doc: https://github.com/casadi/casadi/wiki/L_1ae

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1235

serialize(self, casadi::SerializingStream & s)

Serialize an object.

Extra doc: https://github.com/casadi/casadi/wiki/L_1ah

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1250

set(self, DM m, bool ind1, Sparsity sp)
set(self, DM m, bool ind1, Slice rr) None
set(self, DM m, bool ind1, IM rr) None
set(self, DM m, bool ind1, Slice rr, Slice cc) None
set(self, DM m, bool ind1, Slice rr, IM cc) None
set(self, DM m, bool ind1, IM rr, Slice cc) None
set(self, DM m, bool ind1, IM rr, IM cc) None
static set_max_depth(int eq_depth)
set_nz(self, DM m, bool ind1, Slice k)
set_nz(self, DM m, bool ind1, IM k) None
static set_precision(int precision)
static set_scientific(bool scientific)
static set_width(int width)
sparse(self) PyObject *
sparsity(*args)

Get an owning reference to the sparsity pattern.

sparsity(self) -> Sparsity

Extra doc: https://github.com/casadi/casadi/wiki/L_19j

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L977

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L977-L977

str(*args)

Get string representation.

str(self, bool more) -> str

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L878

to_file(*args)

Export numerical matrix to file

to_file(self, str filename, str format)

Supported formats:

*   - .mtx   Matrix Market (sparse)
*   - .txt   Ascii full precision representation (sparse)
*            Whitespace separated, aligned.
*            Comments with # % or /
*            Uses C locale
*            Structural zeros represented by 00
*            Does not scale well for large sparse matrices
*

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1270

static triplet([int] row, [int] col, DM d) DM
static triplet([int] row, [int] col, DM d, (int,int) rc) DM
static triplet([int] row, [int] col, DM d, int nrow, int ncol) DM
static type_name() str
static unary(int op, DM x) DM

2.2. SX

class SX(*args)
static binary(int op, SX x, SX y) SX
clear(self)
dep(self, int ch) SX
static deserialize(std::istream & stream) SX
static deserialize(casadi::DeserializingStream & s) SX
static deserialize(str s) SX
disp(*args)

Print a representation of the object.

disp(self, bool more)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L875

element_hash(self) int
elements(*args)

Get all elements.

elements(self) -> [SXElem]

Extra doc: https://github.com/casadi/casadi/wiki/L_1a3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1133

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1133-L1133

enlarge(*args)

Enlarge matrix.

enlarge(self, int nrow, int ncol, [int] rr, [int] cc, bool ind1)

Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros

Extra doc: https://github.com/casadi/casadi/wiki/L_19i

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L950

erase(*args)

Erase a submatrix (leaving structural zeros in its place)

erase(self, [int] rr, bool ind1) erase(self, [int] rr, [int] cc, bool ind1)

Erase elements of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19g

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L935

erase(self, [int] rr, bool ind1)

Erase a submatrix (leaving structural zeros in its place)

Erase elements of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19g

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L935

erase(self, [int] rr, [int] cc, bool ind1)

Erase a submatrix (leaving structural zeros in its place)

Erase rows and/or columns of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19f

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L927

export_code(self, str lang, dict options)
static eye(int n) SX
static from_file(str filename, str format_hint) DM
get(self, bool ind1, Sparsity sp) SX
get(self, bool ind1, Slice rr) SX
get(self, bool ind1, IM rr) SX
get(self, bool ind1, Slice rr, Slice cc) SX
get(self, bool ind1, Slice rr, IM cc) SX
get(self, bool ind1, IM rr, Slice cc) SX
get(self, bool ind1, IM rr, IM cc) SX
static get_free(Function f) [SX]
static get_input(Function f) [SX]
static get_max_depth() int
get_nz(self, bool ind1, Slice k) SX
get_nz(self, bool ind1, IM k) SX
has_duplicates(self) bool
has_nz(*args)

Returns true if the matrix has a non-zero at location rr, cc.

has_nz(self, int rr, int cc) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L219

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L219-L219

has_zeros(*args)

Check if the matrix has any zero entries which are not structural

has_zeros(self) -> bool

zeros.

Extra doc: https://github.com/casadi/casadi/wiki/L_1a1

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1123

static inf(*args)

create a matrix with all inf

inf(int nrow, int ncol) -> SX inf((int,int) rc) -> SX inf(Sparsity sp) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_19k

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1003

inf(int nrow, int ncol)

create a matrix with all inf

Extra doc: https://github.com/casadi/casadi/wiki/L_19k

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1002

inf((int,int) rc)

create a matrix with all inf

Extra doc: https://github.com/casadi/casadi/wiki/L_19k

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1003

inf(Sparsity sp)

create a matrix with all inf

Extra doc: https://github.com/casadi/casadi/wiki/L_19k

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1001

info(self) dict
is_commutative(self) bool
is_constant(*args)

Check if the matrix is constant (note that false negative answers are

is_constant(self) -> bool

possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19v

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1083

is_eye(*args)

check if the matrix is an identity matrix (note that false negative

is_eye(self) -> bool

answers

are possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_1a0

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1112

is_integer(*args)

Check if the matrix is integer-valued.

is_integer(self) -> bool

(note that false negative answers are possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19w

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1090

is_leaf(self) bool
is_minus_one(*args)

check if the matrix is -1 (note that false negative answers are

is_minus_one(self) -> bool

possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19z

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1105

is_one(*args)

check if the matrix is 1 (note that false negative answers are

is_one(self) -> bool

possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19y

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1100

is_op(self, int op) bool
is_regular(self) bool
is_smooth(self) bool
is_symbolic(self) bool
is_valid_input(self) bool
is_zero(*args)

check if the matrix is 0 (note that false negative answers are

is_zero(self) -> bool

possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19x

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1095

static matrix_matrix(int op, SX x, SX y) SX
static matrix_scalar(int op, SX x, SX y) SX
n_dep(self) int
name(self) str
static nan(*args)

create a matrix with all nan

nan(int nrow, int ncol) -> SX nan((int,int) rc) -> SX nan(Sparsity sp) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_19l

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1012

nan(int nrow, int ncol)

create a matrix with all nan

Extra doc: https://github.com/casadi/casadi/wiki/L_19l

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1011

nan((int,int) rc)

create a matrix with all nan

Extra doc: https://github.com/casadi/casadi/wiki/L_19l

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1012

nan(Sparsity sp)

create a matrix with all nan

Extra doc: https://github.com/casadi/casadi/wiki/L_19l

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1010

nonzeros(*args)

Get all nonzeros.

nonzeros(self) -> [SXElem]

Extra doc: https://github.com/casadi/casadi/wiki/L_1a4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1140

op(self) int
print_dense(*args)

Print dense matrix-stype.

print_dense(self, bool truncate)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L887

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L671-L673

print_scalar(*args)

Print scalar.

print_scalar(self)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L881

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L594-L618

print_sparse(*args)

Print sparse matrix style.

print_sparse(self, bool truncate)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L890

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L676-L678

print_split(*args)

Get strings corresponding to the nonzeros and the interdependencies.

print_split(self) -> ([str] OUTPUT, [str] OUTPUT)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L871

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L681-L685

print_vector(*args)

Print vector-style.

print_vector(self, bool truncate)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L884

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L621-L623

printme(self, SX y) SX
static rand(*args)

Create a matrix with uniformly distributed random numbers.

rand(int nrow, int ncol) -> SX rand((int,int) rc) -> SX rand(Sparsity sp) -> SX

Extra doc: https://github.com/casadi/casadi/wiki/L_1ab

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201-L1203

rand(Sparsity sp)
rand(int nrow, int ncol)

Create a matrix with uniformly distributed random numbers.

Extra doc: https://github.com/casadi/casadi/wiki/L_1ab

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1195

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1195-L1198

rand((int,int) rc)

Create a matrix with uniformly distributed random numbers.

Extra doc: https://github.com/casadi/casadi/wiki/L_1ab

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201-L1203

remove(*args)

Remove columns and rows.

remove(self, [int] rr, [int] cc)

Remove/delete rows and/or columns of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19h

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L942

reserve(self, int nnz)
reserve(self, int nnz, int ncol) None
reset_input(self)
resize(self, int nrow, int ncol)
static rng(int seed)
static scalar_matrix(int op, SX x, SX y) SX
serialize(*args)

Serialize an object.

serialize(self) -> str serialize(self, casadi::SerializingStream & s)

Extra doc: https://github.com/casadi/casadi/wiki/L_1ah

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1250

serialize(self)

Serialize.

Extra doc: https://github.com/casadi/casadi/wiki/L_1ae

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1235

serialize(self, casadi::SerializingStream & s)

Serialize an object.

Extra doc: https://github.com/casadi/casadi/wiki/L_1ah

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1250

set(self, SX m, bool ind1, Sparsity sp)
set(self, SX m, bool ind1, Slice rr) None
set(self, SX m, bool ind1, IM rr) None
set(self, SX m, bool ind1, Slice rr, Slice cc) None
set(self, SX m, bool ind1, Slice rr, IM cc) None
set(self, SX m, bool ind1, IM rr, Slice cc) None
set(self, SX m, bool ind1, IM rr, IM cc) None
static set_max_depth(int eq_depth)
set_nz(self, SX m, bool ind1, Slice k)
set_nz(self, SX m, bool ind1, IM k) None
static set_precision(int precision)
static set_scientific(bool scientific)
static set_width(int width)
sparsity(*args)

Get an owning reference to the sparsity pattern.

sparsity(self) -> Sparsity

Extra doc: https://github.com/casadi/casadi/wiki/L_19j

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L977

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L977-L977

str(*args)

Get string representation.

str(self, bool more) -> str

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L878

to_file(*args)

Export numerical matrix to file

to_file(self, str filename, str format)

Supported formats:

*   - .mtx   Matrix Market (sparse)
*   - .txt   Ascii full precision representation (sparse)
*            Whitespace separated, aligned.
*            Comments with # % or /
*            Uses C locale
*            Structural zeros represented by 00
*            Does not scale well for large sparse matrices
*

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1270

static triplet([int] row, [int] col, SX d) SX
static triplet([int] row, [int] col, SX d, (int,int) rc) SX
static triplet([int] row, [int] col, SX d, int nrow, int ncol) SX
static type_name() str
static unary(int op, SX x) SX

2.3. MX

class MX(*args)

MX - Matrix expression.

The MX class is used to build up trees made up from MXNodes. It is a more

general graph representation than the scalar expression, SX, and much less efficient for small objects. On the other hand, the class allows much more general operations than does SX, in particular matrix valued

operations and calls to arbitrary differentiable functions.

The MX class is designed to have identical syntax with the Matrix<> template

class, and uses DM (i.e. Matrix<double>) as its internal

representation of the values at a node. By keeping the syntaxes identical, it is possible to switch from one class to the other, as well as inlining MX functions to SXElem functions.

Note that an operation is always “lazy”, making a matrix multiplication will create a matrix multiplication node, not perform the actual multiplication.

Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_py

C++ includes: mx.hpp

attachAssert(*args)

returns itself, but with an assertion attached

attachAssert(self, MX y, str fail_message) -> MX

If y does not evaluate to 1, a runtime error is raised

Extra doc: https://github.com/casadi/casadi/wiki/L_rg

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L810

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L700-L705

static binary(*args)

Create nodes by their ID.

binary(int op, MX x, MX y) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_r1

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L398

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L508-L533

static bspline_dual([float] x, [[float]] knots, [int] degree, dict opts) DM
dep(*args)

Get the nth dependency as MX.

dep(self, int ch) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_qj

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L236

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L731-L733

static deserialize(casadi::DeserializingStream & s) MX
static einstein(*args)

Computes an einstein dense tensor contraction.

einstein(MX A, MX B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> MX einstein(MX A, MX B, MX C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> MX

Computes the product: C_c = A_a + B_b where a b c are index/einstein

notation in an encoded form

For example, an matrix-matrix product may be written as: C_ij = A_ik B_kj

The encoded form uses strictly negative numbers to indicate labels. For the

above example, we would have: a {-1, -3} b {-3, -2} c {-1 -2}

Extra doc: https://github.com/casadi/casadi/wiki/L_r5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L520

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L647-L653

einstein(MX A, MX B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c)

Computes an einstein dense tensor contraction.

Computes the product: C_c = A_a + B_b where a b c are index/einstein

notation in an encoded form

For example, an matrix-matrix product may be written as: C_ij = A_ik B_kj

The encoded form uses strictly negative numbers to indicate labels. For the

above example, we would have: a {-1, -3} b {-3, -2} c {-1 -2}

Extra doc: https://github.com/casadi/casadi/wiki/L_r5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L520

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L647-L653

einstein(MX A, MX B, MX C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c)

Computes an einstein dense tensor contraction.

Computes the product: C_c = A_a + B_b where a b c are index/einstein

notation in an encoded form

For example, an matrix-matrix product may be written as: C_ij = A_ik B_kj

The encoded form uses strictly negative numbers to indicate labels. For the

above example, we would have: a {-1, -3} b {-3, -2} c {-1 -2}

Extra doc: https://github.com/casadi/casadi/wiki/L_r5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L514

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L639-L645

enlarge(*args)

Enlarge matrix.

enlarge(self, int nrow, int ncol, [int] rr, [int] cc, bool ind1)

Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros

Extra doc: https://github.com/casadi/casadi/wiki/L_qg

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L211

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L619-L627

erase(*args)

Erase a submatrix (leaving structural zeros in its place)

erase(self, [int] rr, bool ind1) erase(self, [int] rr, [int] cc, bool ind1)

Erase elements of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_qf

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L204

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L605-L617

erase(self, [int] rr, bool ind1)

Erase a submatrix (leaving structural zeros in its place)

Erase elements of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_qf

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L204

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L605-L617

erase(self, [int] rr, [int] cc, bool ind1)

Erase a submatrix (leaving structural zeros in its place)

Erase rows and/or columns of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_qe

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L196

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L591-L603

eval_mx(*args)

Evaluate the MX node with new symbolic dependencies.

eval_mx(self, [MX] arg) -> [MX]

Extra doc: https://github.com/casadi/casadi/wiki/L_rn

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L856

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L2171-L2177

static eye(int n) MX
get(*args)

Get a submatrix, two arguments

get(self, bool ind1, int rr) -> MX get(self, bool ind1, Sparsity sp) -> MX get(self, bool ind1, Slice rr) -> MX get(self, bool ind1, IM rr) -> MX get(self, bool ind1, MX rr) -> MX get(self, bool ind1, int rr, int cc) -> MX get(self, bool ind1, int rr, Slice cc) -> MX get(self, bool ind1, Slice rr, int cc) -> MX get(self, bool ind1, Slice rr, Slice cc) -> MX get(self, bool ind1, Slice rr, IM cc) -> MX get(self, bool ind1, Slice rr, MX cc) -> MX get(self, bool ind1, IM rr, Slice cc) -> MX get(self, bool ind1, IM rr, IM cc) -> MX get(self, bool ind1, MX rr, Slice cc) -> MX get(self, bool ind1, MX rr, MX cc) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L460

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L219-L222

get(self, bool ind1, IM rr)
get(self, bool ind1, Slice rr, IM cc)
get(self, bool ind1, IM rr, Slice cc)
get(self, bool ind1, IM rr, IM cc)
get(self, bool ind1, int rr)

Get a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L436

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L436-L438

get(self, bool ind1, Sparsity sp)

Get a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L434

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L195-L201

get(self, bool ind1, Slice rr)

Get a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L432

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L172-L175

get(self, bool ind1, MX rr)

Get a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L435

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L203-L207

get(self, bool ind1, int rr, int cc)

Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L454

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L454-L457

get(self, bool ind1, int rr, Slice cc)

Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L449

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L449-L451

get(self, bool ind1, Slice rr, int cc)

Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L445

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L445-L447

get(self, bool ind1, Slice rr, Slice cc)

Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L443

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L142-L145

get(self, bool ind1, Slice rr, MX cc)

Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L459

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L209-L212

get(self, bool ind1, MX rr, Slice cc)

Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L458

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L214-L217

get(self, bool ind1, MX rr, MX cc)

Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L460

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L219-L222

static get_free(Function f) [MX]
static get_input(Function f) [MX]
static get_max_depth() int
get_nz(*args)

Get a set of nonzeros

get_nz(self, bool ind1, int kk) -> MX get_nz(self, bool ind1, Slice kk) -> MX get_nz(self, bool ind1, IM kk) -> MX get_nz(self, bool ind1, MX kk) -> MX get_nz(self, bool ind1, Slice inner, MX outer) -> MX get_nz(self, bool ind1, MX inner, Slice outer) -> MX get_nz(self, bool ind1, MX inner, MX outer) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L488

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L428-L431

get_nz(self, bool ind1, IM kk)
get_nz(self, bool ind1, int kk)

Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L483

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L483-L485

get_nz(self, bool ind1, Slice kk)

Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L480

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L385-L388

get_nz(self, bool ind1, MX kk)

Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L482

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L423-L426

get_nz(self, bool ind1, Slice inner, MX outer)

Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L487

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L433-L436

get_nz(self, bool ind1, MX inner, Slice outer)

Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L486

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L438-L441

get_nz(self, bool ind1, MX inner, MX outer)

Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L488

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L428-L431

get_output(*args)

Get an output.

get_output(self, int oind) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_ql

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L246

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L846-L848

get_temp(self) int
has_duplicates(self) bool
static inf(*args)

create a matrix with all inf

inf(int nrow, int ncol) -> MX inf((int,int) rc) -> MX inf(Sparsity sp) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_r2

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L408

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L555-L557

inf(int nrow, int ncol)

create a matrix with all inf

Extra doc: https://github.com/casadi/casadi/wiki/L_r2

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L407

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L551-L553

inf((int,int) rc)

create a matrix with all inf

Extra doc: https://github.com/casadi/casadi/wiki/L_r2

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L408

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L555-L557

inf(Sparsity sp)

create a matrix with all inf

Extra doc: https://github.com/casadi/casadi/wiki/L_r2

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L406

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L559-L561

info(*args)

Obtain information about node

info(self) -> dict

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L374

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L799-L801

static interpn_linear([MX] x, MX v, [MX] xq, dict opts) MX
is_binary(*args)

Is binary operation.

is_binary(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L365

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L787-L789

is_call(*args)

Check if evaluation.

is_call(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L269

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L751-L753

is_commutative(*args)

Check if commutative operation.

is_commutative(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L287

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L823-L828

is_constant(*args)

Check if constant.

is_constant(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L266

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L747-L749

is_eye(*args)

check if identity

is_eye(self) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_qu

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L339

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L938-L940

is_minus_one(*args)

check if zero (note that false negative answers are possible)

is_minus_one(self) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_qx

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L354

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L954-L956

is_multiplication(*args)

Check if multiplication.

is_multiplication(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L284

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L771-L773

is_norm(*args)

Check if norm.

is_norm(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L290

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L775-L777

is_one(*args)

check if zero (note that false negative answers are possible)

is_one(self) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_qw

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L349

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L950-L952

is_op(*args)

Is it a certain operation.

is_op(self, int op) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L281

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L767-L769

is_output(*args)

Check if evaluation output.

is_output(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L275

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L759-L761

is_regular(*args)

Checks if expression does not contain NaN or Inf.

is_regular(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L362

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L962-L968

is_symbolic(*args)

Check if symbolic.

is_symbolic(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L263

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L743-L745

is_transpose(*args)

Is the expression a transpose?

is_transpose(self) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_qy

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L359

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L958-L960

is_unary(*args)

Is unary operation.

is_unary(self) -> bool

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L368

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L791-L793

is_valid_input(*args)

Check if matrix can be used to define function inputs.

is_valid_input(self) -> bool

Valid inputs for MXFunctions are combinations of Reshape, concatenations and SymbolicMX

Extra doc: https://github.com/casadi/casadi/wiki/L_qn

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L297

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L898-L900

is_zero(*args)

check if zero (note that false negative answers are possible)

is_zero(self) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_qv

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L344

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L942-L948

join_primitives(*args)

Join an expression along symbolic primitives.

join_primitives(self, [MX] v) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_qr

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L317

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L922-L928

mapping(*args)

Get an IM representation of a GetNonzeros or SetNonzeros node.

mapping(self) -> IM

Extra doc: https://github.com/casadi/casadi/wiki/L_ri

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L825

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L830-L832

monitor(*args)

Monitor an expression.

monitor(self, str comment) -> MX

Returns itself, but with the side effect of printing the nonzeros along with a comment

Extra doc: https://github.com/casadi/casadi/wiki/L_rh

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L817

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L707-L709

n_dep(*args)

Get the number of dependencies of a binary SXElem.

n_dep(self) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_qm

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L251

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L735-L737

n_out(*args)

Number of outputs.

n_out(self) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_qk

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L241

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L842-L844

n_primitives(*args)

Get the number of primitives for MXFunction inputs/outputs.

n_primitives(self) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_qo

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L302

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L902-L904

name(*args)

Get the name.

name(self) -> str

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L254

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L739-L741

static nan(*args)

create a matrix with all nan

nan(int nrow, int ncol) -> MX nan((int,int) rc) -> MX nan(Sparsity sp) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_r3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L417

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L567-L569

nan(int nrow, int ncol)

create a matrix with all nan

Extra doc: https://github.com/casadi/casadi/wiki/L_r3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L416

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L563-L565

nan((int,int) rc)

create a matrix with all nan

Extra doc: https://github.com/casadi/casadi/wiki/L_r3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L417

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L567-L569

nan(Sparsity sp)

create a matrix with all nan

Extra doc: https://github.com/casadi/casadi/wiki/L_r3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L415

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L571-L573

op(*args)

Get operation type.

op(self) -> int

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L371

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L795-L797

primitives(*args)

Get primitives.

primitives(self) -> [MX]

Extra doc: https://github.com/casadi/casadi/wiki/L_qp

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L307

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L906-L912

printme(self, MX b) MX
reset_input(self)
serialize(*args)

Serialize an object.

serialize(self, casadi::SerializingStream & s)

Extra doc: https://github.com/casadi/casadi/wiki/L_qz

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L379

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L803-L805

set(*args)

set(self, MX m, bool ind1, Sparsity sp) set(self, MX m, bool ind1, Slice rr) set(self, MX m, bool ind1, IM rr) set(self, MX m, bool ind1, Slice rr, Slice cc) set(self, MX m, bool ind1, Slice rr, IM cc) set(self, MX m, bool ind1, IM rr, Slice cc) set(self, MX m, bool ind1, IM rr, IM cc)

set(self, MX m, bool ind1, IM rr)
set(self, MX m, bool ind1, Slice rr, IM cc)
set(self, MX m, bool ind1, IM rr, Slice cc)
set(self, MX m, bool ind1, IM rr, IM cc)
set(self, MX m, bool ind1, Sparsity sp)

Set a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L467

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L372-L383

set(self, MX m, bool ind1, Slice rr)

Set a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L465

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L299-L302

set(self, MX m, bool ind1, Slice rr, Slice cc)

Set a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L472

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L224-L227

static set_max_depth(int eq_depth)
set_nz(*args)

Set a set of nonzeros

set_nz(self, MX m, bool ind1, int kk) set_nz(self, MX m, bool ind1, Slice kk) set_nz(self, MX m, bool ind1, IM kk) set_nz(self, MX m, bool ind1, MX kk)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L496

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L496-L496

set_nz(self, MX m, bool ind1, IM kk)
set_nz(self, MX m, bool ind1, int kk)

Set a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L496

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L496-L496

set_nz(self, MX m, bool ind1, Slice kk)

Set a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L493

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L443-L446

set_nz(self, MX m, bool ind1, MX kk)

Set a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L495

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L504-L506

set_temp(self, int t)
sparsity(*args)

Get an owning reference to the sparsity pattern.

sparsity(self) -> Sparsity

Extra doc: https://github.com/casadi/casadi/wiki/L_qd

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L189

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L189-L189

split_primitives(*args)

Split up an expression along symbolic primitives.

split_primitives(self, MX x) -> [MX]

Extra doc: https://github.com/casadi/casadi/wiki/L_qq

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L312

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L914-L920

static test_cast(casadi::SharedObjectInternal const * ptr) bool
to_DM(self) DM
static type_name() str
static unary(*args)

Create nodes by their ID.

unary(int op, MX x) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_r1

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L399

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L535-L537

which_function(*args)

Get function - only valid when is_call() is true.

which_function(self) -> Function

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L272

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L755-L757

which_output(*args)

Get the index of evaluation output - only valid when is_output() is true.

which_output(self) -> int

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L278

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L763-L765

2.4. Sparsity

class Sparsity(*args)
add_nz(self, int rr, int cc) int
amd(self) [int]
append(self, Sparsity sp)
appendColumns(self, Sparsity sp)
static band(int n, int p) Sparsity
static banded(int n, int p) Sparsity
btf(self) -> (int , [int] OUTPUT, [int] OUTPUT, [int] OUTPUT, [int] OUTPUT, [int] OUTPUT, [int] OUTPUT)
bw_lower(self) int
bw_upper(self) int
colind(self) [int]
colind(self, int cc) int
columns(self) int
combine(self, Sparsity y, bool f0x_is_zero, bool function0_is_zero) Sparsity
compress(self) [int]
static compressed([int] v, bool order_rows) Sparsity
static dense(int nrow, int ncol) Sparsity
static dense((int, int) rc) Sparsity
density(self) float
static deserialize(std::istream & stream) Sparsity
static deserialize(casadi::DeserializingStream & s) Sparsity
static deserialize(str s) Sparsity
dfs(self, int j, int top, [int] pinv) -> (int , [int] INOUT, [int] INOUT, [bool] INOUT)
static diag(int nrow) Sparsity
static diag((int, int) rc) Sparsity
static diag(int nrow, int ncol) Sparsity
dim(self, bool with_nz) str
enlarge(self, int nrow, int ncol, [int] rr, [int] cc, bool ind1)
enlargeColumns(self, int ncol, [int] cc, bool ind1)
enlargeRows(self, int nrow, [int] rr, bool ind1)
erase(self, [int] rr, bool ind1) [int]
erase(self, [int] rr, [int] cc, bool ind1) [int]
etree(self, bool ata) [int]
export_code(self, str lang, dict options)
find(self, bool ind1) [int]
static from_file(str filename, str format_hint) Sparsity
get_ccs(self) -> ([int] OUTPUT, [int] OUTPUT)
get_col(self) [int]
get_crs(self) -> ([int] OUTPUT, [int] OUTPUT)
get_diag(self) -> (Sparsity , [int] OUTPUT)
get_lower(self) [int]
get_nz(self) [int]
get_nz(self, int rr, int cc) int
get_nz(self, [int] rr, [int] cc) [int]
get_triplet(self) -> ([int] OUTPUT, [int] OUTPUT)
get_upper(self) [int]
has_nz(self, int rr, int cc) bool
hash(self) std::size_t
info(self) dict
intersect(self, Sparsity y) Sparsity
is_column(self) bool
is_dense(self) bool
is_diag(self) bool
is_empty(self, bool both) bool
is_equal(self, Sparsity y) bool
is_equal(self, int nrow, int ncol, [int] colind, [int] row) bool
is_reshape(self, Sparsity y) bool
is_row(self) bool
is_scalar(self, bool scalar_and_dense) bool
is_singular(self) bool
is_square(self) bool
is_stacked(self, Sparsity y, int n) bool
is_subset(self, Sparsity rhs) bool
is_symmetric(self) bool
is_transpose(self, Sparsity y) bool
is_tril(self, bool strictly) bool
is_triu(self, bool strictly) bool
is_vector(self) bool
static kkt(Sparsity H, Sparsity J, bool with_x_diag, bool with_lam_g_diag) Sparsity
largest_first(self) [int]
ldl(self, bool amd) -> (Sparsity , [int] OUTPUT)
static lower(int n) Sparsity
makeDense(self) -> (Sparsity , [int] OUTPUT)
nnz(self) int
nnz_diag(self) int
nnz_lower(self, bool strictly) int
nnz_upper(self, bool strictly) int
static nonzeros(int nrow, int ncol, [int] nz, bool ind1) Sparsity
numel(self) int
pattern_inverse(self) Sparsity
pmult(self, [int] p, bool permute_rows, bool permute_columns, bool invert_permutation) Sparsity
postfix_dim(self) str
qr_sparse(self, bool amd) -> (Sparsity OUTPUT, Sparsity OUTPUT, [int] OUTPUT, [int] OUTPUT)
removeDuplicates(self) [int]
repr_el(self, int k) str
resize(self, int nrow, int ncol)
row(self) [int]
row(self, int el) int
static rowcol([int] row, [int] col, int nrow, int ncol) Sparsity
rows(self) int
rowsSequential(self, bool strictly) bool
static scalar(bool dense_scalar) Sparsity
scc(self) -> (int , [int] OUTPUT, [int] OUTPUT)
serialize(self) str
serialize(self, casadi::SerializingStream & s) None
size(self)
size(self, int axis) int
size1(self) int
size2(self) int
spy(self)
spy_matlab(self, str mfile)
star_coloring(self, int ordering, int cutoff) Sparsity
star_coloring2(self, int ordering, int cutoff) Sparsity
sub(self, [int] rr, Sparsity sp, bool ind1) -> (Sparsity , [int] OUTPUT)
sub(self, [int] rr, [int] cc, bool ind1) -> (Sparsity , [int] OUTPUT) None
static test_cast(casadi::SharedObjectInternal const * ptr) bool
to_file(self, str filename, str format_hint)
transpose(self, bool invert_mapping) -> (Sparsity , [int] OUTPUT)
static triplet(int nrow, int ncol, [int] row, [int] col) Sparsity
static triplet(int nrow, int ncol, [int] row, [int] col, bool invert_mapping) -> (Sparsity , [int] OUTPUT) None
static type_name() str
uni_coloring(self, Sparsity AT, int cutoff) Sparsity
static unit(int n, int el) Sparsity
unite(self, Sparsity y) Sparsity
static upper(int n) Sparsity

2.5. Function

class Function(*args)

Function object.

A Function instance is a general multiple-input, multiple-output function where each input and output can be a sparse matrix.

For an introduction to this class, see the CasADi user guide. Function is a reference counted and

immutable class; copying a class instance is very cheap and its behavior (with some exceptions) is not affected by calling its member functions.

Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_1uw

>List of available options

Id

Type

Description

Used in

ad_weight

OT_DOUBLE

Weighting factor for derivative calculation.When there is an option of either using forward or reverse mode directional derivatives, the condition ad_wei ght*nf<=(1-ad_we ight)*na is used where nf and na are estimates of the number of forward/reverse mode directional derivatives needed. By default, ad_weight is calculated automatically, but this can be overridden by setting this option. In particular, 0 means forcing forward mode and 1 forcing reverse mode. Leave unset for (class specific) heuristics.

casadi::Function Internal

ad_weight_sp

OT_DOUBLE

Weighting factor for sparsity pattern calculation calc ulation.Override s default behavior. Set to 0 and 1 to force forward and reverse mode respectively. Cf. option “ad_weight”. When set to -1, sparsity is completely ignored and dense matrices are used.

casadi::Function Internal

always_inline

OT_BOOL

Force inlining.

casadi::Function Internal

compiler

OT_STRING

Just-in-time compiler plugin to be used.

casadi::Function Internal

custom_jacobian

OT_FUNCTION

Override CasADi’s AD. Use together with ‘jac_penalty’: 0. Note: Highly experimental. Syntax may break often.

casadi::Function Internal

derivative_of

OT_FUNCTION

The function is a derivative of another function. The type of derivative (directional derivative, Jacobian) is inferred from the function name.

casadi::Function Internal

dump

OT_BOOL

Dump function to file upon first evaluation. [false]

casadi::Function Internal

dump_dir

OT_STRING

Directory to dump inputs/outputs to. Make sure the directory exists [.]

casadi::Function Internal

dump_format

OT_STRING

Choose file format to dump matrices. See DM.from_file [mtx]

casadi::Function Internal

dump_in

OT_BOOL

Dump numerical values of inputs to file (readable with DM.from_file ) [default: false]

casadi::Function Internal

dump_out

OT_BOOL

Dump numerical values of outputs to file (readable with DM.from_file ) [default: false]

casadi::Function Internal

enable_fd

OT_BOOL

Enable derivative calculation by finite differencing. [default: false]]

casadi::Function Internal

enable_forward

OT_BOOL

Enable derivative calculation using generated functions for Jacobian-times- vector products - typically using forward mode AD - if available. [default: true]

casadi::Function Internal

enable_jacobian

OT_BOOL

Enable derivative calculation using generated functions for Jacobians of all differentiable outputs with respect to all differentiable inputs - if available. [default: true]

casadi::Function Internal

enable_reverse

OT_BOOL

Enable derivative calculation using generated functions for transposed Jacobian-times- vector products - typically using reverse mode AD - if available. [default: true]

casadi::Function Internal

fd_method

OT_STRING

Method for finite differencing [default ‘central’]

casadi::Function Internal

fd_options

OT_DICT

Options to be passed to the finite difference instance

casadi::Function Internal

forward_options

OT_DICT

Options to be passed to a forward mode constructor

casadi::Function Internal

gather_stats

OT_BOOL

Deprecated option (ignored): Statistics are now always collected.

casadi::Function Internal

input_scheme

OT_STRINGVECTOR

Deprecated option (ignored)

casadi::Function Internal

inputs_check

OT_BOOL

Throw exceptions when the numerical values of the inputs don’t make sense

casadi::Function Internal

is_diff_in

OT_BOOLVECTOR

Indicate for each input if it should be differentiable.

casadi::Function Internal

is_diff_out

OT_BOOLVECTOR

Indicate for each output if it should be differentiable.

casadi::Function Internal

jac_penalty

OT_DOUBLE

When requested for a number of forward/reverse directions, it may be cheaper to compute first the full jacobian and then multiply with seeds, rather than obtain the requested directions in a straightforward manner. Casadi uses a heuristic to decide which is cheaper. A high value of ‘jac_penalty’ makes it less likely for the heurstic to chose the full Jacobian strategy. The special value -1 indicates never to use the full Jacobian strategy

casadi::Function Internal

jacobian_options

OT_DICT

Options to be passed to a Jacobian constructor

casadi::Function Internal

jit

OT_BOOL

Use just-in-time compiler to speed up the evaluation

casadi::Function Internal

jit_cleanup

OT_BOOL

Cleanup up the temporary source file that jit creates. Default: true

casadi::Function Internal

jit_name

OT_STRING

The file name used to write out code. The actual file names used depend on ‘jit_t emp_suffix’ and include extensions. Default: ‘jit_tmp’

casadi::Function Internal

jit_options

OT_DICT

Options to be passed to the jit compiler.

casadi::Function Internal

jit_serialize

OT_STRING

Specify behaviour when serializing a jitted function: SOURCE|link|embe d.

casadi::Function Internal

jit_temp_suffix

OT_BOOL

Use a temporary (seemingly random) filename suffix for generated code and libraries. This is desired for thread- safety. This behaviour may defeat caching compiler wrappers. Default: true

casadi::Function Internal

max_io

OT_INT

Acceptable number of inputs and outputs. Warn if exceeded.

casadi::Function Internal

max_num_dir

OT_INT

Specify the maximum number of directions for derivative functions. Overrules the builtin optimize d_num_dir.

casadi::Function Internal

never_inline

OT_BOOL

Forbid inlining.

casadi::Function Internal

output_scheme

OT_STRINGVECTOR

Deprecated option (ignored)

casadi::Function Internal

post_expand

OT_BOOL

After construction, expand this Function . Default: False

casadi::Function Internal

post_expand_opti ons

OT_DICT

Options to be passed to post- construction expansion. Default: empty

casadi::Function Internal

print_in

OT_BOOL

Print numerical values of inputs [default: false]

casadi::Function Internal

print_out

OT_BOOL

Print numerical values of outputs [default: false]

casadi::Function Internal

print_time

OT_BOOL

print information about execution time. Implies record_time.

casadi::Function Internal

record_time

OT_BOOL

record information about execution time, for retrieval with stats() .

casadi::Function Internal

regularity_check

OT_BOOL

Throw exceptions when NaN or Inf appears during evaluation

casadi::Function Internal

reverse_options

OT_DICT

Options to be passed to a reverse mode constructor

casadi::Function Internal

user_data

OT_VOIDPTR

A user-defined field that can be used to identify the function or pass additional information

casadi::Function Internal

verbose

OT_BOOL

Verbose evaluation for debugging

casadi::Function Internal

C++ includes: function.hpp

assert_size_in(*args)

Assert that an input dimension is equal so some given value.

assert_size_in(self, int i, int nrow, int ncol)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1189

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1715-L1721

assert_size_out(*args)

Assert that an output dimension is equal so some given value.

assert_size_out(self, int i, int nrow, int ncol)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1192

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1723-L1728

static bspline(str name, [[float]] knots, [float] coeffs, [int] degree, int m, dict opts) Function
buffer()

Create a FunctionBuffer object for evaluating with minimal overhead

call(*args)

Evaluate the function symbolically or numerically.

call(self, dict:DM arg, bool always_inline, bool never_inline) -> dict:DM call(self, [DM] arg, bool always_inline, bool never_inline) -> [DM] call(self, [SX] arg, bool always_inline, bool never_inline) -> [SX] call(self, dict:SX arg, bool always_inline, bool never_inline) -> dict:SX call(self, dict:MX arg, bool always_inline, bool never_inline) -> dict:MX call(self, [MX] arg, bool always_inline, bool never_inline) -> [MX]

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L524

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1407-L1414

call(self, dict:DM arg, bool always_inline, bool never_inline)

Evaluate the function symbolically or numerically.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L520

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1389-L1396

call(self, [DM] arg, bool always_inline, bool never_inline)

Evaluate the function symbolically or numerically.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L514

call(self, [SX] arg, bool always_inline, bool never_inline)

Evaluate the function symbolically or numerically.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L516

call(self, dict:SX arg, bool always_inline, bool never_inline)

Evaluate the function symbolically or numerically.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L522

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1398-L1405

call(self, dict:MX arg, bool always_inline, bool never_inline)

Evaluate the function symbolically or numerically.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L524

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1407-L1414

call(self, [MX] arg, bool always_inline, bool never_inline)

Evaluate the function symbolically or numerically.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L518

change_option(*args)

Change option after object creation for debugging.

change_option(self, str option_name, GenericType option_value)

This is only possible for a selected number of options that do not change the numerical results of the computation, e.g. to enable a more

verbose

output or saving to file.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w2

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L455

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1114-L1124

static check_name(str name) bool
checkout(*args)

Checkout a memory object.

checkout(self) -> int

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1195

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1703-L1705

static conditional(str name, Function f, dict opts) Function
static conditional(str name, [Function] f, Function f_def, dict opts) Function
convert_in(*args)

Convert from/to input/output lists/map.

convert_in(self, dict:DM arg) -> [DM] convert_in(self, [DM] arg) -> dict:DM convert_in(self, [SX] arg) -> dict:SX convert_in(self, dict:SX arg) -> [SX] convert_in(self, dict:MX arg) -> [MX] convert_in(self, [MX] arg) -> dict:MX

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L996

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1587-L1589

convert_in(self, dict:DM arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L988

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1555-L1557

convert_in(self, [DM] arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L987

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1551-L1553

convert_in(self, [SX] arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L991

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1567-L1569

convert_in(self, dict:SX arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L992

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1571-L1573

convert_in(self, dict:MX arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L996

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1587-L1589

convert_in(self, [MX] arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L995

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1583-L1585

convert_out(*args)

Convert from/to input/output lists/map.

convert_out(self, dict:DM arg) -> [DM] convert_out(self, [DM] arg) -> dict:DM convert_out(self, [SX] arg) -> dict:SX convert_out(self, dict:SX arg) -> [SX] convert_out(self, dict:MX arg) -> [MX] convert_out(self, [MX] arg) -> dict:MX

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L998

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1595-L1597

convert_out(self, dict:DM arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L990

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1563-L1565

convert_out(self, [DM] arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L989

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1559-L1561

convert_out(self, [SX] arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L993

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1575-L1577

convert_out(self, dict:SX arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L994

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1579-L1581

convert_out(self, dict:MX arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L998

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1595-L1597

convert_out(self, [MX] arg)

Convert from/to input/output lists/map.

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L997

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1591-L1593

default_in(*args)

Get default input value.

default_in(self, int ind) -> float

Extra doc: https://github.com/casadi/casadi/wiki/L_1vm

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L346

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1416-L1418

static deserialize(std::istream & stream) Function
static deserialize(casadi::DeserializingStream & s) Function
static deserialize(str s) Function
expand(*args)

Expand a function to SX.

expand(self) -> Function expand(self, str name, dict opts) -> Function

Extra doc: https://github.com/casadi/casadi/wiki/L_1v5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L207

expand(self)

Expand a function to SX.

Extra doc: https://github.com/casadi/casadi/wiki/L_1v5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L206

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L274-L282

expand(self, str name, dict opts)

Expand a function to SX.

Extra doc: https://github.com/casadi/casadi/wiki/L_1v5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L207

export_code(*args)

Export function in specific language.

export_code(self, str lang, dict options) -> str export_code(self, str lang, str fname, dict options)

Only allowed for (a subset of) SX/MX Functions

Extra doc: https://github.com/casadi/casadi/wiki/L_1wz

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L902

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1238-L1242

export_code(self, str lang, dict options)

Export function in specific language.

Only allowed for (a subset of) SX/MX Functions

Extra doc: https://github.com/casadi/casadi/wiki/L_1wz

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L902

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1238-L1242

export_code(self, str lang, str fname, dict options)

Export function in specific language.

Only allowed for (a subset of) SX/MX Functions

Extra doc: https://github.com/casadi/casadi/wiki/L_1wz

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L875

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1199-L1203

factory(self, str name, [str] s_in, [str] s_out, dict:[str] aux, dict opts) Function
find(*args)

Get a specific function embedded in the expression graphs.

find(self, int max_depth) -> [Function] find(self, int max_depth, str name) -> Function

max_depth: Maximum depth - a negative number indicates no maximum

name: Name of function needed

Extra doc: https://github.com/casadi/casadi/wiki/L_1y7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1233

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1796-L1813

find(self, int max_depth)

Get all functions embedded in the expression graphs.

max_depth: Maximum depth - a negative number indicates no maximum

Extra doc: https://github.com/casadi/casadi/wiki/L_1y6

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1225

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1778-L1794

find(self, int max_depth, str name)

Get a specific function embedded in the expression graphs.

max_depth: Maximum depth - a negative number indicates no maximum

name: Name of function needed

Extra doc: https://github.com/casadi/casadi/wiki/L_1y7

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1233

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1796-L1813

static fix_name(str name) str
fold(*args)

Create a mapaccumulated version of this function.

fold(self, int N, dict opts) -> Function

Suppose the function has a signature of:

f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

F: (x0, U) -> (X , Y )

 with
     U: horzcat([u0, u1, ..., u_(N-1)])
     X: horzcat([x1, x2, ..., x_N])
     Y: horzcat([y0, y1, ..., y_(N-1)])

 and
     x1, y0 <- f(x0, u0)
     x2, y1 <- f(x1, u1)
     ...
     x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for- loop:

much faster at construction time

potentially much faster compilation times (for codegen)

offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for- loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly

slower at evaluation, than a plain for-loop. The effect is

similar to that

of a for-loop with a check-pointing instruction after

each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L698

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L475-L481

forward(*args)

Get a function that calculates nfwd forward derivatives.

forward(self, int nfwd) -> Function

 Returns a function with <tt>n_in + n_out + n_in</tt> inputs
 and <tt>nfwd</tt> outputs.
 The first <tt>n_in</tt> inputs correspond to nondifferentiated inputs.
 The next <tt>n_out</tt> inputs correspond to nondifferentiated outputs.
 and the last <tt>n_in</tt> inputs correspond to forward seeds,
 stacked horizontally
 The  <tt>n_out</tt> outputs correspond to forward sensitivities,
 stacked horizontally.     *
 <tt>(n_in = n_in(), n_out = n_out())</tt>

The functions returned are cached, meaning that if called multiple timed
with the same value, then multiple references to the same function will be returned.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wq

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L800

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1077-L1083

free_mx(*args)

Get all the free variables of the function.

free_mx(self) -> [MX]

Extra doc: https://github.com/casadi/casadi/wiki/L_1xb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1019

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1611-L1617

free_sx(*args)

Get all the free variables of the function.

free_sx(self) -> [SX]

Extra doc: https://github.com/casadi/casadi/wiki/L_1xa

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1014

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1603-L1609

generate(*args)

Export / Generate C code for the function.

generate(self, dict opts) -> str generate(self, str fname, dict opts) -> str

Extra doc: https://github.com/casadi/casadi/wiki/L_1wv

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L840

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1130-L1132

generate(self, dict opts)

Export / Generate C code for the function.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wv

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L840

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1130-L1132

generate(self, str fname, dict opts)

Export / Generate C code for the function.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wu

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L835

generate_dependencies(*args)

Export / Generate C code for the dependency function.

generate_dependencies(self, str fname, dict opts) -> str

Extra doc: https://github.com/casadi/casadi/wiki/L_1ww

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L845

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1140-L1142

generate_in(*args)

Export an input file that can be passed to generate C code with a

generate_in(self, str fname) -> [DM] generate_in(self, str fname, [DM] arg)

main.

See:

generate_out

See:

convert_in to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wx

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L855

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1174-L1182

generate_in(self, str fname)

Export an input file that can be passed to generate C code with a main.

See:

generate_out

See:

convert_in to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wx

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L855

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1174-L1182

generate_in(self, str fname, [DM] arg)

Export an input file that can be passed to generate C code with a main.

See:

generate_out

See:

convert_in to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wx

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L854

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1144-L1157

generate_lifted(*args)

Extract the functions needed for the Lifted Newton method.

generate_lifted(self) -> (Function OUTPUT, Function OUTPUT)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xc

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1024

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1631-L1637

generate_out(*args)

Export an output file that can be checked with generated C code

generate_out(self, str fname) -> [DM] generate_out(self, str fname, [DM] arg)

output.

See:

generate_in

See:

convert_out to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wy

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L866

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1184-L1192

generate_out(self, str fname)

Export an output file that can be checked with generated C code output.

See:

generate_in

See:

convert_out to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wy

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L866

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1184-L1192

generate_out(self, str fname, [DM] arg)

Export an output file that can be checked with generated C code output.

See:

generate_in

See:

convert_out to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wy

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L865

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1159-L1172

get_free(*args)

Get free variables as a string.

get_free(self) -> [str]

Extra doc: https://github.com/casadi/casadi/wiki/L_1x9

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1009

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1126-L1128

get_function(*args)

Get a dependency function.

get_function(self) -> [str] get_function(self, str name) -> Function

Extra doc: https://github.com/casadi/casadi/wiki/L_1y4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1213

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1761-L1767

get_function(self, str name)

Get a dependency function.

Extra doc: https://github.com/casadi/casadi/wiki/L_1y4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1213

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1761-L1767

get_function(self)

Get a list of all functions.

Extra doc: https://github.com/casadi/casadi/wiki/L_1y3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1208

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1753-L1759

has_free(*args)

Does the function have free variables.

has_free(self) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_1x8

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1004

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1627-L1629

has_function(*args)

Check if a particular dependency exists.

has_function(self, str fname) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_1y5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1218

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1769-L1776

has_option(*args)

Does a particular option exist.

has_option(self, str option_name) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_1w1

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L447

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1105-L1112

has_spfwd(*args)

Is the class able to propagate seeds through the algorithm?

has_spfwd(self) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_1xl

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1078

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1619-L1621

has_sprev(*args)

Is the class able to propagate seeds through the algorithm?

has_sprev(self) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_1xl

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1079

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1623-L1625

hessian_old(*args)

[DEPRECATED] Replaced by Function::factory.

hessian_old(self, int iind, int oind) -> Function

Extra doc: https://github.com/casadi/casadi/wiki/L_1w5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L471

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L862-L870

static if_else(str name, Function f_true, Function f_false, dict opts) Function
index_in(*args)

Find the index for a string describing a particular entry of an input

index_in(self, str name) -> int

scheme.

example: schemeEntry(“x_opt”) -> returns NLPSOL_X if FunctionInternal adheres to SCHEME_NLPINput

Extra doc: https://github.com/casadi/casadi/wiki/L_1vk

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L333

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L925-L931

index_out(*args)

Find the index for a string describing a particular entry of an output

index_out(self, str name) -> int

scheme.

example: schemeEntry(“x_opt”) -> returns NLPSOL_X if FunctionInternal adheres to SCHEME_NLPINput

Extra doc: https://github.com/casadi/casadi/wiki/L_1vl

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L341

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L933-L939

info(*args)

Obtain information about function

info(self) -> dict

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1236

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1842-L1844

instruction_MX(*args)

Get the MX node corresponding to an instruction (MXFunction)

instruction_MX(self, int k) -> MX

Extra doc: https://github.com/casadi/casadi/wiki/L_1xj

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1064

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1647-L1653

instruction_constant(*args)

Get the floating point output argument of an instruction (SXFunction)

instruction_constant(self, int k) -> float

Extra doc: https://github.com/casadi/casadi/wiki/L_1xh

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1052

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1679-L1685

instruction_id(*args)

Identifier index of the instruction (SXFunction/MXFunction)

instruction_id(self, int k) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_1xf

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1040

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1663-L1669

instruction_input(*args)

Locations in the work vector for the inputs of the instruction.

instruction_input(self, int k) -> [int]

(SXFunction/MXFunction)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xg

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1047

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1671-L1677

instruction_output(*args)

Location in the work vector for the output of the instruction.

instruction_output(self, int k) -> [int]

(SXFunction/MXFunction)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1059

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1687-L1693

instructions_sx(*args)

Get the SX node corresponding to all instructions (SXFunction)

instructions_sx(self) -> SX

Note: input and output instructions have no SX representation. This method returns nan for those instructions.

Extra doc: https://github.com/casadi/casadi/wiki/L_1xk

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1072

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1655-L1661

is_a(*args)

Check if the function is of a particular type.

is_a(self, str type, bool recursive) -> bool

Optionally check if name matches one of the base classes (default true)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xw

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1144

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1599-L1601

is_diff_in(*args)

Get differentiability of inputs/output.

is_diff_in(self) -> [bool] is_diff_in(self, int ind) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L390

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1005-L1011

is_diff_in(self)

Get differentiability of inputs/output.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L390

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1005-L1011

is_diff_in(self, int ind)

Get differentiability of inputs/output.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L388

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L989-L995

is_diff_out(*args)

Get differentiability of inputs/output.

is_diff_out(self) -> [bool] is_diff_out(self, int ind) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L391

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1013-L1019

is_diff_out(self)

Get differentiability of inputs/output.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L391

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1013-L1019

is_diff_out(self, int ind)

Get differentiability of inputs/output.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L389

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L997-L1003

jac_sparsity(*args)

Get, if necessary generate, the sparsity of a single Jacobian block.

jac_sparsity(self, bool compact) -> [Sparsity] jac_sparsity(self, int oind, int iind, bool compact) -> Sparsity

Extra doc: https://github.com/casadi/casadi/wiki/L_1wt

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L830

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L909-L915

jac_sparsity(self, bool compact)

Get, if necessary generate, the sparsity of all Jacobian blocks.

Extra doc: https://github.com/casadi/casadi/wiki/L_1ws

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L825

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L898-L907

jac_sparsity(self, int oind, int iind, bool compact)

Get, if necessary generate, the sparsity of a single Jacobian block.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wt

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L830

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L909-L915

jacobian(*args)

Calculate all Jacobian blocks.

jacobian(self) -> Function

Generates a function that takes all non-differentiated inputs and outputs and calculates all Jacobian blocks. Inputs that are not needed

by the

routine are all-zero sparse matrices with the correct dimensions. Output blocks that are not calculated, e.g. if the corresponding input or output is marked non-differentiated are also all-zero sparse. The Jacobian blocks are sorted starting by all the blocks for the first output, then all the blocks for the second output and so on. E.g. f : (x, y) -> (r, s) results in the function jac_f : (x, y, out_r, out_s) -> (jac_r_x, jac_r_y, jac_s_x,

jac_s_y)

This function is cached.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w6

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L508

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L882-L888

jacobian_old(*args)

[DEPRECATED] Replaced by Function::factory.

jacobian_old(self, int iind, int oind) -> Function

Extra doc: https://github.com/casadi/casadi/wiki/L_1w4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L466

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L854-L860

static jit(*args)

Create a just-in-time compiled function from a C language string.

jit(str name, str body, [str] name_in, [str] name_out, dict opts) -> Function jit(str name, str body, [str] name_in, [str] name_out, [Sparsity] sparsity_in, [Sparsity] sparsity_out, dict opts) -> Function

The names and sparsity patterns of all the inputs and outputs must be

provided. If sparsities are not provided, all inputs and outputs are

assumed to be scalar. Only specify the function body, assuming that input and output nonzeros are stored in arrays with the specified naming convension. The data type used is ‘casadi_real’, which is typically equal to ‘double or another data type with the same API as ‘double.

Inputs may be null pointers. This means that the all entries are zero.

Outputs may be null points. This means that the corresponding result can be

ignored.

If an error occurs in the evaluation, issue “return 1;”;

The final generated function will have a structure similar to:

casadi_int fname(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, void* mem) { const casadi_real *x1, *x2; casadi_real *r1, *r2; x1 = *arg++; x2 = *arg++; r1 = *res++; r2 =

*res++;

<FUNCTION_BODY> return 0; }

Extra doc: https://github.com/casadi/casadi/wiki/L_1v3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L189

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L260-L272

jit(str name, str body, [str] name_in, [str] name_out, dict opts)

Create a just-in-time compiled function from a C language string.

The names and sparsity patterns of all the inputs and outputs must be

provided. If sparsities are not provided, all inputs and outputs are

assumed to be scalar. Only specify the function body, assuming that input and output nonzeros are stored in arrays with the specified naming convension. The data type used is ‘casadi_real’, which is typically equal to ‘double or another data type with the same API as ‘double.

Inputs may be null pointers. This means that the all entries are zero.

Outputs may be null points. This means that the corresponding result can be

ignored.

If an error occurs in the evaluation, issue “return 1;”;

The final generated function will have a structure similar to:

casadi_int fname(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, void* mem) { const casadi_real *x1, *x2; casadi_real *r1, *r2; x1 = *arg++; x2 = *arg++; r1 = *res++; r2 =

*res++;

<FUNCTION_BODY> return 0; }

Extra doc: https://github.com/casadi/casadi/wiki/L_1v3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L185

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L251-L258

jit(str name, str body, [str] name_in, [str] name_out, [Sparsity] sparsity_in, [Sparsity] sparsity_out, dict opts)

Create a just-in-time compiled function from a C language string.

The names and sparsity patterns of all the inputs and outputs must be

provided. If sparsities are not provided, all inputs and outputs are

assumed to be scalar. Only specify the function body, assuming that input and output nonzeros are stored in arrays with the specified naming convension. The data type used is ‘casadi_real’, which is typically equal to ‘double or another data type with the same API as ‘double.

Inputs may be null pointers. This means that the all entries are zero.

Outputs may be null points. This means that the corresponding result can be

ignored.

If an error occurs in the evaluation, issue “return 1;”;

The final generated function will have a structure similar to:

casadi_int fname(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, void* mem) { const casadi_real *x1, *x2; casadi_real *r1, *r2; x1 = *arg++; x2 = *arg++; r1 = *res++; r2 =

*res++;

<FUNCTION_BODY> return 0; }

Extra doc: https://github.com/casadi/casadi/wiki/L_1v3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L189

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L260-L272

static load(str filename) Function
map(*args)

Map with reduction.

map(self, int n, str parallelization) -> Function map(self, int n, [bool] reduce_in, [bool] reduce_out, dict opts) -> Function map(self, int n, str parallelization, int max_num_threads) -> Function map(self, str name, str parallelization, int n, [str] reduce_in, [str] reduce_out, dict opts) -> Function map(self, str name, str parallelization, int n, [int] reduce_in, [int] reduce_out, dict opts) -> Function

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L745

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L603-L609

map(self, int n, str parallelization, int max_num_threads)
map(self, int n, [bool] reduce_in, [bool] reduce_out, dict opts)

Map with reduction.

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L745

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L603-L609

map(self, str name, str parallelization, int n, [str] reduce_in, [str] reduce_out, dict opts)

Map with reduction.

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L741

map(self, str name, str parallelization, int n, [int] reduce_in, [int] reduce_out, dict opts)

Map with reduction.

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L737

map(self, int n, str parallelization)

Create a mapped version of this function.

Suppose the function has a signature of:

f: (a, p) -> ( s )

The the mapped version has the signature:

F: (A, P) -> (S )

 with
     A: horzcat([a0, a1, ..., a_(N-1)])
     P: horzcat([p0, p1, ..., p_(N-1)])
     S: horzcat([s0, s1, ..., s_(N-1)])
 and
     s0 <- f(a0, p0)
     s1 <- f(a1, p1)
     ...
     s_(N-1) <- f(a_(N-1), p_(N-1))

parallelization: Type of parallelization used: unroll|serial|openmp

Extra doc: https://github.com/casadi/casadi/wiki/L_1wj

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L726

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L675-L710

mapaccum(*args)

Create a mapaccumulated version of this function.

mapaccum(self, int N, dict opts) -> Function mapaccum(self, str name, int N, dict opts) -> Function mapaccum(self, str name, int N, int n_accum, dict opts) -> Function mapaccum(self, str name, int n, [str] accum_in, [str] accum_out, dict opts) -> Function mapaccum(self, str name, int n, [int] accum_in, [int] accum_out, dict opts) -> Function

Suppose the function has a signature of:

f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

F: (x0, U) -> (X , Y )

 with
     U: horzcat([u0, u1, ..., u_(N-1)])
     X: horzcat([x1, x2, ..., x_N])
     Y: horzcat([y0, y1, ..., y_(N-1)])

 and
     x1, y0 <- f(x0, u0)
     x2, y1 <- f(x1, u1)
     ...
     x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for- loop:

much faster at construction time

potentially much faster compilation times (for codegen)

offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for- loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly

slower at evaluation, than a plain for-loop. The effect is

similar to that

of a for-loop with a check-pointing instruction after

each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L697

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L482-L484

mapaccum(self, int N, dict opts)

Create a mapaccumulated version of this function.

Suppose the function has a signature of:

f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

F: (x0, U) -> (X , Y )

 with
     U: horzcat([u0, u1, ..., u_(N-1)])
     X: horzcat([x1, x2, ..., x_N])
     Y: horzcat([y0, y1, ..., y_(N-1)])

 and
     x1, y0 <- f(x0, u0)
     x2, y1 <- f(x1, u1)
     ...
     x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for- loop:

much faster at construction time

potentially much faster compilation times (for codegen)

offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for- loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly

slower at evaluation, than a plain for-loop. The effect is

similar to that

of a for-loop with a check-pointing instruction after

each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L697

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L482-L484

mapaccum(self, str name, int N, dict opts)

Create a mapaccumulated version of this function.

Suppose the function has a signature of:

f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

F: (x0, U) -> (X , Y )

 with
     U: horzcat([u0, u1, ..., u_(N-1)])
     X: horzcat([x1, x2, ..., x_N])
     Y: horzcat([y0, y1, ..., y_(N-1)])

 and
     x1, y0 <- f(x0, u0)
     x2, y1 <- f(x1, u1)
     ...
     x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for- loop:

much faster at construction time

potentially much faster compilation times (for codegen)

offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for- loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly

slower at evaluation, than a plain for-loop. The effect is

similar to that

of a for-loop with a check-pointing instruction after

each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L686

mapaccum(self, str name, int N, int n_accum, dict opts)

Create a mapaccumulated version of this function.

Suppose the function has a signature of:

f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

F: (x0, U) -> (X , Y )

 with
     U: horzcat([u0, u1, ..., u_(N-1)])
     X: horzcat([x1, x2, ..., x_N])
     Y: horzcat([y0, y1, ..., y_(N-1)])

 and
     x1, y0 <- f(x0, u0)
     x2, y1 <- f(x1, u1)
     ...
     x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for- loop:

much faster at construction time

potentially much faster compilation times (for codegen)

offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for- loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly

slower at evaluation, than a plain for-loop. The effect is

similar to that

of a for-loop with a check-pointing instruction after

each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L687

mapaccum(self, str name, int n, [str] accum_in, [str] accum_out, dict opts)

Create a mapaccumulated version of this function.

Suppose the function has a signature of:

f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

F: (x0, U) -> (X , Y )

 with
     U: horzcat([u0, u1, ..., u_(N-1)])
     X: horzcat([x1, x2, ..., x_N])
     Y: horzcat([y0, y1, ..., y_(N-1)])

 and
     x1, y0 <- f(x0, u0)
     x2, y1 <- f(x1, u1)
     ...
     x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for- loop:

much faster at construction time

potentially much faster compilation times (for codegen)

offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for- loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly

slower at evaluation, than a plain for-loop. The effect is

similar to that

of a for-loop with a check-pointing instruction after

each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L693

mapaccum(self, str name, int n, [int] accum_in, [int] accum_out, dict opts)

Create a mapaccumulated version of this function.

Suppose the function has a signature of:

f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

F: (x0, U) -> (X , Y )

 with
     U: horzcat([u0, u1, ..., u_(N-1)])
     X: horzcat([x1, x2, ..., x_N])
     Y: horzcat([y0, y1, ..., y_(N-1)])

 and
     x1, y0 <- f(x0, u0)
     x2, y1 <- f(x1, u1)
     ...
     x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for- loop:

much faster at construction time

potentially much faster compilation times (for codegen)

offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for- loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly

slower at evaluation, than a plain for-loop. The effect is

similar to that

of a for-loop with a check-pointing instruction after

each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L689

mapsum(*args)

Evaluate symbolically in parallel and sum (matrix graph)

mapsum(self, [MX] x, str parallelization) -> [MX]

parallelization: Type of parallelization used: unroll|serial|openmp

Extra doc: https://github.com/casadi/casadi/wiki/L_1wh

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L642

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L722-L729

max_in(*args)

Get largest input value.

max_in(self, int ind) -> float

Extra doc: https://github.com/casadi/casadi/wiki/L_1vn

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L351

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1420-L1422

min_in(*args)

Get smallest input value.

min_in(self, int ind) -> float

Extra doc: https://github.com/casadi/casadi/wiki/L_1vo

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L356

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1424-L1426

mx_in(*args)

Get symbolic primitives equivalent to the input expressions.

mx_in(self) -> [MX] mx_in(self, int ind) -> MX mx_in(self, str iname) -> MX

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L949

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1527-L1529

mx_in(self)

Get symbolic primitives equivalent to the input expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L949

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1527-L1529

mx_in(self, int ind)

Get symbolic primitives equivalent to the input expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L945

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1519-L1521

mx_in(self, str iname)

Get symbolic primitives equivalent to the input expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L946

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L946-L948

mx_out(*args)

Get symbolic primitives equivalent to the output expressions.

mx_out(self) -> [MX] mx_out(self, int ind) -> MX mx_out(self, str oname) -> MX

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L967

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1531-L1533

mx_out(self)

Get symbolic primitives equivalent to the output expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L967

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1531-L1533

mx_out(self, int ind)

Get symbolic primitives equivalent to the output expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L963

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1523-L1525

mx_out(self, str oname)

Get symbolic primitives equivalent to the output expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L964

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L964-L966

n_in(*args)

Get the number of function inputs.

n_in(self) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_1v8

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L228

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L785-L787

n_instructions(*args)

Number of instruction in the algorithm (SXFunction/MXFunction)

n_instructions(self) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_1xe

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1035

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1639-L1645

n_nodes(*args)

Number of nodes in the algorithm.

n_nodes(self) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_1xd

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1030

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1695-L1701

n_out(*args)

Get the number of function outputs.

n_out(self) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_1v9

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L233

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L789-L791

name(*args)

Name of the function.

name(self) -> str

Extra doc: https://github.com/casadi/casadi/wiki/L_1xv

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1137

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1244-L1250

name_in(*args)

Get input scheme name by index.

name_in(self) -> [str] name_in(self, int ind) -> str

Extra doc: https://github.com/casadi/casadi/wiki/L_1vi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L320

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L941-L947

name_in(self)

Get input scheme.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vg

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L310

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L917-L919

name_in(self, int ind)

Get input scheme name by index.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vi

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L320

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L941-L947

name_out(*args)

Get output scheme name by index.

name_out(self) -> [str] name_out(self, int ind) -> str

Extra doc: https://github.com/casadi/casadi/wiki/L_1vj

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L325

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L949-L955

name_out(self, int ind)

Get output scheme name by index.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vj

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L325

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L949-L955

name_out(self)

Get output scheme.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vh

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L315

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L921-L923

nnz_in(*args)

Get number of input nonzeros.

nnz_in(self) -> int nnz_in(self, int ind) -> int nnz_in(self, str iname) -> int

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vc

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L271

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L271-L271

nnz_in(self)

Get number of input nonzeros.

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vc

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L269

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L817-L819

nnz_in(self, int ind)

Get number of input nonzeros.

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vc

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L270

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L833-L835

nnz_in(self, str iname)

Get number of input nonzeros.

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vc

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L271

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L271-L271

nnz_out(*args)

Get number of output nonzeros.

nnz_out(self) -> int nnz_out(self, int ind) -> int nnz_out(self, str oname) -> int

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vd

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L282

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L282-L282

nnz_out(self)

Get number of output nonzeros.

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vd

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L280

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L821-L823

nnz_out(self, int ind)

Get number of output nonzeros.

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vd

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L281

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L837-L839

nnz_out(self, str oname)

Get number of output nonzeros.

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vd

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L282

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L282-L282

nominal_in(*args)

Get nominal input value.

nominal_in(self, int ind) -> [float]

Extra doc: https://github.com/casadi/casadi/wiki/L_1vp

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L361

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1428-L1430

nominal_out(*args)

Get nominal output value.

nominal_out(self, int ind) -> [float]

Extra doc: https://github.com/casadi/casadi/wiki/L_1vq

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L366

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1432-L1434

numel_in(*args)

Get number of input elements.

numel_in(self) -> int numel_in(self, int ind) -> int numel_in(self, str iname) -> int

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L293

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L293-L293

numel_in(self)

Get number of input elements.

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L291

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L825-L827

numel_in(self, int ind)

Get number of input elements.

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L292

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L841-L843

numel_in(self, str iname)

Get number of input elements.

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L293

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L293-L293

numel_out(*args)

Get number of output elements.

numel_out(self) -> int numel_out(self, int ind) -> int numel_out(self, str oname) -> int

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L304

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L304-L304

numel_out(self)

Get number of output elements.

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L302

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L829-L831

numel_out(self, int ind)

Get number of output elements.

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L303

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L845-L847

numel_out(self, str oname)

Get number of output elements.

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L304

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L304-L304

nz_from_in(*args)

Convert from/to flat vector of input/output nonzeros.

nz_from_in(self, [DM] arg) -> [float]

Extra doc: https://github.com/casadi/casadi/wiki/L_1x6

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L974

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1535-L1537

nz_from_out(*args)

Convert from/to flat vector of input/output nonzeros.

nz_from_out(self, [DM] arg) -> [float]

Extra doc: https://github.com/casadi/casadi/wiki/L_1x6

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L975

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1539-L1541

nz_to_in(*args)

Convert from/to flat vector of input/output nonzeros.

nz_to_in(self, [float] arg) -> [DM]

Extra doc: https://github.com/casadi/casadi/wiki/L_1x6

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L976

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1543-L1545

nz_to_out(*args)

Convert from/to flat vector of input/output nonzeros.

nz_to_out(self, [float] arg) -> [DM]

Extra doc: https://github.com/casadi/casadi/wiki/L_1x6

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L977

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1547-L1549

oracle(*args)

Get oracle.

oracle(self) -> Function

Extra doc: https://github.com/casadi/casadi/wiki/L_1vu

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L407

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1816-L1822

print_dimensions(*args)

Print dimensions of inputs and outputs.

print_dimensions(self)

Extra doc: https://github.com/casadi/casadi/wiki/L_1vy

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L432

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1093-L1095

print_option(*args)

Print all information there is to know about a certain option.

print_option(self, str name)

Extra doc: https://github.com/casadi/casadi/wiki/L_1w0

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L442

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1101-L1103

print_options(*args)

Print options to a stream.

print_options(self)

Extra doc: https://github.com/casadi/casadi/wiki/L_1vz

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L437

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1097-L1099

release(*args)

Release a memory object.

release(self, int mem)

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1198

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1707-L1709

reverse(*args)

Get a function that calculates nadj adjoint derivatives.

reverse(self, int nadj) -> Function

 Returns a function with <tt>n_in + n_out + n_out</tt> inputs
 and <tt>n_in</tt> outputs.
 The first <tt>n_in</tt> inputs correspond to nondifferentiated inputs.
 The next <tt>n_out</tt> inputs correspond to nondifferentiated outputs.
 and the last <tt>n_out</tt> inputs correspond to adjoint seeds,
 stacked horizontally
 The  <tt>n_in</tt> outputs correspond to adjoint sensitivities,
 stacked horizontally.     *
 <tt>(n_in = n_in(), n_out = n_out())</tt>

 <tt>(n_in = n_in(), n_out = n_out())</tt>

The functions returned are cached, meaning that if called multiple timed
with the same value, then multiple references to the same function will be returned.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wr

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L820

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1085-L1091

save(*args)

Save Function to a file.

save(self, str fname, dict opts)

See:

load

Extra doc: https://github.com/casadi/casadi/wiki/L_240

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L900

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1206-L1209

serialize(*args)

[INTERNAL]

serialize(self, dict opts) -> str

Serialize.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x2

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L893

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1211-L1215

size1_in(*args)

Get input dimension.

size1_in(self, int ind) -> int size1_in(self, str iname) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L240

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L240-L240

size1_in(self, int ind)

Get input dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L239

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L793-L795

size1_in(self, str iname)

Get input dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L240

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L240-L240

size1_out(*args)

Get output dimension.

size1_out(self, int ind) -> int size1_out(self, str oname) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L254

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L254-L254

size1_out(self, int ind)

Get output dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L253

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L801-L803

size1_out(self, str oname)

Get output dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L254

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L254-L254

size2_in(*args)

Get input dimension.

size2_in(self, int ind) -> int size2_in(self, str iname) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L242

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L242-L242

size2_in(self, int ind)

Get input dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L241

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L797-L799

size2_in(self, str iname)

Get input dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L242

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L242-L242

size2_out(*args)

Get output dimension.

size2_out(self, int ind) -> int size2_out(self, str oname) -> int

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L256

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L256-L256

size2_out(self, int ind)

Get output dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L255

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L805-L807

size2_out(self, str oname)

Get output dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L256

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L256-L256

size_in(*args)

Get input dimension.

size_in(self, int ind) -> (int,int) size_in(self, str iname) -> (int,int)

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L244

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L244-L246

size_in(self, int ind)

Get input dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L243

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L809-L811

size_in(self, str iname)

Get input dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L244

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L244-L246

size_out(*args)

Get output dimension.

size_out(self, int ind) -> (int,int) size_out(self, str oname) -> (int,int)

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L258

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L258-L260

size_out(self, int ind)

Get output dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L257

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L813-L815

size_out(self, str oname)

Get output dimension.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L258

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L258-L260

slice(*args)

returns a new function with a selection of inputs/outputs of the

slice(self, str name, [int] order_in, [int] order_out, dict opts) -> Function

original

Extra doc: https://github.com/casadi/casadi/wiki/L_1wl

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L754

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L713-L720

sparsity_in(*args)

Get sparsity of a given input.

sparsity_in(self, int ind) -> Sparsity sparsity_in(self, str iname) -> Sparsity

Extra doc: https://github.com/casadi/casadi/wiki/L_1vr

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L373

sparsity_in(self, int ind)

Get sparsity of a given input.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vr

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L372

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L957-L963

sparsity_in(self, str iname)

Get sparsity of a given input.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vr

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L373

sparsity_jac(*args)

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian

sparsity_jac(self, str iind, int oind, bool compact, bool symmetric) -> Sparsity sparsity_jac(self, int iind, int oind, bool compact, bool symmetric) -> Sparsity sparsity_jac(self, int iind, str oind, bool compact, bool symmetric) -> Sparsity sparsity_jac(self, str iind, str oind, bool compact, bool symmetric) -> Sparsity

block

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L485

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L485-L488

sparsity_jac(self, str iind, int oind, bool compact, bool symmetric)

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L477

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L477-L480

sparsity_jac(self, int iind, int oind, bool compact, bool symmetric)

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L475

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L873-L879

sparsity_jac(self, int iind, str oind, bool compact, bool symmetric)

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L481

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L481-L484

sparsity_jac(self, str iind, str oind, bool compact, bool symmetric)

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L485

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L485-L488

sparsity_out(*args)

Get sparsity of a given output.

sparsity_out(self, int ind) -> Sparsity sparsity_out(self, str iname) -> Sparsity

Extra doc: https://github.com/casadi/casadi/wiki/L_1vs

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L381

sparsity_out(self, int ind)

Get sparsity of a given output.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vs

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L380

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L973-L979

sparsity_out(self, str iname)

Get sparsity of a given output.

Extra doc: https://github.com/casadi/casadi/wiki/L_1vs

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L381

stats(*args)

Get all statistics obtained at the end of the last evaluate call.

stats(self, int mem) -> dict

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L932

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L894-L896

sx_in(*args)

Get symbolic primitives equivalent to the input expressions.

sx_in(self) -> [SX] sx_in(self, int iind) -> SX sx_in(self, str iname) -> SX

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L944

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1503-L1509

sx_in(self)

Get symbolic primitives equivalent to the input expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L944

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1503-L1509

sx_in(self, int iind)

Get symbolic primitives equivalent to the input expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L940

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1487-L1493

sx_in(self, str iname)

Get symbolic primitives equivalent to the input expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L941

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L941-L943

sx_out(*args)

Get symbolic primitives equivalent to the output expressions.

sx_out(self) -> [SX] sx_out(self, int oind) -> SX sx_out(self, str oname) -> SX

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L962

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1511-L1517

sx_out(self)

Get symbolic primitives equivalent to the output expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L962

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1511-L1517

sx_out(self, int oind)

Get symbolic primitives equivalent to the output expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L958

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1495-L1501

sx_out(self, str oname)

Get symbolic primitives equivalent to the output expressions.

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L959

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L959-L961

sz_arg(*args)

Get required length of arg field.

sz_arg(self) -> size_t

Extra doc: https://github.com/casadi/casadi/wiki/L_1xm

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1085

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1025-L1025

sz_iw(*args)

Get required length of iw field.

sz_iw(self) -> size_t

Extra doc: https://github.com/casadi/casadi/wiki/L_1xo

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1095

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1029-L1029

sz_res(*args)

Get required length of res field.

sz_res(self) -> size_t

Extra doc: https://github.com/casadi/casadi/wiki/L_1xn

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1090

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1027-L1027

sz_w(*args)

Get required length of w field.

sz_w(self) -> size_t

Extra doc: https://github.com/casadi/casadi/wiki/L_1xp

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1100

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1031-L1031

static type_name() str
uses_output(*args)

Do the derivative functions need nondifferentiated outputs?

uses_output(self) -> bool

Extra doc: https://github.com/casadi/casadi/wiki/L_1w3

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L460

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L849-L851

which_depends(*args)

Which variables enter with some order.

which_depends(self, str s_in, [str] s_out, int order, bool tr) -> [bool]

order: Only 1 (linear) and 2 (nonlinear) allowed

tr: Flip the relationship. Return which expressions contain the variables

Extra doc: https://github.com/casadi/casadi/wiki/L_1vx

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L425

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1745-L1751

wrap(*args)

Wrap in an Function instance consisting of only one MX call.

wrap(self) -> Function

Extra doc: https://github.com/casadi/casadi/wiki/L_1vv

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L412

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1824-L1826

wrap_as_needed(*args)

Wrap in a Function with options.

wrap_as_needed(self, dict opts) -> Function

Extra doc: https://github.com/casadi/casadi/wiki/L_1vw

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L417

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1828-L1830

3. Solvers

3.1. NLP

nlpsol(*args)

nlpsol(str name, str solver, Importer compiler, dict opts) -> Function nlpsol(str name, str solver, NlpBuilder nl, dict opts) -> Function nlpsol(str name, str solver, dict:SX nlp, dict opts) -> Function nlpsol(str name, str solver, dict:MX nlp, dict opts) -> Function nlpsol(str name, str solver, str fname, dict opts) -> Function

nlpsol(str name, str solver, Importer compiler, dict opts)
nlpsol(str name, str solver, NlpBuilder nl, dict opts)
nlpsol(str name, str solver, dict:MX nlp, dict opts)
nlpsol(str name, str solver, str fname, dict opts)
nlpsol(str name, str solver, dict:SX nlp, dict opts)

Create an NLP solver Creates a solver for the following parametric

nonlinear program (NLP):

min          F(x, p)
x

subject to
LBX <=   x    <= UBX
LBG <= G(x, p) <= UBG
p  == P

nx: number of decision variables
ng: number of constraints
np: number of parameters

General information

>List of available options

Id

Type

Description

Used in

bound_consistenc y

OT_BOOL

Ensure that primal-dual solution is consistent with the bounds

casadi::Nlpsol

calc_f

OT_BOOL

Calculate ‘f’ in the Nlpsol base class

casadi::Nlpsol

calc_g

OT_BOOL

Calculate ‘g’ in the Nlpsol base class

casadi::Nlpsol

calc_lam_p

OT_BOOL

Calculate ‘lam_p’ in the Nlpsol base class

casadi::Nlpsol

calc_lam_x

OT_BOOL

Calculate ‘lam_x’ in the Nlpsol base class

casadi::Nlpsol

calc_multipliers

OT_BOOL

Calculate Lagrange multipliers in the Nlpsol base class

casadi::Nlpsol

common_options

OT_DICT

Options for auto-generated functions

casadi::OracleFu nction

discrete

OT_BOOLVECTOR

Indicates which of the variables are discrete, i.e. integer- valued

casadi::Nlpsol

error_on_fail

OT_BOOL

When the numerical process returns unsuccessfully, raise an error (default false).

casadi::Nlpsol

eval_errors_fata l

OT_BOOL

When errors occur during evaluation of f,g,…,stop the iterations

casadi::Nlpsol

expand

OT_BOOL

Replace MX with SX expressions in problem formulation [false]

casadi::OracleFu nction

ignore_check_vec

OT_BOOL

If set to true, the input shape of F will not be checked.

casadi::Nlpsol

iteration_callba ck

OT_FUNCTION

A function that will be called at each iteration with the solver as input. Check documentation of Callback .

casadi::Nlpsol

iteration_callba ck_ignore_errors

OT_BOOL

If set to true, errors thrown by iteration_callba ck will be ignored.

casadi::Nlpsol

iteration_callba ck_step

OT_INT

Only call the callback function every few iterations.

casadi::Nlpsol

min_lam

OT_DOUBLE

Minimum allowed multiplier value

casadi::Nlpsol

monitor

OT_STRINGVECTOR

Set of user problem functions to be monitored

casadi::OracleFu nction

no_nlp_grad

OT_BOOL

Prevent the creation of the ‘nlp_grad’ function

casadi::Nlpsol

oracle_options

OT_DICT

Options to be passed to the oracle function

casadi::Nlpsol

sens_linsol

OT_STRING

Linear solver used for parametric sensitivities (default ‘qr’).

casadi::Nlpsol

sens_linsol_opti ons

OT_DICT

Linear solver options used for parametric sensitivities.

casadi::Nlpsol

show_eval_warnin gs

OT_BOOL

Show warnings generated from function evaluations [true]

casadi::OracleFu nction

specific_options

OT_DICT

Options for specific auto- generated functions, overwriting the defaults from common_options. Nested dictionary.

casadi::OracleFu nction

verbose_init

OT_BOOL

Print out timing information about the different stages of initialization

casadi::Nlpsol

warn_initial_bou nds

OT_BOOL

Warn if the initial guess does not satisfy LBX and UBX

casadi::Nlpsol

>Input scheme: casadi::NlpsolInput (NLPSOL_NUM_IN = 8)

Full name

Short

Description

NLPSOL_X0

x0

Decision variables, initial guess (nx x 1)

NLPSOL_P

p

Value of fixed parameters (np x 1)

NLPSOL_LBX

lbx

Decision variables lower bound (nx x 1), default -inf.

NLPSOL_UBX

ubx

Decision variables upper bound (nx x 1), default +inf.

NLPSOL_LBG

lbg

Constraints lower bound (ng x 1), default -inf.

NLPSOL_UBG

ubg

Constraints upper bound (ng x 1), default +inf.

NLPSOL_LAM_X0

lam_x0

Lagrange multipliers for bounds on X, initial guess (nx x 1)

NLPSOL_LAM_G0

lam_g0

Lagrange multipliers for bounds on G, initial guess (ng x 1)

>Output scheme: casadi::NlpsolOutput (NLPSOL_NUM_OUT = 6)

Full name

Short

Description

NLPSOL_X

x

Decision variables at the optimal solution (nx x 1)

NLPSOL_F

f

Cost function value at the optimal solution (1 x 1)

NLPSOL_G

g

Constraints function at the optimal solution (ng x 1)

NLPSOL_LAM_X

lam_x

Lagrange multipliers for bounds on X at the solution (nx x 1)

NLPSOL_LAM_G

lam_g

Lagrange multipliers for bounds on G at the solution (ng x 1)

NLPSOL_LAM_P

lam_p

Lagrange multipliers for bounds on P at the solution (np x 1)

List of plugins - AmplInterface

  • blocksqp

  • bonmin

  • ipopt

  • knitro

  • snopt

  • worhp

  • custom

  • qrsqp

  • scpgen

  • sqpmethod

Note: some of the plugins in this list might not be available on your

system. Also, there might be extra plugins available to you that are not listed here. You can obtain their documentation with Nlpsol.doc(“myextraplugin”)

WORHP interface.

>List of available options

Id

Type

Description

solver

OT_STRING

AMPL solver binary

This is a modified version of blockSQP by Janka et al.

Dennis Janka, Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_224

>List of available options

Id

Type

Description

block_hess

OT_INT

Blockwise Hessian approximation?

col_eps

OT_DOUBLE

Epsilon for COL scaling strategy

col_tau1

OT_DOUBLE

tau1 for COL scaling strategy

col_tau2

OT_DOUBLE

tau2 for COL scaling strategy

conv_strategy

OT_INT

Convexification strategy

delta

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

delta_h0

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

eps

OT_DOUBLE

Values smaller than this are regarded as numerically zero

eta

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

fallback_scaling

OT_INT

If indefinite update is used, the type of fallback strategy

fallback_update

OT_INT

If indefinite update is used, the type of fallback strategy

gamma_f

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

gamma_theta

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

globalization

OT_BOOL

Enable globalization

hess_damp

OT_INT

Activate Powell damping for BFGS

hess_damp_fac

OT_DOUBLE

Damping factor for BFGS Powell modification

hess_lim_mem

OT_INT

Full or limited memory

hess_memsize

OT_INT

Memory size for L-BFGS updates

hess_scaling

OT_INT

Scaling strategy for Hessian approximation

hess_update

OT_INT

Type of Hessian approximation

ini_hess_diag

OT_DOUBLE

Initial Hessian guess: diagonal matrix diag(iniHessDiag)

kappa_f

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

kappa_minus

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

kappa_plus

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

kappa_plus_max

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

kappa_soc

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

linsol

OT_STRING

The linear solver to be used by the QP method

max_consec_reduced_steps

OT_INT

Maximum number of consecutive reduced steps

max_consec_skipped_updates

OT_INT

Maximum number of consecutive skipped updates

max_conv_qp

OT_INT

How many additional QPs may be solved for convexification per iteration?

max_it_qp

OT_INT

Maximum number of QP iterations per SQP iteration

max_iter

OT_INT

Maximum number of SQP iterations

max_line_search

OT_INT

Maximum number of steps in line search

max_soc_iter

OT_INT

Maximum number of SOC line search iterations

max_time_qp

OT_DOUBLE

Maximum number of time in seconds per QP solve per SQP iteration

nlinfeastol

OT_DOUBLE

Nonlinear feasibility tolerance

obj_lo

OT_DOUBLE

Lower bound on objective function [-inf]

obj_up

OT_DOUBLE

Upper bound on objective function [inf]

opttol

OT_DOUBLE

Optimality tolerance

print_header

OT_BOOL

Print solver header at startup

print_iteration

OT_BOOL

Print SQP iterations

print_maxit_reached

OT_BOOL

Print error when maximum number of SQP iterations reached

qp_init

OT_BOOL

Use warmstarting

qpsol

OT_STRING

The QP solver to be used by the SQP method

qpsol_options

OT_DICT

Options to be passed to the QP solver

restore_feas

OT_BOOL

Use feasibility restoration phase

rho

OT_DOUBLE

Feasibility restoration phase parameter

s_f

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

s_theta

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

schur

OT_BOOL

Use qpOASES Schur compliment approach

skip_first_globalization

OT_BOOL

No globalization strategy in first iteration

theta_max

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

theta_min

OT_DOUBLE

Filter line search parameter, cf. IPOPT paper

warmstart

OT_BOOL

Use warmstarting

which_second_derv

OT_INT

For which block should second derivatives be provided by the user

zeta

OT_DOUBLE

Feasibility restoration phase parameter

When in warmstart mode, output NLPSOL_LAM_X may be used as input

NOTE: Even when max_iter == 0, it is not guaranteed that input(NLPSOL_X0) == output(NLPSOL_X). Indeed if bounds on X or constraints are unmet, they will differ.

For a good tutorial on BONMIN, see http://drops.dagstuhl.de/volltexte/2009/2089/pdf/09061.WaechterAndreas.Paper.2089.pdf

A good resource about the algorithms in BONMIN is: Wachter and L. T.

Biegler, On the Implementation of an Interior-Point Filter Line-Search

Algorithm for Large-Scale Nonlinear Programming, Mathematical Programming 106(1), pp. 25-57, 2006 (As Research Report RC 23149, IBM T. J. Watson Research Center, Yorktown, USA

Caveats: with default options, multipliers for the decision variables are wrong

for equality constraints. Change the ‘fixed_variable_treatment’ to

‘make_constraint’ or ‘relax_bounds’ to obtain correct results.

Extra doc: https://github.com/casadi/casadi/wiki/L_223

>List of available options

Id

Type

Description

bonmin

OT_DICT

Options to be passed to BONMIN

con_integer_md

OT_DICT

Integer metadata (a dictionary with lists of integers) about constraints to be passed to BONMIN

con_numeric_md

OT_DICT

Numeric metadata (a dictionary with lists of reals) about constraints to be passed to BONMIN

con_string_md

OT_DICT

String metadata (a dictionary with lists of strings) about constraints to be passed to BONMIN

grad_f

OT_FUNCTION

Function for calculating the gradient of the objective (column, autogenerated by default)

grad_f_options

OT_DICT

Options for the autogenerated gradient of the objective.

hess_lag

OT_FUNCTION

Function for calculating the Hessian of the Lagrangian (autogenerated by default)

hess_lag_options

OT_DICT

Options for the autogenerated Hessian of the Lagrangian.

jac_g

OT_FUNCTION

Function for calculating the Jacobian of the constraints (autogenerated by default)

jac_g_options

OT_DICT

Options for the autogenerated Jacobian of the constraints.

pass_nonlinear_constrai nts

OT_BOOL

Pass list of constraints entering nonlinearly to BONMIN

pass_nonlinear_variable s

OT_BOOL

Pass list of variables entering nonlinearly to BONMIN

sos1_groups

OT_INTVECTORVECTOR

Options for the autogenerated gradient of the objective.

sos1_priorities

OT_INTVECTOR

Options for the autogenerated gradient of the objective.

sos1_weights

OT_DOUBLEVECTORVECTOR

Options for the autogenerated gradient of the objective.

var_integer_md

OT_DICT

Integer metadata (a dictionary with lists of integers) about variables to be passed to BONMIN

var_numeric_md

OT_DICT

Numeric metadata (a dictionary with lists of reals) about variables to be passed to BONMIN

var_string_md

OT_DICT

String metadata (a dictionary with lists of strings) about variables to be passed to BONMIN

When in warmstart mode, output NLPSOL_LAM_X may be used as input

NOTE: Even when max_iter == 0, it is not guaranteed that input(NLPSOL_X0) == output(NLPSOL_X). Indeed if bounds on X or constraints are unmet, they will differ.

For a good tutorial on IPOPT, see http://drops.dagstuhl.de/volltexte/2009/2089/pdf/09061.WaechterAndreas.Paper.2089.pdf

A good resource about the algorithms in IPOPT is: Wachter and L. T.

Biegler, On the Implementation of an Interior-Point Filter Line-Search

Algorithm for Large-Scale Nonlinear Programming, Mathematical Programming 106(1), pp. 25-57, 2006 (As Research Report RC 23149, IBM T. J. Watson Research Center, Yorktown, USA

Caveats: with default options, multipliers for the decision variables are wrong

for equality constraints. Change the ‘fixed_variable_treatment’ to

‘make_constraint’ or ‘relax_bounds’ to obtain correct results.

Extra doc: https://github.com/casadi/casadi/wiki/L_21y

>List of available options

Id

Type

Description

clip_inactive_lam

OT_BOOL

Explicitly set Lagrange multipliers to 0 when bound is deemed inactive (default: false).

con_integer_md

OT_DICT

Integer metadata (a dictionary with lists of integers) about constraints to be passed to IPOPT

con_numeric_md

OT_DICT

Numeric metadata (a dictionary with lists of reals) about constraints to be passed to IPOPT

con_string_md

OT_DICT

String metadata (a dictionary with lists of strings) about constraints to be passed to IPOPT

convexify_margin

OT_DOUBLE

When using a convexification strategy, make sure that the smallest eigenvalue is at least this (default: 1e-7).

convexify_strategy

OT_STRING

NONE|regularize|eigen- reflect|eigen-clip. Strategy to convexify the Lagrange Hessian before passing it to the solver.

grad_f

OT_FUNCTION

Function for calculating the gradient of the objective (column, autogenerated by default)

hess_lag

OT_FUNCTION

Function for calculating the Hessian of the Lagrangian (autogenerated by default)

inactive_lam_strategy

OT_STRING

Strategy to detect if a bound is inactive. RELTOL: use solver-defined constraint tolerance * inactive_lam_value|abstol: use inactive_lam_value

inactive_lam_value

OT_DOUBLE

Value used in inactive_lam_strategy (default: 10).

ipopt

OT_DICT

Options to be passed to IPOPT

jac_g

OT_FUNCTION

Function for calculating the Jacobian of the constraints (autogenerated by default)

max_iter_eig

OT_DOUBLE

Maximum number of iterations to compute an eigenvalue decomposition (default: 50).

pass_nonlinear_variables

OT_BOOL

Pass list of variables entering nonlinearly to IPOPT

var_integer_md

OT_DICT

Integer metadata (a dictionary with lists of integers) about variables to be passed to IPOPT

var_numeric_md

OT_DICT

Numeric metadata (a dictionary with lists of reals) about variables to be passed to IPOPT

var_string_md

OT_DICT

String metadata (a dictionary with lists of strings) about variables to be passed to IPOPT

KNITRO interface

Extra doc: https://github.com/casadi/casadi/wiki/L_22c

>List of available options

Id

Type

Description

complem_variables

OT_INTVECTORVECTOR

List of complementary constraints on simple bounds. Pair (i, j) encodes complementarity between the bounds on variable i and variable j.

contype

OT_INTVECTOR

Type of constraint

detect_linear_constraint s

OT_BOOL

Detect type of constraints

knitro

OT_DICT

Options to be passed to KNITRO

SNOPT interface

Extra doc: https://github.com/casadi/casadi/wiki/L_22m

>List of available options

Id

Type

Description

snopt

OT_DICT

Options to be passed to SNOPT

start

OT_STRING

Warm-start options for Worhp: cold|warm|hot

Designed for Worhp 1.12

>List of available options

Id

Type

Description

worhp

OT_DICT

Options to be passed to WORHP

A textbook CustomNlpsol

Extra doc: https://github.com/casadi/casadi/wiki/L_23d

A textbook SQPMethod

Extra doc: https://github.com/casadi/casadi/wiki/L_22u

A structure-exploiting sequential quadratic programming (to be come

sequential convex programming) method for nonlinear programming.

Extra doc: https://github.com/casadi/casadi/wiki/L_232

>List of available options

Id

Type

Description

beta

OT_DOUBLE

Line-search parameter, restoration factor of stepsize

c1

OT_DOUBLE

Armijo condition, coefficient of decrease in merit

codegen

OT_BOOL

C-code generation

hessian_approximation

OT_STRING

gauss-newton|exact

lbfgs_memory

OT_INT

Size of L-BFGS memory.

max_iter

OT_INT

Maximum number of SQP iterations

max_iter_ls

OT_INT

Maximum number of linesearch iterations

merit_memsize

OT_INT

Size of memory to store history of merit function values

merit_start

OT_DOUBLE

Lower bound for the merit function parameter

name_x

OT_STRINGVECTOR

Names of the variables.

print_header

OT_BOOL

Print the header with problem statistics

print_x

OT_INTVECTOR

Which variables to print.

qpsol

OT_STRING

The QP solver to be used by the SQP method

qpsol_options

OT_DICT

Options to be passed to the QP solver

reg_threshold

OT_DOUBLE

Threshold for the regularization.

regularize

OT_BOOL

Automatic regularization of Lagrange Hessian.

tol_du

OT_DOUBLE

Stopping criterion for dual infeasability

tol_pr

OT_DOUBLE

Stopping criterion for primal infeasibility

tol_pr_step

OT_DOUBLE

Stopping criterion for the step size

tol_reg

OT_DOUBLE

Stopping criterion for regularization

A textbook SQPMethod

Extra doc: https://github.com/casadi/casadi/wiki/L_22x

>List of available options

Id

Type

Description

beta

OT_DOUBLE

Line-search parameter, restoration factor of stepsize

c1

OT_DOUBLE

Armijo condition, coefficient of decrease in merit

convexify_margin

OT_DOUBLE

When using a convexification strategy, make sure that the smallest eigenvalue is at least this (default: 1e-7).

convexify_strategy

OT_STRING

NONE|regularize|eigen- reflect|eigen-clip. Strategy to convexify the Lagrange Hessian before passing it to the solver.

elastic_mode

OT_BOOL

Enable the elastic mode which is used when the QP is infeasible (default: false).

gamma_0

OT_DOUBLE

Starting value for the penalty parameter of elastic mode (default: 1).

gamma_1_min

OT_DOUBLE

Minimum value for gamma_1 (default: 1e-5).

gamma_max

OT_DOUBLE

Maximum value for the penalty parameter of elastic mode (default: 1e20).

hess_lag

OT_FUNCTION

Function for calculating the Hessian of the Lagrangian (autogenerated by default)

hessian_approximation

OT_STRING

limited-memory|exact

init_feasible

OT_BOOL

Initialize the QP subproblems with a feasible initial value (default: false).

jac_fg

OT_FUNCTION

Function for calculating the gradient of the objective and Jacobian of the constraints (autogenerated by default)

lbfgs_memory

OT_INT

Size of L-BFGS memory.

max_iter

OT_INT

Maximum number of SQP iterations

max_iter_eig

OT_DOUBLE

Maximum number of iterations to compute an eigenvalue decomposition (default: 50).

max_iter_ls

OT_INT

Maximum number of linesearch iterations

merit_memory

OT_INT

Size of memory to store history of merit function values

min_iter

OT_INT

Minimum number of SQP iterations

min_step_size

OT_DOUBLE

The size (inf-norm) of the step size should not become smaller than this.

print_header

OT_BOOL

Print the header with problem statistics

print_iteration

OT_BOOL

Print the iterations

print_status

OT_BOOL

Print a status message after solving

qpsol

OT_STRING

The QP solver to be used by the SQP method [qpoases]

qpsol_options

OT_DICT

Options to be passed to the QP solver

second_order_corrections

OT_BOOL

Enable second order corrections. These are used when a step is considered bad by the merit function and constraint norm (default: false).

tol_du

OT_DOUBLE

Stopping criterion for dual infeasability

tol_pr

OT_DOUBLE

Stopping criterion for primal infeasibility

Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_21q

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/nlpsol.hpp#L72

3.2. QP

3.2.1. High-level

qpsol(str name, str solver, dict:SX qp, dict opts) Function
qpsol(str name, str solver, dict:MX qp, dict opts) Function

3.2.2. Low-level

conic(*args)

Create a QP solver Solves the following strictly convex problem:

conic(str name, str solver, dict:Sparsity qp, dict opts) -> Function

min          1/2 x' H x + g' x
x

subject to
LBA <= A x <= UBA
LBX <= x   <= UBX

resize(Q x, np, np) + P >= 0 (psd)

with :
H sparse (n x n) positive definite
g dense  (n x 1)
A sparse (nc x n)
Q sparse symmetric (np^2 x n)
P sparse symmetric (np x nq)

n: number of decision variables (x)
nc: number of constraints (A)
nq: shape of psd constraint matrix

If H is not positive-definite, the solver should throw an error.

Second-order cone constraints can be added as psd constraints through a helper function ‘soc’:

x in R^n y in R

|| x ||_2 <= y

<=>

soc(x, y) psd

This can be proven with soc(x, y)=[y*I x; x’ y] using the Shur complement.

General information

>List of available options

Id

Type

Description

Used in

ad_weight

OT_DOUBLE

Weighting factor for derivative calculation.When there is an option of either using forward or reverse mode directional derivatives, the condition ad_wei ght*nf<=(1-ad_we ight)*na is used where nf and na are estimates of the number of forward/reverse mode directional derivatives needed. By default, ad_weight is calculated automatically, but this can be overridden by setting this option. In particular, 0 means forcing forward mode and 1 forcing reverse mode. Leave unset for (class specific) heuristics.

casadi::Function Internal

ad_weight_sp

OT_DOUBLE

Weighting factor for sparsity pattern calculation calc ulation.Override s default behavior. Set to 0 and 1 to force forward and reverse mode respectively. Cf. option “ad_weight”. When set to -1, sparsity is completely ignored and dense matrices are used.

casadi::Function Internal

always_inline

OT_BOOL

Force inlining.

casadi::Function Internal

compiler

OT_STRING

Just-in-time compiler plugin to be used.

casadi::Function Internal

custom_jacobian

OT_FUNCTION

Override CasADi’s AD. Use together with ‘jac_penalty’: 0. Note: Highly experimental. Syntax may break often.

casadi::Function Internal

derivative_of

OT_FUNCTION

The function is a derivative of another function. The type of derivative (directional derivative, Jacobian) is inferred from the function name.

casadi::Function Internal

discrete

OT_BOOLVECTOR

Indicates which of the variables are discrete, i.e. integer- valued

casadi::Conic

dump

OT_BOOL

Dump function to file upon first evaluation. [false]

casadi::Function Internal

dump_dir

OT_STRING

Directory to dump inputs/outputs to. Make sure the directory exists [.]

casadi::Function Internal

dump_format

OT_STRING

Choose file format to dump matrices. See DM.from_file [mtx]

casadi::Function Internal

dump_in

OT_BOOL

Dump numerical values of inputs to file (readable with DM.from_file ) [default: false]

casadi::Function Internal

dump_out

OT_BOOL

Dump numerical values of outputs to file (readable with DM.from_file ) [default: false]

casadi::Function Internal

enable_fd

OT_BOOL

Enable derivative calculation by finite differencing. [default: false]]

casadi::Function Internal

enable_forward

OT_BOOL

Enable derivative calculation using generated functions for Jacobian-times- vector products - typically using forward mode AD - if available. [default: true]

casadi::Function Internal

enable_jacobian

OT_BOOL

Enable derivative calculation using generated functions for Jacobians of all differentiable outputs with respect to all differentiable inputs - if available. [default: true]

casadi::Function Internal

enable_reverse

OT_BOOL

Enable derivative calculation using generated functions for transposed Jacobian-times- vector products - typically using reverse mode AD - if available. [default: true]

casadi::Function Internal

error_on_fail

OT_BOOL

When the numerical process returns unsuccessfully, raise an error (default true).

casadi::Conic

fd_method

OT_STRING

Method for finite differencing [default ‘central’]

casadi::Function Internal

fd_options

OT_DICT

Options to be passed to the finite difference instance

casadi::Function Internal

forward_options

OT_DICT

Options to be passed to a forward mode constructor

casadi::Function Internal

gather_stats

OT_BOOL

Deprecated option (ignored): Statistics are now always collected.

casadi::Function Internal

input_scheme

OT_STRINGVECTOR

Deprecated option (ignored)

casadi::Function Internal

inputs_check

OT_BOOL

Throw exceptions when the numerical values of the inputs don’t make sense

casadi::Function Internal

is_diff_in

OT_BOOLVECTOR

Indicate for each input if it should be differentiable.

casadi::Function Internal

is_diff_out

OT_BOOLVECTOR

Indicate for each output if it should be differentiable.

casadi::Function Internal

jac_penalty

OT_DOUBLE

When requested for a number of forward/reverse directions, it may be cheaper to compute first the full jacobian and then multiply with seeds, rather than obtain the requested directions in a straightforward manner. Casadi uses a heuristic to decide which is cheaper. A high value of ‘jac_penalty’ makes it less likely for the heurstic to chose the full Jacobian strategy. The special value -1 indicates never to use the full Jacobian strategy

casadi::Function Internal

jacobian_options

OT_DICT

Options to be passed to a Jacobian constructor

casadi::Function Internal

jit

OT_BOOL

Use just-in-time compiler to speed up the evaluation

casadi::Function Internal

jit_cleanup

OT_BOOL

Cleanup up the temporary source file that jit creates. Default: true

casadi::Function Internal

jit_name

OT_STRING

The file name used to write out code. The actual file names used depend on ‘jit_t emp_suffix’ and include extensions. Default: ‘jit_tmp’

casadi::Function Internal

jit_options

OT_DICT

Options to be passed to the jit compiler.

casadi::Function Internal

jit_serialize

OT_STRING

Specify behaviour when serializing a jitted function: SOURCE|link|embe d.

casadi::Function Internal

jit_temp_suffix

OT_BOOL

Use a temporary (seemingly random) filename suffix for generated code and libraries. This is desired for thread- safety. This behaviour may defeat caching compiler wrappers. Default: true

casadi::Function Internal

max_io

OT_INT

Acceptable number of inputs and outputs. Warn if exceeded.

casadi::Function Internal

max_num_dir

OT_INT

Specify the maximum number of directions for derivative functions. Overrules the builtin optimize d_num_dir.

casadi::Function Internal

never_inline

OT_BOOL

Forbid inlining.

casadi::Function Internal

output_scheme

OT_STRINGVECTOR

Deprecated option (ignored)

casadi::Function Internal

post_expand

OT_BOOL

After construction, expand this Function . Default: False

casadi::Function Internal

post_expand_opti ons

OT_DICT

Options to be passed to post- construction expansion. Default: empty

casadi::Function Internal

print_in

OT_BOOL

Print numerical values of inputs [default: false]

casadi::Function Internal

print_out

OT_BOOL

Print numerical values of outputs [default: false]

casadi::Function Internal

print_problem

OT_BOOL

Print a numeric description of the problem

casadi::Conic

print_time

OT_BOOL

print information about execution time. Implies record_time.

casadi::Function Internal

record_time

OT_BOOL

record information about execution time, for retrieval with stats().

casadi::Function Internal

regularity_check

OT_BOOL

Throw exceptions when NaN or Inf appears during evaluation

casadi::Function Internal

reverse_options

OT_DICT

Options to be passed to a reverse mode constructor

casadi::Function Internal

user_data

OT_VOIDPTR

A user-defined field that can be used to identify the function or pass additional information

casadi::Function Internal

verbose

OT_BOOL

Verbose evaluation for debugging

casadi::Function Internal

>Input scheme: casadi::ConicInput (CONIC_NUM_IN = 12)

Full name

Short

Description

CONIC_H

h

The square matrix H: sparse, (n x n). Only the lower triangular part is actually used. The matrix is assumed to be symmetrical.

CONIC_G

g

The vector g: dense, (n x 1)

CONIC_A

a

The matrix A: sparse, (nc x n) - product with x must be dense.

CONIC_LBA

lba

dense, (nc x 1)

CONIC_UBA

uba

dense, (nc x 1)

CONIC_LBX

lbx

dense, (n x 1)

CONIC_UBX

ubx

dense, (n x 1)

CONIC_X0

x0

dense, (n x 1)

CONIC_LAM_X0

lam_x0

dense

CONIC_LAM_A0

lam_a0

dense

CONIC_Q

q

The matrix Q: sparse symmetric, (np^2 x n)

CONIC_P

p

The matrix P: sparse symmetric, (np x np)

>Output scheme: casadi::ConicOutput (CONIC_NUM_OUT = 4)

Full name

Short

Description

CONIC_X

x

The primal solution.

CONIC_COST

cost

The optimal cost.

CONIC_LAM_A

lam_a

The dual solution corresponding to linear bounds.

CONIC_LAM_X

lam_x

The dual solution corresponding to simple bounds.

List of plugins - cbc

  • clp

  • cplex

  • ecos

  • gurobi

  • highs

  • hpmpc

  • mosek

  • ooqp

  • osqp

  • qpalm

  • qpoases

  • sqic

  • superscs

  • ipqp

  • nlpsol

  • qrqp

Note: some of the plugins in this list might not be available on your

system. Also, there might be extra plugins available to you that are not listed here. You can obtain their documentation with Conic.doc(“myextraplugin”)

Interface to Cbc solver for sparse Quadratic Programs

Extra doc: https://github.com/casadi/casadi/wiki/L_221

>List of available options

Id

Type

Description

cbc

OT_DICT

Options to be passed to CBC.Three sets of options are supported. The first can be found in OsiSolverParameters.hpp. The second can be found in CbcModel.hpp. The third are options that can be passed to CbcMain1.

hot_start

OT_BOOL

Hot start with x0 [Default false].

sos_groups

OT_INTVECTORVECTOR

Definition of SOS groups by indices.

sos_types

OT_INTVECTOR

Specify 1 or 2 for each SOS group.

sos_weights

OT_DOUBLEVECTORVECTOR

Weights corresponding to SOS entries.

Interface to Clp solver for sparse Quadratic Programs

Extra doc: https://github.com/casadi/casadi/wiki/L_22d

>List of available options

Id

Type

Description

clp

OT_DICT

Options to be passed to CLP. A first set of options can be found in ClpParameters.hpp. eg. ‘PrimalTolerance’. There are other options in additions. ‘AutomaticScaling’ (bool) is recognised. ‘initial_solve’ (default off) activates the use of Clp’s initialSolve. ‘initial_solve_options’ takes a dictionary with following keys (see ClpSolve.hpp): SolveType (string), PresolveType (string), NumberPasses, SpecialOptions (intvectorvector), IndependentOptions (intvectorvector).

Interface to Cplex solver for sparse Quadratic Programs

Extra doc: https://github.com/casadi/casadi/wiki/L_22a

>List of available options

Id

Type

Description

cplex

OT_DICT

Options to be passed to CPLEX

dep_check

OT_INT

Detect redundant constraints.

dump_filename

OT_STRING

The filename to dump to.

dump_to_file

OT_BOOL

Dumps QP to file in CPLEX format.

mip_start

OT_BOOL

Hot start integers with x0 [Default false].

qp_method

OT_INT

Determines which CPLEX algorithm to use.

sos_groups

OT_INTVECTORVECTOR

Definition of SOS groups by indices.

sos_types

OT_INTVECTOR

Specify 1 or 2 for each SOS group.

sos_weights

OT_DOUBLEVECTORVECTOR

Weights corresponding to SOS entries.

tol

OT_DOUBLE

Tolerance of solver

warm_start

OT_BOOL

Use warm start with simplex methods (affects only the simplex methods).

Interface to the ECOS Solver for quadratic programming

Extra doc: https://github.com/casadi/casadi/wiki/L_22e

>List of available options

Id

Type

Description

ecos

OT_DICT

Options to be passed to ecos.

vtype

OT_STRINGVECTOR

Type of variables: [CONTINUOUS|binary|integer|semicont|semiint]

Interface to the GUROBI Solver for quadratic programming

Extra doc: https://github.com/casadi/casadi/wiki/L_22q

>List of available options

Id

Type

Description

gurobi

OT_DICT

Options to be passed to gurobi.

sos_groups

OT_INTVECTORVECTOR

Definition of SOS groups by indices.

sos_types

OT_INTVECTOR

Specify 1 or 2 for each SOS group.

sos_weights

OT_DOUBLEVECTORVECTOR

Weights corresponding to SOS entries.

vtype

OT_STRINGVECTOR

Type of variables: [CONTINUOUS|bin ary|integer|semicont|semiint]

Interface to HiGHS solver for sparse Quadratic Programs, see highs.dev for more information and https://www.maths.ed.ac.uk/hall/HiGHS/HighsOptions.html

for a list of options.

Extra doc: https://github.com/casadi/casadi/wiki/L_22f

>List of available options

Id

Type

Description

highs

OT_DICT

Options to be passed to HiGHS.

Interface to HMPC Solver

In order to use this interface, you must:

Decision variables must only by state and control, and the variable

ordering must be [x0 u0 x1 u1 …]

The constraints must be in order: [ gap0 lincon0 gap1 lincon1 ]

gap: Ak+1 = Ak xk + Bk uk lincon: yk= Ck xk + Dk uk

A0 B0 -I
C0 D0
       A1 B1 -I
       C1 D1

where I must be a diagonal sparse matrix Either supply all of N, nx, ng, nu options or rely on automatic detection

Extra doc: https://github.com/casadi/casadi/wiki/L_22p

>List of available options

Id

Type

Description

N

OT_INT

OCP horizon

blasfeo_target

OT_STRING

hpmpc target

inf

OT_DOUBLE

HPMPC cannot handle infinities. Infinities will be replaced by this option’s value.

max_iter

OT_INT

Max number of iterations

mu0

OT_DOUBLE

Max element in cost function as estimate of max multiplier

ng

OT_INTVECTOR

Number of non-dynamic constraints, length N+1

nu

OT_INTVECTOR

Number of controls, length N

nx

OT_INTVECTOR

Number of states, length N+1

print_level

OT_INT

Amount of diagnostic printing [Default: 1].

target

OT_STRING

hpmpc target

tol

OT_DOUBLE

Tolerance in the duality measure

warm_start

OT_BOOL

Use warm-starting

Interface to the MOSEK Solver for quadratic programming

Extra doc: https://github.com/casadi/casadi/wiki/L_21x

>List of available options

Id

Type

Description

mosek

OT_DICT

Options to be passed to mosek.

vtype

OT_STRINGVECTOR

Type of variables: [CONTINUOUS|binary|integer|semicont|semiint]

Interface to the OOQP Solver for quadratic programming The current

implementation assumes that OOQP is configured with the MA27 sparse linear solver.

NOTE: when doing multiple calls to evaluate(), check if you need to

reInit();

Extra doc: https://github.com/casadi/casadi/wiki/L_222

>List of available options

Id

Type

Description

artol

OT_DOUBLE

tolerance as provided with setArTol to OOQP

mutol

OT_DOUBLE

tolerance as provided with setMuTol to OOQP

print_level

OT_INT

Print level. OOQP listens to print_level 0, 10 and 100

Interface to the OSQP Solver for quadratic programming

Extra doc: https://github.com/casadi/casadi/wiki/L_220

>List of available options

Id

Type

Description

osqp

OT_DICT

const Options to be passed to osqp.

warm_start_dual

OT_BOOL

Use lam_a0 and lam_x0 input to warmstart [Default: truw].

warm_start_primal

OT_BOOL

Use x0 input to warmstart [Default: true].

Interface to the QPALM Solver for quadratic programming

Extra doc: https://github.com/casadi/casadi/wiki/L_22n

>List of available options

Id

Type

Description

qpalm

OT_DICT

const Options to be passed to qpalm.

warm_start_dual

OT_BOOL

Use lam_a0 and lam_x0 input to warmstart [Default: true].

warm_start_primal

OT_BOOL

Use x0 input to warmstart [Default: true].

Interface to QPOases Solver for quadratic programming

Extra doc: https://github.com/casadi/casadi/wiki/L_22o

>List of available options

Id

Type

Description

CPUtime

OT_DOUBLE

The maximum allowed CPU time in seconds for the whole initialisation (and the actually required one on output). Disabled if unset.

boundRelaxation

OT_DOUBLE

Initial relaxation of bounds to start homotopy and initial value for far bounds.

boundTolerance

OT_DOUBLE

If upper and lower bounds differ less than this tolerance, they are regarded equal, i.e. as equality constraint.

enableCholeskyRefactorisation

OT_INT

Specifies the frequency of a full re-factorisation of projected Hessian matrix: 0: turns them off, 1: uses them at each iteration etc.

enableDriftCorrection

OT_INT

Specifies the frequency of drift corrections: 0: turns them off.

enableEqualities

OT_BOOL

Specifies whether equalities should be treated as always active (True) or not (False)

enableFarBounds

OT_BOOL

Enables the use of far bounds.

enableFlippingBounds

OT_BOOL

Enables the use of flipping bounds.

enableFullLITests

OT_BOOL

Enables condition-hardened (but more expensive) LI test.

enableInertiaCorrection

OT_BOOL

Should working set be repaired when negative curvature is discovered during hotstart.

enableNZCTests

OT_BOOL

Enables nonzero curvature tests.

enableRamping

OT_BOOL

Enables ramping.

enableRegularisation

OT_BOOL

Enables automatic Hessian regularisation.

epsDen

OT_DOUBLE

Denominator tolerance for ratio tests.

epsFlipping

OT_DOUBLE

Tolerance of squared Cholesky diagonal factor which triggers flipping bound.

epsIterRef

OT_DOUBLE

Early termination tolerance for iterative refinement.

epsLITests

OT_DOUBLE

Tolerance for linear independence tests.

epsNZCTests

OT_DOUBLE

Tolerance for nonzero curvature tests.

epsNum

OT_DOUBLE

Numerator tolerance for ratio tests.

epsRegularisation

OT_DOUBLE

Scaling factor of identity matrix used for Hessian regularisation.

finalRamping

OT_DOUBLE

Final value for ramping strategy.

growFarBounds

OT_DOUBLE

Factor to grow far bounds.

hessian_type

OT_STRING

Type of Hessian - see qpOASES documentation [UNKNO WN|posdef|semidef|indef|zero |identity]]

initialFarBounds

OT_DOUBLE

Initial size for far bounds.

initialRamping

OT_DOUBLE

Start value for ramping strategy.

initialStatusBounds

OT_STRING

Initial status of bounds at first iteration.

linsol_plugin

OT_STRING

Linear solver plugin

maxDualJump

OT_DOUBLE

Maximum allowed jump in dual variables in linear independence tests.

maxPrimalJump

OT_DOUBLE

Maximum allowed jump in primal variables in nonzero curvature tests.

max_schur

OT_INT

Maximal number of Schur updates [75]

nWSR

OT_INT

The maximum number of working set recalculations to be performed during the initial homotopy. Default is 5(nx + nc)

numRefinementSteps

OT_INT

Maximum number of iterative refinement steps.

numRegularisationSteps

OT_INT

Maximum number of successive regularisation steps.

printLevel

OT_STRING

Defines the amount of text output during QP solution, see Section 5.7

schur

OT_BOOL

Use Schur Complement Approach [false]

sparse

OT_BOOL

Formulate the QP using sparse matrices. [false]

terminationTolerance

OT_DOUBLE

Relative termination tolerance to stop homotopy.

Interface to the SQIC solver for quadratic programming

Extra doc: https://github.com/casadi/casadi/wiki/L_21s

Interface to the SuperSCS solver for conic programming

Joris Gillis, 2019

Extra doc: https://github.com/casadi/casadi/wiki/L_21z

>List of available options

Id

Type

Description

superscs

OT_DICT

Options to be passed to superscs.

Solves QPs using a Mehrotra predictor-corrector interior point method

Extra doc: https://github.com/casadi/casadi/wiki/L_23c

>List of available options

Id

Type

Description

constr_viol_tol

OT_DOUBLE

Constraint violation tolerance [1e-8].

dual_inf_tol

OT_DOUBLE

Dual feasibility violation tolerance [1e-8]

linear_solver

OT_STRING

A custom linear solver creator function [default: ldl]

linear_solver_options

OT_DICT

Options to be passed to the linear solver

max_iter

OT_INT

Maximum number of iterations [1000].

min_lam

OT_DOUBLE

Smallest multiplier treated as inactive for the initial active set [0].

print_header

OT_BOOL

Print header [true].

print_info

OT_BOOL

Print info [true].

print_iter

OT_BOOL

Print iterations [true].

Solve QPs using an Nlpsol Use the ‘nlpsol’ option to specify the NLP solver

to use.

Extra doc: https://github.com/casadi/casadi/wiki/L_235

>List of available options

Id

Type

Description

nlpsol

OT_STRING

Name of solver.

nlpsol_options

OT_DICT

Options to be passed to solver.

Solve QPs using an active-set method

Extra doc: https://github.com/casadi/casadi/wiki/L_22y

>List of available options

Id

Type

Description

constr_viol_tol

OT_DOUBLE

Constraint violation tolerance [1e-8].

dual_inf_tol

OT_DOUBLE

Dual feasibility violation tolerance [1e-8]

max_iter

OT_INT

Maximum number of iterations [1000].

min_lam

OT_DOUBLE

Smallest multiplier treated as inactive for the initial active set [0].

print_header

OT_BOOL

Print header [true].

print_info

OT_BOOL

Print info [true].

print_iter

OT_BOOL

Print iterations [true].

print_lincomb

OT_BOOL

Print dependant linear combinations of constraints [false]. Printed numbers are 0-based indices into the vector of [simple bounds;linear bounds]

Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_21n

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/conic.hpp#L98

3.3. Integrator

integrator(*args)

integrator(str name, str solver, dict:SX dae, dict opts) -> Function integrator(str name, str solver, dict:MX dae, dict opts) -> Function

integrator(str name, str solver, dict:MX dae, dict opts)
integrator(str name, str solver, dict:SX dae, dict opts)

Create an ODE/DAE integrator Solves an initial value problem (IVP) coupled to a terminal value problem with differential equation given as an implicit

ODE coupled to an algebraic equation and a set of

quadratures:

Initial conditions at t=t0
x(t0)  = x0
q(t0)  = 0

Forward integration from t=t0 to t=tf
der(x) = function(x, z, p, t)                  Forward ODE
0 = fz(x, z, p, t)                  Forward algebraic equations
der(q) = fq(x, z, p, t)                  Forward quadratures

Terminal conditions at t=tf
rx(tf)  = rx0
rq(tf)  = 0

Backward integration from t=tf to t=t0
der(rx) = gx(rx, rz, rp, x, z, p, t)        Backward ODE
0 = gz(rx, rz, rp, x, z, p, t)        Backward algebraic equations
der(rq) = gq(rx, rz, rp, x, z, p, t)        Backward quadratures

where we assume that both the forward and backwards integrations are index-1
(i.e. dfz/dz, dgz/drz are invertible) and furthermore that
gx, gz and gq have a linear dependency on rx, rz and rp.

General information

>List of available options

Id

Type

Description

Used in

augmented_option s

OT_DICT

Options to be passed down to the augmented integrator, if one is constructed.

casadi::Integrat or

common_options

OT_DICT

Options for auto-generated functions

casadi::OracleFu nction

expand

OT_BOOL

Replace MX with SX expressions in problem formulation [false]

casadi::Integrat or

grid

OT_DOUBLEVECTOR

Time grid

casadi::Integrat or

monitor

OT_STRINGVECTOR

Set of user problem functions to be monitored

casadi::OracleFu nction

number_of_finite _elements

OT_INT

Number of finite elements

casadi::Integrat or

output_t0

OT_BOOL

Output the state at the initial time

casadi::Integrat or

print_stats

OT_BOOL

Print out statistics after integration

casadi::Integrat or

rootfinder

OT_STRING

An implicit function solver

casadi::Integrat or

rootfinder_optio ns

OT_DICT

Options to be passed to the NLP Solver

casadi::Integrat or

show_eval_warnin gs

OT_BOOL

Show warnings generated from function evaluations [true]

casadi::OracleFu nction

simplify

OT_BOOL

Implement as MX Function (codege neratable/serial izable) default: false

casadi::Integrat or

simplify_options

OT_DICT

Any options to pass to simplified form Function constructor

casadi::Integrat or

specific_options

OT_DICT

Options for specific auto- generated functions, overwriting the defaults from common_options. Nested dictionary.

casadi::OracleFu nction

t0

OT_DOUBLE

Beginning of the time horizon

casadi::Integrat or

tf

OT_DOUBLE

End of the time horizon

casadi::Integrat or

>Input scheme: casadi::IntegratorInput (INTEGRATOR_NUM_IN = 6)

Full name

Short

Description

INTEGRATOR_X0

x0

Differential state at the initial time.

INTEGRATOR_P

p

Parameters.

INTEGRATOR_Z0

z0

Initial guess for the algebraic variable.

INTEGRATOR_RX0

rx0

Backward differential state at the final time.

INTEGRATOR_RP

rp

Backward parameter vector.

INTEGRATOR_RZ0

rz0

Initial guess for the backwards algebraic variable.

>Output scheme: casadi::IntegratorOutput (INTEGRATOR_NUM_OUT = 6)

Full name

Short

Description

INTEGRATOR_XF

xf

Differential state at the final time.

INTEGRATOR_QF

qf

Quadrature state at the final time.

INTEGRATOR_ZF

zf

Algebraic variable at the final time.

INTEGRATOR_RXF

rxf

Backward differential state at the initial time.

INTEGRATOR_RQF

rqf

Backward quadrature state at the initial time.

INTEGRATOR_RZF

rzf

Backward algebraic variable at the initial time.

List of plugins - cvodes

  • idas

  • collocation

  • rk

Note: some of the plugins in this list might not be available on your

system. Also, there might be extra plugins available to you that are not listed here. You can obtain their documentation with Integrator.doc(“myextraplugin”)

Interface to CVodes from the Sundials suite.

A call to evaluate will integrate to the end.

You can retrieve the entire state trajectory as follows, after the evaluate

call: Call reset. Then call integrate(t_i) and getOuput for a series of

times t_i.

Extra doc: https://github.com/casadi/casadi/wiki/L_228

>List of available options

Id

Type

Description

abstol

OT_DOUBLE

Absolute tolerence for the IVP solution

disable_internal_warnings

OT_BOOL

Disable SUNDIALS internal warning messages

fsens_all_at_once

OT_BOOL

Calculate all right hand sides of the sensitivity equations at once

fsens_err_con

OT_BOOL

include the forward sensitivities in all error controls

interpolation_type

OT_STRING

Type of interpolation for the adjoint sensitivities

linear_multistep_method

OT_STRING

Integrator scheme: BDF|adams

linear_solver

OT_STRING

A custom linear solver creator function [default: qr]

linear_solver_options

OT_DICT

Options to be passed to the linear solver

max_krylov

OT_INT

Maximum Krylov subspace size

max_multistep_order

OT_INT

Maximum order for the (variable-order) multistep method

max_num_steps

OT_INT

Maximum number of integrator steps

max_order

OT_DOUBLE

Maximum order

max_step_size

OT_DOUBLE

Max step size [default: 0/inf]

min_step_size

OT_DOUBLE

Min step size [default: 0/0.0]

newton_scheme

OT_STRING

Linear solver scheme in the Newton method: DIRECT|gmres|bcgstab|tfqmr

nonlin_conv_coeff

OT_DOUBLE

Coefficient in the nonlinear convergence test

nonlinear_solver_iteration

OT_STRING

Nonlinear solver type: NEWTON|functional

quad_err_con

OT_BOOL

Should the quadratures affect the step size control

reltol

OT_DOUBLE

Relative tolerence for the IVP solution

second_order_correction

OT_BOOL

Second order correction in the augmented system Jacobian [true]

sensitivity_method

OT_STRING

Sensitivity method: SIMULTANEOUS|staggered

step0

OT_DOUBLE

initial step size [default: 0/estimated]

steps_per_checkpoint

OT_INT

Number of steps between two consecutive checkpoints

stop_at_end

OT_BOOL

Stop the integrator at the end of the interval

use_preconditioner

OT_BOOL

Precondition the iterative solver [default: true]

Interface to IDAS from the Sundials suite.

Extra doc: https://github.com/casadi/casadi/wiki/L_225

>List of available options

Id

Type

Description

abstol

OT_DOUBLE

Absolute tolerence for the IVP solution

abstolv

OT_DOUBLEVECTOR

Absolute tolerarance for each component

calc_ic

OT_BOOL

Use IDACalcIC to get consistent initial conditions.

calc_icB

OT_BOOL

Use IDACalcIC to get consistent initial conditions for backwards system [default: equal to calc_ic].

cj_scaling

OT_BOOL

IDAS scaling on cj for the user-defined linear solver module

constraints

OT_INTVECTOR

Constrain the solution y=[x,z]. 0 (default): no constraint on yi, 1: yi >= 0.0, -1: yi <= 0.0, 2: yi > 0.0, -2: yi < 0.0.

disable_internal_warnings

OT_BOOL

Disable SUNDIALS internal warning messages

first_time

OT_DOUBLE

First requested time as a fraction of the time interval

fsens_err_con

OT_BOOL

include the forward sensitivities in all error controls

init_xdot

OT_DOUBLEVECTOR

Initial values for the state derivatives

interpolation_type

OT_STRING

Type of interpolation for the adjoint sensitivities

linear_solver

OT_STRING

A custom linear solver creator function [default: qr]

linear_solver_options

OT_DICT

Options to be passed to the linear solver

max_krylov

OT_INT

Maximum Krylov subspace size

max_multistep_order

OT_INT

Maximum order for the (variable-order) multistep method

max_num_steps

OT_INT

Maximum number of integrator steps

max_order

OT_DOUBLE

Maximum order

max_step_size

OT_DOUBLE

Maximim step size

newton_scheme

OT_STRING

Linear solver scheme in the Newton method: DIRECT|gmres|bcgstab|tfqmr

nonlin_conv_coeff

OT_DOUBLE

Coefficient in the nonlinear convergence test

quad_err_con

OT_BOOL

Should the quadratures affect the step size control

reltol

OT_DOUBLE

Relative tolerence for the IVP solution

second_order_correction

OT_BOOL

Second order correction in the augmented system Jacobian [true]

sensitivity_method

OT_STRING

Sensitivity method: SIMULTANEOUS|staggered

step0

OT_DOUBLE

initial step size [default: 0/estimated]

steps_per_checkpoint

OT_INT

Number of steps between two consecutive checkpoints

stop_at_end

OT_BOOL

Stop the integrator at the end of the interval

suppress_algebraic

OT_BOOL

Suppress algebraic variables in the error testing

use_preconditioner

OT_BOOL

Precondition the iterative solver [default: true]

Fixed-step implicit Runge-Kutta integrator ODE/DAE integrator based on collocation schemes

The method is still under development

Extra doc: https://github.com/casadi/casadi/wiki/L_234

>List of available options

Id

Type

Description

augmented_options

OT_DICT

Options to be passed down to the augmented integrator, if one is constructed.

collocation_scheme

OT_STRING

Collocation scheme: radau|legendre

expand

OT_BOOL

Replace MX with SX expressions in problem formulation [false]

grid

OT_DOUBLEVECTOR

Time grid

interpolation_order

OT_INT

Order of the interpolating polynomials

number_of_finite_elements

OT_INT

Number of finite elements

output_t0

OT_BOOL

Output the state at the initial time

print_stats

OT_BOOL

Print out statistics after integration

rootfinder

OT_STRING

An implicit function solver

rootfinder_options

OT_DICT

Options to be passed to the NLP Solver

simplify

OT_BOOL

Implement as MX Function (codegeneratable/serializa ble) default: false

simplify_options

OT_DICT

Any options to pass to simplified form Function constructor

t0

OT_DOUBLE

Beginning of the time horizon

tf

OT_DOUBLE

End of the time horizon

Fixed-step explicit Runge-Kutta integrator for ODEs Currently implements RK4.

The method is still under development

Extra doc: https://github.com/casadi/casadi/wiki/L_23a

Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_21k

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integrator.hpp#L85

3.4. Rootfinding

rootfinder(*args)

rootfinder(str name, str solver, dict:SX rfp, dict opts) -> Function rootfinder(str name, str solver, dict:MX rfp, dict opts) -> Function rootfinder(str name, str solver, Function f, dict opts) -> Function

rootfinder(str name, str solver, dict:MX rfp, dict opts)
rootfinder(str name, str solver, Function f, dict opts)
rootfinder(str name, str solver, dict:SX rfp, dict opts)

Create a solver for rootfinding problems Takes a function where one of the inputs is unknown and one of the outputs is a residual function

that is

always zero, defines a new function where the the unknown input has been replaced by a guess for the unknown and the residual output has been replaced by the calculated value for the input.

For a function [y0, y1, …,yi, .., yn] = F(x0, x1, …, xj, …, xm),

where xj is unknown and yi=0, defines a new function [y0, y1, …,xj,

..,

yn] = G(x0, x1, …, xj_guess, …, xm),

xj and yi must have the same dimension and d(yi)/d(xj) must be invertable.

By default, the first input is unknown and the first output is the

residual. General information

>List of available options

Id

Type

Description

Used in

common_options

OT_DICT

Options for auto-generated functions

casadi::OracleFu nction

constraints

OT_INTVECTOR

Constrain the unknowns. 0 (default): no constraint on ui, 1: ui >= 0.0, -1: ui <= 0.0, 2: ui > 0.0, -2: ui < 0.0.

casadi::Rootfind er

error_on_fail

OT_BOOL

When the numerical process returns unsuccessfully, raise an error (default false).

casadi::Rootfind er

expand

OT_BOOL

Replace MX with SX expressions in problem formulation [false]

casadi::OracleFu nction

implicit_input

OT_INT

Index of the input that corresponds to the actual root- finding

casadi::Rootfind er

implicit_output

OT_INT

Index of the output that corresponds to the actual root- finding

casadi::Rootfind er

jacobian_functio n

OT_FUNCTION

Function object for calculating the Jacobian (autogenerated by default)

casadi::Rootfind er

linear_solver

OT_STRING

User-defined linear solver class. Needed for sensitivities.

casadi::Rootfind er

linear_solver_op tions

OT_DICT

Options to be passed to the linear solver.

casadi::Rootfind er

monitor

OT_STRINGVECTOR

Set of user problem functions to be monitored

casadi::OracleFu nction

show_eval_warnin gs

OT_BOOL

Show warnings generated from function evaluations [true]

casadi::OracleFu nction

specific_options

OT_DICT

Options for specific auto- generated functions, overwriting the defaults from common_options. Nested dictionary.

casadi::OracleFu nction

>Input scheme: casadi::RootfinderInput (ROOTFINDER_NUM_IN = 2)

Full name

Short

Description

ROOTFINDER_X0

x0

Initial guess for the solution.

ROOTFINDER_P

p

Parameters.

>Output scheme: casadi::RootfinderOutput (ROOTFINDER_NUM_OUT = 1)

Full name

Short

Description

ROOTFINDER_X

x

Solution to the system of equations.

List of plugins - kinsol

  • fast_newton

  • nlpsol

  • newton

Note: some of the plugins in this list might not be available on your

system. Also, there might be extra plugins available to you that are not listed here. You can obtain their documentation with Rootfinder.doc(“myextraplugin”)

KINSOL interface from the Sundials suite

Extra doc: https://github.com/casadi/casadi/wiki/L_226

>List of available options

Id

Type

Description

abstol

OT_DOUBLE

Stopping criterion tolerance

disable_internal_warnings

OT_BOOL

Disable KINSOL internal warning messages

exact_jacobian

OT_BOOL

Use exact Jacobian information

f_scale

OT_DOUBLEVECTOR

Equation scaling factors

iterative_solver

OT_STRING

gmres|bcgstab|tfqmr

linear_solver_type

OT_STRING

dense|banded|iterative|use r_defined

lower_bandwidth

OT_INT

Lower bandwidth for banded linear solvers

max_iter

OT_INT

Maximum number of Newton iterations. Putting 0 sets the default value of KinSol.

max_krylov

OT_INT

Maximum Krylov space dimension

pretype

OT_STRING

Type of preconditioner

print_level

OT_INT

Verbosity level

strategy

OT_STRING

Globalization strategy

u_scale

OT_DOUBLEVECTOR

Variable scaling factors

upper_bandwidth

OT_INT

Upper bandwidth for banded linear solvers

use_preconditioner

OT_BOOL

Precondition an iterative solver

Implements simple newton iterations to solve an implicit function.

Extra doc: https://github.com/casadi/casadi/wiki/L_237

>List of available options

Id

Type

Description

abstol

OT_DOUBLE

Stopping criterion tolerance on ||g||__inf)

abstolStep

OT_DOUBLE

Stopping criterion tolerance on step size

max_iter

OT_INT

Maximum number of Newton iterations to perform before returning.

Implements simple newton iterations to solve an implicit function.

Extra doc: https://github.com/casadi/casadi/wiki/L_236

>List of available options

Id

Type

Description

abstol

OT_DOUBLE

Stopping criterion tolerance on max(|F|)

abstolStep

OT_DOUBLE

Stopping criterion tolerance on step size

line_search

OT_BOOL

Enable line-search (default: true)

max_iter

OT_INT

Maximum number of Newton iterations to perform before returning.

print_iteration

OT_BOOL

Print information about each iteration

Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_21r

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/rootfinder.hpp#L74

3.5. Linear systems

class Linsol(*args)

Linear solver.

Create a solver for linear systems of equations Solves the linear system A*X = B or A^T*X = B for X with A square and non-singular

If A is structurally singular, an error will be thrown during init. If

A is numerically singular, the prepare step will fail.

General informationList of plugins - csparsecholesky

  • csparse

  • ma27

  • lapacklu

  • lapackqr

  • mumps

  • ldl

  • qr

  • tridiag

  • symbolicqr

Note: some of the plugins in this list might not be available on your

system. Also, there might be extra plugins available to you that are not listed here. You can obtain their documentation with Linsol.doc(“myextraplugin”)

Linsol with CSparseCholesky Interface

Extra doc: https://github.com/casadi/casadi/wiki/L_21u

Linsol with CSparseCholesky Interface

Extra doc: https://github.com/casadi/casadi/wiki/L_22s

Linsol with CSparse Interface

Extra doc: https://github.com/casadi/casadi/wiki/L_21t

Linsol with CSparse Interface

Extra doc: https://github.com/casadi/casadi/wiki/L_22r

Interface to the sparse direct linear solver MA27 Works for symmetric

indefinite systems Partly adopted from qpOASES 3.2 Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_229

This class solves the linear system A.x=b by making an LU factorization of A: A = L.U, with L lower and U upper triangular

Extra doc: https://github.com/casadi/casadi/wiki/L_22h

>List of available options

Id

Type

Description

allow_equilibration_failure

OT_BOOL

Non-fatal error when equilibration fails

equilibration

OT_BOOL

Equilibrate the matrix

This class solves the linear system A.x=b by making an QR factorization of A: A = Q.R, with Q orthogonal and R upper triangular

Extra doc: https://github.com/casadi/casadi/wiki/L_22g

>List of available options

Id

Type

Description

max_nrhs

OT_INT

Maximum number of right-hand-sides that get processed in a single pass [default:10].

Interface to the sparse direct linear solver MUMPS Works for symmetric indefinite systems Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_22t

>List of available options

Id

Type

Description

posdef

OT_BOOL

Positive definite

symmetric

OT_BOOL

Symmetric matrix

Linear solver using sparse direct LDL factorization

Extra doc: https://github.com/casadi/casadi/wiki/L_233

Linear solver using sparse direct QR factorization

Extra doc: https://github.com/casadi/casadi/wiki/L_22z

Linear solver for tridiagonal matrices

Extra doc: https://github.com/casadi/casadi/wiki/L_22v

Linear solver for sparse least-squares problems Inspired from https://github.com/scipy/scipy/blob/v0.14.0/scipy/sparse/linalg/isolve/lsqr.py#L96

Extra doc: https://github.com/casadi/casadi/wiki/L_230

Linsol based on QR factorization with sparsity pattern based reordering without partial pivoting

Extra doc: https://github.com/casadi/casadi/wiki/L_231

>List of available options

Id

Type

Description

fopts

OT_DICT

Options to be passed to generated function objects

Joel Andersson

Extra doc: https://github.com/casadi/casadi/wiki/L_1kh

C++ includes: linsol.hpp

static doc(str name) str
static has_plugin(str name) bool
static load_plugin(str name)
neig(*args)

Number of negative eigenvalues.

neig(self, DM A) -> int

Not available for all solvers

Extra doc: https://github.com/casadi/casadi/wiki/L_1kk

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L119

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L166-L171

nfact(*args)

[INTERNAL]

nfact(self, DM A)

Numeric factorization of the linear system.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L106

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L127-L130

plugin_name(*args)

Query plugin name.

plugin_name(self) -> str

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L97

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L65-L67

rank(*args)

Matrix rank.

rank(self, DM A) -> int

Not available for all solvers

Extra doc: https://github.com/casadi/casadi/wiki/L_1kl

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L126

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L177-L182

sfact(*args)

[INTERNAL]

sfact(self, DM A)

Symbolic factorization of the linear system, e.g. selecting pivots.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L103

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L105-L108

solve(*args)

Solve linear system of equations

solve(self, DM A, DM B, bool tr) -> DM solve(self, MX A, MX B, bool tr) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L111

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L101-L103

solve(self, DM A, DM B, bool tr)

Solve linear system of equations

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L110

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L73-L99

solve(self, MX A, MX B, bool tr)

Solve linear system of equations

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L111

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L101-L103

sparsity(*args)

Get linear system sparsity.

sparsity(self) -> Sparsity

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L100

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L69-L71

stats(*args)

Get all statistics obtained at the end of the last evaluate call.

stats(self, int mem) -> dict

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.hpp#L129

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/linsol.cpp#L218-L220

static type_name() str