You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are now in position to solve the problem with the `hybrj` solver from MINPACK.jl through the `fsolve`
384
-
function, providing the Jacobian. Let us do some benchmarking.
385
-
386
-
```@example main
387
-
@benchmark fsolve(nle!, jnle!, ξ; show_trace=false) # initial guess given to the solver
388
-
```
389
-
390
-
We can also use the [preparation step](https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface/stable/tutorial1/#Preparing-for-multiple-gradients) of DifferentiationInterface.jl.
Copy file name to clipboardExpand all lines: docs/src/tutorial-iss.md
+12-70Lines changed: 12 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,11 +30,11 @@ Let us consider the following optimal control problem:
30
30
with $t_0 = 0$, $t_f = 1$, $x_0 = -1$, $x_f = 0$, $\alpha=1.5$ and $\forall\, t \in [t_0, t_f]$, $x(t) \in \R$.
31
31
32
32
```@example main
33
-
t0 = 0
34
-
tf = 1
35
-
x0 = -1
36
-
xf = 0
37
-
α = 1.5
33
+
const t0 = 0
34
+
const tf = 1
35
+
const x0 = -1
36
+
const xf = 0
37
+
const α = 1.5
38
38
ocp = @def begin
39
39
40
40
t ∈ [t0, tf], time
@@ -145,50 +145,17 @@ nothing # hide
145
145
146
146
## Resolution of the shooting equation
147
147
148
-
At the end, solving (BVP) is equivalent to solve $S(p_0) = 0$. This is what we call the
149
-
**indirect simple shooting method**. We define an initial guess.
148
+
At the end, solving (BVP) is equivalent to solve $S(p_0) = 0$. This is what we call the **indirect simple shooting method**. We define an initial guess.
150
149
151
150
```@example main
152
-
ξ = [0.1] # initial guess
151
+
ξ = [0.1] # initial guess
153
152
nothing # hide
154
153
```
155
154
156
-
### NonlinearSolve.jl
157
-
158
-
We first use the [NonlinearSolve.jl](https://github.com/SciML/NonlinearSolve.jl) package to solve the shooting
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.
158
+
192
159
```@setup main
193
160
using MINPACK
194
161
function fsolve(f, j, x; kwargs...)
@@ -203,12 +170,6 @@ function fsolve(f, j, x; kwargs...)
203
170
end
204
171
```
205
172
206
-
Instead of the [NonlinearSolve.jl](https://github.com/SciML/NonlinearSolve.jl) package we can use the
207
-
[MINPACK.jl](https://github.com/sglyon/MINPACK.jl) package to solve
208
-
the shooting equation. To compute the Jacobian of the shooting function we use the
209
-
[DifferentiationInterface.jl](https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface) package with
We are now in position to solve the problem with the `hybrj` solver from MINPACK.jl through the `fsolve`
228
-
function, providing the Jacobian. Let us do some benchmarking.
229
-
230
-
```@example main
231
-
@benchmark fsolve(nle!, jnle!, ξ; show_trace=false) # initial guess given to the solver
232
-
```
233
-
234
-
We can also use the [preparation step](https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface/stable/tutorial1/#Preparing-for-multiple-gradients) of DifferentiationInterface.jl.
@@ -257,10 +204,7 @@ sol = φ((t0, tf), x0, p0_sol)
257
204
plot(sol)
258
205
```
259
206
260
-
In the indirect shooting method, the research of the optimal control is replaced by the computation
261
-
of its associated extremal. This computation is equivalent to finding the initial covector solution
262
-
to the shooting function. Let us plot the extremal in the phase space and the shooting function with
263
-
the solution.
207
+
In the indirect shooting method, the research of the optimal control is replaced by the computation of its associated extremal. This computation is equivalent to finding the initial covector solution to the shooting function. Let us plot the extremal in the phase space and the shooting function with the solution.
0 commit comments