Skip to content

Commit

Permalink
Merge pull request #6 from control-toolbox/5-print-the-trace-in-the-d…
Browse files Browse the repository at this point in the history
…ocumentation

Show trace now
  • Loading branch information
remydutto authored Aug 13, 2024
2 parents 98a9563 + db04951 commit 1f3afa5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
MINPACK = "4854310b-de5a-5eb6-a2a5-c1dee2bd17f9"
OptimalControl = "5f98b655-cc9a-415a-b60e-744165666948"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[compat]
MINPACK = "1.3"
julia = "1.10"
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ makedocs(
sitename = "Geometric preconditioner",
format = Documenter.HTML(
prettyurls = false,
#size_threshold_ignore = [""],
size_threshold_ignore = ["2D-example.md"],
assets=[
asset("https://control-toolbox.org/assets/css/documentation.css"),
asset("https://control-toolbox.org/assets/js/documentation.js"),
Expand Down
26 changes: 20 additions & 6 deletions docs/src/2D-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ end
nothing # hide
```

```@setup main
using MINPACK
function fsolve(f, j, x; kwargs...)
try
MINPACK.fsolve(f, j, x; kwargs...)
catch e
println("Erreur using MINPACK")
println(e)
println("hybrj not supported. Replaced by hybrd even if it is not visible on the doc.")
MINPACK.fsolve(f, x; kwargs...)
end
end
function fsolve(f, x; kwargs...)
MINPACK.fsolve(f, x; kwargs...)
end
```

Thanks to the control-toolbox, the flow $\varphi$ of the (true) Hamiltonian

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

!!! Don't show the trace !!!

```@example main
sol = ϕ((t0, tf), x0, p0_sol.x) # get the optimal trajectory
plot(sol) # plot
Expand Down Expand Up @@ -188,10 +204,9 @@ However, the solver $\texttt{hybrd1}$ uses rank 1 approximation to actualize the
```@example main
JS!(js, ξ) = (js[:] .= JS(ξ); nothing) # intermediate function
p0_sol = fsolve(S!, JS!, ξ, show_trace = true) # solve
println(p0_sol)
```

!!! Don't show the trace !!!

```@example main
sol = ϕ((t0, tf), x0, p0_sol.x) # get the optimal trajectory
plt = plot(sol) # plot
Expand Down Expand Up @@ -358,10 +373,9 @@ Shoot!(shoot, ξ) = (shoot[:] .= Shoot(ξ[1]); nothing) # intermediate fun
JShoot!(jshoot, ξ) = (jshoot[:] .= JShoot(ξ); nothing) # intermediate function
p0_sol = fsolve(Shoot!, JShoot!, ξ, show_trace = true) # solve
println(p0_sol)
```

!!! Don't show the trace !!!

```@example main
# get optimal trajectory
sol_ = φ((t0, tf), x0, p0_sol.x[1], saveat=range(t0, tf, 500))
Expand Down

0 comments on commit 1f3afa5

Please sign in to comment.