diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 33e0721f3..26829769a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,6 +13,7 @@ jobs: version: - '1.10' - '1.11' + - '1.12' os: - ubuntu-latest - windows-latest diff --git a/.markdownlint.json b/.markdownlint.json index c49604421..91b0b98a3 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,4 +1,5 @@ { "MD046": false, - "MD013": false + "MD013": false, + "MD033": false } \ No newline at end of file diff --git a/Project.toml b/Project.toml index 18f40956d..18988829f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "OptimalControl" uuid = "5f98b655-cc9a-415a-b60e-744165666948" authors = ["Olivier Cots "] -version = "1.1.4" +version = "1.1.5" [deps] ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a" diff --git a/docs/make.jl b/docs/make.jl index fc08a7e99..5ca95a33b 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -150,7 +150,7 @@ makedocs(; ], "Manual" => [ "Define a problem" => "manual-abstract.md", - "Use AI" => "manual-ai-ded.md", + "Use AI" => "manual-ai-llm.md", "Problem characteristics" => "manual-model.md", "Set an initial guess" => "manual-initial-guess.md", "Solve a problem" => "manual-solve.md", diff --git a/docs/src/assets/Manifest.toml b/docs/src/assets/Manifest.toml index 9867d270e..023e60bd6 100644 --- a/docs/src/assets/Manifest.toml +++ b/docs/src/assets/Manifest.toml @@ -2831,7 +2831,7 @@ uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" version = "1.59.0+0" [[deps.oneTBB_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl"] +deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl"] git-tree-sha1 = "d5a767a3bb77135a99e433afe0eb14cd7f6914c3" uuid = "1317d2d5-d96f-522e-a858-c73665f53c3e" version = "2022.0.0+0" diff --git a/docs/src/example-double-integrator-time.md b/docs/src/example-double-integrator-time.md index 7a0ea6749..77faee835 100644 --- a/docs/src/example-double-integrator-time.md +++ b/docs/src/example-double-integrator-time.md @@ -12,7 +12,7 @@ and the limit conditions x(0) = (1,2), \quad x(t_f) = (0,0). ``` -This problem can be interpretated as a simple model for a wagon with constant mass moving along a line without fricton. +This problem can be interpreted as a simple model for a wagon with constant mass moving along a line without friction. ```@raw html diff --git a/docs/src/index.md b/docs/src/index.md index 25b9687f8..4c26ec6b0 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -75,13 +75,33 @@ If you want to ask a question, feel free to start a discussion [here](https://gi ## Reproducibility +```@setup main +using Pkg +using InteractiveUtils +using Markdown + +# Download links for the benchmark environment +function _downloads_toml(DIR) + link_manifest = joinpath("assets", DIR, "Manifest.toml") + link_project = joinpath("assets", DIR, "Project.toml") + return Markdown.parse(""" + You can download the exact environment used to build this documentation: + - πŸ“¦ [Project.toml]($link_project) - Package dependencies + - πŸ“‹ [Manifest.toml]($link_manifest) - Complete dependency tree with versions + """) +end +``` + +```@example main +_downloads_toml(".") # hide +``` + ```@raw html -
The documentation of this package was built using these direct dependencies, +
ℹ️ Version info ``` -```@example -using Pkg # hide -Pkg.status() # hide +```@example main +versioninfo() # hide ``` ```@raw html @@ -89,12 +109,11 @@ Pkg.status() # hide ``` ```@raw html -
and using this machine and Julia version. +
πŸ“¦ Package status ``` -```@example -using InteractiveUtils # hide -versioninfo() # hide +```@example main +Pkg.status() # hide ``` ```@raw html @@ -102,37 +121,13 @@ versioninfo() # hide ``` ```@raw html -
A more complete overview of all dependencies and their versions is also provided. +
πŸ“š Complete manifest ``` -```@example -using Pkg # hide +```@example main Pkg.status(; mode = PKGMODE_MANIFEST) # hide ``` ```@raw html
``` - -```@eval -using TOML -using Markdown -version = TOML.parse(read("../../Project.toml", String))["version"] -name = TOML.parse(read("../../Project.toml", String))["name"] -link_manifest = "https://github.com/control-toolbox/" * - name * - ".jl/tree/gh-pages/v" * - version * - "/assets/Manifest.toml" -link_project = "https://github.com/control-toolbox/" * - name * - ".jl/tree/gh-pages/v" * - version * - "/assets/Project.toml" -Markdown.parse("""You can also download the -[manifest]($link_manifest) -file and the -[project]($link_project) -file. -""") -``` diff --git a/docs/src/juliacon-paris-2025.md b/docs/src/juliacon-paris-2025.md index 3f2699926..a37b9e590 100644 --- a/docs/src/juliacon-paris-2025.md +++ b/docs/src/juliacon-paris-2025.md @@ -361,7 +361,7 @@ Total wall-clock secs = 0.083 - New applications (space mechanics, biology, quantum mechanics and more) -> check David's talk - Collection of problems: [OptimalControlProblems.jl](https://control-toolbox.org/OptimalControlProblems.jl) -- ... and open to contributions! Give it a [try](@ref manual-ai-ded), give it a star ⭐️ +- ... and open to contributions! Give it a [try](@ref manual-ai-llm), give it a star ⭐️ ```@raw html OptimalControl.jl diff --git a/docs/src/manual-abstract.md b/docs/src/manual-abstract.md index c1371ba60..ffa2b326e 100644 --- a/docs/src/manual-abstract.md +++ b/docs/src/manual-abstract.md @@ -334,7 +334,7 @@ o = @def begin u ∈ R, control -1 ≀ v ≀ 1 x₁(0) == -1 - xβ‚‚(0) - v == 0 # OK: the boundary contraint may involve the variable + xβ‚‚(0) - v == 0 # OK: the boundary constraint may involve the variable x(1) == [0, 0] αΊ‹(t) == [xβ‚‚(t), u(t)] ∫( 0.5u(t)^2 ) β†’ min @@ -342,7 +342,7 @@ end ``` !!! warning - When solving with the option `:exa` to rely on the ExaModels modeller (check the [solve section](@ref manual-solve)), for instance to [solve on GPU](@ref manual-solve-gpu), it is **compulsory** that *nonlinear* constraints (not ranges) are *scalar*, whatever the type (boundary, variable, controle, state, mixed). + When solving with the option `:exa` to rely on the ExaModels modeller (check the [solve section](@ref manual-solve)), for instance to [solve on GPU](@ref manual-solve-gpu), it is **compulsory** that *nonlinear* constraints (not ranges) are *scalar*, whatever the type (boundary, variable, control, state, mixed). ## [Mayer cost](@id manual-abstract-mayer) diff --git a/docs/src/manual-ai-ded.md b/docs/src/manual-ai-ded.md deleted file mode 100644 index 722d08eed..000000000 --- a/docs/src/manual-ai-ded.md +++ /dev/null @@ -1,91 +0,0 @@ -# [Use AI](@id manual-ai-ded) - -Using now common models from AI, it is an elementary task to have such an agent learn the syntax of OptimalControl.jl DSL, then use the agent to translate standard math into this DSL. Here is a typical prompt, pointing to the [DSL syntax](@ref manual-abstract-syntax): - -``` -Learn the syntax of OptimalControl.jl DSL described at the link below -to translate math into this DSL (Julia language): -https://control-toolbox.org/OptimalControl.jl/stable/manual-abstract.html. -``` - -Now, here is an extract of, *e.g.*, [claude.ai](https://claude.ai) answer (Sonnet 4 model) to the request below: - -``` -Translate the problem below into this DSL: - - minimise the final time tf - under the constraint q''(t) = u(t) - with -1 <= u(t) <= 1, - q(0) = 1, q'(0) = -2, q(tf) = 3, q'(tf) = 1, and q'(t) <= 1. -``` - -```julia -@def begin - tf ∈ R, variable - t ∈ [0, tf], time - x = (q, v) ∈ RΒ², state - u ∈ R, control - - # Variable constraint - tf β‰₯ 0 - - # Control constraint - -1 ≀ u(t) ≀ 1 - - # Initial conditions - q(0) == 1 - v(0) == -2 - - # Final conditions - q(tf) == 3 - v(tf) == 1 - - # Path constraint - v(t) ≀ 1 - - # Dynamics (q'' = u becomes first-order system) - αΊ‹(t) == [v(t), u(t)] - - # Objective: minimize final time - tf β†’ min -end -``` - -The answer is syntactically correct and can be updated, for instance according to the new request below: - -``` -Use a form compatible with examodels. -``` - -```julia -@def begin - tf ∈ R, variable - t ∈ [0, tf], time - x = (q, v) ∈ RΒ², state - u ∈ R, control - - # Variable constraint - tf β‰₯ 0 - - # Control constraint - -1 ≀ u(t) ≀ 1 - - # Initial conditions - q(0) == 1 - v(0) == -2 - - # Final conditions - q(tf) == 3 - v(tf) == 1 - - # Path constraint - v(t) ≀ 1 - - # Dynamics (coordinate-wise for ExaModels) - βˆ‚(q)(t) == v(t) - βˆ‚(v)(t) == u(t) - - # Objective: minimize final time - tf β†’ min -end -``` \ No newline at end of file diff --git a/docs/src/manual-ai-llm.md b/docs/src/manual-ai-llm.md new file mode 100644 index 000000000..db87ecbcd --- /dev/null +++ b/docs/src/manual-ai-llm.md @@ -0,0 +1,116 @@ +# [Use AI](@id manual-ai-llm) + +Using now common models from AI, it is an elementary task to have such an agent learn the syntax of OptimalControl.jl DSL, then use the agent to translate standard math into this DSL. Here is a typical prompt, pointing to the [DSL syntax](@ref manual-abstract-syntax): + +```text +Learn the syntax of OptimalControl.jl DSL described at the link below +to translate math into this DSL (Julia language): +https://control-toolbox.org/OptimalControl.jl/stable/manual-abstract.html. +``` + +```@raw html + +``` + +Now, here is an extract of, *e.g.*, [claude.ai](https://claude.ai) answer (Sonnet 4 model) to the request below: + +```text +Translate the problem below into this DSL: + + minimise the final time tf + under the constraint q''(t) = u(t) + with -1 <= u(t) <= 1, + q(0) = 1, q'(0) = -2, q(tf) = 3, q'(tf) = 1, and q'(t) <= 1. +``` + +```julia +@def begin + tf ∈ R, variable + t ∈ [0, tf], time + x = (q, v) ∈ RΒ², state + u ∈ R, control + + # Variable constraint + tf β‰₯ 0 + + # Control constraint + -1 ≀ u(t) ≀ 1 + + # Initial conditions + q(0) == 1 + v(0) == -2 + + # Final conditions + q(tf) == 3 + v(tf) == 1 + + # Path constraint + v(t) ≀ 1 + + # Dynamics (q'' = u becomes first-order system) + αΊ‹(t) == [v(t), u(t)] + + # Objective: minimize final time + tf β†’ min +end +``` + +The answer is syntactically correct and can be updated, for instance according to the new request below: + +```text +Use a form compatible with examodels. +``` + +```julia +@def begin + tf ∈ R, variable + t ∈ [0, tf], time + x = (q, v) ∈ RΒ², state + u ∈ R, control + + # Variable constraint + tf β‰₯ 0 + + # Control constraint + -1 ≀ u(t) ≀ 1 + + # Initial conditions + q(0) == 1 + v(0) == -2 + + # Final conditions + q(tf) == 3 + v(tf) == 1 + + # Path constraint + v(t) ≀ 1 + + # Dynamics (coordinate-wise for ExaModels) + βˆ‚(q)(t) == v(t) + βˆ‚(v)(t) == u(t) + + # Objective: minimize final time + tf β†’ min +end +``` diff --git a/docs/src/manual-flow-ocp.md b/docs/src/manual-flow-ocp.md index b0bcf96d3..9a6f34d1d 100644 --- a/docs/src/manual-flow-ocp.md +++ b/docs/src/manual-flow-ocp.md @@ -81,7 +81,7 @@ julia> f = Flow(ocp, u) ERROR: ExtensionError. Please make: julia> using OrdinaryDiffEq ``` -As you can see, an error occured since we need the package [OrdinaryDiffEq.jl](https://docs.sciml.ai/DiffEqDocs). +As you can see, an error occurred since we need the package [OrdinaryDiffEq.jl](https://docs.sciml.ai/DiffEqDocs). This package provides numerical integrators to compute solutions of the ordinary differential equation $\dot{z}(t) = \vec{\mathbf{H}}(z(t))$. @@ -179,7 +179,7 @@ The pseudo-Hamiltonian of this problem is H(t, x, p, u) = p\, u\, (1+\tan\, t) + p^0 u^2 /2, ``` -where $p^0 = -1$ since we are in the normal case. We can notice that the pseudo-Hamiltonian is non-autonomous since it explicitely depends on the time $t$. +where $p^0 = -1$ since we are in the normal case. We can notice that the pseudo-Hamiltonian is non-autonomous since it explicitly depends on the time $t$. ```@example main is_autonomous(ocp) diff --git a/docs/src/manual-flow-others.md b/docs/src/manual-flow-others.md index de446fac2..e7d5960ae 100644 --- a/docs/src/manual-flow-others.md +++ b/docs/src/manual-flow-others.md @@ -62,7 +62,7 @@ The package [OrdinaryDiffEq.jl](https://docs.sciml.ai/DiffEqDocs) provides numer ## Extremals from the Hamiltonian -The pairs $(x, p)$ solution of the Hamitonian vector field are called *extremals*. We can compute some constructing the flow from the optimal control problem and the control in feedback form. Another way to compute extremals is to define explicitely the Hamiltonian. +The pairs $(x, p)$ solution of the Hamitonian vector field are called *extremals*. We can compute some constructing the flow from the optimal control problem and the control in feedback form. Another way to compute extremals is to define explicitly the Hamiltonian. ```@example main H(x, p, u) = p[1] * x[2] + p[2] * u - 0.5 * u^2 # pseudo-Hamiltonian diff --git a/docs/src/manual-plot.md b/docs/src/manual-plot.md index b2039b6fc..1238496e8 100644 --- a/docs/src/manual-plot.md +++ b/docs/src/manual-plot.md @@ -271,7 +271,7 @@ plt = plot(sol; label="sol1", size=(700, 500)) plot!(plt, sol2; label="sol2", linestyle=:dash) ``` -You can also, implicitely, use the current plot. +You can also, implicitly, use the current plot. ```@example main plot(sol; label="sol1", size=(700, 500)) diff --git a/test/ctdirect/problems/simple_integrator.jl b/test/ctdirect/problems/simple_integrator.jl index 491844510..7a9473837 100644 --- a/test/ctdirect/problems/simple_integrator.jl +++ b/test/ctdirect/problems/simple_integrator.jl @@ -1,5 +1,5 @@ # simple intergator -# min enery, dual control +# min energy, dual control function simple_integrator() @def ocp begin