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
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
In this tutorial we present the indirect simple shooting method on a simple example.
8
4
9
5
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
167
163
168
164
```@setup main-iss
169
165
using MINPACK
166
+
using NonlinearSolve # interface to NLE solvers
167
+
struct MYSOL
168
+
x::Vector{Float64}
169
+
end
170
170
function fsolve(f, j, x; kwargs...)
171
171
try
172
172
MINPACK.fsolve(f, j, x; kwargs...)
173
173
catch e
174
174
println("Error using MINPACK")
175
175
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))
0 commit comments