Skip to content

Commit 4500e37

Browse files
committed
Remove draft meta and improve MINPACK error handling
- Remove @meta Draft = false block - Use NonlinearSolve with SimpleNewtonRaphson as fallback when MINPACK hybrj is not supported - Add MYSOL struct to handle return value compatibility
1 parent 00d8045 commit 4500e37

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

docs/src/tutorial-iss.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# [Indirect simple shooting](@id tutorial-indirect-simple-shooting)
22

3-
```@meta
4-
Draft = false
5-
```
6-
73
In this tutorial we present the indirect simple shooting method on a simple example.
84

95
Let us start by importing the necessary packages. We import the [OptimalControl.jl](https://control-toolbox.org/OptimalControl.jl) package to define the optimal control problem. We import the [Plots.jl](https://docs.juliaplots.org) package to plot the solution. The [OrdinaryDiffEq.jl](https://docs.sciml.ai/OrdinaryDiffEq) package is used as the ODE solver backend by the Flow function from OptimalControl.jl and the [MINPACK.jl](https://github.com/sglyon/MINPACK.jl) package permits to solve the shooting equation.
@@ -167,14 +163,21 @@ We can use the [MINPACK.jl](https://github.com/sglyon/MINPACK.jl) to solve the s
167163

168164
```@setup main-iss
169165
using MINPACK
166+
using NonlinearSolve # interface to NLE solvers
167+
struct MYSOL
168+
x::Vector{Float64}
169+
end
170170
function fsolve(f, j, x; kwargs...)
171171
try
172172
MINPACK.fsolve(f, j, x; kwargs...)
173173
catch e
174174
println("Error using MINPACK")
175175
println(e)
176-
println("hybrj not supported. Replaced by hybrd even if it is not visible on the doc.")
177-
MINPACK.fsolve(f, x; kwargs...)
176+
println("hybrj not supported. Replaced by NonlinearSolve even if it is not visible on the doc.")
177+
nle! = (s, ξ, λ) -> f(s, ξ)
178+
prob = NonlinearProblem(nle!, ξ)
179+
sol = solve(prob, SimpleNewtonRaphson(); abstol=1e-8, reltol=1e-8, show_trace=Val(true))
180+
return MYSOL(sol.u)
178181
end
179182
end
180183
```

0 commit comments

Comments
 (0)