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
Copy file name to clipboardExpand all lines: docs/src/tutorial-iss.md
+9-59Lines changed: 9 additions & 59 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
@@ -148,48 +148,13 @@ nothing # hide
148
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.
149
149
150
150
```@example main
151
-
ξ = [0.1] # initial guess
151
+
ξ = [0.1] # initial guess
152
152
nothing # hide
153
153
```
154
154
155
-
### NonlinearSolve.jl
156
-
157
-
We first use the [NonlinearSolve.jl](https://github.com/SciML/NonlinearSolve.jl) package to solve the shooting equation. Let us define the problem.
For small nonlinear systems, the [`SimpleNewtonRaphson()` descent algorithm](https://docs.sciml.ai/NonlinearSolve/stable/tutorials/code_optimization/) may be faster.
Instead of the[NonlinearSolve.jl](https://github.com/SciML/NonlinearSolve.jl) package we can use[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.
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.
We are now in position to solve the problem with the `hybrj` solver from MINPACK.jl through the `fsolve` function, providing the Jacobian. Let us do some benchmarking to compare the performance with the NonlinearSolve.jl package above.
224
-
225
-
```@example main
226
-
@benchmark fsolve(nle!, jnle!, ξ; show_trace=false) # initial guess given to the solver
227
-
```
228
-
229
-
We can also use the [preparation step](https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface/stable/tutorial1/#Preparing-for-multiple-gradients) of DifferentiationInterface.jl.
0 commit comments