docs: minimal 1-D bang–singular–bang example (phase O) - #937
Merged
Conversation
New examples/turnpike.md: the scalar turnpike ẋ = u, |u| ≤ 1, fixed horizon, ∫x² → min. Solved direct then indirect. Because the cost is linear in u the control is bang except on a singular arc, and here the singular feedback drops straight out of the optimality conditions (p ≡ 0 ⟹ ṗ = 2x = 0 ⟹ x = 0 ⟹ u_s = 0) — no Poisson brackets, unlike examples/singular-control.md. Shooting on [p0, t1, t2] (fixed horizon), with the singular arc read off the direct solution the Goddard-tutorial way (t12 = t[abs.(φ.(t)) .≤ η], switching function ≡ costate here). Three constant-control flows concatenated with *. Solver lands on p0 = -1, t1 = 1, t2 = 3/2, cost 3/8. Wired into make.jl and gallery.md directly before "Singular control"; cross-linked from singular-control.md and shooting.md (§ switching times as unknowns); forward pointer to the Goddard problem for the harder case. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
New page
docs/src/examples/turnpike.md— a minimal 1-D singular-control example, solved both directly and indirectly.The scalar turnpike:
The pseudo-Hamiltonian$H = p,u - x^2$ is linear in $u$ , so the control is bang except on a singular arc — and here the singular feedback drops straight out of the optimality conditions, $p\equiv 0 \Rightarrow \dot p = 2x = 0 \Rightarrow x = 0 \Rightarrow u_s = 0$ , with no Poisson brackets. The optimal solution is bang ($-1$ ) on $[0,1]$ , singular ($0$ ) on $[1,3/2]$ , bang ($+1$ ) on $[3/2,2]$ , with $p_0=-1$ and cost $3/8$ .
Why
examples/singular-control.mdis the only page showing a singular arc, and it is a 2-D Zermelo problem needing the fullLift/@Lie/H₀₀₁/H₁₀₁chain. There was nowhere lighter for a reader who just wants to see a bang–singular–bang solution. This page is also the concrete case thatflows/shooting.md§Switching times as unknowns describes in prose but never works (two unknown switching times).Contents
solve, one plot; the flat turnpike plateau at@Lie.[p0, t1, t2](fixed horizon). The guess for the singular arc is read off the direct solution the way the Goddard tutorial does it —t12 = t[abs.(φ.(t)) .≤ η], where the switching function is just the costate here.f₋ * (t1, f₀) * (t2, f₊), overlaid on the direct plot; objectiveWiring
docs/make.jlanddocs/src/examples/gallery.md— inserted directly before Singular control (the minimal singular case, then the bracket-heavy 2-D one). Happy to move it after Time minimisation (bang–bang) if you prefer the tighter bang-arc thread.examples/singular-control.md(opening pointer) andflows/shooting.md(§ switching times as unknowns).geometry/overview.mdleft untouched — flagged as a maintainer call in the plan.Verification
julia --project=. docs/make.jlon this branch:examples/turnpike.htmlrenders; both its figures are SVG, no new.png.cannot resolveerrors — all pre-existing@extrefnoise (Plots.plot(::CTModels…)×4,CTBase.Strategies.parameter×2), unchanged frommain; none from this page.@ref examples-turnpikelinks resolve.p0 = -1,t1 = 1,t2 = 3/2, direct cost0.37495, shooting residual ~1e-16.One note: this OCP is autonomous + fixed-time + no
variable, so theFlow(ocp, u)control law is arity 2 —(x, p) -> …, not the arity-3(x, p, v) -> …form used indouble-integrator-time.md(which hastf ∈ R, variable).Add the
run documentationlabel to build the site in CI.🤖 Generated with Claude Code