MPC QP Solver Mathematics
A linear-model MPC step is a quadratic program; solving it fast and reliably each cycle is what makes real-time predictive control feasible.
The quadratic program
With a linear model and quadratic cost, the MPC optimal-control problem is a convex quadratic program (QP) in the stacked decision vector of predicted states and inputs. Convexity means a unique global optimum and reliable solvers - essential when a wrong or late command reaches machine actuators.
Condensed QP form:
min_z (1/2) z' H z + g' z
s.t. A_ineq z <= b_ineq , A_eq z = b_eq
z : stacked inputs (and states) over the horizon
H : block-diagonal from Q, R, P (H symmetric PD -> convex)
constraints from envelope, actuator, slew limits
Interior-point versus active-set versus ADMM
Three solver families dominate. Interior-point methods follow the central path and converge in few, expensive iterations - good for large horizons. Active-set methods guess the binding constraints and are very fast when warm-started near the previous solution. ADMM (e.g. the OSQP style) splits the problem into cheap steps and is robust on embedded hardware. The stack chooses per loop by size and latency budget.
# ADMM step for the MPC QP (OSQP-style, schematic)
for it in range(max_it):
x = solve_kkt(H + rho*A.T@A, -(g + A.T@(rho*z - y))) # linear solve
z = clip(A@x + y/rho, lo, hi) # projection onto box
y = y + rho*(A@x - z) # dual update
if primal_res()<eps and dual_res()<eps: break
Warm starting and time bounds
Because MPC re-solves a slightly changed problem each cycle, warm-starting from the previous solution slashes iterations - the optimum moves little between cycles. The stack also bounds solve time: it caps iterations and, if the QP has not converged, applies the best feasible iterate rather than missing the control deadline. A guaranteed feasible fallback command exists for every cycle.
- Convex QP: unique global optimum, dependable solvers.
- Interior-point: few costly iterations, large horizons.
- Active-set / ADMM: fast warm-started and embedded-friendly.
- Bounded time: iteration cap + feasible fallback for hard real time.
Solver choice and tolerances are part of the control-loop's timing budget, coordinated with the FPGA command handoff so the optimized command always arrives inside the deterministic deadline.