Skip to content

Commit e56d32a

Browse files
authored
Merge pull request #3 from control-toolbox/2-doc-update-links
up links and more
2 parents 98fdf8b + 65c0864 commit e56d32a

File tree

8 files changed

+39
-37
lines changed

8 files changed

+39
-37
lines changed

docs/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ OptimalControl = "5f98b655-cc9a-415a-b60e-744165666948"
1111
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1212
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1313
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
14-
Tutorials = "cb10daa6-a5e5-4c25-a171-ae181b8ea3c9"
1514

1615
[compat]
1716
DifferentiationInterface = "0.6"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ makedocs(;
88
sitename="Tutorials",
99
format=Documenter.HTML(;
1010
repolink="https://" * repo_url,
11-
prettyurls=true,
11+
prettyurls=false,
1212
size_threshold_ignore=[
1313
""
1414
],

docs/src/tutorial-continuation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This usually gives better and faster convergence than solving each problem with
1212

1313
The most compact syntax to perform a discrete continuation is to use a function that returns the OCP for a given value of the continuation parameter, and solve a sequence of these problems. We illustrate this on a very basic double integrator with increasing fixed final time.
1414

15-
First we load the required packages
15+
First we load the required packages:
1616

1717
```@example main
1818
using OptimalControl
@@ -21,7 +21,7 @@ using Printf
2121
using Plots
2222
```
2323

24-
and write a function that returns the OCP for a given final time
24+
and write a function that returns the OCP for a given final time:
2525

2626
```@example main
2727
function ocp_T(T)

docs/src/tutorial-discretisation.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ When calling `solve`, the option `disc_method=...` can be used to set the discre
55
In addition to the default implicit `:trapeze` method (aka Crank-Nicolson), other choices are available, namely implicit `:midpoint` and the Gauss-Legendre collocations with 2 and stages, `:gauss_legendre_2` and `:gauss_legendre_3`, of order 4 and 6 respectively.
66
Note that higher order methods will typically lead to larger NLP problems for the same number of time steps, and that accuracy will also depend on the smoothness of the problem.
77

8-
As an example we will use the [Goddard problem](@ref tutorial-goddard)
8+
As an example we will use the [Goddard problem](@ref tutorial-goddard).
9+
910
```@example main
1011
using OptimalControl # to define the optimal control problem and more
1112
using NLPModelsIpopt # to solve the problem via a direct method
@@ -57,23 +58,28 @@ nothing # hide
5758
```
5859
Now let us compare different discretisations
5960
```@example main
61+
x_style = (legend=:none,)
62+
p_style = (legend=:none,)
63+
6064
sol_trapeze = solve(ocp; tol=1e-8)
61-
plot(sol_trapeze)
65+
plt = plot(sol_trapeze; solution_label="trapeze", state_style=x_style, costate_style=p_style)
6266
6367
sol_midpoint = solve(ocp, disc_method=:midpoint; tol=1e-8)
64-
plot!(sol_midpoint)
68+
plot!(plt, sol_midpoint; solution_label="midpoint", state_style=x_style, costate_style=p_style);
6569
6670
sol_euler = solve(ocp, disc_method=:euler; tol=1e-8)
67-
plot!(sol_euler)
71+
plot!(plt, sol_euler; solution_label="euler", state_style=x_style, costate_style=p_style);
6872
6973
sol_euler_imp = solve(ocp, disc_method=:euler_implicit; tol=1e-8)
70-
plot!(sol_euler_imp)
74+
plot!(plt, sol_euler_imp; solution_label="euler implicit", state_style=x_style, costate_style=p_style);
7175
7276
sol_gl2 = solve(ocp, disc_method=:gauss_legendre_2; tol=1e-8)
73-
plot!(sol_gl2)
77+
plot!(plt, sol_gl2; solution_label="gauss legendre 2", state_style=x_style, costate_style=p_style);
7478
7579
sol_gl3 = solve(ocp, disc_method=:gauss_legendre_3; tol=1e-8)
76-
plot!(sol_gl3)
80+
plot!(plt, sol_gl3; solution_label="gauss legendre 3", state_style=x_style, costate_style=p_style);
81+
82+
plot(plt, size=(800, 800))
7783
```
7884

7985
## Large problems and AD backend

docs/src/tutorial-goddard.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ $v(t) \leq v_{\max}$. The initial state is fixed while only the final mass is pr
3434
as well as constrained arcs due to the path constraint on the velocity (see below).
3535

3636
We import the [OptimalControl.jl](https://control-toolbox.org/OptimalControl.jl) package to define the optimal control problem and
37-
[NLPModelsIpopt.jl](https://github.com/JuliaSmoothOptimizers/NLPModelsIpopt.jl) to solve it.
38-
We import the [Plots.jl](https://github.com/JuliaPlots/Plots.jl) package to plot the solution.
39-
The [OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl) package is used to
37+
[NLPModelsIpopt.jl](https://jso.dev/NLPModelsIpopt.jl) to solve it.
38+
We import the [Plots.jl](https://docs.juliaplots.org) package to plot the solution.
39+
The [OrdinaryDiffEq.jl](https://docs.sciml.ai/OrdinaryDiffEq) package is used to
4040
define the shooting function for the indirect method and the [MINPACK.jl](https://github.com/sglyon/MINPACK.jl) package permits to solve the shooting equation.
4141

4242
```@example main
@@ -119,15 +119,11 @@ bang arc with maximal control, followed by a singular arc, then by a boundary ar
119119
arc is with zero control. Note that the switching function vanishes along the singular and
120120
boundary arcs.
121121

122-
!!! tip "Interactions with an optimal control solution"
123-
124-
Please check [`state`](@ref), [`costate`](@ref), [`control`](@ref) and [`variable`](@ref) to get data from the solution. The functions `state`, `costate` and `control` return functions of time and `variable` returns a vector. The function [`time_grid`](@ref) returns the discretized time grid returned by the solver.
125-
126122
```@example main
127-
t = time_grid(direct_sol)
128-
x = state(direct_sol)
129-
u = control(direct_sol)
130-
p = costate(direct_sol)
123+
t = time_grid(direct_sol) # the time grid as a vector
124+
x = state(direct_sol) # the state as a function of time
125+
u = control(direct_sol) # the control as a function of time
126+
p = costate(direct_sol) # the costate as a function of time
131127
132128
H1 = Lift(F1) # H1(x, p) = p' * F1(x)
133129
φ(t) = H1(x(t), p(t)) # switching function
@@ -193,9 +189,7 @@ as well as the associated multiplier for the *order one* state constraint on the
193189

194190
which is the reason why we use the `@Lie` macro to compute Poisson brackets below.
195191

196-
With the help of the [differential geometry primitives](https://control-toolbox.org/CTBase.jl/stable/api-diffgeom.html)
197-
from [CTBase.jl](https://control-toolbox.org/OptimalControl.jl/stable/api-ctbase.html),
198-
these expressions are straightforwardly translated into Julia code:
192+
With the help of differential geometry primitives, these expressions are straightforwardly translated into Julia code:
199193

200194
```@example main
201195
# Controls
@@ -284,11 +278,11 @@ We aggregate the data to define the initial guess vector.
284278

285279
### MINPACK.jl
286280

287-
We can use [NonlinearSolve.jl](https://github.com/SciML/NonlinearSolve.jl) package or, instead, the
281+
We can use [NonlinearSolve.jl](https://docs.sciml.ai/NonlinearSolve) package or, instead, the
288282
[MINPACK.jl](https://github.com/sglyon/MINPACK.jl) package to solve
289283
the shooting equation. To compute the Jacobian of the shooting function we use the
290-
[DifferentiationInterface.jl](https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface) package with
291-
[ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) backend.
284+
[DifferentiationInterface.jl](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface) package with
285+
[ForwardDiff.jl](https://juliadiff.org/ForwardDiff.jl) backend.
292286

293287
```@setup main
294288
using NonlinearSolve # interface to NLE solvers

docs/src/tutorial-iss.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
In this tutorial we present the indirect simple shooting method on a simple example.
44

55
Let us start by importing the necessary packages.
6+
We import the [OptimalControl.jl](https://control-toolbox.org/OptimalControl.jl) package to define the optimal control problem.
7+
We import the [Plots.jl](https://docs.juliaplots.org) package to plot the solution.
8+
The [OrdinaryDiffEq.jl](https://docs.sciml.ai/OrdinaryDiffEq) package is used to define the shooting function for the indirect method and the [MINPACK.jl](https://github.com/sglyon/MINPACK.jl) package permits to solve the shooting equation.
9+
610

711
```@example main
812
using OptimalControl # to define the optimal control problem and its flow
913
using OrdinaryDiffEq # to get the Flow function from OptimalControl
10-
using NonlinearSolve # interface to NLE solvers
1114
using MINPACK # NLE solver: use to solve the shooting equation
1215
using Plots # to plot the solution
1316
```
@@ -154,7 +157,7 @@ nothing # hide
154157

155158
### MINPACK.jl
156159

157-
We can use [NonlinearSolve.jl](https://github.com/SciML/NonlinearSolve.jl) package or, instead, [MINPACK.jl](https://github.com/sglyon/MINPACK.jl) to solve the shooting equation. To compute the Jacobian of the shooting function we use [DifferentiationInterface.jl](https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface) with [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) backend.
160+
We can use [NonlinearSolve.jl](https://docs.sciml.ai/NonlinearSolve) package or, instead, [MINPACK.jl](https://github.com/sglyon/MINPACK.jl) to solve the shooting equation. To compute the Jacobian of the shooting function we use [DifferentiationInterface.jl](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface) with [ForwardDiff.jl](https://juliadiff.org/ForwardDiff.jl) backend.
158161

159162
```@setup main
160163
using MINPACK

docs/src/tutorial-lqr-basic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ and the initial condition
2020

2121
We aim to solve this optimal control problem for different values of $t_f$.
2222
First, we need to import the [OptimalControl.jl](https://control-toolbox.org/OptimalControl.jl) package to define the
23-
optimal control problem and [NLPModelsIpopt.jl](jso.dev/NLPModelsIpopt.jl) to solve it.
23+
optimal control problem and [NLPModelsIpopt.jl](https://jso.dev/NLPModelsIpopt.jl) to solve it.
2424
We also need to import the [Plots.jl](https://docs.juliaplots.org) package to plot the solution.
2525

2626
```@example main

docs/src/tutorial-nlp.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ CurrentModule = OptimalControl
77
We describe here some more advanced operations related to the discretized optimal control problem.
88
When calling `solve(ocp)` three steps are performed internally:
99

10-
- first, the OCP is discretized into a DOCP (a nonlinear optimization problem) with [`direct_transcription`](@ref),
11-
- then, this DOCP is solved (with the internal function [`solve_docp`](@ref)),
12-
- finally, a functional solution of the OCP is rebuilt from the solution of the discretized problem, with [`OptimalControlSolution`](@ref).
10+
- first, the OCP is discretized into a DOCP (a nonlinear optimization problem),
11+
- then, this DOCP is solved with a nonlinear programming (NLP) solver, which returns a solution of the discretized problem,
12+
- finally, a functional solution of the OCP is rebuilt from the solution of the discretized problem.
1313

1414
These steps can also be done separately, for instance if you want to use your own NLP solver.
1515

@@ -55,7 +55,7 @@ We can now use the solver of our choice to solve it.
5555

5656
## Resolution of the NLP problem
5757

58-
For a first example we use the `ipopt` solver from [NLPModelsIpopt.jl](https://github.com/JuliaSmoothOptimizers/NLPModelsIpopt.jl) package to solve the NLP problem.
58+
For a first example we use the `ipopt` solver from [NLPModelsIpopt.jl](https://jso.dev/NLPModelsIpopt.jl) package to solve the NLP problem.
5959

6060
```@example main
6161
using NLPModelsIpopt
@@ -82,14 +82,14 @@ nlp_sol = madnlp(nlp)
8282

8383
## Initial guess
8484

85-
An initial guess, including warm start, can be passed to [`direct_transcription`](@ref) the same way as for `solve`.
85+
An initial guess, including warm start, can be passed to [`direct_transcription`](https://control-toolbox.org/OptimalControl.jl/stable/dev-ctdirect.html#CTDirect.direct_transcription-Tuple{Model,%20Vararg{Any}}) the same way as for `solve`.
8686

8787
```@example main
8888
docp, nlp = direct_transcription(ocp; init=sol)
8989
nothing # hide
9090
```
9191

92-
It can also be changed after the transcription is done, with [`set_initial_guess`](@ref).
92+
It can also be changed after the transcription is done, with [`set_initial_guess`](https://control-toolbox.org/OptimalControl.jl/stable/dev-ctdirect.html#CTDirect.set_initial_guess-Tuple{CTDirect.DOCP,%20Any,%20Any}).
9393

9494
```@example main
9595
set_initial_guess(docp, nlp, sol)

0 commit comments

Comments
 (0)