The model-based baselines set the ceiling: the expert and MPC both succeed in every episode.
The comparison. the companion book example evaluates every policy on the nominal plant, with 60 start states per seed and five seeds, with and without the safety filter (rates , and a margin of 0.03, three standard deviations of the plant noise).
The model-based baselines set the ceiling: the expert and MPC both succeed in every episode. Among the learners, behaviour cloning on clean demonstrations is the weakest (0.143, collisions 0.857). Noise injection into the demonstrator’s actions raises it to 0.573, and DAgger reaches 0.957, the best learned policy. The diffusion policy trained on the noise-injected demonstrations reaches 0.750, and trained on DAgger’s aggregate data 0.863 (half-width 0.112, so five seeds do not settle its order against DAgger). On identical noise-injected demonstrations the diffusion policy beats the regression policy (0.750 against 0.573, with slightly overlapping intervals); the multimodal start is one plausible reason, not a tested one. The regression policy trained with DAgger (0.957) beat the diffusion policy trained once (0.750), so on-policy data mattered more than the choice of head. The filter rows show that the filter costs nothing when it is not needed: success is unchanged for DAgger and MPC (0.957 and 1.000), wall violations are 0.000 throughout, and the filter changed 0.0002 of the diffusion policy’s actions. The wall is simply far from where these policies go; the next listing puts it in the way.
The filter with a wrong model. Theorem 8.7 and Proposition 8.8 predict that the filter is safe when the plant is the model, or when a margin covers the disagreement. the companion book example tests this with the adversary of the companion book example on plants that differ from the nominal model, and with a learned policy on a windy plant.
On the exact plant the filter holds in all 200 episodes. With only the plant’s noise () the same filter fails in 0.980 of them: a tiny disagreement, repeated at every step of an adversary that sits on the boundary, produces violation almost surely. A margin of 0.03 restores 0.000. The wind plants show the margin requirement of Proposition 8.8: a wind of 0.5 adds a velocity increment of 0.05 per step, and the margin 0.03 fails (1.000) while 0.06 holds; for wind 0.8 (increment 0.08) the margin 0.09 is the first to hold. A filter that knows the wind and adds a 0.03 margin for noise also holds. The actuator gain error (0.6) needs only the 0.03 margin, although the proposition’s sufficient bound for it would be larger. The last row is the hard limit: with wind 1.5 no variant holds, because the acceleration available against the wind is only and the constraint is infeasible thousands of times (4,781 infeasible calls even for the filter that knows the plant). A filter cannot create authority that the actuators do not have.
The bottom block applies the filter to the DAgger policy on a plant with wind 0.8 that the filter does not model. Without a filter 0.106 of the episodes violate the wall; a margin of 0.06 reduces that to 0.028 and 0.09 to 0.000. Success is unchanged within its wide intervals (0.661 without the filter and at margin 0.09), and the share of steps on which the filter intervenes grows with the margin, from 0.004 at zero to 0.038 at 0.09 and 0.062 at 0.12. With three seeds the intervals are very wide (violations at margin zero 0.106 with half-width 0.322); the pattern, not the exact figures, is the finding.
Latency. Real controllers act on observations that are already old. the companion book example delays the observation by control steps (0.1 s each) for policies that re-plan at every step () and for the diffusion policy executing four-action chunks.
The expert (a feedback law designed for no delay) and MPC succeed in every episode up to a delay of 3 steps; at 4 steps the expert fails completely while MPC still succeeds in 0.867, probably because its control penalty makes it gentler (untested). The learned policies degrade earlier: DAgger falls from 0.967 at no delay to 0.850 at 2 steps, 0.342 at 3 and 0.083 at 4, and the diffusion policy with from 0.925 to 0.725, 0.050 and 0.000. Executing four-action chunks costs accuracy at zero delay (0.733) and does not buy robustness to delay here (0.600 at 2 steps, 0.108 at 3). Chunks would help only if aligned with the delay, that is, if the policy predicted the actions for the time at which they will be applied (Exercise 8.10).
Unmodelled dynamics. The expert’s gains, the MPC model and the training data of the learners all assume the nominal plant, except for the “MPC matched” column, which is given the true model. Each cell shows success rate, collision rate and mean final distance.
A weaker actuator (gain 0.6) barely affects the feedback expert (1.00) and the learned policies (0.95 and 0.90) but costs the nominal-model MPC 15 percentage points (0.85), perhaps because it plans with too much authority (untested). Drag at 1.5 per second leaves the expert and the learners largely intact and defeats nominal-model MPC entirely (0.00, stopping 0.25 from the goal); with its model matched, MPC succeeds in every episode. The wind of 0.5 defeats nominal MPC (0.00, final distance 0.46) and hurts the diffusion policy (0.73, final distance 2.00, so some episodes leave the workspace), while the expert, matched MPC and DAgger are fine (1.00, 1.00, 0.97). We believe nominal MPC fails because it has no integral action and leaves a steady-state offset under a constant disturbance; we did not test that, and we attribute the diffusion policy’s wandering to states outside its training distribution, also untested. The final row combines all three mismatches and nothing works well: DAgger reaches 0.17, the expert collides in 0.51 of the episodes, and even MPC with the true model fails (final distance 0.47). Learned policies do not escape mismatch; they trade a wrong model for data from a different plant.
Randomization on the arm. The second environment is a planar two-link arm in a vertical plane with the standard rigid-body equations (Spong, Hutchinson and Vidyasagar, 2006), integrated by semi-implicit Euler. The controller is the LQR gain of the companion book example for the nominal arm linearized at the goal, applied with gravity compensation from the nominal model, torque limited and, in “reality”, delayed. Its one design scalar is the control weight (in ). Simulation chooses by minimizing the reach cost three ways: on the nominal arm, on arms with randomized masses and friction, and on arms with those and a randomized torque delay. The “real” arm has masses 1.3 and 1.7 kg, friction 0.25 and a 5-step delay.
The nominal arm’s best weight is , with simulated cost 0.354, but on the real arm that choice costs 2.912, a gap of 2.558. The real arm’s best weight on this grid is with cost 1.215, so the gap is mostly a matter of a wrong design point. Randomizing masses and friction alone does not help: it picks the same weight in all five draws, and the real cost is again 2.912 (simulated cost 0.444, gap 2.468). Adding the randomized delay shifts the choice to a geometric mean of and the real cost falls to 1.802 (half-width 0.923, so the draws disagree considerably), with a simulated cost of 1.365 and a gap of 0.437. This is Theorem 8.6(c) in practice: randomization helps exactly where it covers the mismatch that matters, here the delay, and not where it covers a different one.
Continue with the book
Explore the full treatment, worked examples, and exercises in Applied AI for Generation and Control.
Companion article for Applied AI for Generation and Control, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
