Boundary Value Problem Incompatible With Ensemble Simulations

Hi all,

I have a boundary value differential equation that I would like to solve, and it has a random coefficient. I would like to be able to use the Ensemble Simulation functionality documented here, as I have with initial value problems in the past. However, when I try to use this with a BVP, I get the following stacktrace:

ERROR: MethodError: no method matching __solve(::EnsembleProblem{BVProblem{Vector{Float64}, Tuple{Int64, Float64}, true, Vector{Float64}, ODEFunction{true, typeof(ode!), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, typeof(bc!), SciMLBase.StandardBVProblem, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, typeof(prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, ::GeneralMIRK4; trajectories=10)
Closest candidates are:
  __solve(::BVProblem, ::Union{BoundaryValueDiffEq.GeneralMIRK, BoundaryValueDiffEq.MIRK}; dt, kwargs...) at ~/.julia/packages/BoundaryValueDiffEq/xfc07/src/solve.jl:26
  __solve(::SciMLBase.AbstractEnsembleProblem, ::Union{Nothing, SciMLBase.DEAlgorithm}; kwargs...) at ~/.julia/packages/SciMLBase/BoNUy/src/ensemble/basic_ensemble_solve.jl:50
  __solve(::SciMLBase.AbstractEnsembleProblem, ::Union{Nothing, SciMLBase.DEAlgorithm}, ::SciMLBase.BasicEnsembleAlgorithm; trajectories, batch_size, pmap_batch_size, kwargs...) at ~/.julia/packages/SciMLBase/BoNUy/src/ensemble/basic_ensemble_solve.jl:97
  ...
Stacktrace:
 [1] solve(prob::EnsembleProblem{BVProblem{Vector{Float64}, Tuple{Int64, Float64}, true, Vector{Float64}, ODEFunction{true, typeof(ode!), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, typeof(bc!), SciMLBase.StandardBVProblem, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, typeof(prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, args::GeneralMIRK4; kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:trajectories,), Tuple{Int64}}})
   @ DiffEqBase ~/.julia/packages/DiffEqBase/bMXa3/src/solve.jl:101
 [2] top-level scope
   @ ~/Desktop/BvpTest.jl:22

It appears to me that the issue is that the BVP solvers are not recognized as part of the SciMLBase DEAlgorithm ecosystem. It is worth noting that there is a comment in this script that seems to indicate that this is in the process of getting fixed, but I want to make sure that I am not missing something.

Here is a MWE for the above error:

using BoundaryValueDiffEq, Random

function ode!(du, u, p, t)
    du[1] = u[2]
    du[2] = -p[1]*u[1]
end

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

function prob_func(prob, i, repeat)
    remake(prob, p = [rand()])
end

initial_guess = [0., 1.]
tspan = (0, pi/2)
p = [rand()]
bvp = BVProblem(ode!, bc!, initial_guess, tspan, p)
ensemble_prob = EnsembleProblem(bvp, prob_func = prob_func)
sim = solve(ensemble_prob, GeneralMIRK4(), trajectories = 10)

If anybody can shed light on if this is being worked on, or if I’ve been silly and missed something in my code, I would be greatly appreciative!

This is solved now: use the correct abstract algorithm by ChrisRackauckas · Pull Request #77 · SciML/BoundaryValueDiffEq.jl · GitHub

Thanks for the report!

1 Like