AI Wiki中文/EN

Model predictive control: re-plan at every step, apply only the first move

模型预测控制

How MPC turns a finite-horizon constrained optimal control problem into feedback: the receding-horizon law, linear MPC as a quadratic program, why a finite horizon can destabilise and how terminal cost and terminal set restore recursive feasibility and Lyapunov descent, with a synthetic double-integrator demo that keeps a velocity limit clipped LQR cannot see.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Plan ahead, act once, look again

Model predictive control steers a system by planning a short way ahead, over and over. At every step it predicts the next few moves, picks the best plan that obeys every limit, carries out only the first move, and then plans again. A typical use is a cart that must reach a goal without breaking a motor limit or a speed limit.

A cart must travel four metres and stop. Its motor force is limited, and for safety its speed must never exceed one metre per second. A linear feedback law tuned for this task will command eleven times the available force at the start. Clip that command to the motor limit and the force is respected, but the controller still does not account for the speed limit: the cart accelerates past it and overshoots the goal.

Model predictive control (MPC), also called receding-horizon control, handles this by planning. At each sampling instant it measures the current state. It uses a model to predict the next N steps. It then solves an optimisation problem that chooses the whole input sequence for those steps subject to every constraint. It applies only the first input. At the next instant it measures the new state and solves again. The core idea is to forecast the system with a dynamic model and optimise that forecast to choose the current move. Because that move depends on the initial state, MPC also needs the state, usually estimated from past measurements. The horizon “recedes” because it keeps sliding forward in time. Basic concept Receding-horizon MPC

Constraints, such as actuator saturation (a motor or valve stuck at its maximum output), distinguish MPC from standard linear quadratic control. The linear quadratic regulator (LQR) is the classic optimal feedback for a linear model with quadratic cost. Without constraints and with the right terminal cost (a penalty on the final predicted state), linear MPC reproduces the LQR gain exactly. With constraints, it produces a nonlinear feedback law that is not written in closed form, because it is evaluated only at the state where it is needed. Constraints as the distinguishing feature

This article states the finite-horizon problem and shows how linear MPC becomes a quadratic program (an optimisation with quadratic cost and linear constraints). It explains why a finite horizon can destabilise a loop and which terminal ingredients prevent it. It then checks these claims on three original, synthetic numerical examples. The Riccati recursion and the infinite-horizon regulator are covered in LQR, the general theory in optimal control, and the transcription methods used to solve the inner problem in trajectory optimization.

The finite-horizon problem and its receding-horizon law

This section writes the MPC problem down, shows which part of its answer is actually applied, and works one small example by hand. For a discrete-time model x⁺ = f(x, u), MPC solves at the current state x the problem

PN(x):VN0(x)=min⁡u ∑k=0N−1ℓ(x(k),u(k))+Vf(x(N))s.t. x(0)=x, x(k+1)=f(x(k),u(k)), (x(k),u(k))∈Z, x(N)∈Xf\mathbb{P}_N(x):\quad V_N^0(x)=\min_{\mathbf u}\ \sum_{k=0}^{N-1}\ell\bigl(x(k),u(k)\bigr)+V_f\bigl(x(N)\bigr)\quad\text{s.t.}\ x(0)=x,\ x(k+1)=f\bigl(x(k),u(k)\bigr),\ \bigl(x(k),u(k)\bigr)\in\mathbb Z,\ x(N)\in\mathbb X_f

In words: choose the next N inputs to make the total cost as small as possible, while the predicted path follows the model and obeys every limit. Here N is the horizon, ℓ the stage cost, V_f the terminal cost, Z the set of admissible state–input pairs and X_f the terminal set. The problem is parametric in x; the set X_N of states from which some feasible input sequence exists is its domain, the feasible set. Problem (2.1)–(2.8) A rate limit |u(k) − u(k−1)| ≤ c fits the same template by adding a state z with z⁺ = u. Rate constraints

If u⁰(x) = (u⁰(0; x), …, u⁰(N−1; x)) is the optimal sequence, MPC applies only its first element:

κN(x)=u0(0;x),x+=f(x,κN(x))\kappa_N(x)=u^0(0;x),\qquad x^+=f\bigl(x,\kappa_N(x)\bigr)

In words: the controller’s output at state x is the first move of the best plan from x, and the system then moves to its next state x⁺. κ_N is a genuine state-feedback law, but it is implicit: MPC evaluates it only at the states actually visited. Computing κ_N for every state is usually intractable once there are constraints or nonlinearities and more than a few state dimensions, so Rawlings, Mayne and Diehl regard MPC as a practical way to implement the dynamic-programming solution one state at a time. Implicit law and DP Tedrake makes the same point: the MPC policy has no closed form and is represented only through the optimisation; explicit MPC is the line of work that tries to tabulate it. Implicit policy For the dynamic-programming background, see recursion and dynamic programming and Bellman equations.

In the linear case the usual choice is a quadratic stage and terminal cost:

