CasADI

Working with professor Yash Pant, this library is mentioned pretty often. Can be used such as in MPC.

CasADi provides interfaces to solve quadratic programs (QPs).

Also looking into this for Code19.

Two main types of expressions:

  • SX (Symbolic Expression) is simpler, faster for small problems, and works with sparse matrices. It is used when problem size and complexity are relatively low.
  • MX (Matrix Expression) is more general, supporting dynamic sizes and large-scale problems, and is better suited for complex optimization tasks involving large matrices.

Casadi for real-time:

# Example of exporting an NLP solver
opti = casadi.Opti()
 
# Define decision variables, objective, constraints, etc.
x = opti.variable()
y = opti.variable()
opti.minimize(x**2 + y**2)
opti.subject_to(x + y == 1)
 
# Create the solver
p_opts = {"expand": True}  # pre-processing for efficiency
s_opts = {"max_iter": 100}  # solver settings
solver = opti.solver('ipopt', p_opts, s_opts)
 
# Export the solver to a function that can be called at runtime
f = solver.callable()

CasADI Interpolant

Learning this interpolant

Learning MPC

if you want to use CasADI in real-time, you should really consider: https://github.com/Tim-Salzmann/l4casadi

Resources:

In the function , you’re returning the derivatives of the current state, not the new state itself.

This is a fundamental concept in modeling systems using differential equations. Here’s why:

What f(x, u) Represents The function f(x, u) describes the rate of change (the derivative) of the state vector x at a given moment, based on the current state x and the control input u.