Repository navigation
feat: analytic solution of the continuous problem in the metadata (#379) - #403
Merged
Merged
Conversation
:reference_solution, optional, a function of the parameters giving the state, the control, the objective and the source, or nothing where it is not known. Filled for beam and bryson_denham (Bryson, Denham & Dreyfus 1963, boundary arc). Checked on the OptimalControl model: at the solution, the constraint violation and the objective gap of the discretized problem vanish at order 2. Every description cites its sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
ocots
marked this pull request as ready for review
November 7, 2026 12:44
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.
Closes #379. Part 5 of #306. Conventions: ct-conventions v0.10.0, ct-agents v0.4.0.
Scope, as agreed in #379
Of the declared fields listed in #306, only what is not a judgment and can be checked:
:reference_solution(optional): the analytic solution of the continuous problem.ext/Descriptions/<p>.md, the single place; no:referencesfield that would duplicate them.Dropped:
:tags(:hardis a judgment;:large_stateor:analyticare computable, fromfeaturesor from:reference_solution);:corleone(we write our own problems, #308: a pointer to a SciML problem that differs from ours, unchecked, would suggest an equivalence that does not hold). A descriptive structure (singular arcs, boundary arcs, stiffness, turnpike), characteristics rather than judgments, is for later.Design
ext/MetaData/<p>.jl::reference_solution => p -> …, a function of the parameters, like:init([Metadata] Shared initial guess in the metadata, read by every modeling #377). It returns(state=t -> …, control=t -> …, objective=…, source=…), ornothingfor the parameters the solution is not known for.src/solutions.jl: the analytic solutions._bryson_denham_solution(Bryson, Denham & Dreyfus 1963, https://doi.org/10.2514/3.2107), shared bybeam(cost∫u², J = 8/(9ℓ) = 8.889) andbryson_denham(cost½∫u², J = 4/(9ℓ) = 4): ẋ₁ = x₂, ẋ₂ = u on [0, 1], x(0) = (0, 1), x(1) = (0, -1), x₁ ≤ ℓ, known for ℓ ≤ 1/6 (boundary arc on [3ℓ, 1 − 3ℓ]).METADATA_SCHEMA.optionalgainsreference_solution=Function.OptimalControlProblems.reference_solution_data(problem, parameters=nothing), not exported.Tests
test/suite/OptimalControl/test_reference_solution.jl: the solution solves the model. At the analytic point, on the trapezoidal discretization of the OptimalControl model, the constraint violation and the gap of the objective to the analytic one vanish with the step at order 2 (from 100 to 400 steps, divided by at least 10). Generic: every problem with a:reference_solution, all its constraints. Shown failing on a wrong objective (bryson_denhamwith weight 1): the gap does not decrease.reference_solution_datawith and without parameters,nothingfor a problem without one;_bryson_denham_solution: values, junctions,nothingoutside its domain (no boundary arc, other horizon or boundary conditions, lower bound above 0).Referencessection with at least one entry (cites_sources, with positive and negative cases); the reference solutions have a state, a control, a finite objective and a source.NLPModelsadded to thetest/suite/OptimalControlenvironment.Local: core 739 passed; OptimalControl reference solution 4 passed.
Documentation
docs/src/problems-introduction.md: the analytic solution, with an example; theproblem_metadatadocstring lists the field.🤖 Generated with Claude Code