Skip to content
pierreluxPublic

About

A graduate-level introduction to reinforcement learning as a framework for modeling, optimization, and control, connecting dynamic models, data, and applications beyond standard benchmarks.

Resources

Stars

22 stars

Watchers

3 watching

Forks

Latest commit

 

History

325 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RL & Control

Source for Building Up RL: From Dynamics and Control to Learning, built with Jupyter Book 2 and MyST.

Set up

The Python environment and lockfile are managed by uv:

uv sync

The browser lab uses jupyterlite-xeus, which needs micromamba while assembling its WebAssembly environment. Install it with your package manager before building the lab (for example, brew install micromamba on macOS).

Build and preview

The production-equivalent book build executes every MyST code cell and treats warnings as failures:

BASE_URL=/rlbook uv run jupyter-book build --html --execute --strict

Build the browser notebooks into the same site:

uv run jupyter lite build --lite-dir lab --contents notebooks --output-dir _build/html/lab

For local authoring, use uv run jupyter-book start --execute --port 3000. The browser lab can be served separately with uv run jupyter lite serve --lite-dir lab --contents notebooks.

Keep --execute on builds as well as previews: it includes notebook outputs even when execution results are cached. A build without it can leave only the captions of generated figures and animations. Stop the preview before running a separate build, since both commands write to _build/site, then restart it with the authoring command above.

publish.sh performs both strict builds and publishes the assembled _build/html directory to gh-pages with ghp-import.

Rebuild the single-file GPU inference demo gallery with:

uv run python scripts/build_gpu_demo_gallery.py

Authoring conventions

  • pyproject.toml is the dependency source of truth; requirements.txt is only a pip-compatible entry point.
  • Build-time code cells must be deterministic and must not write generated data back into tracked source files.
  • Short checks use native {exercise} and {solution} directives. Solutions carry :class: dropdown and stable labels such as ex-dp-check-1.
  • Altair is the default for compact browser-side analytical interactions. Expensive solver results remain precomputed.
  • Reactive marimo components are deliberately limited to focused conceptual islands and must include a static fallback.
  • interactive/ contains standalone HTML demonstrations copied verbatim into the site. lab/ contains the xeus environment and curated JupyterLite notebooks.
  • interactive/projects.html is the final-project page (brief, topic matcher, topic explorer). It loads interactive/projects-data/topics.json, which is the source of truth for the topics: edit that file to add or change one. Link to the page with its absolute URL, since MyST rewrites relative links to files in interactive/ into hashed copies under /build/, where the page cannot find its data.
  • Every project topic requires a control object with state (including observations), action (including timing), dynamics (what carries forward and how actions affect it) and objective (horizon goal and constraints). Forecasting, static response fitting and one-off rankings must feed an explicit sequential decision problem. Use scope to identify required model extensions or causal assumptions; compare policies using the same available information and a justified action-response model or off-policy evaluation.

For prose-first executed examples, put figure metadata on the MyST code-cell directive and remove the input from the rendered page:

```{code-cell} python
:tags: [remove-input]
:label: fig-example
:caption: A concise caption that states what the computation shows.

figure = make_figure(results)
display(figure)
```

Use remove-cell for imports and simulation setup that must execute without leaving a notebook block. Use hide-input only when a visible Source disclosure is intentional. After changing an imported Python module, run uv run jupyter-book clean --execute -y; MyST's execution cache does not track changes inside imported files.

Notebooks 01–06 are generated from their source definitions. To regenerate those notebooks, run:

uv run python lab/generate_notebooks.py

Notebooks 07 and 08 are authored directly in lab/notebooks/; the generator does not overwrite them. Notebook 07 uses SymPy in Colab or local Jupyter. Notebook 08, 08_collocation_from_nodes.ipynb, is a short, self-contained NumPy/SciPy/Matplotlib demonstration of direct collocation for Colab, local Jupyter, and the browser lab, saved with its outputs. It is also a page of the book, listed in the myst.yml table of contents under the Demos part and served at /collocation-from-nodes; the book build executes it like any other page. The collocation chapter links to its section headings, for example lab/notebooks/08_collocation_from_nodes.ipynb#step-5-solve-and-check, so a renamed heading must be renamed in the chapter too; the notebook tests check these anchors. It is stored in Colab's notebook layout: format 4.0, a Python 3 kernel, and text cells that each begin with their heading. Its five figure and animation cells start with # @title and carry the hide-input tag, which folds their code in Colab and in the book. Its formulas avoid a backslash followed by punctuation, such as \, and \\, so that they render the same way in Colab and in Jupyter. tests/test_collocation_demo_notebook.py executes its code cells and checks the results. See the lab guide for a description. After editing the notebook, execute it from a fresh Python 3 kernel before saving; in the browser lab, use Python (XPython).

