BoundaryValueDiffEqShooting

Single shooting method and multiple shooting method. To only use the Shooting methods form BoundaryValueDiffEq.jl, you need to install them use the Julia package manager:

using Pkg
Pkg.add("BoundaryValueDiffEqShooting")

BoundaryValueDiffEqShooting reexports the problem constructors, solve and ReturnCode its documented workflow uses (see Reexported API); the ODE algorithm has to come from its own solver package:

using BoundaryValueDiffEqShooting
using OrdinaryDiffEqTsit5: Tsit5

function f!(du, u, p, t)
    du[1] = u[2]
    du[2] = 0
    return
end

function bc!(residual, u, p, t)
    residual[1] = u(0.0)[1] - 1
    residual[2] = u(1.0)[1]
    return
end

prob = BVProblem(f!, bc!, [1.0, -1.0], (0.0, 1.0); nlls = Val(false))
sol = solve(prob, Shooting(Tsit5()); abstol = 1.0e-8)

@assert sol.retcode == ReturnCode.Success
@assert isapprox(sol(0.0)[1], 1.0; atol = 1.0e-6)
@assert isapprox(sol(1.0)[1], 0.0; atol = 1.0e-6)
# output

Full List of Methods

  • Shooting: Single shooting methods, reduces BVP to an initial value problem and solves the IVP.
  • MultipleShooting: Reduces BVP to an initial value problem and solves the IVP. Significantly more stable than Single Shooting.

Detailed Solvers Explanation

BoundaryValueDiffEqShooting.ShootingType
Shooting(ode_alg; kwargs...)
Shooting(ode_alg, nlsolve; kwargs...)
Shooting(; ode_alg = nothing, nlsolve = nothing, optimize = nothing, jac_alg = nothing) -> Shooting

Configures the single-shooting algorithm for a boundary value problem. Single shooting integrates one initial value problem and solves for the initial condition that satisfies the boundary conditions.

Arguments

  • ode_alg: algorithm used to solve the internal SciMLBase.ODEProblem. Pass this as the first positional argument or keyword argument. nothing selects a loaded polyalgorithm; otherwise an ODE algorithm must be supplied.
  • nlsolve: nonlinear-solver algorithm for the shooting residual. Its autodiff setting is superseded by jac_alg when a Jacobian algorithm is materialized.

Keywords

  • ode_alg = nothing: ODE algorithm, as described above.
  • nlsolve = nothing: nonlinear-solver algorithm, as described above.
  • optimize = nothing: optimization-solver algorithm used when the selected BVP solve path formulates the residual as an optimization problem.
  • jac_alg = nothing: BVPJacobianAlgorithm configuration. When omitted, the constructor derives it from nlsolve and the problem during solve initialization. For single shooting, only its diffmode setting is used; the default is AutoForwardDiff when applicable and otherwise AutoFiniteDiff.

Fields

  • ode_alg: configured ODE algorithm or nothing.
  • nlsolve: configured nonlinear-solver algorithm or nothing.
  • optimize: configured optimization-solver algorithm or nothing.
  • jac_alg::BVPJacobianAlgorithm: materialized Jacobian-algorithm configuration.

Returns

  • Shooting: an algorithm object accepted by SciMLBase.solve for a boundary value problem.

Examples

using BoundaryValueDiffEqShooting: Shooting
using OrdinaryDiffEqTsit5: Tsit5

alg = Shooting(Tsit5())
@assert alg isa Shooting
# output
source
BoundaryValueDiffEqShooting.MultipleShootingType
MultipleShooting(;
        nshoots::Int, ode_alg = nothing, nlsolve = nothing,
        optimize = nothing, grid_coarsening = true, jac_alg = nothing
    ) -> MultipleShooting
MultipleShooting(nshoots::Int; kwargs...)
MultipleShooting(nshoots::Int, ode_alg; kwargs...)
MultipleShooting(nshoots::Int, ode_alg, nlsolve; kwargs...)

Configures the multiple-shooting algorithm for a boundary value problem. Multiple shooting integrates an IVP on nshoots subintervals and solves for their matching initial conditions; it is generally more stable than Shooting.

Arguments

  • nshoots::Int: number of shooting subintervals.
  • ode_alg: algorithm used to solve each internal SciMLBase.ODEProblem. Pass this as the second positional argument or keyword argument. nothing selects a loaded polyalgorithm; otherwise an ODE algorithm must be supplied.
  • nlsolve: nonlinear-solver algorithm for the multiple-shooting residual.

Keywords

  • ode_alg = nothing: ODE algorithm, as described above.

  • nlsolve = nothing: nonlinear-solver algorithm, as described above.

  • optimize = nothing: optimization-solver algorithm used when the selected BVP solve path formulates the residual as an optimization problem.

  • jac_alg = nothing: BVPJacobianAlgorithm configuration. When omitted, the constructor derives it from nlsolve and the problem during solve initialization.

    • For TwoPointBVProblem, only diffmode is used (defaults to AutoSparse(AutoForwardDiff()) if possible else AutoSparse(AutoFiniteDiff())).
    • For BVProblem, bc_diffmode and nonbc_diffmode are used. For nonbc_diffmode we default to AutoSparse(AutoForwardDiff()) if possible else AutoSparse(AutoFiniteDiff()). For bc_diffmode, we default to AutoForwardDiff if possible else AutoFiniteDiff.
  • grid_coarsening = true: coarsens the multiple-shooting grid while generating a stable IVP solution. Supported values are:

    • true: Halve the grid size, till we reach a grid size of 1.
    • false: Do not coarsen the grid. Solve a Multiple Shooting Problem and finally solve a Single Shooting Problem.
    • AbstractVector{<:Int} or Ntuple{N, <:Integer}: Use the provided grid coarsening. For example, if nshoots = 10 and grid_coarsening = [5, 2], then the grid will be coarsened to [5, 2]. Note that 1 should not be present in the grid coarsening.
    • Function: Takes the current number of shooting points and returns the next number of shooting points. For example, if nshoots = 10 and grid_coarsening = n -> n ÷ 2, then the grid will be coarsened to [5, 2].
  • platform = CPU(): KernelAbstractions backend used to evaluate the per-interval internal ODE solves when the internal ensemblealg is EnsembleThreads (the default). Currently only the CPU backend is supported, since the internal solves run through the standard ODE integrator interface.

Fields

  • ode_alg: configured ODE algorithm or nothing.
  • nlsolve: configured nonlinear-solver algorithm or nothing.
  • optimize: configured optimization-solver algorithm or nothing.
  • jac_alg::BVPJacobianAlgorithm: materialized Jacobian-algorithm configuration.
  • platform: KernelAbstractions backend used for the internal ODE solves.
  • nshoots::Int: configured number of shooting subintervals.
  • grid_coarsening: configured grid-coarsening strategy.

Returns

  • MultipleShooting: an algorithm object accepted by SciMLBase.solve for a boundary value problem.

Examples

using BoundaryValueDiffEqShooting: MultipleShooting
using OrdinaryDiffEqTsit5: Tsit5

alg = MultipleShooting(8, Tsit5(); grid_coarsening = true)
@assert alg isa MultipleShooting
# output
source