Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ Draft = false
```
=#
makedocs(;
draft=false,
draft=true, # if draft is true, then the julia code from .md is not executed # debug
# to disable the draft mode in a specific markdown file, use the following:
# ```@meta
# Draft = false
# ```
#draft=false,
#warnonly=[:cross_references, :autodocs_block],
sitename="OptimalControl.jl",
format=Documenter.HTML(;
Expand All @@ -150,6 +155,7 @@ makedocs(;
],
"Manual" => [
"Define a problem" => "manual-abstract.md",
"Use AI" => "manual-ai-ded.md",
"Problem characteristics" => "manual-model.md",
"Set an initial guess" => "manual-initial-guess.md",
"Solve a problem" => "manual-solve.md",
Expand Down
85 changes: 85 additions & 0 deletions docs/src/manual-ai-ded.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# [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
```
46 changes: 28 additions & 18 deletions docs/src/manual-solve-gpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,21 @@ Computation on GPU is currently only tested with CUDA, and the associated backen
sol = solve(ocp, :exa, :madnlp; exa_backend=CUDABackend())
```

```
▫ This is OptimalControl version v1.1.0 running with: direct, exa, madnlp.

▫ The optimal control problem is solved with CTDirect version v0.16.0.
```julia
▫ This is OptimalControl version v1.1.2 running with: direct, exa, madnlp.

▫ The optimal control problem is solved with CTDirect version v0.17.2.

┌─ The NLP is modelled with ExaModels and solved with MadNLP.
┌─ The NLP is modelled with ExaModels and solved with MadNLPMumps.
├─ Number of time steps⋅: 250
└─ Discretisation scheme: trapeze
└─ Discretisation scheme: midpoint

▫ This is MadNLP version v0.8.7, running with cuDSS v0.4.0
▫ This is MadNLP version v0.8.12, running with cuDSS v0.6.0

Number of nonzeros in constraint Jacobian............: 2506
Number of nonzeros in Lagrangian Hessian.............: 2006
Number of nonzeros in constraint Jacobian............: 2256
Number of nonzeros in Lagrangian Hessian.............: 1251

Total number of variables............................: 754
variables with only lower bounds: 0
Expand All @@ -64,21 +65,30 @@ Total number of inequality constraints...............: 251
inequality constraints with lower and upper bounds: 251
inequality constraints with only upper bounds: 0

iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 1.0200000e+00 1.10e+00 1.00e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0
...
26 9.8902986e+00 2.22e-16 7.11e-15 -9.0 1.32e-04 - 1.00e+00 1.00e+00h 1
iter objective inf_pr inf_du inf_compl lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 1.0200000e+00 1.10e+00 1.00e+00 1.01e+01 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0
1 1.0199978e+00 1.10e+00 1.45e+00 8.73e-02 -1.0 1.97e+02 - 5.05e-03 4.00e-07h 1
...
27 9.8891249e+00 2.22e-16 7.11e-15 1.60e-09 -9.0 2.36e-04 - 1.00e+00 1.00e+00h 1

Number of Iterations....: 26
Number of Iterations....: 27

(scaled) (unscaled)
Objective...............: 9.8902986337530514e+00 9.8902986337530514e+00
Objective...............: 9.8891248915014458e+00 9.8891248915014458e+00
Dual infeasibility......: 7.1054273576010019e-15 7.1054273576010019e-15
Constraint violation....: 2.2204460492503131e-16 2.2204460492503131e-16
Complementarity.........: 4.8363494304578671e-09 4.8363494304578671e-09
Overall NLP error.......: 4.8363494304578671e-09 4.8363494304578671e-09

...
Complementarity.........: 1.5999963912421547e-09 1.5999963912421547e-09
Overall NLP error.......: 1.5999963912421547e-09 1.5999963912421547e-09

Number of objective function evaluations = 28
Number of objective gradient evaluations = 28
Number of constraint evaluations = 28
Number of constraint Jacobian evaluations = 28
Number of Lagrangian Hessian evaluations = 27
Total wall-clock secs in solver (w/o fun. eval./lin. alg.) = 0.126
Total wall-clock secs in linear solver = 0.103
Total wall-clock secs in NLP function evaluations = 0.022
Total wall-clock secs = 0.251

EXIT: Optimal Solution Found (tol = 1.0e-08).
```
Loading