Introduction to Robot Learning · Lecture 14 of 25 · CMU 16-831

Optimal Control & Planning, Part 2

What if you don't have clean equations — only a learned, black-box model you can poke and sample? You plan by trying many action plans, scoring each, and steering your sampling toward the good ones. From sampling-based MPC to learned-model RL, and the one idea that keeps the planner honest: uncertainty.

Prerequisites: the MPC / trajectory-optimization picture from Part 1 + basic probability (mean, variance, a Gaussian) + a little Python. No knowledge of LQR internals needed.
11
Chapters
5
Simulations
3
Code Labs

Chapter 0: When You Can't Write Down the Equations

In Part 1 we lived in a world of clean equations. The dynamics were given to us — a tidy formula for where the robot lands next — and we solved for the optimal action sequence with calculus: LQR, iLQR, sequential convex programming. Take the gradient, set up the Riccati recursion, get a controller. Beautiful, exact, and fast.

Now strip that luxury away. Suppose your "model" of the world is one of these:

In every one of these, you can do exactly one thing cheaply: ask "what happens if I do this?" You feed in a candidate action sequence, roll it forward through the model, and read off the total cost. You cannot easily differentiate it. You can only sample it.

The one idea of this lecture. When you can only evaluate a model, not differentiate it, you plan by trial: sample many action sequences, roll each one out through the model to score it, and then shift your sampling toward the cheap ones. Repeat. The distribution of plans tightens around the good region until it collapses onto a near-optimal plan. No gradients required — just the ability to ask the model a lot of questions.

That single recipe — sample, roll out, score, refit, repeat — is the spine of everything here. The Cross-Entropy Method (CEM) and MPPI are two ways to do the "refit" step. And once we can plan against any model we can sample, the obvious next move is to learn the model from data — which opens model-based RL: PILCO, PETS, MBPO. The whole second half is about one danger that lurks the moment the model is learned rather than given: the planner will happily exploit the model's mistakes, and uncertainty is how we stop it.

Let's watch the core loop before we name a single algorithm. The widget below is a planner trying to reach a goal past an obstacle. It samples a cloud of candidate trajectories (faint), keeps the cheapest few (bright), and refits its sampling distribution to them. Press Refit and watch the cloud tighten around a path that curves around the wall.

Sample → score → refit — watch the plan cloud tighten

The planner samples candidate trajectories from a distribution, scores each by how close it gets to the goal without hitting the obstacle, keeps the cheapest "elite" few (warm), and refits. Press Refit one round a few times, or Run to convergence.

Round 0 — wide cloud, knows nothing yet.

Notice two things. The cloud started fat and dumb — trajectories everywhere, most of them slamming into the wall. After a few refits it is a tight ribbon hugging a path around the obstacle. No equation for "curve around the wall" was ever written. The planner discovered it by trying, scoring, and concentrating. That is the power and the price of sampling: it asks nothing of the model except many evaluations.

Why would an engineer reach for a sampling-based planner instead of a gradient-based one like iLQR?

Chapter 1: Model Predictive Control — Plan, Act, Forget, Replan

Before we sample anything, we need the loop that all of this lives inside. It is the single most important control idea of the lecture: Model Predictive Control (MPC), also called receding-horizon control.

The full problem is daunting. The robot must act for a long time — a horizon T of maybe thousands of steps — minimizing the total cost over the whole episode. Solving for all T actions at once is expensive and brittle: the moment reality deviates from your plan (and it will), the tail of the plan is worthless. MPC's answer is a piece of genuine engineering wisdom: don't.

The MPC trick, in one sentence. At every time step, look only a short distance ahead — a planning horizon H that is much smaller than the full T — solve that little optimization, then execute only the very first action and throw the rest away. Next step, you re-measure where you actually are and solve a fresh little problem. Plan far, commit to one step, replan.

