Features by Example#

This page showcases how specific acados features can be used by pointing to the relevant examples. If you are new to acados, we highly recommend to start with the getting_started examples:

Getting started with Model Predictive Control#

In particular, the closed-loop examples are a great starting point to develop model predictive control (MPC) in a simulation. Here, an OCP solver (AcadosOcpSolver) is used to compute the control inputs and an integrator (AcadosSimSolver) is used to simulate the real system.

Simulation and Sensitivity propagation#

Optimal Control Problem Formulation#

Parameter updates

Cost formulations

acados supports general nonlinear cost, but can also exploit particular cost structures such as (non)linear least-squares costs and convex-over-nonlinear costs. For more details on how to exploit convex outer structure in costs and constraints with a (Generalized) Gauss-Newton Hessian approximation, please refer to Messerer2021a.

Soft constraints

Convex-over-nonlinear constraints

  • Python

  • currently not supported for MATLAB

Multi-phase OCP

Constraints and cost on control rate

Moving horizon estimation (MHE)

Discretization with a nonuniform grid

Time-varying reference tracking

One-sided constraints

Algorithmic features and solver options#

Real-time iterations (RTI)

acados supports real-time iterations (RTI) for fast MPC applications. In particular, the computations can be split in a preparation phase and a feedback phase to reduce the control delay. For further details, we refer to Diehl2001a and Gros2020b.pdf.

Advanced-step real-time iterations (AS-RTI) Relevant publications: Frey2024a, Nurkanovic2019a

Solver timeout

Cost integration

Globalization

Differential dynamic programming (DDP)

In addition to the standard SQP method, acados also supports solving OCPs with differential dynamic programming (DDP). In this case, the OCP needs to be unconstrained. In Python, constraints can be easily reformulated as penalties using AcadosOcp.formulate_constraint_as_L2_penalty and AcadosOcp.formulate_constraint_as_Huber_penalty.

Partial condensing

Use a qp_solver starting with PARTIAL_CONDENSING, use qp_solver_cond_N to set the horizon of the partially condensed QP. Additionally, one can use qp_solver_cond_block_size to specify how many blocks are condensed into one block in partial condensing.

Zero-order robust optimization (zoRO)

Relevant publications: Frey2024, Zanelli2021

Solution sensitivities

acados can compute solution sensitivities of the OCP solution map with respect to global parameters and the initial state, i.e. it implements so-called differentiable MPC. Both forward and adjoint sensitivity methods are supported. For more details, please refer to (and cite) the corresponding publication: Frey2025

Forward sensitivities

  • Python

  • currently not supported for MATLAB/Octave

Adjoint solution sensitivities

  • Python

  • currently not supported for MATLAB/Octave

General nonlinear programs#

If you want to solve a general nonlinear program (NLP), i.e. a nonlinear optimization problem without OCP structure, you can still use acados by formulating your problem as an OCP with a horizon of zero, i.e. AcadosOcpOptions.N_horizon = 0. In this case, you obtain an OCP with terminal cost and constraints only. Therefore, all optimization variables should be combined in AcadosModel.x. The cost and constraints should use the corresponding fields with suffix _e.