ℓ(x,u)=12(x⊤Qx+u⊤Ru),Vf(x)=12x⊤Px\ell(x,u)=\tfrac12\left(x^\top Qx+u^\top Ru\right),\qquad V_f(x)=\tfrac12 x^\top Px

Here Q weights the state error, R weights the input effort and P weights the final predicted state. Large Q relative to R drives the state to the origin quickly with large inputs; large R gives slower, gentler responses. Choosing Q and R is not obvious, and MPC inherits this tuning difficulty from LQ control. Q and R

Linear MPC is a quadratic program. With linear dynamics, quadratic cost and polyhedral constraints, P_N(x) is a QP. QP structure There are two ways to write it. One keeps the states as decision variables and imposes the dynamics as equality constraints; the other eliminates them by forward simulation,

x[n]=Anx[0]+∑k=0n−1A n−1−kBu[k]x[n]=A^n x[0]+\sum_{k=0}^{n-1}A^{\,n-1-k}Bu[k]

so that only the inputs remain. In words: each future state is the start state pushed forward n steps, plus the effect of every earlier input. Direct shooting The eliminated, or condensed, problem has fewer variables but dense matrices; the full problem is larger but sparse and banded. Rawlings, Mayne and Diehl’s rule of thumb is that condensing is typically preferable for short horizons and a sparse solver on the full problem for long ones. Condensing Either way the result is a convex problem whose optimality conditions are the KKT conditions of constrained optimisation; convexity is what makes the global optimum reachable. An ellipsoidal terminal set keeps the problem convex but makes it no longer a QP. Ellipsoidal terminal set

A one-dimensional example by hand. Rawlings, Mayne and Diehl’s Example 2.5 takes x⁺ = x + u, ℓ = (x² + u²)/2, V_f = x²/2, |u| ≤ 1 and N = 2. Substituting the dynamics, the cost becomes (3/2)x² + x(2u₀ + u₁) + ½uᵀHu with H = [[3, 1], [1, 2]]. The unconstrained minimiser is −H⁻¹[2, 1]ᵀx = −(1/5)[3, 1]ᵀx, so as long as the input bound is inactive the first move is −3x/5. Working through the constrained cases, the book obtains κ_N(x) = −sat(3x/5): a piecewise-affine law with a piecewise-quadratic value function. Examples 2.5–2.6 The constraint turns a linear controller into a saturated one, and it does so by optimisation, not by clipping after the fact.

Optimal over N steps is not the same as stable

This section shows that planning optimally over N steps does not by itself make the loop stable, and which extra ingredients fix that. A finite-horizon optimiser looks only N steps ahead. Beyond the horizon it does not care where the state goes, and applying its first move repeatedly can produce a loop that diverges. Rawlings, Mayne and Diehl show this with a two-state linear system: A = [[4/3, −2/3], [1, 0]], B = [1, 0]ᵀ, Q = CᵀC + 0.001I, R = 0.001. They use the first gain of the N = 5 finite-horizon LQ problem as a fixed feedback. The closed-loop eigenvalue then has magnitude 1.307; a magnitude above 1 means the state eventually grows without bound, so the loop is unstable. N = 7 gives 0.989, and the infinite-horizon gain gives 0.664. Finite-horizon instability Part 1 of the program below reproduces these numbers.

The standard stability proof uses the optimal value V_N⁰ as a Lyapunov function. It needs a descent property along the closed loop,

VN0(f(x,κN(x)))≤VN0(x)−ℓ(x,κN(x))V_N^0\bigl(f(x,\kappa_N(x))\bigr)\le V_N^0(x)-\ell\bigl(x,\kappa_N(x)\bigr)

In words: after one closed-loop step, the optimal cost must drop by at least the stage cost just paid. This does not usually hold for a finite horizon unless the terminal cost, the terminal set and the stage cost are chosen together. Descent (2.17) The book’s basic assumption (Assumption 2.14) asks that inside the terminal set some admissible input keeps the state in the set while the terminal cost decreases at least as fast as the stage cost is paid:

∀x∈Xf ∃u: (x,u)∈Z,f(x,u)∈Xf,Vf(f(x,u))−Vf(x)≤−ℓ(x,u)\forall x\in\mathbb X_f\ \exists u:\ (x,u)\in\mathbb Z,\quad f(x,u)\in\mathbb X_f,\quad V_f\bigl(f(x,u)\bigr)-V_f(x)\le-\ell(x,u)

In words, X_f is control invariant (some allowed input keeps the state inside it) and V_f is a local control Lyapunov function on it (a cost that such an input can always lower), together with lower and upper bounds on ℓ and V_f. Assumption 2.14 The proof of descent is constructive: take yesterday’s optimal sequence, drop its first input, shift the rest forward, and append the input that the assumption guarantees inside X_f. That shifted sequence is feasible for today’s problem and costs at most V_N⁰(x) − ℓ(x, κ_N(x)), so the optimum costs no more. Shifted candidate Under these assumptions plus a weak controllability condition, the origin is asymptotically stable for the closed loop with region of attraction X_N (Theorem 2.19), and exponentially stable when the bounds are quadratic (Theorem 2.21). Theorems 2.19 and 2.21

