|
37 | 37 | nothing # hide
|
38 | 38 | ```
|
39 | 39 |
|
| 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 | + |
40 | 57 | Thanks to the control-toolbox, the flow $\varphi$ of the (true) Hamiltonian
|
41 | 58 |
|
42 | 59 | ```math
|
@@ -72,10 +89,9 @@ The main goal now is to find the zero of $S$. To this purpose, we use the numeri
|
72 | 89 | ξ = [-1.0] # initial guess
|
73 | 90 | S!(s, ξ) = (s[:] .= S(ξ[1]); nothing) # intermediate function
|
74 | 91 | p0_sol = fsolve(S!, ξ, show_trace = true) # solve
|
| 92 | +println(p0_sol) |
75 | 93 | ```
|
76 | 94 |
|
77 |
| -!!! Don't show the trace !!! |
78 |
| - |
79 | 95 | ```@example main
|
80 | 96 | sol = ϕ((t0, tf), x0, p0_sol.x) # get the optimal trajectory
|
81 | 97 | plot(sol) # plot
|
@@ -188,10 +204,9 @@ However, the solver $\texttt{hybrd1}$ uses rank 1 approximation to actualize the
|
188 | 204 | ```@example main
|
189 | 205 | JS!(js, ξ) = (js[:] .= JS(ξ); nothing) # intermediate function
|
190 | 206 | p0_sol = fsolve(S!, JS!, ξ, show_trace = true) # solve
|
| 207 | +println(p0_sol) |
191 | 208 | ```
|
192 | 209 |
|
193 |
| -!!! Don't show the trace !!! |
194 |
| - |
195 | 210 | ```@example main
|
196 | 211 | sol = ϕ((t0, tf), x0, p0_sol.x) # get the optimal trajectory
|
197 | 212 | plt = plot(sol) # plot
|
@@ -358,10 +373,9 @@ Shoot!(shoot, ξ) = (shoot[:] .= Shoot(ξ[1]); nothing) # intermediate fun
|
358 | 373 | JShoot!(jshoot, ξ) = (jshoot[:] .= JShoot(ξ); nothing) # intermediate function
|
359 | 374 |
|
360 | 375 | p0_sol = fsolve(Shoot!, JShoot!, ξ, show_trace = true) # solve
|
| 376 | +println(p0_sol) |
361 | 377 | ```
|
362 | 378 |
|
363 |
| -!!! Don't show the trace !!! |
364 |
| - |
365 | 379 | ```@example main
|
366 | 380 | # get optimal trajectory
|
367 | 381 | sol_ = φ((t0, tf), x0, p0_sol.x[1], saveat=range(t0, tf, 500))
|
|
0 commit comments