Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Receding-Horizon Control

The trajectory optimization methods presented so far compute a complete control trajectory from an initial state to a final time or state. Once computed, this trajectory is executed without modification, making these methods fundamentally open-loop. The control function, u[k]\mathbf{u}[k] in discrete time or u(t)\mathbf{u}(t) in continuous time, depends only on the clock, reading off precomputed values from memory or interpolating between them. This approach assumes perfect models and no disturbances. Under these idealized conditions, repeating the same control sequence from the same initial state would always produce identical results.

Real systems face modeling errors, external disturbances, and measurement noise that accumulate over time. A precomputed trajectory becomes increasingly irrelevant as these perturbations push the actual system state away from the predicted path. The solution is to incorporate feedback, making control decisions that respond to the current state rather than blindly following a predetermined schedule. While dynamic programming provides the theoretical framework for deriving feedback policies through value functions and Bellman equations, there exists a more direct approach that leverages the trajectory optimization methods already developed.

Can the finite-horizon planner itself become a feedback controller by solving again whenever a new state is measured?

Closing the Loop by Replanning

Which action from each finite-horizon solution should be applied before the state is measured and the horizon is shifted forward?

Model Predictive Control creates a feedback controller by repeatedly solving trajectory optimization problems. Rather than computing a single trajectory for the entire task duration, MPC solves a finite-horizon problem at each time step, starting from the current measured state. The controller then applies only the first control action from this solution before repeating the entire process. This strategy transforms any trajectory optimization method into a feedback controller.

The battery example in Model Interfaces used a transparent current governor: it tested a local voltage and thermal envelope after updating one resistance parameter. MPC retains that structured model but optimizes an entire future current sequence and repeats the optimization as measurements arrive.

The Receding Horizon Principle

The defining characteristic of MPC is its receding horizon strategy. At each time step, the controller solves an optimization problem looking a fixed duration into the future, but this prediction window constantly moves forward in time. The horizon “recedes” because it always starts from the current time and extends forward by the same amount.

Consider the discrete-time optimal control problem in Bolza form:

minimizecT(xN)+k=0N1c(xk,uk)subject toxk+1=f(xk,uk)g(xk,uk)0uminukumaxgivenx0=xcurrent\begin{aligned} \text{minimize} \quad & c_T(\mathbf{x}_N) + \sum_{k=0}^{N-1} c(\mathbf{x}_k, \mathbf{u}_k) \\ \text{subject to} \quad & \mathbf{x}_{k+1} = \mathbf{f}(\mathbf{x}_k, \mathbf{u}_k) \\ & \mathbf{g}(\mathbf{x}_k, \mathbf{u}_k) \leq \mathbf{0} \\ & \mathbf{u}_{\text{min}} \leq \mathbf{u}_k \leq \mathbf{u}_{\text{max}} \\ \text{given} \quad & \mathbf{x}_0 = \mathbf{x}_{\text{current}} \end{aligned}

At time step tt, this problem optimizes over the interval [t,t+N][t, t+N]. At the next time step t+1t+1, the horizon shifts to [t+1,t+N+1][t+1, t+N+1]. What makes this work is that only the first control u0\mathbf{u}_0^* from each optimization is applied. The remaining controls u1,,uN1\mathbf{u}_1^*, \ldots, \mathbf{u}_{N-1}^* are discarded, though they may initialize the next optimization through warm-starting.

This receding horizon principle enables feedback without computing an explicit policy. By constantly updating predictions based on current measurements, MPC naturally corrects for disturbances and model errors. The apparent waste of computing but not using most of the trajectory is actually the mechanism that provides robustness.

Horizon Selection and Problem Formulation

The choice of prediction horizon depends on the control objective. We distinguish between three cases, each requiring different mathematical formulations.

Infinite-Horizon Regulation

For stabilization problems where the system must operate indefinitely around an equilibrium, the true objective is:

J=k=0c(xk,uk)J_\infty = \sum_{k=0}^{\infty} c(\mathbf{x}_k, \mathbf{u}_k)

Since this cannot be solved directly, MPC approximates it with:

minimizeVf(xN)+k=0N1c(xk,uk)subject toxk+1=f(xk,uk)xNXfother constraints\begin{aligned} \text{minimize} \quad & V_f(\mathbf{x}_N) + \sum_{k=0}^{N-1} c(\mathbf{x}_k, \mathbf{u}_k) \\ \text{subject to} \quad & \mathbf{x}_{k+1} = \mathbf{f}(\mathbf{x}_k, \mathbf{u}_k) \\ & \mathbf{x}_N \in \mathcal{X}_f \\ & \text{other constraints} \end{aligned}