The same construction gives recursive feasibility: if X_f is control invariant, X_N is positive invariant under the MPC law, so if the problem is solvable at the initial state it stays solvable forever. Recursive feasibility Tedrake describes the simplest instance, a final-value constraint x[N] = x* at a fixed point: the shifted previous solution padded with the equilibrium input is feasible, and with zero cost at the equilibrium the optimal cost is non-increasing and serves as a Lyapunov function. Recursive feasibility and Lyapunov

The linear constrained recipe. For linear systems with input and state constraints, a standard choice is V_f(x) = ½xᵀPx with P from the discrete algebraic Riccati equation,

P=Q+A⊤PA−A⊤PB (B⊤PB+R)−1B⊤PA,K=−(B⊤PB+R)−1B⊤PAP=Q+A^\top PA-A^\top PB\,(B^\top PB+R)^{-1}B^\top PA,\qquad K=-(B^\top PB+R)^{-1}B^\top PA

and X_f the maximal invariant constraint-admissible set of the LQR closed loop x⁺ = (A + BK)x. Here P is the cost-to-go matrix of the unconstrained infinite-horizon problem and K is the matching LQR gain. Then the origin is exponentially stable in X_N, and the problem is a QP when the state and input constraints are polyhedral. Linear constrained case Without constraints and with this terminal cost, the MPC law equals the LQR gain for every horizon length. Unconstrained LQ For a stable A with only input constraints, using the zero-input cost (AᵀPA + Q = P) as terminal cost works with no terminal constraint at all and gives global exponential stability. Stable A More generally the terminal constraint can be dropped by inflating the terminal cost to βV_f with β large enough, provided the initial state lies in a suitable subset; this is attractive because input-only constraints are easier to handle. Omitting the terminal constraint

These guarantees are nominal. They assume the model is exact, the next state is exactly the predicted one and the global optimum is computed. Nominal setting Disturbances, model error and state-estimation error can push the state out of the feasible set, and then the optimiser has no solution and the controller fails. The book recommends soft state constraints where design aims allow, or switching to soft constraints until the hard ones can be met again; robust MPC addresses uncertainty more systematically. Soft constraints

Solving the problem in real time

This section covers what changes when the problem must be solved quickly and possibly with a nonlinear model. In practice the line between convex and nonconvex MPC problems usually coincides with the line between linear and nonlinear models. Nonlinear MPC is nearly always nonconvex and can have several local minima; the book’s Example 8.1 illustrates this with f(x, u) = x + u − 2u² and N = 1. Convex vs nonconvex Continuity can also fail: for linear dynamics with polyhedral constraints the value function is continuous, but the book exhibits a nonlinear system with a terminal equality constraint whose MPC law and value function jump. Continuity

Rawlings, Mayne and Diehl argue that insisting on an exact solution is not a good idea. Computation delays the feedback, and optimisation errors smaller than the modelling error barely change closed-loop behaviour, so the choice of algorithm is a trade-off between accuracy and time. Inexact solutions Online algorithms exploit the fact that consecutive problems are nearly the same: warm-start from the previous solution, shift it one step forward, split the work into a preparation phase before the measurement arrives and a short feedback phase after, and in the limit perform one iteration per sampling time while the problem itself moves (real-time iteration). Online algorithms Tedrake calls linear MPC so well understood that it is considered the de facto generalisation of LQR for linear systems with linear constraints. Linear MPC

Two warnings about terminal equality constraints. With x_N = 0, a large state dimension n, a small input dimension m and Nm < n, the equality constraints outnumber the variables, so the linear independence constraint qualification (LICQ) cannot hold. LICQ And the feasible set X_N, which is the region of attraction for many of these controllers, can usually be computed only for small linear-polyhedral problems; in practice it is estimated by simulation. Feasible set

Three synthetic experiments

This section runs three small experiments that check the claims above. The program below is original, synthetic and deterministic; it uses only numpy and runs in well under a second. Part 1 reproduces the finite-horizon instability example: it iterates the Riccati recursion N − 1 times from the terminal weight P = Q, takes the first gain K(0) and prints the eigenvalue magnitudes of A + BK(0). Part 2 solves Example 2.5 as a box-constrained QP. It uses a projected-gradient loop (a gradient step followed by clipping back into the box; step 1/λ_max, 2000 iterations) and compares the first input with −sat(3x/5). Part 3 uses a double integrator, a cart whose input is its acceleration (dt = 0.1 s, A = [[1, 0.1], [0, 1]], B = [0.005, 0.1]ᵀ). It drives the cart from position 4 at rest to the origin over 80 steps (8 s). The weights are Q = diag(1, 0.1) and R = 0.1, and the limits are |u| ≤ 1 and |velocity| ≤ 1. It compares unconstrained LQR, LQR clipped to |u| ≤ 1, and MPC with horizon N = 30 (3 s) and terminal cost ½xᵀPx from the DARE. The MPC problem is the condensed QP with 30 inputs and 60 inequality rows (30 input bounds and 30 predicted-velocity bounds). It is solved by a hand-written ADMM (alternating direction method of multipliers) loop: 300 iterations per step, fixed ρ = 1, warm-started by shifting the previous solution. Projected gradient and ADMM are our own implementation choices; neither source prescribes them.

