Amortized Nonlinear Model Predictive Control
Amortized Nonlinear Model Predictive Control
Francesco Pillitteri, Alberto Bemporad
IMT School for Advanced Studies Lucca
[arXiv:2606.05840]
Nonlinear Model Predictive Control (NMPC) is among the most general frameworks for constrained optimal control: at each sampling instant, a finite-horizon optimization problem is solved, the first element of the optimal input sequence is applied, and the process repeats. The key challenge is that for nonlinear systems the underlying program is a nonlinear program (NLP), whose per-step solve time can be orders of magnitude larger than the available sampling period—rendering real-time deployment infeasible on resource-constrained hardware.
This post summarizes our approach1 to addressing this challenge for the broad class of input-affine nonlinear systems.
The Core Idea: From NLP to a Small QP
Consider a discrete-time input-affine system
where is the state and is the control input. At each step, NMPC solves a horizon- optimal control problem over the joint decision vector , a vector of dimension that can be very large.
The key structural observation is that the one-step state map is affine in for any fixed :
where and . This means every constraint that is affine in can be written as a linear inequality. A standard quadratic stage cost with output map , linearized around , yields a quadratic objective in . The resulting single-step QP is:
where and are state- and reference-dependent cost parameters, hard constraints encode input bounds and affine-in-input constraints (e.g., torque limits via inverse dynamics), and the soft-constraint slack ensures feasibility for state bounds.
This QP has only decision variables—far fewer than the full NLP—and is always feasible by construction.
Learning the QP Parameters: Residual-Corrector Architecture
The QP parameters must encode the entire -step value function, not just the one-step stage cost. The analytic baseline , obtained by linearizing the output map around , captures only the first-step contribution:
A neural network learns the residual corrections over this baseline. The Cholesky factor yields the corrected Hessian , with the diagonal of passed through a softplus to guarantee for any network output. The resulting QP is solved by a differentiable interior-point layer, which provides exact constraint satisfaction and differentiable gradients through the solution.

The analytic baseline provides a warm, structured initialization; the network learns only the correction needed to match the full NLP over the remaining horizon steps.
Training: A Hybrid KKT Loss
The network is trained offline on a dataset of NLP solutions with their primal-dual variables. The loss combines four terms:
Supervised imitation directly penalizes the deviation from the optimal first control action:
KKT stationarity penalizes violations of the first-order optimality conditions of the full NLP at the network’s prediction, using the optimal dual variables from the dataset as fixed anchors:
Fischer–Burmeister complementarity enforces the complementarity and inequality feasibility conditions in smooth differentiable form via , which satisfies .
Regularization towards the analytic baseline prevents the learned corrections from drifting unnecessarily far.
The KKT and FB terms are evaluated at a mixed primal : the full optimal solution with the first control block and the resulting one-step-ahead state replaced by the network’s prediction. This gives an optimization-informed gradient signal near constraint boundaries once the supervised term has converged, at the cost of a first-order approximation in .
Case Study: Three-Link Planar Robotic Arm
We validate on a three-link planar arm with gravity (, , joint accelerations as inputs). The prediction model is a simplified double integrator , while the plant is simulated with full Euler–Lagrange dynamics—representing a deliberate model mismatch. The MPC horizon is steps.
The stage cost is nonlinear through the forward kinematics:
Hard constraints include torque limits enforced via inverse dynamics and acceleration bounds; state (joint position and velocity) bounds are softened. The single-step QP has decision variables and 36 inequality rows.
The network is a three-hidden-layer MLP (, ReLU), mapping an 8-dimensional input to the 9-dimensional residual . It is initialized to zero so that at startup the QP recovers the analytic one-step solution.
Training uses 100,000 samples from closed-loop IPOPT trajectories, 200 epochs with Adam and cosine learning-rate decay.
Results
We compare against: full-horizon IPOPT (optimality reference), acados SQP-RTI (one Gauss–Newton iteration per step), and a direct MLP with identical architecture but without the differentiable QP layer.

End-effector trajectories from a common initial configuration (filled circle) to the target (star). The amortized QP closely tracks the IPOPT trajectory, while RTI and the direct MLP deviate visibly.
| Metric | Amort. QP | RTI | IPOPT | Direct MLP |
|---|---|---|---|---|
| Mean solve time (ms) | 0.116 | 2.453 | 211.8 | 0.095 |
| Speedup vs. IPOPT | 1826× | 86× | — | 2229× |
| Convergence | 100/100 | 88/100 | 100/100 | 73/100 |
| Mean EE error (m) | 1.5×10⁻³ | 4.2×10⁻² | 1.2×10⁻³ | 4.0×10⁻² |
| Mean ratio vs. IPOPT | 1.047 | 1.175 | 1.000 | 1.120 |
| Max torque violation (N·m) | 0 | ~0 | ~0 | 46.3 |
| Max accel. violation (rad/s²) | 0 | ~0 | ~0 | 20.8 |
The amortized policy runs in 0.116 ms on a mobile CPU—a 21× speedup over RTI and an 1826× speedup over IPOPT—while achieving closed-loop cost within 4.7% of the IPOPT optimum and converging on all 100 test scenarios. Hard constraints on torque and acceleration are satisfied to numerical precision; slack variables are active in only 0.7% of steps.
By contrast, acados RTI diverges on 12/100 scenarios, and the direct MLP converges on only 73/100 with hard constraint violations up to 46.3 N·m in torque—confirming that the differentiable QP layer is essential for both feasibility and reliability.
Conclusion
We have shown that, for input-affine nonlinear systems, the optimal MPC control move can be approximated by a small state-dependent QP whose parameters are predicted by a neural network. The residual-corrector architecture—analytic baseline plus learned correction, solved by a differentiable interior-point layer—achieves near-optimal closed-loop performance with guaranteed constraint satisfaction at inference times in the sub-millisecond range.
Footnotes
-
F. Pillitteri and A. Bemporad, “Amortized Nonlinear Model Predictive Control,” arXiv preprint arXiv:2606.05840 [eess.SY], 2026. https://arxiv.org/abs/2606.05840 ↩