Concretely, at time t, with the robot truly at state xt, MPC solves an H-step trajectory optimization: choose actions ut, ut+1, …, ut+H−1 that minimize the sum of step costs over the next H steps, subject to the dynamics. It gets back a whole optimal sequence. Then it does something that feels wasteful but is exactly right:

Sense xt
Re-measure the true current state. This is where feedback enters.
↓ solve an H-step plan from xt
Plan ut…ut+H−1
Optimize the short look-ahead window (sampling or gradients).
↓ keep only the first action
Execute ut
Apply just one action to the real robot. Discard the rest of the plan.
↻ t ← t+1, re-sense, replan from scratch

Two consequences make MPC the workhorse of modern robotics.

It is implicitly closed-loop. Because the first action depends on the freshly-measured state xt, MPC is feedback control even though each inner solve is "open-loop planning." A gust of wind shoves the robot; next step it re-measures, sees the new state, and the fresh plan pushes back. We solve open-loop look-aheads, but the replanning loop makes the overall behavior react. That is the whole reason we throw the plan away — the rest of it was computed from a state we are no longer in.

The terminal cost matters enormously. A short horizon H is cheap, but it is short-sighted — it can't see past the window's edge. So MPC tacks a terminal cost V(xt+H) onto the end of the window: an estimate of "how much more it'll cost from wherever you end up." That terminal cost is a value function (Lecture 7's V), and it can come from heuristics, from offline data, or from a learned value network. A good terminal cost lets you shrink H dramatically — you don't need to plan far if you have a decent estimate of the future at the horizon's edge.

MPC under disturbance — why throwing the plan away wins

A cart must reach the target. The open-loop controller plans once at t=0 and executes the whole plan blindly. The MPC controller replans every step from where it actually is. Crank the disturbance and watch open-loop drift while MPC re-aims.

Disturbance 0.40
Ready.
Take-away. MPC = solve a short-horizon plan, execute one action, re-sense, repeat. The inner solve can be anything that optimizes the look-ahead — gradients (Part 1) or sampling (the rest of this lecture). The replanning loop turns those open-loop solves into robust closed-loop control.

MPC computes a full H-step action sequence but executes only the first action, then replans. Why discard the rest?

Chapter 2: Random Shooting — The Dumbest Thing That Works

Inside the MPC window we need to solve a planning problem we cannot differentiate. The simplest possible idea is almost embarrassing, and yet it is the foundation everything else refines.

Random shooting: draw N action sequences completely at random, roll each one through the model, total up its cost, and keep the single cheapest one. That's it. Execute the first action of the winner, then (in MPC) throw it away and redraw next step.

Let's make the data flow concrete, because this is the template for CEM and MPPI too.

Sample
Draw N candidate action sequences u(1), …, u(N), each of length H, from a distribution (random shooting: uniform or a fixed Gaussian).
↓ roll each one through the model
Roll out & score
For each sequence, simulate xt+1 = f(xt, ut) forward H steps and sum the step costs → total costs C(1), …, C(N).
↓ pick the cheapest
Select
Random shooting: take argmin C. (CEM and MPPI differ only in how they use the scores — that's the whole story.)
↻ execute first action, replan next step

The appeal is total generality. The model f can be a neural network, a contact-rich simulator, a piecewise-defined mess — the planner never looks inside it. It only calls "roll out and tell me the cost." Non-differentiable cost? Fine. Discrete actions? Fine. And every one of those N rollouts is independent, so you can run them in parallel on a GPU, evaluating thousands of plans at once.

The weakness is just as plain. Random shooting throws darts blindly. If the good region of action-space is a thin sliver — a narrow gap between two obstacles, say — you'll almost never hit it by chance, and pumping up N pays off slowly. You're wasting the vast majority of rollouts on hopeless plans, and you learn nothing from one round to the next: every redraw starts from the same blind distribution.

The fix that defines the field. Don't keep redrawing blindly. After scoring, move your sampling distribution toward the good samples and draw the next batch from there. Concentrate your darts where they've been landing well. That single change — iteratively refit the sampling distribution — turns random shooting into the Cross-Entropy Method, the subject of the next chapter.

Below, the lab pits random shooting against pure random guessing on a 1-D control problem: pick an action that drives a noisy system to a target. Your job is the one line that makes "shooting" smarter than "guess once" — selecting the best of many rollouts.

Random shooting samples N action sequences and keeps the best. What is its core weakness compared to CEM?

Chapter 3: The Cross-Entropy Method — Refit to the Elites

The Cross-Entropy Method (CEM) is random shooting with a memory. Instead of sampling from a fixed blind distribution forever, CEM keeps a Gaussian sampling distribution over action sequences — a mean μ (the current best guess for the plan) and a covariance Σ (how much it's still exploring) — and tightens it round after round.

Here is the whole algorithm. It fits in one breath:

1. Sample
Draw N action sequences from the Gaussian N(μ, Σ).
↓ roll out through the model
2. Score
Get each sequence's total cost C(1), …, C(N).
↓ sort by cost, take the top performers
3. Select elites
Keep the K cheapest sequences (K « N), the "elite set."
↓ refit the Gaussian to ONLY the elites
4. Refit
New μ = mean of the elites. New Σ = (co)variance of the elites. Loop to step 1.
↻ repeat until Σ collapses; output μ

Read step 4 slowly, because it is the heart of CEM. We do not move μ toward all the samples — only toward the elites, the cheapest K. We literally throw away everything but the top performers and pretend they are our new training data for the distribution. The mean slides toward where the good plans clustered; the variance shrinks because the elites are, by construction, close to each other.

μ ← (1/K) ∑k∈elite u(k)     Σ ← (1/K) ∑k∈elite (u(k) − μ)(u(k) − μ)

Why does this converge to a good plan? Each round, the elite set is a slightly better-than-average slice of the current cloud. Refitting to it nudges the whole distribution into that better region. Next round's samples are drawn from there, so the new elites are better still. The cloud chases its own best tail downhill, and the variance shrinks as the elites bunch up — until Σ is tiny and μ is your plan.

The intuition that sticks. CEM is "fit a distribution to your winners, then play again." Imagine an archer who, after each volley, looks at her three best arrows, re-centers her aim on their average, and tightens her spread to match. Volley by volley her grouping shrinks onto the bullseye. The elites are the best arrows; μ is where she aims; Σ is how wide she's still spraying.

The price of this elegance: CEM is greedy. By tightening only around the elites it can collapse onto a local optimum and never discover a far-off better region — the same risk the gradient methods of Part 1 face. The cure is to keep N large, K not too small, and to inflate Σ a little each round (or floor it) so the cloud doesn't strangle itself before it has explored.

CEM in 2-D — watch the Gaussian tighten onto the goal

Each candidate is a 2-D "plan parameter" (think: aim point). The cloud is the current Gaussian's samples; elites are the K cheapest (closest to the goal); the ellipse is N(μ, Σ). Press Iterate and watch μ slide to the goal while Σ shrinks.

Samples N 80
Elite fraction 0.20
Iter 0 — wide cloud.

Slide the elite fraction up to 0.5 (keep half the samples) and the cloud barely tightens — you're averaging in mediocre plans. Slide it down to 0.05 (keep just a couple) and it tightens fast but risks collapsing onto a fluke. That tension — tighten fast vs. stay safe — is the one knob CEM really has.

In CEM, the new mean μ and covariance Σ are computed from which samples?

Chapter 4: One CEM Iteration, By Hand

Algorithms only become yours when you push real numbers through them. Let's do exactly one CEM iteration with a pencil, in 1-D, so you can see the mean move and the variance shrink with your own eyes.

Setup. We're searching for a single scalar control u. The cost is C(u) = (u − 3)2, so the true optimum is u = 3 with cost 0. We don't know that — we only get to evaluate C. Start with a wide Gaussian: μ = 0, σ = 2 (so σ² = 4). We'll sample N = 6 candidates and keep the K = 3 cheapest as elites.

Step 1 — sample. Suppose our 6 draws from N(0, 4) come out (rounded) as:

u = (−1.0,  0.5,  1.5,  2.5,  3.5,  4.5)

Step 2 — score. Plug each into C(u) = (u − 3)2:

u−1.00.51.52.53.54.5
C(u)=(u−3)²16.06.252.250.250.252.25

Step 3 — select elites. The K = 3 cheapest costs are 0.25, 0.25, and 2.25. Two ways to tie-break give the same lesson; take the three lowest: u = 2.5 (cost 0.25), u = 3.5 (cost 0.25), and u = 1.5 (cost 2.25). The elite set is:

elites = (1.5,  2.5,  3.5)

Step 4 — refit. New mean is the average of the elites:

μnew = (1.5 + 2.5 + 3.5) / 3 = 7.5 / 3 = 2.5

New variance is the (population) variance of the elites about that new mean. The deviations are (1.5 − 2.5, 2.5 − 2.5, 3.5 − 2.5) = (−1, 0, +1), so:

σ²new = ((−1)² + 0² + (+1)²) / 3 = 2/3 ≈ 0.667  ⇒  σnew0.816
What just happened, in numbers. The mean leapt from μ = 0 toward the optimum: 0 → 2.5 (the true best is 3). The spread collapsed: σ = 2 → 0.816, variance 4 → 0.667 — the cloud is now six times tighter and centered far closer to the answer. One iteration. Run it again from N(2.5, 0.667) and μ creeps toward 3 while σ shrinks further. That is CEM converging, by hand.

Now we'll do the same thing in code — but this time you write the refit. The lab samples, scores, and selects the elites for you; you supply the one step that is CEM: recompute μ and Σ from the elite set, and verify the mean moved toward the optimum while the variance shrank.

Starting at μ=0, σ=2 with cost (u−3)², after the by-hand iteration above we got μ≈2.5 and σ≈0.82. What do these two numbers tell you about CEM's progress?

Chapter 5: MPPI — A Soft, Weighted Vote of the Samples

CEM makes a hard cut: a sample is either elite (counts fully) or not (counts zero). MPPI — Model Predictive Path Integral control — replaces that hard cut with a soft one. Instead of throwing away the non-elites, MPPI gives every sample a weight and takes a weighted average. Cheap plans get heavy weight; expensive plans get nearly zero. Nothing is discarded; everything votes, but the good ones vote louder.

The weighting is an exponential of the negative cost. For each sampled sequence with cost C(i), its weight is:

w(i) = exp(−C(i) / λ) / ∑j exp(−C(j) / λ)

Read it piece by piece. The lower the cost, the bigger exp(−C/λ), so cheap plans get more weight. The denominator just normalizes the weights to sum to 1 (it's a softmax over negative costs). And λ (lambda) is the temperature — the one knob that controls how sharply MPPI prefers the best plans:

The new control sequence is just the weighted average:

μ ← ∑i w(i) u(i)

That's the whole update. Sample N sequences from N(μ, Σ), roll them out, weight by exp(−C/λ), average. Like CEM it's an MPC inner loop: do this each step, execute the first action, shift the mean by one for warm-starting, replan.

CEM vs. MPPI in one line. CEM is a hard vote: top-K elites count fully, everyone else counts zero. MPPI is a soft vote: everyone counts, weighted by exp(−cost/temperature). As λ → 0, MPPI's soft vote sharpens toward "only the very best counts" — the two methods meet at the greedy extreme. Both are the same skeleton (sample, roll out, score, update) with a different rule for turning scores into an update.

Why is MPPI everywhere in real-time robotics? Because the soft average is smooth and the whole thing parallelizes brutally well. The original paper runs MPPI with a neural-network dynamics model for aggressive off-road driving; on the deck, the instructor notes a GPU implementation hitting 8192 samples, a 40-step horizon, at ~80 Hz on a laptop GPU. Thousands of full rollouts, eighty times a second. That throughput is why sampling-based MPC went from "the dumb baseline" to the method flying drones and racing cars.

MPPI temperature — sharpen or soften the weighted vote

N sampled controls (bars), each shaded by its weight w = exp(−cost/λ). The warm marker is the weighted-average control μ; the teal curve is the cost. Drag λ: low temperature concentrates weight on the cheapest plan; high temperature flattens it toward a plain average.

Temperature λ 1.00

Concretely the weighted average pulls toward the cheap plans: with mostly-far samples around the optimum at u = 3, an exponential weighting yields a control near 2–3, while a plain unweighted mean of the same samples sits down near 0. The exponential of the negative cost is what does the work — it is a softmax over the rollout costs, and the temperature λ sets how sharply that softmax peaks on the cheapest plan. (You built exactly this softmax in the Lecture 7 spirit of "score, then weight by score.")

In MPPI, what does the temperature λ control?

Chapter 6: Now Learn the Model — and Meet Its Lies

Everything so far assumed the model f was given — a simulator or known dynamics we could roll out. The whole point of robot learning is that often we don't have it. So we learn the dynamics from data: collect transitions (state, action, next-state) by running the robot, then fit a model fθ to predict the next state. Now we can plan against the learned model with all the tools above. This is model-based reinforcement learning (MBRL).

The promise is enormous: sample efficiency. A learned model lets you "imagine" thousands of rollouts in your head without touching the real, slow, fragile robot — the firehose-of-data problem from Lecture 1, attacked head-on. PILCO learns a cart-pole from scratch in a handful of trials; PETS matches model-free methods with eight-to-a-hundred times less real-world data. When every real episode costs seconds and risks hardware, that efficiency is the whole game.

But a learned model is a liar, and the planner is a relentless exploiter of lies. Here is the failure that haunts all of MBRL:

Model exploitation — the central villain. A planner's job is to find the action sequence the model says is cheapest. If the model is wrong somewhere — say it hallucinates that flooring the throttle off a cliff costs nothing, because it has never seen that region — the planner will find that exact lie and drive straight into it. The optimizer doesn't seek good behavior; it seeks low predicted cost, and a confident-but-wrong model offers low predicted cost for free. The better your planner, the harder it exploits the model's mistakes.

Why does the model lie precisely where the planner looks? Because the planner pushes toward regions of high reward, which are often regions it has never visited — exactly where the model has no data and its predictions are arbitrary. PILCO's authors draw the picture sharply: given a handful of observed transitions, many different functions could have produced them. A model that commits to one specific function makes confident predictions far from the data — and those predictions are essentially arbitrary, yet asserted with full confidence. That overconfidence is the trap.

Model exploitation — one overconfident model vs. an ensemble

The true dynamics (dashed) are known only at the training points. A single model draws one confident curve everywhere. An ensemble of models agrees near data and fans out where data is missing (the shaded band). Toggle between them and watch where the planner's "best" point lands — the single model invites exploitation in the data desert.

The single model's "best" point sits out in the data desert, confident and wrong — the planner would happily chase it. The ensemble's disagreement there warns the planner off: if your models can't agree, you have no business trusting any of them. That single idea — represent what you don't know, and let the planner respect it — is what separates the three methods we'll meet next. PILCO uses a Gaussian process to put error bars everywhere. PETS uses an ensemble of networks. MBPO keeps its imagined rollouts short so the model never has time to lie too far.

Two flavors of uncertainty

PETS draws a distinction worth holding onto, because it tells you which uncertainty an ensemble fixes:

UncertaintyWhat it isDoes more data kill it?
AleatoricInherent randomness of the system — sensor noise, process noise. The world is genuinely stochastic.No — it's irreducible. Capture it by predicting a distribution (mean + variance), not a point.
EpistemicYour own ignorance — you just haven't seen enough data to pin down the dynamics here.Yes — it vanishes with infinite data. This is what an ensemble's disagreement measures, and what model exploitation feeds on.
A planner using a learned model drives the robot into a state the model has never seen, where the model confidently (and wrongly) predicts a great outcome. What is this failure called, and what kind of uncertainty is at fault?

Chapter 7: PILCO — Error Bars Everywhere, Solve in Closed Form

PILCO (Probabilistic Inference for Learning COntrol, Deisenroth & Rasmussen 2011) was the breakthrough that made "learn from scratch in a handful of trials" real. Its recipe is the purest answer to model exploitation: never let the model be overconfident in the first place.

PILCO has three deliberate choices, each aimed at model bias.

1. The dynamics model is a Gaussian process (GP). A GP is non-parametric and Bayesian: instead of fitting one curve, it places a distribution over functions consistent with the data. Near observed transitions it is confident (tight error bars); far from them it widens out (huge error bars). It cannot be confidently wrong in the data desert because it explicitly says "I don't know here." This is exactly the picture from Chapter 6 — uncertainty that grows away from data, built in.

2. Policy evaluation is done in closed form. This is the surprising part. PILCO doesn't Monte-Carlo a thousand rollouts. It propagates the uncertainty analytically: starting from a Gaussian over the current state, it pushes that distribution one step forward through the GP, approximates the (non-Gaussian) result as a Gaussian again ("moment matching"), and repeats. The output is a closed-form predicted cost-to-go for the whole horizon, with the model's uncertainty folded in. Plans that pass through uncertain regions automatically incur uncertain (and thus penalized) cost — the GP's honesty propagates into the plan's score.

3. Policy improvement uses analytic policy gradients. Because the predicted cost is a closed-form, differentiable function of the policy parameters, PILCO can compute the exact gradient of long-term cost with respect to the policy and do gradient descent on it. No sampling-based policy search, no high-variance estimates — an analytic gradient straight down the cost surface.

Collect
Run the current policy on the real robot for one trial; add the transitions to the dataset.
↓ fit the probabilistic model
Learn GP dynamics
Fit a Gaussian process — a distribution over dynamics functions, confident near data, uncertain far from it.
↓ evaluate in closed form
Analytic policy eval
Propagate state uncertainty through the GP analytically (moment matching) to get the expected long-term cost.
↓ improve via exact gradient
Analytic policy gradient
Differentiate the cost w.r.t. the policy parameters; gradient-descend to a better policy.
↻ back to the real robot with the improved policy
Why it's so data-efficient. By accounting for model uncertainty everywhere, PILCO refuses to be fooled by a confident-but-wrong dynamics prediction. A plan that relies on a region the GP is unsure about is penalized in expectation, so the policy is steered toward what the data actually supports. That single discipline is why PILCO learns control tasks in a handful of trials where ordinary RL needs hundreds or thousands.

The catch. Gaussian processes are gorgeous but they scale poorly — their cost grows roughly with the cube of the number of data points, and the squared-exponential kernel assumes smooth dynamics. That smoothness assumption breaks on the discontinuous, contact-rich dynamics of real robots (a foot hitting the ground is not smooth). PETS, next, keeps PILCO's obsession with uncertainty but swaps the GP for neural networks that scale to big data and rough dynamics.

PILCO is famously data-efficient. Which design choice is most directly responsible for fighting model bias?

Chapter 8: PETS — Probabilistic Ensembles, Trajectory Sampling

PETS (Probabilistic Ensembles with Trajectory Sampling, Chua et al. 2018) scales PILCO's uncertainty discipline to deep networks and contact-rich dynamics. The name is the algorithm: a probabilistic ensemble for the model, plus trajectory sampling to plan with it. Two pieces, each capturing one flavor of uncertainty from Chapter 6.

Probabilistic ensemble (the "PE")

Each model in the ensemble is a probabilistic neural network: it does not output a single next state, it outputs a distribution — a mean and a variance for the next state. That variance captures aleatoric uncertainty (the world's inherent noise). The network is trained to maximize the likelihood of the observed transitions, i.e. to predict both where the next state lands and how noisy that landing is.

Then PETS trains several such networks (the paper uses B = 5), each on a bootstrap of the data — a resampled copy. Where the data is plentiful, all five learn the same thing and agree. Where data is scarce, each extrapolates differently and they disagree. That disagreement across the ensemble is the epistemic uncertainty — the "I haven't seen enough here" signal. So a single ensemble captures both flavors at once: each member's predicted variance is aleatoric; the spread between members is epistemic.

The whole point of the ensemble. Five disagreeing models in the data desert is a flashing warning light. When PETS plans, a candidate action sequence that drifts into a region where the ensemble disagrees produces wildly different predicted outcomes — some cheap, some catastrophic. Averaging over them, that plan looks risky, not free. The ensemble's disagreement is precisely what stops the planner from exploiting a single model's confident lie.

Trajectory sampling (the "TS")

How do you turn an ensemble into a single cost for the CEM planner to minimize? You can't just average the means — that throws away the disagreement. PETS instead does trajectory sampling: launch a population of "particles" from the current state, and propagate each particle forward by sampling. At each step a particle picks one ensemble member and samples a next state from that member's predicted distribution. Over the horizon, particles that wander into uncertain regions scatter (because the members disagree there); particles in well-known regions stay tight. The cost of an action sequence is the average cost over all particles — so uncertainty inflates the cost exactly where the model is unsure.

Wrap it in MPC: at each real step, run CEM (Chapter 3) over action sequences, scoring each by trajectory sampling through the probabilistic ensemble, execute the first action, replan. The result matches model-free methods like Soft Actor-Critic and PPO on hard benchmarks while using 8× to 125× fewer real-world samples.

Let's quantify the key signal: does ensemble disagreement actually grow as you leave the training data? The lab fits a tiny ensemble of linear models to data on one interval and measures their disagreement (variance of predictions) as you move away. You compute the disagreement; the check confirms it explodes in the data desert.

In PETS, what does the disagreement between the ensemble members measure, and why does it matter for planning?

Chapter 9: MBPO — Short Imagined Rollouts, Branched From Reality

PILCO and PETS plan with the model at every step (sampling-based MPC). MBPO (Model-Based Policy Optimization, Janner et al. 2019) does something different: it uses the learned model to generate extra training data for a model-free RL algorithm. The model is a data factory, not a planner. And it confronts the model-error problem with a beautifully simple insight.

The core insight: trust the model only briefly. A learned model is accurate for one step, decent for a few, and garbage after many — errors compound the longer you roll out (the same compounding villain from Lecture 1, now inside the model's predictions). The fix is not a better model. It's to only ever roll the model out for a few steps, and to start each short rollout from a real state the robot actually visited. Long imagined rollouts are where the model's lies dominate; short ones keep the error small.

That is the branched rollout. Picture the robot's real trajectory as a trunk. At many points along that trunk — real, visited states — MBPO branches off a short (k-step, often just 1) imagined rollout under the learned model and the current policy. Because the branch starts from a real state and runs only a few steps, the model never has time to drift far. These short branches generate a flood of cheap, mostly-accurate synthetic transitions.

Collect real data
Run the policy on the real robot; add transitions to the real buffer Denv.
↓ fit the model to all real data
Train the ensemble model
Fit a probabilistic ensemble pθ(s′,r | s,a) by maximum likelihood (PETS-style model).
↓ branch SHORT rollouts off real states
Generate synthetic data
Sample real states from Denv; roll the policy forward k steps under the model; store these in a model buffer Dmodel.
↓ train the policy on the cheap synthetic flood
Optimize the policy
Run a model-free learner (e.g. SAC) on the model-generated data — many policy updates per real step.
↻ better policy collects better real data

The payoff is that the policy can take 20–40 gradient updates per single real environment step — far more than is stable for a model-free method on real data alone, because the model manufactures the extra transitions. MBPO surpasses prior model-based methods' sample efficiency, matches the best model-free methods' final performance, and — crucially — scales to long-horizon tasks that make other model-based methods fail entirely, precisely because it never asks the model for a long prediction.

Two design choices keep MBPO honest, and both are familiar now:

The trade-off MBPO names in its title. "When to trust your model" — the answer is "for a few steps, branched off real states, with an ensemble watching for exploitation." More model usage means more cheap data but more bias; MBPO tunes that dial by limiting rollout length to where the model's error is still small.

MBPO uses its learned model to generate short rollouts branched from real states, rather than long rollouts from the initial state. Why?

Chapter 10: Connections — The Map of Planning Without Equations

You now own the second half of optimal control: how to plan and learn when you can't write down the dynamics, only sample them. Everything in this lecture hangs on the spine from Chapter 0 — sample, roll out, score, update, replan — and on the one danger that appears the moment the model is learned: model exploitation, which uncertainty defeats.

The sampling-based planners

MethodHow it uses the scoresOne-line idea
Random shootingKeep the single argminThrow N darts, keep the best. Blind, but trivially parallel.
CEMHard cut: top-K elitesRefit a Gaussian to the cheapest K; tighten round by round.
MPPISoft cut: exp(−cost/λ) weightsWeighted vote of all samples; temperature sets greediness. ~80 Hz on a GPU.

The model-based RL methods

MethodModelHow the model is usedUncertainty trick
PILCOGaussian processClosed-form planning + analytic policy gradientError bars everywhere; smooth, low-data, doesn't scale
PETSProbabilistic ensemble (NNs)Sampling-based MPC (CEM + trajectory sampling)Ensemble disagreement = epistemic; per-model variance = aleatoric
MBPOProbabilistic ensemble (NNs)Generate short branched rollouts to train a model-free policyShort rollouts cap error; ensemble blocks exploitation
Cheat sheet — the vocabulary you now own.
  • MPC = plan H steps from the true current state, execute only the first action, re-sense, replan. Implicitly closed-loop; a good terminal cost lets H shrink.
  • Sampling-based planning = sample action sequences, roll out through the model, score, update the sampling distribution. Needs no gradient — only rollouts. Parallelizes on GPUs.
  • CEM = refit a Gaussian to the top-K elite (cheapest) sampled plans each round; mean slides to the good region, variance collapses.
  • MPPI = update toward the exp(−cost/λ)-weighted average of all samples; λ trades greedy (small) vs. uniform (large).
  • Model-based RL = learn the dynamics from data, then plan/imagine with it for sample efficiency.
  • Model exploitation = the planner finds and chases the model's confident errors in unvisited regions — the central MBRL failure.
  • Aleatoric vs. epistemic = inherent noise (predict a distribution) vs. lack of data (ensemble disagreement); only epistemic shrinks with more data.
  • PILCO / PETS / MBPO = GP + closed-form gradients / probabilistic ensemble + trajectory-sampling MPC / probabilistic ensemble + short branched rollouts for a model-free learner.

Where to go next on this site

This lesson is Part 2 of the optimal-control pair and the gateway to model-based RL. Continue along the 16-831 spine and dig deeper with the companion Gleams:

The test of this lesson. Open the Lecture 14 slides at the "Sampling-based TO/MPC" pages. You should be able to explain, from memory: why you'd sample instead of differentiate; the shared skeleton of random shooting / CEM / MPPI and the one line where each differs; what model exploitation is and how PILCO, PETS, and MBPO each defeat it; and the difference between aleatoric and epistemic uncertainty. If you can, you're ready for deep model-based RL.

"When you can't differentiate the world, you negotiate with it — one sampled plan at a time."