DiffEqDocs.jl icon indicating copy to clipboard operation
DiffEqDocs.jl copied to clipboard

Problem with SDE example

Open yezhengkai opened this issue 3 years ago • 1 comments

When I run the following code snippet in REPL, a MethodError occurs.

using DifferentialEquations
α=1
β=1
u₀=1/2
f(u,p,t) = α*u
g(u,p,t) = β*u
f_analytic(u₀,p,t,W) = u₀*exp((α-(β^2)/2)*t+β*W)
ff = SDEFunction(f,g,analytic=f_analytic)
prob = SDEProblem(ff,g,u₀,(0.0,1.0))
ensembleprob = EnsembleProblem(prob)
sol = solve(ensembleprob,EnsembleThreads(),trajectories=1000)
ERROR: MethodError: no method matching __solve(::EnsembleProblem{SDEProblem{Float64,Tuple{Float64,Float64},false,SciMLBase.NullParameters,Nothing,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},typeof(f_analytic),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Nothing},typeof(SciMLBase.DEFAULT_PROB_FUNC),typeof(SciMLBase.DEFAULT_OUTPUT_FUNC),typeof(SciMLBase.DEFAULT_REDUCTION),Nothing}, ::EnsembleThreads; trajectories=1000)
Closest candidates are:
  __solve(::SciMLBase.AbstractEnsembleProblem, ::Union{Nothing, SciMLBase.DEAlgorithm}; kwargs...) at D:\Program_Files_user\portable\julia-1.5.3\.julia\packages\SciMLBase\DrPil\src\ensemble\basic_ensemble_solve.jl:50
  __solve(::SciMLBase.AbstractEnsembleProblem, ::Union{Nothing, SciMLBase.DEAlgorithm}, ::SciMLBase.BasicEnsembleAlgorithm; trajectories, batch_size, pmap_batch_size, kwargs...) at D:\Program_Files_user\portable\julia-1.5.3\.julia\packages\SciMLBase\DrPil\src\ensemble\basic_ensemble_solve.jl:97
  __solve(::SciMLBase.AbstractNoiseProblem, ::Any...; dt, kwargs...) at D:\Program_Files_user\portable\julia-1.5.3\.julia\packages\DiffEqNoiseProcess\3EzjL\src\solve.jl:1
  ...
Stacktrace:
 [1] solve(::EnsembleProblem{SDEProblem{Float64,Tuple{Float64,Float64},false,SciMLBase.NullParameters,Nothing,SDEFunction{false,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},typeof(f_analytic),Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Nothing},typeof(SciMLBase.DEFAULT_PROB_FUNC),typeof(SciMLBase.DEFAULT_OUTPUT_FUNC),typeof(SciMLBase.DEFAULT_REDUCTION),Nothing}, ::EnsembleThreads; kwargs::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:trajectories,),Tuple{Int64}}}) at D:\Program_Files_user\portable\julia-1.5.3\.julia\packages\DiffEqBase\krS36\src\solve.jl:96
 [2] top-level scope at REPL[11]:1

The documentation of the "Ensemble Simulations" may be out-of-date. https://github.com/SciML/DiffEqDocs.jl/blob/5fac611774039631dac585aee7b640a6b9fc5053/docs/src/tutorials/sde_example.md#L121-L123 To solve EnsembleProblem by solve the second argument should be Solver/nothing. For example, sol = solve(ensembleprob,SRIW1(),EnsembleThreads(),trajectories=1000) works fine.

yezhengkai avatar Mar 08 '21 06:03 yezhengkai

yeah that should get the solver

ChrisRackauckas avatar Mar 08 '21 06:03 ChrisRackauckas

All examples are updated and tested, so this should be good now.

ChrisRackauckas avatar Dec 10 '22 09:12 ChrisRackauckas