The modeling chapter reads committed trajectories and figures so that an ordinary book build does not rerun long experiments. Regenerate its domain artifacts with:

uv run python scripts/build_swing_modeling_artifacts.py
uv run python scripts/build_bixi_artifacts.py --seeds 512
uv run python scripts/build_gimbal_artifacts.py
uv run --group artifacts python scripts/build_battery_artifacts.py
uv run python scripts/build_cubesat_artifacts.py

The battery builder uses the optional, lockfile-pinned PyBaMM dependency. A normal book build reads its committed trajectories and does not solve the cell model.

The BIXI builder consumes the small, checksum-pinned derived data committed in data/bixi/; it does not download the original archive. Recreating those derived inputs from official source files is documented in data/bixi/README.md.

Semi-truck alley dock with single shooting

The numerical trajectory optimization chapter parks a tractor-semitrailer by single shooting: the 320 speed and steering values are the only decision variables, and L-BFGS-B minimizes the cost of one differentiable rollout. Rebuild its two scenarios, static figures, results tables, and browser replay data with:

uv run python scripts/build_truck_parking_artifacts.py

The replay shows checkpointed optimizer iterates and a fixed plan's future rig poses. The experiment's artifact notes document the kinematic model, the data format, and the finer-replay arrival checks, including the steering-amplification diagnostic that compares reverse-mode derivatives with the product of per-interval hitch Jacobians.

Boat docking with iLQR and DDP

The iLQR and DDP chapter follows the LQR section of finite-horizon dynamic programming and derives the methods through successive approximation and backward elimination. Rebuild its two docking scenarios, four optimizer runs, static figures, and interactive replay data with:

uv run python scripts/build_boat_docking_artifacts.py

Regenerate the same chapter's thermoacoustic pull-down results and figures with:

uv run python scripts/build_thermoacoustic_pulldown_artifacts.py

The browser replay separates optimizer iteration from simulation time. It shows a fixed plan's remaining trajectory and future boat poses. Ordinary book builds read the saved artifacts and do not run the optimizers. The experiment's artifact notes document the model, data format, and finer-integration arrival and hull-clearance checks. The second builder records the thermoacoustic refrigerator's pull-down solves and static figures; its artifact notes describe the synthetic model and checks.

MPPI experiments

The Model Predictive Path Integral Control chapter follows continuous-time transcription and collocation.

The MPPI chapter reads the precomputed aircraft experiment. The separate Path-Integral Stochastic Control chapter contains the HJB derivation and Brownian-passage experiment. Regenerate the numerical results, static figures, and standalone browser replays with:

uv run python scripts/build_brownian_mppi_artifacts.py
uv run python scripts/build_aircraft_mppi_artifacts.py

The aircraft experiment uses numerical OpenAP performance models and the committed ERA5 wind extraction in data/aircraft/. Recreating that extraction from the original local GRIB file requires a temporary ecCodes environment:

uv run --no-project --with eccodes==2.48.0 --with numpy==2.5.3 python scripts/prepare_aircraft_wind.py

Neither ordinary book builds nor browser replay fetch weather data or rerun the optimizers. The aircraft's synthetic gust process is separate from the historical mean-wind snapshot. Controller comparisons keep planner random numbers independent from the realized physical disturbances.

French edition

French chapters live in fr/ under the same file names as the English ones, and the Français / English button in the top menu switches to the same chapter in the other edition. publish.sh builds the French site into _build/html/fr with tools/french.py build. Chapters without a French file appear in English under a short notice, and translated chapters whose English source changed since their translation show an "update pending" notice.

fr/translations.yml records the English commit each French chapter matches. After editing an English chapter:

python3 tools/french.py status                 # which translations are stale
python3 tools/french.py diff stochastic-dp.md   # English changes to carry over
python3 tools/french.py mark stochastic-dp.md   # after updating fr/stochastic-dp.md

Part titles and the site title are in fr/book.yml; the TOC itself always follows myst.yml. Terminology and typography rules are in fr/GLOSSAIRE.md. Keep code cells identical to the English ones so the French build reuses the execution cache. When a French heading replaces an English one that other chapters link to implicitly, add the English slug as an explicit label above it, for example (decision-rules-and-policies)=.

About

A graduate-level introduction to reinforcement learning as a framework for modeling, optimization, and control, connecting dynamic models, data, and applications beyond standard benchmarks.

Resources

Stars

22 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages