TL;DR
Model predictive path integral (MPPI) control runs model predictive control without solving a gradient-based optimisation. At each step it samples many random perturbations of the current action plan, rolls each one out through a model, and scores each rollout by its total cost. The plan is then moved toward the perturbations that scored well, with each one weighted by an exponential of its cost. As in MPC, only the first action is applied, and the planner runs again at the next step.
Where you'll see it: real-time control of legged robots, drones and off-road vehicles, where the cost has jumps such as collisions and a GPU can roll out thousands of samples in parallel.
Intuition
A crowd of scouts in fog
Imagine a group of hikers lost in fog, trying to reach the lowest point of a valley. Nobody can see the slope, but each hiker can take a step and feel the ground there. The group sends many scouts off in slightly different random directions. Each scout reports the height it reached. The group then moves its centre toward the scouts who went lowest, and it gives the lowest scouts the most say. Repeat, and the group drifts downhill without ever computing a slope.
MPPI works the same way. The "scouts" are sampled action sequences, the "height" is the cost of the rollout, and the "centre" is the current plan. The "model" predicts where each sequence leads, so the scouts can be simulated rather than walked.
Why not just use gradients?
Ordinary MPC, covered in Model Predictive Control, needs the cost and the dynamics to be smooth enough to differentiate. Real robots break this. A contact changes the dynamics abruptly, a collision adds a cost that jumps from zero to a large value, and a black-box simulator may give no derivatives at all. Sampling needs only one thing: the ability to roll out a candidate plan and score it. The cost of that freedom is that the planner must draw many samples, and it has to average them sensibly.
The loop
flowchart LR A[Shift last plan forward] --> B[Sample K noisy action sequences] B --> C[Roll each one out through the model] C --> D[Score each rollout with its cost] D --> E[Weight by exp of minus cost over lambda] E --> F[Move the plan by the weighted average of the noise] F --> G[Apply the first action and wait for the next state] G --> A
The math
Use a discrete-time model , where is the state at step and is the action. The planner keeps a nominal action sequence over a horizon of steps. Let be a running cost, a terminal cost, a noise covariance, and a temperature that sets how sharply the planner prefers low-cost samples.
Draw perturbation sequences with each independent. Roll out from the measured state using , then score the rollout
Here is the total cost of sample . The last term in the sum is the control cost implied by the Gaussian noise model. It is what makes the weighting below match a KL penalty with the same .
Where the weighting comes from
The update rule looks like a heuristic, but it has a precise origin. Let be the distribution over perturbation sequences, which is the Gaussian noise the sampler draws from. Let be any other distribution over perturbations. Consider the objective
It trades off a low expected cost against staying close to the noise model, where is the KL divergence. The Gibbs Variational Principle says the minimiser is the exponentially tilted distribution
The planner wants the mean of , because adding that mean to the nominal plan moves the plan to where low-cost perturbations live. The mean is . This is an expectation under of the perturbation weighted by , so it can be estimated from the samples. That is exactly Importance Sampling: draw from , reweight by the density ratio, which here is proportional to .
The update
With subtracted for numerical stability, the normalised weights are
Subtracting does not change the weights, because it cancels in the normalisation. It only keeps the exponentials from underflowing when costs are large.
- Shift the previous nominal sequence one step forward, and fill the last slot with a copy of its final action.
- Draw noise sequences from .
- From the measured state, roll out each through the model and compute .
- Compute the weights from and .
- Update for every .
- Apply the first action to the real system. Repeat at the next measurement.
Worked examples
Take a one-dimensional system , with , horizon , , , and nominal . The rollout cost is , so the best action is , which reaches zero. Because the nominal is zero, the control term in vanishes.
- Draw three perturbations: , , .
- Roll out and score. , , .
- Subtract and exponentiate. The raw weights are , , , with sum .
- Normalise. The weights are , and .
- Update the nominal action. .
- Apply . The state becomes .
Interpretation: with three samples the plan moved about 64 percent of the way to the optimum in one step. The best sample carried most of the weight, but the other two still contributed. The effective sample size, one divided by the sum of squared normalised weights, is about here, which is the number of samples that effectively count.
Use the same three samples and costs as above, and change only .
- At , the raw weights are , and . The sum is .
- The normalised weights are , and .
- The update is .
- At , the raw weights are , and . The normalised weights are , about and .
- The update is .
Interpretation: a large averages the samples almost evenly, so the plan moves only a little toward the best one. A small makes the planner behave like a greedy pick of the single best sample. Tuning is the main decision in MPPI, and the plot shows why.
- lambda = 0.5
- lambda = 1
- lambda = 4
Tradeoffs and failure modes
MPPI is flexible because it needs only forward simulation and a cost. It is costly because its estimate of the best action is only as good as the samples behind it.
| Situation | What goes wrong | Better choice |
|---|---|---|
| too small | One sample takes almost all the weight, so the plan jumps between samples and the effective sample size collapses | Raise , or draw more samples |
| too large | The weights are nearly equal and the plan barely moves toward low cost | Lower |
| Too few samples for times the action dimension | The estimate has high variance and the controller is erratic | More samples per step, a shorter horizon, or smoother noise |
| Noise too large | Applied actions are jerky and the plan wanders | Reduce , or correlate the noise across time |
| Smooth, differentiable dynamics and cost | Sampling wastes compute on an estimate that gradients would give exactly | Gradient-based Model Predictive Control |
| Collision or contact costs with jumps | Gradients are undefined or misleading | MPPI, which only needs rollouts and scores |
Sampling gives no finite-sample guarantee that the plan is optimal. Its quality depends on the samples and on the model. A learned model can be wrong far from its training data, and the planner will happily exploit that error if the sampled rollouts go there. This is the same failure mode as in Model-Based Reinforcement Learning, and it is handled the same way: check the effective sample size, keep the horizon no longer than the model is accurate, and penalise states the model has not seen.
History
The idea comes from a line of work connecting optimal control to probability. In the mid-2000s, Bert Kappen showed that for a restricted class of stochastic optimal control problems, the nonlinear Hamilton–Jacobi–Bellman equation (the continuous-time form of the Bellman Equation) becomes linear after a logarithmic change of variables. Its solution is then an exponential average over sampled trajectories, which he called path integral control. The name refers to the path integrals of physics, in which a quantity is an average over all paths weighted by an exponential of an action.
Around 2010, Evangelos Theodorou, Jonas Buchli and Stefan Schaal turned this into a practical sampling method for reinforcement learning and robot control. Their sampled trajectories were weighted by an exponential of their cost, and the controller was updated with the weighted average of the sampled noise.
Grady Williams, Andrew Aldrich and Evangelos Theodorou then made the method a receding-horizon controller. Their 2015 work used covariance-based variable importance sampling for model predictive control. In 2017, Williams and colleagues, including Paul Drews, Brian Goldfain, James Rehg and Theodorou, published the information-theoretic version used in this lesson, with a parallel implementation that ran many rollouts at once on a GPU. That made real-time sampling feasible for autonomous driving, and the method spread to other robots from there.
Check yourself
QuestionIn one sentence, what does the temperature lambda control in MPPI?Show answer
It controls how sharply the rollout weights favour low-cost samples. Weights are proportional to exp(-S/lambda), so a small lambda concentrates weight on the best sample and a large lambda spreads it almost evenly across the samples.
QuestionTwo rollouts have costs 1 and 3, and lambda = 2. Subtract the best cost first, then find the normalised weight of the cost-3 rollout.Show answer
Subtract beta = 1, which gives 0 and 2. The raw weights are exp(0) = 1 and exp(-2/2) = exp(-1) = 0.3679. The sum is 1.3679, so the cost-3 rollout has weight 0.3679 / 1.3679 = 0.2689.
QuestionWhy is the minimum cost subtracted before the exponentials are computed, if it does not change the weights?Show answer
The subtraction cancels in the normalisation, so the weights are unchanged. It keeps the exponentials from underflowing to zero when costs are large, so the weights stay numerically meaningful.
QuestionA robot's cost includes a large penalty whenever it touches an obstacle, which is a jump in the cost. Why might gradient-based MPC struggle here, and why can MPPI handle it?Show answer
The penalty has no useful gradient at the jump, so a gradient solver can stall or be misled near the obstacle. MPPI only needs to roll out each candidate and read its total cost, so the jump simply makes some samples score badly and gets them down-weighted.
QuestionAn MPPI controller has very jerky motion, and its effective sample size is near 1 at every step. What is the most likely cause, and what would you change first?Show answer
The weights have collapsed onto one sample, which usually means lambda is too small for the spread of the costs. Raise lambda first, then check whether more samples or a smaller noise covariance is needed. Adjusting lambda is the cheapest fix and usually addresses the jerkiness directly.
Sources
- Williams, Drews, Goldfain, Rehg, Theodorou (2017), Information-Theoretic Model Predictive Control: Theory and Applications to Autonomous Driving: https://arxiv.org/abs/1707.02342
- Williams, Aldrich, Theodorou (2015), Model Predictive Path Integral Control using Covariance Variable Importance Sampling: https://arxiv.org/abs/1509.01149
- Wikipedia: Model predictive control