Python simple examples as in NLP CasADi documentation

Hello everyone,
I’m approaching in this days acados for my master thesis: a track identification for autonomous cars for my Formula SAE team. At the moment it is entirely written in CasADi, but I’m trying to migrate it under acados.

Reading the documentation however I cannot find anything for my user case: I’ve got a NLP problem composed by a cost function, a system dynamics ad a few inequality constraints. In CasADi I’ve used Direct Collocation as Discretization Method in order to obtain only a cost function and inequality constraints, that can be then solved with ipopt.

What I’m asking is what I’ve to implement in acados: the starting problem (cost+dynamics+constraints) or the directly-collocated one (cost+constraints)? CasADi can handle only the latter, what acados can do?

If it’s possible, I’d like to ask a new example for python_interface: a well-commented transcription of the CasADi NLP documentation, because honestly I don’t know what to write in acados_constraint objects, nor which other objects or methods to call.

Thanks for your help,
have a nice day and great Holidays!

Hi @Maik93,

welcome to our forum!

Since acados is mainly aiming at solving OCPs, we naturally define the problem differently compared to the CasADi NLP interface.
The acados interface take an OCP formulation, i.e. with dynamics.

Did you have a look at the Python examples, and the mathematical formulation of the OCP in acados already?


1 Like

Hi @Maik93,

As Jonathan already pointed out, the way the OCP is specified in acados, is substantially different from the one used in CasADi. This is difference is mainly driven by the different fundamental design choices that characterize the two packages: 1) CasADi aims at solving a broad class of problems, while keeping an eye on performance (e.g. using general purpose high-performance linear algebra and nonlinear program solvers) 2) acados is designed in order to exploit as much as possible the structure of the optimal control problems in order to speedup the computations (see for a comparison with CasADi + Ipopt). I would say this is, in my view, one of the main reasons why the two interfaces are different (and the one of acados a bit more verbose). Anyway, although the interfaces of acados are becoming more and more solid, any feedback from the users is more than welcome :wink:

Regarding the usage of acados_constraint, you might have a look here: You need to specify the expression lh <= h(x,u) <= uh as specified in the OCP formulation and assign it to the attribute con_h_expr. Moreover, you need to specify a name and the CasADi symbolic variables used in the definition of the expression.