Introduction to CasADi

Notes on CasADi, especially the usage of variables in CasADi

CSDN notes link: 1 2


Variables

SX

SX data type represent matrix: create a matrix $x \in R^{2 \times 2}$

x = SX.sym('x', 2, 2)  #  create a matrix $\in R^{2 \times 2}$

print(x)
output: [[x_0, x_2],
	 [x_1, x_3]]

y = x**2
print(y)
output: x^2

MX

Suitable for NLP model

evalf(DM)    # MX to DM

DM

DM mainly used to save matrix and used as function input and output

DM.full()    # show the DM value

DM return values, SX,MX return equation that contains variables
SX have all the elements of the matrix, MX only define the matrix itself

Recent Posts

Timeline of posts