Source-linked AI summary
A software framework for embedded nonlinear model predictive control using a gradient-based augmented Lagrangian approach (GRAMPC)
Tobias Englert, Andreas Völz, Felix Mesmer, Sönke Rhein, Knut Graichen
TL;DR
Online nonlinear MPC must meet demanding computational and embedded-hardware constraints. The paper develops an augmented-Lagrangian framework with a tailored gradient inner solver in GRAMPC and evaluates it across benchmark problems and embedded platforms. The reported results show fast, real-time-feasible computation across the benchmarks, including nonlinear constrained systems, with scaling to larger system dimensions.
Problem
Online MPC requires substantial numerical effort, while embedded implementations additionally require robustness, fast iterates, low code complexity, and small memory footprints.
Method
GRAMPC uses an augmented-Lagrangian algorithm with gradient-based inner minimization for nonlinear constrained optimal control, including semi-implicit and DAE systems.
Results
GRAMPC achieves overall fast and real-time-feasible computation times across benchmark problems, particularly for nonlinear systems and nonlinear constraints, and scales with increasing system dimension.
Takeaways & Limitations
The framework is tailored to embedded MPC and demonstrates applicability through benchmark comparisons and runtime and memory evaluations on dSPACE and ECU platforms.
Takeaways & Limitations
The evaluation is intended to provide a general impression of GRAMPC rather than an objectively rigorous ranking against other solvers.
Abstract
from arXiv · showhide
A nonlinear MPC framework is presented that is suitable for dynamical systems with sampling times in the (sub)millisecond range and that allows for an efficient implementation on embedded hardware. The algorithm is based on an augmented Lagrangian formulation with a tailored gradient method for the inner minimization problem. The algorithm is implemented in the software framework GRAMPC and is a fundamental revision of an earlier version. Detailed performance results are presented for a test set of benchmark problems and in comparison to other nonlinear MPC packages. In addition, runtime results and memory requirements for GRAMPC on ECU level demonstrate its applicability on embedded hardware.
1 Introduction
MPC handles constrained linear and nonlinear systems but requires substantial online numerical effort. Embedded MPC adds demands for robustness, low computation, small memory, and portable code, motivating tailored gradient-based approaches and the GRAMPC evaluation.
- MPC handles linear and nonlinear systems with constraints and multiple inputs, but solving its online optimal control problem is numerically demanding.
- Explicit MPC can reduce online computation for linear systems, but is typically limited to small numbers of state and control variables.
- Nonlinear MPC toolkits use approaches including continuation/GMRES, active-set real-time iterations, and projected gradients.
- Embedded MPC requires numerical robustness, infeasibility tolerance, fast iterates, dynamically consistent trajectories, low code complexity, and a small memory footprint.
- GRAMPC is evaluated on benchmark problems against ACADO and VIATOC, with runtime and memory results on dSPACE and ECU hardware.
2 Problem formulation
GRAMPC formulates broad constrained optimal control problems for MPC, moving horizon estimation, and related applications. Its formulation supports nonlinear, semi-implicit, and DAE systems, while its MPC and MHE applications use receding-horizon optimization and state-estimation transformations.
- 2 Problem formulation: GRAMPC targets MPC, moving horizon estimation, general optimal control, and parameter optimization with a numerical method tailored to embedded applications.
- 2.1 Optimal control problem: The generic problem minimizes terminal and integral costs subject to semi-implicit dynamics, equality constraints, inequality constraints, and box constraints on optimization variables.
- 2.1 Optimal control problem: The formulation supports unknown parameters, free end time, state-dependent and terminal constraints, and semi-implicit dynamics with a constant mass matrix.
- 2.2 Application to model predictive control: MPC repeatedly solves an optimal control problem over a prediction horizon and applies the first control segment before resolving it with the next measured or estimated state.
- 2.2 Application to model predictive control: A quadratic cost penalizes deviation from desired state and input values, while terminal regions and box constraints can encode stability and state limits.
- 2.2 Application to model predictive control: Real-time MPC often omits terminal constraints and limits iterations, using warm starts to reduce suboptimality incrementally.
- 2.2 Application to model predictive control: Shrinking-horizon MPC treats the horizon as a free end time and can impose a terminal equality to reach a desired setpoint in finite time.
- 2.3 Application to moving horizon estimation: MHE estimates the current state by optimizing over past controls and measurements; GRAMPC represents the initial horizon state as a parameter after a time and coordinate transformation.
3 Optimization algorithm
GRAMPC solves constrained optimal control problems by alternating augmented-Lagrangian multiplier updates with a projected-gradient inner minimization. The formulation supports dynamics, constraints, parameters, and free end time while retaining a computational structure suited to embedded, potentially suboptimal implementations.
- Augmented Lagrangian framework: The algorithm uses augmented Lagrangian multipliers and penalties to solve the constrained optimal control problem through an alternating max-min procedure.The inner minimization uses projected gradients, while the outer maximization updates multipliers by steepest ascent.
- Augmented Lagrangian framework: The augmented cost incorporates equality and inequality constraints through multipliers and quadratic penalty terms, including terminal constraints.GRAMPC also handles the corresponding penalties time-dependently for path constraints.
- Outer iterations: GRAMPC initializes multipliers, penalties, and tolerances, checks convergence, and updates multipliers and penalties when convergence has not been reached.In MPC, constraint trajectories can be warm-started from the previous run; gradient variables are likewise initialized from the last sampling step.
- Inner minimization: For fixed multipliers and penalties, the inner problem retains only box constraints and is solved with a projected gradient method over controls, parameters, and optional free end time.The method can stop at a desired accuracy or after a fixed iteration count.
- Inner minimization: The gradient method integrates forward dynamics and backward adjoint dynamics, then computes updates that reduce the Hamiltonian.The Hamiltonian combines the augmented running cost with the dynamics through the adjoint state.
- Inner minimization: The gradient algorithm supports simultaneous line search over search directions and can optimize controls together with parameters and free end time.Scaling factors adjust parameter and end-time step sizes relative to control steps.
4 Structure and usage of GRAMPC
GRAMPC is a portable plain-C framework with interfaces for C++, Matlab/Simulink, and dSpace. Users define an optimal control problem through function templates, configure algorithmic options, and run the solver through largely consistent C/C++ and Matlab procedures.
- General structure: GRAMPC is implemented in plain C, avoids external libraries, and provides interfaces to C++, Matlab/Simulink, and dSpace.The framework is intended to run across different operating systems and hardware.
- General structure: Users create a project by defining problem functions in C templates and setting problem-specific parameters and numerical algorithm options.Options include numerical integration and line-search settings.
- General structure: A GRAMPC project stores parameters and algorithmic options in the grampc structure, which can be modified without recompilation.The same project can therefore be run with different parameters and options.
- Problem definition: The problem definition includes dimensions, dynamics, integral and terminal costs, and equality or inequality constraints.The ball-on-plate example specifies two states, one control, and four inequality constraints.
- Calling procedure and options: C and Matlab interfaces use corresponding Cmex wrappers, while initialization and solver calls remain largely the same across C/C++ and Matlab.Matlab user parameters are restricted to arrays, whereas C user parameters may be arbitrary structures.
- Problem definition: GRAMPC requires state, control, parameter, and end-time derivatives, including multiplied Jacobians to avoid unnecessary zero multiplications for sparse structures.The user supplies derivative functions corresponding to the optimality conditions.
- Calling procedure and options: The solver exposes configurable horizon discretization, iteration limits, constraint handling, and integration methods including Euler, Heun, fourth-order Runge-Kutta, and RODAS.The example sets Nhor, gradient and multiplier iteration limits, inequality constraints, and the Heun integrator.
5 Performance evaluation
The performance evaluation defines an MPC testbench suite to assess GRAMPC under realistic problem settings, compare it with state-of-the-art MPC solvers, and demonstrate portability to real-time and embedded hardware.
- Evaluation scope: The testbench evaluates GRAMPC's computational performance against other state-of-the-art MPC solvers.The evaluation is designed around realistic conditions and meaningful problem settings.
- Evaluation scope: The evaluation also demonstrates GRAMPC's portability to real-time and embedded hardware.The section covers typical MPC, moving horizon estimation, and optimal-control problems.
5.1 General MPC evaluation
GRAMPC is evaluated across diverse MPC benchmarks against ACADO and VIATOC, with emphasis on computation time, integrated cost, scalability, and embedded feasibility. Results indicate fast, real-time-feasible computation, particularly for nonlinear constrained systems, while solver performance varies by problem structure and tuning.
- Benchmark setup: The testbench covers linear, semi-implicit, nonlinear, scalable, and nonlinear-constraint MPC problems, with selected cases evaluated against ACADO and VIATOC.The benchmark set includes three linear problems, a semi-implicit reactor, the scalable nonlinear chain, and constrained PMSM, crane, and vehicle problems; VIATOC excludes three nonlinear-constraint cases.
- Evaluation setup: GRAMPC uses mostly default settings, while ACADO and VIATOC are individually tuned for speed or near-optimal cost.GRAMPC adapts horizon, integration, and iteration parameters; ACADO and VIATOC vary shooting intervals and iterations, with ACADO using qpOASES for quadratic programs.
- Benchmark results: GRAMPC is fastest on the stiff semi-implicit reactor benchmark, although ACADO and VIATOC optimal settings achieve lower integrated cost.GRAMPC can approach a similar cost by deviating from its default parameters.
- Benchmark results: For the state-constrained 2D-crane problem, ACADO has higher cost than GRAMPC because it does not reach the new setpoint within the given time.The nonlinear geometric constraint is active for almost the complete simulation.
- Benchmark results: GRAMPC benefits from native scaling on the CSTR reactor and shows a large cost advantage on the VTOL example under nonlinear dynamics.The paper attributes the VTOL difference to greater accuracy and robustness of GRAMPC’s gradient method when initialized at equilibrium.
- Scalability and timing: 21–57 state variables in the nonlinear-chain benchmark show that GRAMPC scales well, although increasing stiffness causes adaptive integration steps to shrink.The augmented Lagrangian/gradient projection algorithm has linear complexity in state dimension, but the complete nonlinear-chain runtime is also affected by dynamics stiffness.
- Embedded feasibility: GRAMPC’s computation time is nearly constant across MPC iterations, supporting tight upper bounds for real-time guarantees, and its embedded results show small memory usage.On dSpace, all example computation times are below the sampling time; required memory is below 9 kB except for the nonlinear chain and PDE reactor, which use less than 7% of ECU RAM.
5.2 Application examples
GRAMPC is applied to diverse nonlinear optimal-control and estimation problems, including constrained crane control, shrinking-horizon MPC, semi-implicit PDE dynamics, equality-constrained robot motion, and moving horizon estimation. The examples show rapid approximate solutions, trajectory computation in challenging settings, and accurate state estimation.
- 5.2.1 Nonlinear constrained model predictive control: The 3DOF crane problem combines nonlinear dynamics with an obstacle-avoidance constraint that remains active for more than half the simulation.The transition moves the crane from x0 = [−2 m, 0, 2 m, 0, 0, 0]T to xdes = [2 m, 0, 2 m, 0, 0, 0]T.
- 5.2.2 MPC on shrinking horizon: Shrinking-horizon MPC uses a terminal setpoint constraint and treats the prediction horizon as an optimization variable.With strict iteration limits, GRAMPC is initially suboptimal; afterward, the horizon declines linearly and warm-starting subtracts the sampling time from the previous horizon.
- 5.2.3 Semi-implicit problems: GRAMPC handles semi-implicit PDE reactor dynamics by finite-element discretization into M ẋ = f(x, u), using 11 spatial grid points for the simulation.The reactor task stabilizes a stationary temperature profile, and RODAS exploits sparse, banded numerical structure.
- 5.2.4 OCP with equality constraints: Tightening gradient and constraint tolerances increases computation time and iteration counts, while moderate-accuracy solutions are computed quickly.The authors emphasize that improving suboptimal solutions over time is more important for MPC than solving to very small tolerances.
- 5.2.4 OCP with equality constraints: The planar two-arm robot problem is challenging because its optimal trajectory passes through singular configurations of both arms.The resulting solution trajectory is shown in Figure 9.
- 5.2.5 Moving horizon estimation: For moving horizon estimation, GRAMPC tracks noisy reactor states with less than 0.1% relative error for each state variable.The average estimation error is [7.12 kmol m−3, 6.24 kmol m−3, 0.10 °C, 0.09 °C]T, and one iteration requires 11 µs.
6 Conclusions
GRAMPC implements an augmented Lagrangian algorithm for nonlinear MPC and extends an earlier version. The framework supports general nonlinear systems and is tailored for embedded MPC with low memory requirements, including ECU deployment.
- GRAMPC implements an augmented Lagrangian algorithm for nonlinear model predictive control and significantly extends its original 2014 version.
- The framework handles general nonlinear systems described by explicit or semi-implicit differential equations or index-1 differential-algebraic equations.
- GRAMPC supports input constraints, nonlinear state- or input-dependent equality and inequality constraints, unknown parameters, and possibly free end times.These variables also support applications such as moving horizon estimation and shrinking-horizon MPC.
- The algorithm is tailored to embedded MPC with very low memory requirements and is evaluated through runtime results on dSPACE and automotive ECU hardware.
A Transformation of inequality to equality constraints
The appendix transforms inequality constraints into equality constraints using nonnegative slack variables within an augmented Lagrangian formulation. Slack-variable minimizations are solved explicitly or pointwise, and the resulting expressions are inserted into the transformed constraints.
- Nonnegative slack variables v and vT are introduced to incorporate inequality constraints into the existing equality constraints.
- The transformed cost adjoins the constraints to the original cost functional using multipliers, penalties, and corresponding diagonal matrices.
- The augmented Lagrangian approach replaces the original optimal control problem with a max-min problem involving the transformed cost.
- Minimization with respect to the terminal slack variable vT is a strictly convex quadratic problem solved by stationarity and projection when vT ≥0 is violated.
- Minimization with respect to v(t) is pointwise in time because v appears only in the integral and does not affect the dynamics.
- Substituting the explicit slack-variable solutions yields the transformed equality constraints.