import numpy as np

# Synthetic, deterministic illustration of model predictive control (MPC).
# Part 1: a finite-horizon LQ gain used as a fixed feedback can destabilise.
# Part 2: one-dimensional MPC law with an input bound equals -sat(3x/5).
# Part 3: receding-horizon MPC of a constrained double integrator vs LQR.


def riccati_gain(A, B, Q, R, P, steps):
    for _ in range(steps):
        S = B.T @ P @ B + R
        P = Q + A.T @ P @ A - A.T @ P @ B @ np.linalg.solve(S, B.T @ P @ A)
    K = -np.linalg.solve(B.T @ P @ B + R, B.T @ P @ A)
    return K, P


print("Part 1: first gain of an N-step LQ problem used forever")
A1 = np.array([[4 / 3, -2 / 3], [1.0, 0.0]])
B1 = np.array([[1.0], [0.0]])
C1 = np.array([[-2 / 3, 1.0]])
Q1 = C1.T @ C1 + 0.001 * np.eye(2)
R1 = np.array([[0.001]])
for N in (5, 7, 200):
    K, _ = riccati_gain(A1, B1, Q1, R1, Q1.copy(), N - 1)
    eig = np.sort(np.abs(np.linalg.eigvals(A1 + B1 @ K)))[::-1]
    print(f"  N={N:3d}  |eig(A+BK(0))| = {eig[0]:.3f}, {eig[1]:.3f}")

print()
print("Part 2: x+ = x + u, |u| <= 1, N = 2, stage (x^2+u^2)/2, Vf = x^2/2")
H2 = np.array([[3.0, 1.0], [1.0, 2.0]])


def solve_box_qp(H, q, lo, hi, iters=2000):
    # Projected gradient with step 1/L on a box-constrained QP.
    L = np.linalg.eigvalsh(H).max()
    u = np.zeros(len(q))
    for _ in range(iters):
        u = np.clip(u - (H @ u + q) / L, lo, hi)
    return u


for x in (0.5, 1.0, 5 / 3, 2.25, 3.0, 10.0):
    q = np.array([2.0, 1.0]) * x
    u = solve_box_qp(H2, q, -1.0, 1.0)
    V = 1.5 * x * x + q @ u + 0.5 * u @ H2 @ u
    print(f"  x={x:6.3f}  u0={u[0]:+.4f}  -sat(3x/5)={-np.clip(0.6 * x, -1, 1):+.4f}"
          f"  u1={u[1]:+.4f}  V={V:.4f}")

print()
print("Part 3: double integrator, dt = 0.1, |u| <= 1, |velocity| <= 1")
dt = 0.1
A = np.array([[1.0, dt], [0.0, 1.0]])
B = np.array([[0.5 * dt * dt], [dt]])
Q = np.diag([1.0, 0.1])
R = np.array([[0.1]])
K, P = riccati_gain(A, B, Q, R, Q.copy(), 2000)
print(f"  LQR gain K = [{K[0, 0]:.4f}, {K[0, 1]:.4f}]")

N = 30
n, m = 2, 1
Phi = np.zeros((n * N, n))
Gam = np.zeros((n * N, m * N))
Ak = np.eye(n)
for i in range(N):
    Ak = A @ Ak
    Phi[n * i:n * i + n] = Ak
    for j in range(i + 1):
        Gam[n * i:n * i + n, j] = (np.linalg.matrix_power(A, i - j) @ B)[:, 0]
Qbar = np.kron(np.eye(N), Q)
Qbar[-n:, -n:] = P
Rbar = np.kron(np.eye(N), R)
H = Gam.T @ Qbar @ Gam + Rbar
F = Gam.T @ Qbar @ Phi
Vrow = Gam[1::2]
Cmat = np.vstack([np.eye(N), Vrow])
rho, sigma = 1.0, 1e-6
Minv = np.linalg.inv(H + sigma * np.eye(N) + rho * Cmat.T @ Cmat)


def mpc_input(x, warm):
    # ADMM for min 0.5 u'Hu + q'u  s.t.  -1 <= u <= 1,  -1 <= v(k) <= 1.
    q = F @ x
    offset = Vrow.shape[0]
    lo = np.concatenate([-np.ones(N), -np.ones(offset) - Phi[1::2] @ x])
    hi = np.concatenate([np.ones(N), np.ones(offset) - Phi[1::2] @ x])
    u, z, y = warm
    for _ in range(300):
        u = Minv @ (sigma * u - q + Cmat.T @ (rho * z - y))
        Cu = Cmat @ u
        z = np.clip(Cu + y / rho, lo, hi)
        y = y + rho * (Cu - z)
    shift = (np.append(u[1:], u[-1]), z, y)
    return u[0], shift