The terminal cost Vf(xN)V_f(\mathbf{x}_N) approximates k=Nc(xk,uk)\sum_{k=N}^{\infty} c(\mathbf{x}_k, \mathbf{u}_k), the cost-to-go beyond the horizon. The terminal constraint xNXf\mathbf{x}_N \in \mathcal{X}_f ensures the state reaches a region where a known stabilizing controller exists. Without these terminal ingredients, the finite-horizon approximation may produce unstable behavior, as the controller ignores consequences beyond the horizon.

Finite-Duration Tasks

For tasks ending at time tft_f, the true objective spans from current time tt to tft_f:

J[t,tf]=cf(x(tf))+k=ttf1c(xk,uk)J_{[t, t_f]} = c_f(\mathbf{x}(t_f)) + \sum_{k=t}^{t_f-1} c(\mathbf{x}_k, \mathbf{u}_k)

The MPC formulation must adapt as time progresses:

minimizecT,k(xNk)+j=0Nk1c(xj,uj)whereNk=min(N,tftk)cT,k={cfif tk+Nk=tfcTotherwise\begin{aligned} \text{minimize} \quad & c_{T,k}(\mathbf{x}_{N_k}) + \sum_{j=0}^{N_k-1} c(\mathbf{x}_j, \mathbf{u}_j) \\ \text{where} \quad & N_k = \min(N, t_f - t_k) \\ & c_{T,k} = \begin{cases} c_f & \text{if } t_k + N_k = t_f \\ c_T & \text{otherwise} \end{cases} \end{aligned}

As the task approaches completion, the horizon shrinks and the terminal cost switches from the approximation cTc_T to the true final cost cfc_f. This prevents the controller from optimizing beyond task completion, which would produce meaningless or aggressive control actions.

Periodic Tasks

Some systems operate on repeating cycles where the optimal behavior depends on the time of day, week, or season. Consider a commercial building where heating costs are higher at night, electricity prices vary hourly, and occupancy patterns repeat daily. The MPC controller must account for these periodic patterns while planning over a finite horizon.

For tasks with period TpT_p, such as daily building operations, the formulation accounts for transitions across period boundaries:

minimizek=0N1ck(xk,uk,ϕk)whereϕk=(t+k)modTpck(,,ϕ)={cday(,)if ϕ[6am,6pm]cnight(,)otherwise\begin{aligned} \text{minimize} \quad & \sum_{k=0}^{N-1} c_k(\mathbf{x}_k, \mathbf{u}_k, \phi_k) \\ \text{where} \quad & \phi_k = (t + k) \mod T_p \\ & c_k(\cdot, \cdot, \phi) = \begin{cases} c_{\text{day}}(\cdot, \cdot) & \text{if } \phi \in [6\text{am}, 6\text{pm}] \\ c_{\text{night}}(\cdot, \cdot) & \text{otherwise} \end{cases} \end{aligned}

The cost function changes based on the phase ϕ\phi within the period. Constraints may similarly depend on the phase, reflecting different operational requirements at different times.

The MPC Algorithm

The complete MPC procedure implements the receding horizon principle through repeated optimization:

Successive Linearization and Quadratic Approximations

For many regulation and tracking problems, the nonlinear dynamics and costs we encounter can be approximated locally by linear and quadratic functions. The basic idea is to linearize the system around the current operating point and approximate the cost with a quadratic form. This reduces each MPC subproblem to a quadratic program (QP), which can be solved reliably and very quickly using standard solvers.

Suppose the true dynamics are nonlinear,

xk+1=f(xk,uk).\mathbf{x}_{k+1} = f(\mathbf{x}_k,\mathbf{u}_k).

Around a nominal trajectory (xˉk,uˉk)(\bar{\mathbf{x}}_k,\bar{\mathbf{u}}_k), we take a first-order expansion:

xk+1f(xˉk,uˉk)+Ak(xkxˉk)+Bk(ukuˉk),\mathbf{x}_{k+1} \approx f(\bar{\mathbf{x}}_k,\bar{\mathbf{u}}_k) + \mathbf{A}_k(\mathbf{x}_k - \bar{\mathbf{x}}_k) + \mathbf{B}_k(\mathbf{u}_k - \bar{\mathbf{u}}_k),

with Jacobians

Ak=fx(xˉk,uˉk),Bk=fu(xˉk,uˉk).\mathbf{A}_k = \frac{\partial f}{\partial \mathbf{x}}(\bar{\mathbf{x}}_k,\bar{\mathbf{u}}_k), \qquad \mathbf{B}_k = \frac{\partial f}{\partial \mathbf{u}}(\bar{\mathbf{x}}_k,\bar{\mathbf{u}}_k).

Similarly, if the stage cost is nonlinear,

c(xk,uk),c(\mathbf{x}_k,\mathbf{u}_k),

we approximate it quadratically near the nominal point:

c(xk,uk)    xkxkrefQk2+ukukrefRk2,c(\mathbf{x}_k,\mathbf{u}_k) \;\approx\; \|\mathbf{x}_k - \mathbf{x}_k^{\text{ref}}\|_{\mathbf{Q}_k}^2 + \|\mathbf{u}_k - \mathbf{u}_k^{\text{ref}}\|_{\mathbf{R}_k}^2,

with positive semidefinite weighting matrices Qk\mathbf{Q}_k and Rk\mathbf{R}_k.

The resulting MPC subproblem has the form

minx0:N,u0:N1xNxNrefP2+k=0N1(xkxkrefQk2+ukukrefRk2)s.t.xk+1=Akxk+Bkuk+dk,uminukumax,xminxkxmax,x0=xcurrent,\begin{aligned} \min_{\mathbf{x}_{0:N},\mathbf{u}_{0:N-1}} \quad & \|\mathbf{x}_N - \mathbf{x}_N^{\text{ref}}\|_{\mathbf{P}}^2 + \sum_{k=0}^{N-1} \left( \|\mathbf{x}_k - \mathbf{x}_k^{\text{ref}}\|_{\mathbf{Q}_k}^2 + \|\mathbf{u}_k - \mathbf{u}_k^{\text{ref}}\|_{\mathbf{R}_k}^2 \right) \\ \text{s.t.} \quad & \mathbf{x}_{k+1} = \mathbf{A}_k \mathbf{x}_k + \mathbf{B}_k \mathbf{u}_k + \mathbf{d}_k, \\ & \mathbf{u}_{\min} \leq \mathbf{u}_k \leq \mathbf{u}_{\max}, \\ & \mathbf{x}_{\min} \leq \mathbf{x}_k \leq \mathbf{x}_{\max}, \\ & \mathbf{x}_0 = \mathbf{x}_{\text{current}} , \end{aligned}

where dk=f(xˉk,uˉk)AkxˉkBkuˉk\mathbf{d}_k = f(\bar{\mathbf{x}}_k,\bar{\mathbf{u}}_k) - \mathbf{A}_k \bar{\mathbf{x}}_k - \mathbf{B}_k \bar{\mathbf{u}}_k captures the local affine offset.

Because the dynamics are now linear and the cost quadratic, this optimization problem is a convex quadratic program. Quadratic programs are attractive in practice: they can be solved at kilohertz rates with mature numerical methods, making them the backbone of many real-time MPC implementations.

At each MPC step, the controller updates its linearization around the new operating point, constructs the local QP, and solves it. The process repeats, with the linear model and quadratic cost refreshed at every reoptimization. Despite the approximation, this yields a closed-loop controller that inherits the fast computation of QPs while retaining the ability to track trajectories of the underlying nonlinear system.

Theoretical Guarantees

Repeated optimization creates feedback, but which terminal ingredients make feasibility persist and the closed-loop state converge?

The finite-horizon approximation in MPC brings a new challenge: the controller cannot see consequences beyond the horizon. Without proper design, this myopia can destabilize even simple systems. The solution is to carefully encode information about the infinite-horizon problem into the finite-horizon optimization through its terminal conditions.

Before diving into the mathematics, we should first establish what “stability” means and which tasks these theoretical guarantees address, as the notion of stability varies significantly across different control objectives.

Stability Notions Across Control Tasks

The terminal conditions provide different types of guarantees depending on the control objective. For regulation problems, where the task is to drive the state to a fixed equilibrium (xeq,ueq)(\mathbf{x}_\mathrm{eq}, \mathbf{u}_\mathrm{eq}) (often shifted to the origin), the stability guarantee is asymptotic stability: starting sufficiently close to the equilibrium, we have xkxeq\mathbf{x}_k \to \mathbf{x}_\mathrm{eq} while constraints remain satisfied throughout the trajectory (recursive feasibility). This requires the stage cost (x,u)\ell(\mathbf{x},\mathbf{u}) to be positive definite in the deviation from equilibrium.

When tracking a constant setpoint, the task becomes following a constant reference (xref,uref)(\mathbf{x}_\mathrm{ref},\mathbf{u}_\mathrm{ref}) that solves the steady-state equations. This problem is handled by working in error coordinates x~=xxref\tilde{\mathbf{x}}=\mathbf{x}-\mathbf{x}_\mathrm{ref} and u~=uuref\tilde{\mathbf{u}}=\mathbf{u}-\mathbf{u}_\mathrm{ref}, transforming the tracking problem into a regulation problem for the error system. The stability guarantee becomes asymptotic tracking, meaning x~k0\tilde{\mathbf{x}}_k \to 0, again with recursive feasibility.

The terminal conditions we discuss below primarily address regulation and constant reference tracking. Time-varying tracking and economic MPC require additional techniques such as tube MPC and dissipativity theory.

MPC with Stability Guarantees

To provide theoretical guarantees, the finite-horizon MPC problem is augmented with three interconnected components. The terminal cost Vf(x)V_f(\mathbf{x}) approximates the cost-to-go beyond the horizon, providing a surrogate for the infinite-horizon tail that cannot be explicitly optimized. The terminal constraint set Xf\mathcal{X}_f defines a region where we have local knowledge of how to stabilize the system. Finally, the terminal controller κf(x)\kappa_f(\mathbf{x}) provides a local stabilizing control law that remains valid within Xf\mathcal{X}_f.

These components must satisfy specific compatibility conditions to provide theoretical guarantees:

Suboptimality Bounds

The finite-horizon MPC value VN(x)V_N(\mathbf{x}) provides an upper bound approximation of the true infinite-horizon value V(x)V_\infty(\mathbf{x}). Understanding how close this approximation can be tells us about the effectiveness of short-horizon MPC.

The upper bound VN(x)V(x)V_N(\mathbf{x}) \geq V_\infty(\mathbf{x}) follows immediately from the fact that MPC considers fewer control choices. The infinite-horizon controller can choose any sequence (u0,u1,u2,)(\mathbf{u}_0, \mathbf{u}_1, \mathbf{u}_2, \ldots), while the NN-horizon controller is restricted to sequences of the form (u0,,uN1,κf(xN),κf(xN+1),)(\mathbf{u}_0, \ldots, \mathbf{u}_{N-1}, \kappa_f(\mathbf{x}_N), \kappa_f(\mathbf{x}_{N+1}), \ldots) where the tail follows the fixed terminal controller. Since the infinite-horizon problem optimizes over a larger feasible set, its optimal value cannot exceed that of the finite-horizon problem.

Deriving the Approximation Error

The interesting question is bounding the approximation error εN=VN(x)V(x)\varepsilon_N = V_N(\mathbf{x}) - V_\infty(\mathbf{x}). This error represents the cost of being forced to use κf\kappa_f beyond the horizon rather than continuing to optimize.

Let (u0,u1,)(\mathbf{u}_0^*, \mathbf{u}_1^*, \ldots) denote the infinite-horizon optimal control sequence with corresponding state trajectory (x0,x1,)(\mathbf{x}_0^*, \mathbf{x}_1^*, \ldots) where x0=x\mathbf{x}_0^* = \mathbf{x}. The infinite-horizon cost is:

V(x)=k=0(xk,uk)V_\infty(\mathbf{x}) = \sum_{k=0}^{\infty} \ell(\mathbf{x}_k^*, \mathbf{u}_k^*)

Now consider what happens when we truncate this optimal sequence at horizon NN and continue with the terminal controller. The cost becomes:

V~N(x)=k=0N1(xk,uk)+Vf(xN)\tilde{V}_N(\mathbf{x}) = \sum_{k=0}^{N-1} \ell(\mathbf{x}_k^*, \mathbf{u}_k^*) + V_f(\mathbf{x}_N^*)

where Vf(xN)V_f(\mathbf{x}_N^*) approximates the tail cost k=N(xk,uk)\sum_{k=N}^{\infty} \ell(\mathbf{x}_k^*, \mathbf{u}_k^*).

Since VN(x)V_N(\mathbf{x}) is the optimal NN-horizon cost (which may do better than this particular truncated sequence), we have VN(x)V~N(x)V_N(\mathbf{x}) \leq \tilde{V}_N(\mathbf{x}). The approximation error therefore satisfies:

εNV~N(x)V(x)=Vf(xN)k=N(xk,uk)\varepsilon_N \leq \tilde{V}_N(\mathbf{x}) - V_\infty(\mathbf{x}) = V_f(\mathbf{x}_N^*) - \sum_{k=N}^{\infty} \ell(\mathbf{x}_k^*, \mathbf{u}_k^*)

This bound shows that the approximation error depends on how well the terminal cost VfV_f approximates the true tail cost along the infinite-horizon optimal trajectory.

Summary and Outlook

Receding-horizon control turns a finite-horizon optimizer into feedback by reinitializing it from each measured state and applying only the first planned action. Terminal costs, terminal sets, and invariant local controllers connect the truncated problem to recursive feasibility and stability.

The basic loop leaves several design choices unresolved. How should the same replanning mechanism represent tracking, economic objectives, uncertainty, hybrid decisions, solver failures, and hard real-time deadlines? MPC variants and reliable operation organize those choices.

Self-checks

Solution to Exercise 1

Only the first control (or first short control block) is applied. The state is measured again and the horizon is shifted before re-optimizing.

Solution to Exercise 2

The terminal cost approximates value beyond the horizon; the terminal constraint can keep the endpoint in a region from which a known controller remains feasible and stable.

Solution to Exercise 3

The newly measured state contains the accumulated effect of disturbances and model error. Reinitializing the optimization from that state changes the planned controls accordingly.