Skip to content

Commit 1f3afa5

Browse files
authored
Merge pull request #6 from control-toolbox/5-print-the-trace-in-the-documentation
Show trace now
2 parents 98a9563 + db04951 commit 1f3afa5

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

docs/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
55
MINPACK = "4854310b-de5a-5eb6-a2a5-c1dee2bd17f9"
66
OptimalControl = "5f98b655-cc9a-415a-b60e-744165666948"
77
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
8+
9+
[compat]
10+
MINPACK = "1.3"
11+
julia = "1.10"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ makedocs(
55
sitename = "Geometric preconditioner",
66
format = Documenter.HTML(
77
prettyurls = false,
8-
#size_threshold_ignore = [""],
8+
size_threshold_ignore = ["2D-example.md"],
99
assets=[
1010
asset("https://control-toolbox.org/assets/css/documentation.css"),
1111
asset("https://control-toolbox.org/assets/js/documentation.js"),

docs/src/2D-example.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ end
3737
nothing # hide
3838
```
3939

40+
```@setup main
41+
using MINPACK
42+
function fsolve(f, j, x; kwargs...)
43+
try
44+
MINPACK.fsolve(f, j, x; kwargs...)
45+
catch e
46+
println("Erreur using MINPACK")
47+
println(e)
48+
println("hybrj not supported. Replaced by hybrd even if it is not visible on the doc.")
49+
MINPACK.fsolve(f, x; kwargs...)
50+
end
51+
end
52+
function fsolve(f, x; kwargs...)
53+
MINPACK.fsolve(f, x; kwargs...)
54+
end
55+
```
56+
4057
Thanks to the control-toolbox, the flow $\varphi$ of the (true) Hamiltonian
4158

4259
```math
@@ -72,10 +89,9 @@ The main goal now is to find the zero of $S$. To this purpose, we use the numeri
7289
ξ = [-1.0] # initial guess
7390
S!(s, ξ) = (s[:] .= S(ξ[1]); nothing) # intermediate function
7491
p0_sol = fsolve(S!, ξ, show_trace = true) # solve
92+
println(p0_sol)
7593
```
7694

77-
!!! Don't show the trace !!!
78-
7995
```@example main
8096
sol = ϕ((t0, tf), x0, p0_sol.x) # get the optimal trajectory
8197
plot(sol) # plot
@@ -188,10 +204,9 @@ However, the solver $\texttt{hybrd1}$ uses rank 1 approximation to actualize the
188204
```@example main
189205
JS!(js, ξ) = (js[:] .= JS(ξ); nothing) # intermediate function
190206
p0_sol = fsolve(S!, JS!, ξ, show_trace = true) # solve
207+
println(p0_sol)
191208
```
192209

193-
!!! Don't show the trace !!!
194-
195210
```@example main
196211
sol = ϕ((t0, tf), x0, p0_sol.x) # get the optimal trajectory
197212
plt = plot(sol) # plot
@@ -358,10 +373,9 @@ Shoot!(shoot, ξ) = (shoot[:] .= Shoot(ξ[1]); nothing) # intermediate fun
358373
JShoot!(jshoot, ξ) = (jshoot[:] .= JShoot(ξ); nothing) # intermediate function
359374
360375
p0_sol = fsolve(Shoot!, JShoot!, ξ, show_trace = true) # solve
376+
println(p0_sol)
361377
```
362378

363-
!!! Don't show the trace !!!
364-
365379
```@example main
366380
# get optimal trajectory
367381
sol_ = φ((t0, tf), x0, p0_sol.x[1], saveat=range(t0, tf, 500))

0 commit comments

Comments
 (0)