def simulate(policy, steps=80):
    x = np.array([4.0, 0.0])
    xs, us, cost = [x.copy()], [], 0.0
    warm = (np.zeros(N), np.zeros(2 * N), np.zeros(2 * N))
    for _ in range(steps):
        if policy == "mpc":
            u, warm = mpc_input(x, warm)
        else:
            u = (K @ x)[0]
            if policy == "clipped":
                u = float(np.clip(u, -1.0, 1.0))
        cost += x @ Q @ x + R[0, 0] * u * u
        x = A @ x + B[:, 0] * u
        xs.append(x.copy())
        us.append(u)
    xs = np.array(xs)
    us = np.array(us)
    settle = next(k for k in range(len(xs))
                  if np.all(np.abs(xs[k:, 0]) < 0.05)) * dt
    viol = max(np.abs(us).max() - 1.0, np.abs(xs[:, 1]).max() - 1.0, 0.0)
    return dict(umax=np.abs(us).max(), vmax=np.abs(xs[:, 1]).max(), viol=viol,
                xmin=xs[:, 0].min(), cost=cost, settle=settle,
                final=np.abs(xs[-1]).max())


for name in ("lqr", "clipped", "mpc"):
    r = simulate(name)
    print(f"  {name:8s} max|u|={r['umax']:.3f}  max|v|={r['vmax']:.3f}"
          f"  min x={r['xmin']:+.3f}  cost={r['cost']:.2f}"
          f"  settle={r['settle']:.1f}s  violation={r['viol']:.1e}")
Recorded output
Part 1: first gain of an N-step LQ problem used forever
  N=  5  |eig(A+BK(0))| = 1.307, 0.001
  N=  7  |eig(A+BK(0))| = 0.989, 0.001
  N=200  |eig(A+BK(0))| = 0.664, 0.001

Part 2: x+ = x + u, |u| <= 1, N = 2, stage (x^2+u^2)/2, Vf = x^2/2
  x= 0.500  u0=-0.3000  -sat(3x/5)=-0.3000  u1=-0.1000  V=0.2000
  x= 1.000  u0=-0.6000  -sat(3x/5)=-0.6000  u1=-0.2000  V=0.8000
  x= 1.667  u0=-1.0000  -sat(3x/5)=-1.0000  u1=-0.3333  V=2.2222
  x= 2.250  u0=-1.0000  -sat(3x/5)=-1.0000  u1=-0.6250  V=4.2031
  x= 3.000  u0=-1.0000  -sat(3x/5)=-1.0000  u1=-1.0000  V=8.0000
  x=10.000  u0=-1.0000  -sat(3x/5)=-1.0000  u1=-1.0000  V=123.5000

Part 3: double integrator, dt = 0.1, |u| <= 1, |velocity| <= 1
  LQR gain K = [-2.7623, -2.5075]
  lqr      max|u|=11.049  max|v|=3.116  min x=-0.101  cost=145.24  settle=3.6s  violation=1.0e+01
  clipped  max|u|=1.000  max|v|=2.051  min x=-0.534  cost=265.72  settle=6.0s  violation=1.1e+00
  mpc      max|u|=1.000  max|v|=1.000  min x=-0.032  cost=303.54  settle=4.9s  violation=5.3e-09

Part 1. The magnitudes are 1.307 and 0.001 for N = 5, 0.989 and 0.001 for N = 7, and 0.664 and 0.001 for N = 200, which stands in for the infinite horizon. They match the book’s three pairs. Two extra steps of horizon turn an unstable loop into a stable one; optimality over five steps guaranteed nothing.

Part 2. At every tested state the first input equals −sat(3x/5). For x = 1 the bound is inactive: u = (−0.6000, −0.2000) and V = 0.8000. For x = 5/3 the first input just reaches the bound (−1.0000) and V = 2.2222. For x = 2.25 the first input is saturated, the second is −0.6250 and V = 4.2031. At x = 3 and x = 10 both inputs sit at −1, and V = 8.0000 at x = 3. For x = 10 the program prints V = 123.5000. The book prints V_N⁰(10) = 124, but evaluating its own cost at u = (−1, −1) gives ½(100 + 81 + 64 + 1 + 1) = 123.5, so the printed figure is rounded or a slip.

Part 3. The DARE gives the LQR gain K = [−2.7623, −2.5075].

Controllermax abs umax abs velocitymin positioncostsettleviolation
unconstrained LQR11.0493.116−0.101145.243.6 s1.0e+01
LQR clipped to abs(u) ≤ 11.0002.051−0.534265.726.0 s1.1e+00
MPC, N = 301.0001.000−0.032303.544.9 s5.3e-09

The cost is Σ(xᵀQx + Ru²) over the 80 steps, “settle” is the first time after which |position| stays below 0.05, and “violation” is the largest excess over either bound. Unconstrained LQR asks for inputs eleven times the bound. Clipping respects |u| ≤ 1 but cannot see the velocity limit: the cart reaches 2.051 and overshoots to −0.534. MPC keeps both limits (the 5.3e-09 excess is solver tolerance), overshoots only to −0.032 and settles at 4.9 s instead of 6.0 s.

