The pieces of the experiments are as follows, all in control_lib.py.
The pieces of the experiments are as follows, all in control_lib.py. PointMass implements the dynamics of the companion book example for a batch of episodes at once, with nominal() returning the model that planners and filters assume. ExpertPolicy is the state-feedback expert with its latent side. rollout runs closed-loop episodes with an execution horizon, an optional filter and an optional observation delay, and episode_metrics computes the three outcomes. The learners are RegressionPolicy (behaviour cloning by mean-squared error), DiffusionPolicy (the companion book example), GradMPC (a receding-horizon planner solving the problem of the companion book example plus soft penalties for the obstacle and the wall by projected gradient with momentum (the accelerated scheme of Beck and Teboulle, 2009), because the obstacle makes the problem nonconvex and rules out a QP) and WallFilter. The three metrics and the loop:
Demonstrations are collected by running the expert. Each stored pair is a visited state and the expert’s next actions from that state, computed on the nominal model; the demonstrator’s actions can optionally be perturbed during collection (the stored labels stay clean), which is the noise-injection idea of DART (Laskey et al., 2017). DAgger relabels the learner’s visited states with the same expert, using the sign of as the latent side.
All learners are networks with two hidden layers of 96 units, trained with the Adam optimizer of the companion book in single precision. the companion book example describes the task as the expert sees it.
Over 400 episodes the expert succeeds every time on the noisy plant, never collides and never touches the wall; its path stays 0.123 outside the disk at the closest point (0.176 on average) and reaches at most against the wall at 0.75. A share of 0.477 of the detours go above the obstacle. At the symmetric start state the two modes have summed sideways actions and , so their mean is zero (Proposition 8.5). Noise injection changes the visited states only a little by this coarse measure: the standard deviation of is 0.256 for clean demonstrations and 0.266 for demonstrations executed with action noise 0.5, and that of the -velocity 0.312 and 0.314. Each 60-episode set has 3,600 state-chunk pairs. The data sets are small on purpose, so that distribution shift is visible.
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.
