# Model predictive control
## Microsim (three.js)
<div class="microsim-player">
<!-- MICROSIM:PENDING_DEPLOY:BEGIN v1.7 g08 — embed target is not on the CDN; restore with g08 --undeploy-clear -->
<p class="wt-pending"><strong>Microsim staged, not yet on the CDN.</strong> <code>Model_predictive_control.html</code> is built and deploy-ready in <code>Microsims for Dissemination/</code>, but the Netlify project still serves the geometry+spintronics set only. The player is disabled until the deploy lands; the explanatory text below is unchanged.</p>
<!--
<iframe src="https://wikitube-3d-microsims.netlify.app/Model_predictive_control.html" width="100%" height="620" frameborder="0" loading="lazy" sandbox="allow-scripts allow-same-origin"></iframe>
-->
<!-- MICROSIM:PENDING_DEPLOY:END -->
</div>
*A receding-horizon planner that turns [[Optimal_control]] into a real-time loop: each tick it sketches many possible futures — much like a [[Monte_Carlo_method]] — scores them against a goal, and commits to a single move, echoing the look-ahead of [[Dynamic_programming]] and the model-based planning behind [[Reinforcement_learning]].*
> Model predictive control (MPC) is a feedback strategy that, at every step, uses a model of the system to predict how it will behave over a short horizon, picks the input sequence that best drives the prediction toward a target, applies only the first input, and then repeats with fresh measurements. This microsim lets you set the prediction **Horizon**, move the **Target position**, and choose how many candidate plans are sampled, then **Step** or **Play** to watch the controller replan and steer each cycle. The idea it makes visible is the *receding horizon*: always plan several moves ahead, but commit to only the first.
## About this microsim
The sim shows a one-dimensional system — a point that must reach a marker — steered by a predictive controller. Before any theory, drag **Target position** (−9 to 9) and press **Step ►**: the sim samples a batch of candidate action sequences, draws each predicted trajectory across the horizon, highlights the lowest-cost plan, and applies only its first move. Raise **Horizon (steps)** toward 9 and the controller looks farther ahead and anticipates the goal; drop **Candidates sampled** toward 15 and the plans get jerkier and less optimal, while pushing it to 80 yields smoother, more confident moves. Press **Play ►►** to run the loop continuously and **Reset ↺** to start over. The controls let you feel MPC's two core levers — how far ahead to predict, and how hard to search — before reading an equation.
## Related microsims
- [[Optimal_control]] — MPC is receding-horizon optimal control; the parent formulation.
- [[Dynamic_programming]] — the Bellman principle behind optimal sequential decisions and the value function MPC approximates.
- [[Monte_Carlo_method]] — the random sampling the sim uses to evaluate candidate plans.
- [[Reinforcement_learning]] — model-based planning as an alternative to learned control policies.
- [[Calculus_of_variations]] — the continuous-time roots of optimal control that MPC discretizes.
- Process optimization — the industrial setting where MPC first became the standard.
- [[Fuzzy_control_system]] — related ALGORITHM microsim
## Links (Wikipedia order)
<!-- injected from _registry/childlinks/Model_predictive_control.json (2026-07-30T02:09:12Z) -->
`Adaptive_control` · `Alfred_Marcel_Bruckstein` · `Automation_and_Remote_Control` · [[Block_diagram]] · `Bode_plot` · `Chemical_plant` · `Closed-loop_controller` · `Closed-loop_transfer_function` · `Coefficient_diagram_method` · `Collocation_method` · [[Control_engineering]] · `Control_reconfiguration` · [[Control_theory]] · `Control_valve` · `Controllability` · `Convex_polytope` · `Digital_control` · [[Digital_signal_processing]] · `Direct_multiple_shooting_method` · `Distributed_control_system` · `Distributed_parameter_system` · [[Dynamical_system]] · [[Electric_motor]] · `Embedded_system` · `Energy-shaping_control` · `Euler–Lagrange_equation` · `Exponential_growth` · `Feed_forward_(control)` · `Fourier_transform` · `Fractional-order_control` · [[Frequency_response]] · [[Fuzzy_control_system]] · `Fuzzy_logic` · `H-infinity_loop-shaping` · `Hankel_singular_value` · `Hybrid_computer` · `Industrial_control_system` · `Intelligent_control` · [[Kalman_filter]] · `Krener's_theorem` · [[Laplace_transform]] · `Lead–lag_compensator` · `Least_squares` · [[Linear_algebra]] · `Linear–quadratic_regulator` · [[Lyapunov_stability]] · `MATLAB` · `MathWorks` · [[Mechatronics]] · `Minor_loop_feedback` · `Motion_control` · [[Negative_feedback]] · `Nonlinear_control` · [[Nonlinear_system]] · [[Observability]] · [[Optimal_control]] · `Optimization_problem` · [[PID_controller]] · [[Perceptual_control_theory]] · `Performance` · `Piecewise_linear_function` · [[Positive_feedback]] · `Power_electronics` · `Process_variable` · `Programmable_logic_controller` · [[Quantization_(signal_processing)]] · [[Real-time_computing]] · [[Robotics]] · `Robust_control` · `Root_locus_analysis` · `SCADA` · `Servomechanism` · `Shooting_method` · [[Signal-flow_graph]] · `Simulink` · `Software_framework` · `Stability_theory` · `State-space_representation` · `State_observer` · `Steady_state` · `Stochastic_control` · `Superposition_principle` · [[System_dynamics]] · [[System_identification]] · [[Transfer_function]] · [[Z-transform]]
## Overview
Model predictive control, also called *receding-horizon control*, repeatedly solves an online optimization to choose control actions while respecting constraints on inputs and states. Unlike a fixed law such as PID, it uses a dynamic model to predict future behavior over a finite horizon and optimizes a cost encoding the objective. MPC emerged in the process industries in the late 1970s–1980s — Richalet's IDCOM and Cutler and Ramaker's Dynamic Matrix Control (DMC) at Shell — where handling multivariable systems and hard constraints made it standard for refineries and chemical plants. Later theory secured closed-loop stability via terminal costs and constraint sets. Today MPC controls reactors, power converters, autonomous vehicles, robots, and buildings, aided by fast processors and convex solvers.
## How it works — the receding-horizon algorithm
Model the plant in discrete time as $x_{k+1} = f(x_k, u_k)$, with state $x_k$ and input $u_k$; for linear MPC this is $x_{k+1} = A x_k + B u_k$. Given the measured state $x(t)$, MPC chooses a sequence $\mathbf{u} = (u_0,\dots,u_{N-1})$ over $N$ steps to minimize deviation from a reference $r$ plus control effort:
$\min_{\mathbf{u}} \; \sum_{k=0}^{N-1}\Big( \|x_k - r\|_Q^2 + \|u_k\|_R^2 \Big) + \|x_N - r\|_P^2$
subject to the dynamics and to constraints $u_k \in \mathcal{U}$, $x_k \in \mathcal{X}$, where $\|v\|_Q^2 = v^\top Q v$. Three ideas drive it: **prediction** rolls the model forward for any candidate sequence; **optimization** finds the cheapest sequence — with a linear model, quadratic cost, and linear constraints this is a convex quadratic program (QP), solvable in polynomial time; and the **receding horizon** applies only $u_0^\star$, then re-solves next step with new data, closing the feedback loop. The microsim swaps the exact solver for sampling: it draws $M$ random candidates (**Candidates sampled**), simulates each, and keeps the cheapest — a *random-shooting* approximation whose accuracy improves as $M$ grows. Scoring three sampled plans against $r = 5$ illustrates the selection:
| Sampled plan | Predicted end $x_N$ | Cost $\|x_N - r\|^2$ |
|---|---|---|
| A | 4.2 | 0.64 |
| **B** | **5.1** | **0.01 ← chosen** |
| C | 3.3 | 2.89 |
## Controls -> what each maps to
| Control | Maps to | Range / values | Meaning |
|---|---|---|---|
| Horizon (steps) | Prediction horizon $N$ | 2–9 | How many steps ahead each candidate plan is simulated and scored |
| Target position | Reference / setpoint $r$ | −9 to 9 | The state value the controller tries to reach |
| Candidates sampled | Number of candidate sequences $M$ | 15–80 | How many random plans are evaluated before the best is chosen |
| Step ► | One MPC iteration | button | Runs a single plan–select–apply cycle |
| Play ►► | Continuous run | button | Repeats the receding-horizon loop automatically |
| Reset ↺ | Reset state | button | Returns the system to its initial condition |
## Learning objective
After playing, you can predict how horizon length and sample count trade planning quality against computation, and explain why applying only the first move of each plan produces closed-loop feedback.
## Limits and connections
MPC's power has a price: it must solve an optimization inside every sampling interval, so real-time use depends on fast hardware and efficient solvers, and it is only as good as its model. Stability and constraint satisfaction are not automatic — they need careful terminal costs, terminal sets, and horizon choices. The sim's random search is deliberately simple; industrial MPC uses exact QP solvers, and *explicit MPC* precomputes the whole control law offline as a piecewise-affine function of the state. MPC sits between classical [[Optimal_control]], which optimizes over a fixed or infinite horizon offline, and [[Reinforcement_learning]], which learns a policy from data instead of optimizing against a known model each step.
## Poster & source
<div class="microsim-fallback">
<!-- poster image pending backfill -->
<p><em>Live microsim · <a href="https://wikitube-3d-microsims.netlify.app/Model_predictive_control.html">open full</a> · source: Microsims for Dissemination/ALGORITHM_microsims/Model_predictive_control.html</em></p>
</div>
<!-- CRAFT-LINK:START g12 -->
*Built to the [[WT!Three_js_Microsim_Master_Class|three.js Master Class]].*
<!-- CRAFT-LINK:END -->
## Wikipedia : Wikitube
**Strict pair:** [Wikipedia](https://en.wikipedia.org/wiki/Model_predictive_control) : [Wikitube](https://en.wikitube.io/wiki/Model_predictive_control)
## Previous hub tags
Tree parent: [[Control_theory]].
Legacy hubs: `ALGORITHM`.
---
*Sources: 1 legacy note. Minted wave 1, 2026-07-30 (v1.6 order).*