MPC’s accumulated cost, 303.54, is higher than clipped LQR’s 265.72. That is the price of obeying the velocity limit, not a sign that MPC is the worse controller: clipped LQR buys its lower cost by moving faster than allowed. Costs of controllers that satisfy different constraint sets cannot be ranked against each other. As a check on the solver, we reran the program with 3000 ADMM iterations per step instead of 300. Every printed number stayed the same except the MPC violation, which fell from 5.3e-09 to 2.0e-15; this supports reading 5.3e-09 as solver tolerance.

One caveat about what Part 3 demonstrates: the MPC uses the DARE terminal cost but no terminal constraint set, so it is not covered by Theorem 2.19 as stated. It behaves well from this one initial state; that is a demonstration, not a certified design. The model is also exact and the state is measured perfectly, so nothing here tests robustness or estimation.

Where the guarantees stop

This section lists where the results above stop applying. The stability and recursive-feasibility results above are nominal, meaning they hold for the idealised model. They assume an exact model, no disturbance, a perfectly known state and a globally optimal solution. With real sensors the state is estimated (state estimation, Kalman filter). Estimation error makes the problem uncertain; the deterministic results then do not apply directly. Robust and stochastic MPC exist for this, and were not covered by the sections read for this article.

Hard state constraints can make the problem infeasible after an unforeseen disturbance, at which point a naive implementation has no input to apply. Soft constraints with penalties are the usual remedy, at the cost of allowing temporary violations.

For nonlinear models the problem is nonconvex. The solver may return a local minimum, the law may be discontinuous, and the computation per step is larger. A terminal set that certifies stability may be hard to compute; designs that skip it, like Part 3, rely on horizon length and simulation rather than proof.

The examples are synthetic toys: a scalar system, a textbook two-state system and a double integrator from a single initial state. They do not measure the performance of any industrial controller. The history below is second-hand: Rawlings, Mayne and Diehl summarise it in their chapter notes, and none of the original papers was read for this article.

Exercises

These exercises test understanding, a hand calculation, a counterexample and a design choice.

  1. If MPC computes an optimal input sequence for the next N steps, why does it apply only the first input and solve again?

    Answer: Re-solving from the newly measured state is what closes the loop. In the deterministic, exact-model case feedback is unnecessary in principle, because the state evolves exactly as predicted. With disturbances, model error or estimation error, the real state departs from the prediction, and re-optimising from the actual state supplies feedback. The horizon also recedes, so constraints further ahead come into view at each step.

  2. For x⁺ = x + u, N = 2, ℓ = (x² + u²)/2, V_f = x²/2 and |u| ≤ 1, the condensed cost is (3/2)x² + x(2u₀ + u₁) + ½uᵀHu with H = [[3, 1], [1, 2]]. Find the optimal inputs and cost (a) at x = 1 and (b) at x = 2.25.

    Answer: (a) The unconstrained minimiser −(1/5)[3, 1]ᵀx = (−0.6, −0.2) lies inside the box, so it is optimal. V = 1.5 + (−1.2 − 0.2) + ½(3·0.36 + 2·0.12 + 2·0.04) = 1.5 − 1.4 + 0.7 = 0.8. (b) The unconstrained minimiser (−1.35, −0.45) leaves the box. On the face u₀ = −1, stationarity in u₁ gives −1 + 2u₁ + x = 0, so u₁ = 0.5 − 0.5x = −0.625; the multiplier of the active bound is −2.5 + 1.5x = 0.875 > 0, which confirms optimality. V = 4.2031, and the first input −1 equals −sat(3·2.25/5). Both match Part 2.

  3. “A finite-horizon optimal controller stabilises the plant, as long as the horizon is reasonably long.” Is this true?

    Answer: No. In Part 1 the loop is unstable at N = 5 (eigenvalue magnitude 1.307) and stable at N = 7 (0.989). Stability depends on the horizon and the terminal ingredients, not on optimality; guarantees come from a terminal cost and terminal set satisfying Assumption 2.14, or from results on sufficiently long horizons. A terminal equality constraint is no free fix either: with x(N) = 0 and Nm < n, LICQ fails, and a double integrator (n = 2, m = 1) generally cannot be driven to the origin in one step.

  4. A report says “MPC performed worse than saturated LQR: cost 303.54 vs 265.72”. How should this be judged?

    Answer: The two controllers do not satisfy the same constraints. Clipped LQR reaches velocity 2.051, violating the limit of 1 that MPC enforces (maximum 1.000). A fair comparison is among controllers that meet all constraints, and it should also report overshoot (−0.534 vs −0.032) and settling (6.0 s vs 4.9 s). One synthetic plant and one initial state support no general ranking.

  5. A robot joint has torque and velocity limits and a good linear model near its operating point. Suppose (hypothetically) that a small QP can be solved every millisecond. Choose between LQR with clipping, linear MPC and nonlinear MPC.

    Answer: LQR with clipping handles only input limits and ignores state limits, as Part 3 shows. Linear MPC encodes both limits in a QP and can fit a tight budget if the problem is small, warm-started and solved inexactly. Use soft state constraints to avoid infeasibility, and either a terminal cost with a terminal set or a long horizon for stability. Nonlinear MPC is worth its nonconvexity and extra computation only if the linear model is poor over the operating range. Neither source gives robot timing figures; the 1 ms budget is an assumption of the exercise.

