Lesson 16 of 21 in this unit
Plan briefly then observe again.
Use a fitted model to choose actions, execute one, then replan from the observed result.
By the end: Compare open-loop action blocks, receding-horizon control and a direct feedback baseline under the same disturbance while accounting for planning and execution work.
Prerequisites and path options
Why learn this? Compare the benefit of observing and replanning with the work and errors added by a longer search horizon.
Start with something concrete.
You plan several pushes to stop a cart at a marker. A gust changes its speed after the first push. Should you execute the remaining pushes unchanged or measure the cart again before choosing the next push?
Try the interactive modelWhat changes when receding-horizon control receives a new observation?
Change one thing. Watch what follows.
Loading this browser experiment…
Understand what changed.
A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.
The idea in everyday terms
Plan several pushes for a cart, execute one, then look again before choosing the next push. That is receding-horizon control. It changes the plan’s starting point without automatically retraining the model.
What to watch in the experiment
Compare three controllers over the same thirty intervals. One executes an entire planned block before looking again. One looks and replans after every action. A direct feedback rule uses current position and speed without searching through a model. All receive the same optional gust after interval eight.
At horizon six, inspect the ninth interval: the controller that replans uses the new state after the gust; the cached block keeps earlier actions. At horizon one, both planning methods behave the same. Try longer horizons, but do not assume they always help or that the neural model must win.
What the search actually does
The planner tries forces −2, 0 and +2 N. It keeps only six promising partial sequences, so it can miss a better complete plan. Its score balances position, speed and force. Predicted cost and cost after real simulated execution are different evidence.
Make a comparison you can defend
Compare how many intervals finished, the remaining position and speed errors, cost and model calls. An early stopped run can have a small total because it did less. Direct feedback has zero model calls but still does computation. The plot counts clipped values and the numerical trace preserves them.
These are public simulator comparisons, not physical safety guarantees or reserved evaluation. Keep a note explaining whether planning earned its extra work. Captures are temporary until exported; later project assessment and human review remain separate. The worked reference below gives the full rule and limits.
Open the full worked examples, calculations and limitations
This is the same reference used in Technical mode. Expand it whenever you need the exact numbers, assumptions or further explanation.
Planning becomes a feedback loop
A world model predicts what a force might do. A planner uses those predictions to compare candidate force sequences. Model-predictive control repeatedly plans from a measured state, executes the first selected action and plans again after the next measurement. Its look-ahead horizon moves forward each time, which is why it is called a receding horizon.
Replanning is not retraining. In this lab the model remains frozen. What changes is the observed starting state and therefore the plan. If a gust changes velocity, the next plan can start from that changed velocity without pretending the old imagined path happened.
The same task, three controllers
All controllers start at x = 1.2 m and v = 0.4 m/s, target rest at x = 0, and run for thirty 0.1-second intervals. They share the exact discrete simulator and optional +0.6 m/s velocity impulse after interval eight. The impulse is absent from their planning model.
Open-loop blocks observe at each block boundary, choose H actions and execute all H before observing for planning again. They use feedback between blocks but remain open loop within a block. They are not an entirely open-loop thirty-interval policy. Receding-horizon control observes and replans every interval, executing only the first action of its H-action plan. At H = 1 these two methods must coincide.
The direct feedback baseline applies a force proportional to position error and opposing velocity, clipped to ±2 N. Its fixed teaching gains are −1.5 for position and −1.2 for velocity, with the corresponding physical units. It uses no dynamics model or search but still performs sensing and arithmetic. It is allowed to win.
A concrete planning objective
Every candidate interval is scored using its predicted next position and velocity, plus applied force. Reference units make the cost dimensionless. Adding these costs across the horizon ranks the candidate sequence.
Position error matters most in this chosen objective; velocity and force also matter. Changing those weights would change the task preference. The lab separately recomputes cost from actual executed states using the same formula. Predicted low cost is not proof of low actual cost.
Bounded search rather than perfect optimization
Candidate forces are −2, 0 and +2 N. A beam search expands surviving partial sequences, then keeps the six with lowest accumulated predicted cost. At depth one it makes three model calls, at depth two nine, and at each later depth at most eighteen. A ten-interval plan therefore uses at most 156 calls. Ties retain prior beam order and force order −2, 0, +2.
Discarded prefixes can later have led to better outcomes. The search is approximate, even if the dynamics model were exact. The horizon is the number of imagined intervals per plan, not the number of real intervals executed in a click. Each click advances each active controller by one real interval and performs at most two planning searches.
Imagined states beyond |x| = 20 m or |v| = 10 m/s, or nonfinite values, are rejected. If no complete candidate survives, the controller stops explicitly. These limits bound computation; they are not collision constraints, a proof of safety, or a guarantee that future optimization will remain feasible.
Inspect what happened after the impulse
At horizon six, an open-loop block starts at intervals one and seven. The impulse follows interval eight, while that second block still has cached actions. At interval nine, receding-horizon control uses the observed state after interval eight. The open block keeps its earlier actions until the next block boundary. Read the receipts to verify that distinction rather than inferring it from a smooth plot.
The simulator’s actual state is available for diagnostic scoring every interval. That does not mean it enters the open-block planner every interval. Planned states, observed planning inputs and actual outcomes occupy separate trace columns.
Compare work and results honestly
A longer horizon may anticipate braking, but it also searches further through an imperfect model and costs more calls. Replanning can correct accumulated state error without correcting persistent model bias. A model that predicts no action effect may cause the planner to prefer no force because force itself costs something.
Compare completed interval counts, final position and speed, total actual cost, planning calls and simulator calls. A stopped run with a small partial total is not a superior completed run. Model calls exclude baseline fitting/replay, sorting, copying, sensing and rendering; they do not establish equal compute, latency or energy between methods.
These fixed public scenarios are repeated development. Freeze settings for a comparison, retain failed captures and state what remains untested. Reserved tasks, changed-dynamics transfer and independently reviewed implementation belong to later Course 12 work; this lab alone does not complete that evidence.
A ten-step beam search returns its cheapest surviving plan. What has been established?
Take this idea with you.
Use observations to restart planning from what happened, while keeping model fit, search work and actual control evidence distinct. Longer horizons can add cost and model error; direct feedback must remain a serious baseline.
Explore related topics and the topic map
How this topic connects
Explore this topic on the interactive mapUse these connections to review a foundation or choose where to go next. You can open any topic without completing the others.
What it builds on
- Small errors become different futures
Find out how long a model can predict without fresh observations before using it to imagine actions.
- Correct errors using feedback
Understand how repeated correction can reject disturbances or cause oscillation when delayed or too aggressive.
Use a fitted model to choose actions, execute one, then replan from the observed result.
What it enables
- Improve a policy using imagined experience
Understand how a learned simulator can reduce environment interaction while introducing errors that policy optimization may exploit.