SciML’s documentation suggests that the boundary value problem solvers Shooting() and MultipleShooting() should be able to use any of the NonlinearSolve.jl algorithms, but I haven’t been able to find a way to specify the nonlinear solver algorithm that doesn’t result in an error. Any suggestions?
Can you share the code you tried and the full error message?
The argument is nlsolve, i.e. Shooting(nlsolve = TrustRegion()).
But the bigger thing is, what is the error?
Here is a MWE, as usual based on SciML’s SimplePendulum example problem:
using BoundaryValueDiffEq
using Plots
using OrdinaryDiffEq
using NonlinearSolve #added to original example problem
const g = 9.81
L = 1.0
tspan = (0.0, pi / 2)
function simplependulum!(du, u, p, t)
θ = u[1]
dθ = u[2]
du[1] = dθ
du[2] = -(g / L) * sin(θ)
end
u₀_2 = [-1.6, -1.7] # the initial guess
function bc3!(residual, sol, p, t)
residual[1] = sol(pi / 4)[1] + pi / 2 # use the interpolation here, since indexing will be wrong for adaptive methods
residual[2] = sol(pi / 2)[1] - pi / 2
end
bvp3 = BVProblem(simplependulum!, bc3!, u₀_2, tspan)
sol3 = solve(bvp3, Shooting(Tsit5()); nlsolve = TrustRegion()) #modified from original example problem. Using Tsit5 rather than Vern7 and added nsolve = TrustRegion() per email from CR
plot(sol3)
And here is the error message:
ERROR: Unrecognized keyword arguments found.
The only allowed keyword arguments to `solve` are:
(:dense, :saveat, :save_idxs, :tstops, :tspan, :d_discontinuities, :save_everystep, :save_on, :save_start, :save_end, :initialize_save, :adaptive, :abstol, :reltol, :dt, :dtmax, :dtmin, :force_dtmin, :internalnorm, :controller, :gamma, :beta1, :beta2, :qmax, :qmin, :qsteady_min, :qsteady_max, :qoldinit, :failfactor, :calck, :alias_u0, :maxiters, :maxtime, :callback, :isoutofdomain, :unstable_check, :verbose, :merge_callbacks, :progress, :progress_steps, :progress_name, :progress_message, :progress_id, :timeseries_errors, :dense_errors, :weak_timeseries_errors, :weak_dense_errors, :wrap, :calculate_error, :initializealg, :alg, :save_noise, :delta, :seed, :alg_hints, :kwargshandle, :trajectories, :batch_size, :sensealg, :advance_to_tstop, :stop_at_next_tstop, :u0, :p, :default_set, :second_time, :prob_choice, :alias_jump, :alias_noise, :batch, :nlsolve_kwargs, :odesolve_kwargs, :linsolve_kwargs, :ensemblealg, :show_trace, :trace_level, :store_trace, :termination_condition, :alias, :fit_parameters)
See https://diffeq.sciml.ai/stable/basics/common_solver_opts/ for more details.
Unrecognized keyword arguments: [:nlsolve]
Some of the types have been truncated in the stacktrace for improved reading. To emit complete information
in the stack trace, evaluate `TruncatedStacktraces.VERBOSE[] = true` and re-run the code.
Stacktrace:
[1] #checkkwargs#51
@ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1240 [inlined]
[2] checkkwargs
@ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1237 [inlined]
[3] #solve_call#36
@ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:646 [inlined]
[4] solve_call
@ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:627 [inlined]
[5] #solve_up#45
@ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1205 [inlined]
[6] solve_up
@ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1183 [inlined]
[7] solve(prob::BVProblem{…}, args::Shooting{…}; sensealg::Nothing, u0::Nothing, p::Nothing, wrap::Val{…}, kwargs::@Kwargs{…})
@ DiffEqBase C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1096
[8] top-level scope
I had assumed that my code was at fault, but from what Chris wrote it looks like that maybe isn’t the case.
@ThermionicsGuy The solver shoud be Shooting(Tsit5(), nlsolve = TrustRegion())
YES! That works. Thank you very much.