History and further reading

This section gives a short, second-hand history and points to further reading. As summarised in Rawlings, Mayne and Diehl’s chapter notes, Propoi (1963) proposed a form of MPC based on linear programming. Lee and Markus (1967) described re-solving an open-loop problem from the measured state. Richalet and colleagues (1978) triggered a surge of interest in process control, followed by papers such as Cutler and Ramaker (1980). MPC then became widely used in the process industries for problems with hard constraints. Stability was not settled in that early work. Keerthi and Gilbert (1988) showed that a terminal equality constraint stabilises constrained nonlinear discrete-time systems; Chen and Allgöwer (1998) used a terminal cost and terminal set for nonlinear continuous-time systems; and Mayne and colleagues (2000) distilled the conditions into what they called stability axioms. Chapter notes None of these originals was read for this article.

For theory, Rawlings, Mayne and Diehl’s chapters 1, 2 and 8 cover the regulator, stability and numerical methods used here; their later chapters treat robust, stochastic, distributed and explicit MPC. MPC book Tedrake’s trajectory-optimisation chapter presents MPC as trajectory optimisation re-solved in a loop and connects it to time-varying LQR. Underactuated Robotics Related topics: LQR for the Riccati terminal cost, optimal control for the general theory, trajectory optimization for transcription methods, Newton’s method for the solvers inside QP and NLP codes, PID control as the model-free contrast, robot dynamics for robot models, and model-based RL and safe RL for learned-model planning and constraint handling in reinforcement learning.

Make a prediction, then check

In the example, the double integrator must keep |u| ≤ 1 and |velocity| ≤ 1. Clipped LQR accumulates cost 265.72 and MPC 303.54. Which reading is correct?

Choose one answer

Learning objectives

  • State the finite-horizon MPC problem (stage cost, terminal cost, state and input constraints, terminal set), explain why the receding horizon applies only the first input, and write linear MPC as a quadratic program.
  • Explain why finite-horizon optimality does not imply stability, how terminal cost and terminal set yield recursive feasibility and Lyapunov descent, and where the nominal results stop holding under uncertainty, infeasibility and nonconvexity.

Prerequisites & connections

Explore related knowledge →

References

  1. Model Predictive Control: Theory, Computation, and Design, 2nd ed. (fifth printing, 2024 electronic copy) — scoped
    James B. Rawlings; David Q. Mayne; Moritz M. Diehl · 2017
  2. Underactuated Robotics — chapter “Trajectory Optimization” (book/trajopt.html at commit 1e1402f) — scoped
    Russ Tedrake · 2024

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Claude · 2026-12-03 · Independent AI check (Claude subagent, not the author; not a human or expert review). Gemini-app style edits logged in gemini-edits-016a.json were applied to the opening sections before this check; research was done by a separate research subagent (facts.md) and the prose by a writer subagent. I first made readability (D012) edits to the intuition section and section openings in both languages, then checked the edited text. I ran example.py with the pinned interpreter (numpy 1.26.4) with and without OPENBLAS_NUM_THREADS set and diffed against example.stdout.txt (identical), confirmed the python block in en.mdx and zh.mdx is byte-identical to example.py, and matched every quoted number. I reran Part 3 with 3000 ADMM iterations per step: all printed numbers were unchanged except the MPC violation (5.3e-09 to 2.0e-15), so the article's claim of identical printout was corrected. I re-derived Example 2.5 by hand (condensed cost, H, unconstrained minimiser, face solution and multiplier at x = 2.25, V(10) = 123.5) and the exercise answers. I downloaded the Rawlings–Mayne–Diehl fifth-printing PDF myself and read, with printed page = PDF page − 50, pp. 1, 11–12, 21–22 (eigenvalues 1.307/0.989/0.664 for N = 5/7/∞), 89–91, 94, 99–107 (Example 2.5 prints V = 124; κ_N = −sat(3x/5); Theorem 2.7, Example 2.8), 112–122 (recursive feasibility, Assumption 2.14, Theorems 2.19 and 2.21), 131–137, 144–145, 166–169 (history notes), 485–492 and 567–570. I fetched Tedrake's book/trajopt.html at commit 1e1402f and read the 'Direct Shooting', 'Model-Predictive Control', 'Receding-horizon MPC', 'Recursive feasibility' and 'MPC and Lyapunov functions' text. I compared zh and en section by section and checked data.json IDs against src/data/catalogue.txt. Not checked: book pages outside those listed (for example §8.9.1 warm-start details were only skimmed), the cited original papers, and any robust or stochastic MPC material.

  • The example run with the pinned interpreter matches example.stdout.txt; both code blocks are byte-identical to example.py; every number quoted in the prose matches the output.
  • Checked the finite-horizon destabilisation eigenvalues (1.307, 0.989, 0.664) on book pp. 21–22 and Example 2.5 on pp. 99–101 (the book prints V(10) = 124 while its formula gives 123.5; the law is −sat(3x/5)).
  • Confirmed Part 3's MPC has a DARE terminal cost but no terminal set and the article says it is not covered by Theorem 2.19 as stated; MPC's higher cost is explained as the price of obeying the velocity limit.
  • The history only repeats what the book's §2.11 notes say (pp. 166–169), with originals marked as unread; the Tedrake MPC subsections at the pinned commit support the attributed claims.
  • zh and en match section by section in definitions, numbers, exercises, answers and caveats; data.json prerequisite and related IDs exist in the catalogue and the quiz answer is correct.

