Skip to content

docs: results — reading, plotting, and persisting a solution - #867

Open
ocots wants to merge 5 commits into
docs/solvefrom
docs/results
Open

docs: results — reading, plotting, and persisting a solution#867
ocots wants to merge 5 commits into
docs/solvefrom
docs/results

Conversation

@ocots

@ocots ocots commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

Stacked on #866 (docs/solve, not yet merged) — base branch is docs/solve, not main, since PR 7 depends on PR 6 per the work board. Rebase onto main once #866 (and #865) merge.

Writes the three "Results" pages (docs/src/results/), replacing the PR-2 stubs: solution.md, plot.md, save-load.md (new page — this API was undocumented anywhere on the site before). This section is deliberately placed before Flows (PR 8): a Flow-produced trajectory is read and plotted with the exact same generics as a solve-returned Solution, so PR 8 can say "same as Results" instead of repeating this content.

  • solution.md: the spec's own accessor list includes is_empty(sol), which doesn't exist — is_empty only accepts a TimeGridModel, confirmed live via MethodError. Used the real accessor, is_empty_time_grid(sol), instead. Dropped the "Solution struct" section (API-reference material) and the inline export_ocp_solution/import_ocp_solution note, now save-load.md's job.
  • plot.md: ported the attic almost entirely (spec: "thorough and current"), with two real fixes found by executing every example for real:
    • CTModels.jl#392 (the VBox-plotting bug found in docs: modelling — describe an optimal control problem #865, hit once more in docs: solve — direct methods, choosing and configuring them #866) turns out to affect nearly every bare plot(sol) call in this specific attic file — triggered by an empty/default description regardless of styles or layout=. Fixed throughout with explicit :state/:costate/:control selectors or layout=:group, with one clear note near the top instead of repeating the caveat at every occurrence.
    • The flow-plotting section's saveat=fine_grid no longer works as a call-time keyword ((::OptimalControlFlow)(tspan, x0, p0; ...) only accepts variable/unsafe/augment now) — it moved to a construction-time option on Flow(...) itself, and needs a companion dense=false to avoid a SciML-level dense/saveat conflict. Rewrote the subsection around the working form, verified live (117 points vs. 19 on the default grid).
    • Trimmed the plotattr()/Plots.attributes() <details> blocks — generic Plots.jl mechanics, not OptimalControl API.
  • save-load.md (new): every claim verified live — exact JLD2 round-trip, JSON3 round-trip (bit-exact in this run, phrased as "not guaranteed" in general since JSON floats aren't always exact), the real ExtensionError/IncorrectArgument messages, and that a reloaded solution works as an init= warm start identically to a fresh one. Also filed CTModels.jl#399 (feature request, not a bug): filename is documented as a base name with the extension always auto-appended, so filename="sol.jld2" writes sol.jld2.jld2 — confirmed reproducible, documented explicitly on the page with a warning rather than silently worked around.

Test plan

  • julia --project=docs docs/make.jl — full rebuild, two iterations to clean: 0 undefined-binding/no-docs/duplicate-docs warnings, all three pages' @example blocks execute, 0 unresolved @refs from them.
  • npx vitepress build on the Documenter output — site builds; spot-checked cross-links into docs: modelling — describe an optimal control problem #865's modelling-inspect and docs: solve — direct methods, choosing and configuring them #866's solve-initial-guess anchors resolve in the built HTML.
  • test/suite/shape/test_shape_contract.jl — 27/27 passed (backs the scalar-control-shape claim on solution.md).
  • typos — clean.
  • docs/reports/07-results.md acceptance criteria re-checked against the real build (6/6 ticked, two extra findings recorded beyond the checklist).

🤖 Generated with Claude Code

ocots and others added 5 commits August 20, 2026 22:40
Fixes the spec's own accessor list: is_empty(sol) doesn't exist
(is_empty only takes a TimeGridModel, not a Solution) — the real
solution-level check is is_empty_time_grid(sol), which the page now
uses. Drops the "Solution struct" section (API-reference material)
and the inline export/import note (now results/save-load.md's job).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Ports the attic almost entirely (thorough, mostly current per spec),
with two real fixes found by executing it for real:
- CTModels.jl#392 (the VBox plotting bug from PR 5/6) turns out to
  affect nearly every bare plot(sol) call in this file specifically
  — triggered whenever the default (empty) description is used,
  regardless of styles or layout kwargs. Fixed throughout with
  explicit :state/:costate/:control selectors or layout=:group,
  with one clear note up front rather than repeating it everywhere.
- The flow-plotting section's saveat=fine_grid no longer works as a
  call-time keyword; it moved to Flow's construction-time options
  and now needs a companion dense=false to avoid a SciML-level
  dense/saveat conflict. Rewrote the subsection around the working
  form, verified live (117 points vs 19 on the default grid).
Trimmed the plotattr()/Plots.attributes() <details> blocks — generic
Plots.jl mechanics, not OptimalControl API.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
First time export_ocp_solution/import_ocp_solution are documented on
the site. All claims verified live: exact JLD2/JSON3 round-trip, the
double-extension footgun (filename="sol.jld2" writes sol.jld2.jld2),
the real ExtensionError text for both missing backends, and that a
reloaded solution works as an init= warm start identically to a
fresh one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…rk board

Full julia --project=docs docs/make.jl + npx vitepress build rebuild,
clean: 0 undefined-binding/no-docs/duplicate-docs warnings, all three
results/ pages' @example blocks execute, 0 unresolved @refs from
them. test/suite/shape/test_shape_contract.jl re-run (27/27 passed).
typos clean.

All 6 acceptance criteria ticked against that build; two real
findings beyond the checklist recorded in the report: CTModels.jl#392
affecting nearly every bare plot(sol) call in the attic source, and
an off-by-3 line citation in the spec for the plot ExtensionError.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant