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, in discrete time or 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:
At time step , this problem optimizes over the interval . At the next time step , the horizon shifts to . What makes this work is that only the first control from each optimization is applied. The remaining controls 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:
Since this cannot be solved directly, MPC approximates it with:
The terminal cost approximates , the cost-to-go beyond the horizon. The terminal constraint 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 , the true objective spans from current time to :
The MPC formulation must adapt as time progresses:
As the task approaches completion, the horizon shrinks and the terminal cost switches from the approximation to the true final cost . 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 , such as daily building operations, the formulation accounts for transitions across period boundaries:
The cost function changes based on the phase 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,
Around a nominal trajectory , we take a first-order expansion:
with Jacobians
Similarly, if the stage cost is nonlinear,
we approximate it quadratically near the nominal point:
with positive semidefinite weighting matrices and .
The resulting MPC subproblem has the form
where 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 (often shifted to the origin), the stability guarantee is asymptotic stability: starting sufficiently close to the equilibrium, we have while constraints remain satisfied throughout the trajectory (recursive feasibility). This requires the stage cost to be positive definite in the deviation from equilibrium.
When tracking a constant setpoint, the task becomes following a constant reference that solves the steady-state equations. This problem is handled by working in error coordinates and , transforming the tracking problem into a regulation problem for the error system. The stability guarantee becomes asymptotic tracking, meaning , 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 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 defines a region where we have local knowledge of how to stabilize the system. Finally, the terminal controller provides a local stabilizing control law that remains valid within .
These components must satisfy specific compatibility conditions to provide theoretical guarantees:
Suboptimality Bounds¶
The finite-horizon MPC value provides an upper bound approximation of the true infinite-horizon value . Understanding how close this approximation can be tells us about the effectiveness of short-horizon MPC.
The upper bound follows immediately from the fact that MPC considers fewer control choices. The infinite-horizon controller can choose any sequence , while the -horizon controller is restricted to sequences of the form 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 . This error represents the cost of being forced to use beyond the horizon rather than continuing to optimize.
Let denote the infinite-horizon optimal control sequence with corresponding state trajectory where . The infinite-horizon cost is:
Now consider what happens when we truncate this optimal sequence at horizon and continue with the terminal controller. The cost becomes:
where approximates the tail cost .
Since is the optimal -horizon cost (which may do better than this particular truncated sequence), we have . The approximation error therefore satisfies:
This bound shows that the approximation error depends on how well the terminal cost 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.