Source locations checked:

  • Model Predictive Control: Theory, Computation, and Design, 2nd ed. (fifth printing, 2024 electronic copy) — scoped · pdftotext -layout of MPC-book-2nd-edition-5th-printing.pdf (821 PDF pages; printed page = PDF page − 50). Read: copyright/printing history p. iv and Preface to the 2nd ed. pp. vii–viii; §1.1–1.2 opening p. 1; §1.3 Introductory MPC Regulator pp. 11–26 (LQ problem (1.5)–(1.6), constraints as distinguishing feature, Q/R tuning, DP and Example 1.1, backward Riccati (1.10)–(1.14), infinite-horizon motivation with Kalman quote and the N = 5/7/∞ eigenvalue example, controllability, Lemma 1.3, DARE (1.18)); §2.1–2.3 pp. 89–107 (MPC definition, DP vs MPC, recursive feasibility preview, continuous infinite-horizon problem, (2.1)–(2.8), rate constraints, Assumptions 2.2–2.3, Prop. 2.4, κ_N, Examples 2.5–2.6 incl. −sat(3x/5) and V = 124, Theorem 2.7, Example 2.8, start of §2.3); p. 112 (positive invariance, recursive feasibility) and §2.4.1–2.4.4 pp. 112–122 (KL stability, Lyapunov function (2.14)–(2.16), Assumption 2.14, Props. 2.15–2.18, descent proof (2.17)–(2.18), Theorem 2.19, exponential stability Theorem 2.21, IOSS/Assumption 2.23 skimmed); §2.5 opening and §2.5.1–2.5.4 pp. 131–137 (soft constraints, unconstrained LQR, periodic case skimmed, stable A with input constraints, linear constrained with DARE terminal cost and maximal constraint-admissible set); §2.6 pp. 144–145 (omitting terminal constraint, βV_f); end of §2.10 and §2.11 Notes pp. 166–170 (history); §8.1 pp. 485–495 (inexact solution argument, discrete OCP (8.1), convex vs nonconvex, Example 8.1, simultaneous vs sequential, condensing, rule of thumb, continuous OCP (8.5), HJB/indirect/direct families, Euler transcription (8.6)); end of §8.8 and §8.9.1 pp. 567–571 (LICQ with terminal equality, move blocking, code generation, preparation/feedback phase, tangential predictors, warm start and shift, iterating while the problem changes). NOT read: chapters 3–7 (robust, stochastic, estimation, distributed, explicit MPC), §2.4.5 onward except as listed, §2.7–2.9 (suboptimal, economic, discrete actuators), Ch. 8 §8.2–8.8 detail and §8.9.2 onward, appendices, all exercises, and every cited original paper (Propoi, Lee & Markus, Richalet, Cutler & Ramaker, Keerthi & Gilbert, Chen & Allgöwer, Mayne et al. 2000). Noted: Example 2.5 prints V_N⁰(10) = 124 while its own cost evaluates to 123.5.
  • Underactuated Robotics — chapter “Trajectory Optimization” (book/trajopt.html at commit 1e1402f) — scoped · raw book/trajopt.html at commit 1e1402ff50ca9de7bebaf6849a59114085393d2b, tags stripped (identical to the live underactuated.csail.mit.edu/trajopt.html text on 2026-12-03). Read for this topic: chapter intro; 'Problem Formulation'; 'Convex Formulations for Linear Systems' → 'Direct Transcription', 'Direct Shooting', 'Computational Considerations'; 'Local Trajectory Feedback Design' → 'Finite-horizon LQR', 'Model-Predictive Control', 'Receding-horizon MPC', 'Recursive feasibility', 'MPC and Lyapunov functions'. NOT read for this topic: perching case study, Pontryagin, differential flatness, GCS/combinatorial sections, explicit MPC section text, exercises, and the cited works (Garcia89, Camacho13, Bemporad99). Some passages in the HTML are author notes or commented-out drafts; none are used.

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.