SciML / StochasticDelayDiffEq.jl

Stochastic delay differential equations (SDDE) solvers for the SciML scientific machine learning ecosystem
MIT License
25 stars 10 forks source link

Compatibility with WorkPrecisionSet #23

Closed maedoc closed 4 years ago

maedoc commented 4 years ago

I copied the example from the strong order non stiff SDE notebook,

prob = remake(make_prob(),tspan=(0.0,1.0))
reltols = 1.0 ./ 10.0 .^ (1:5)
abstols = reltols#[0.0 for i in eachindex(reltols)]
setups = [Dict(:alg=>SRIW1())
          Dict(:alg=>EM(),:dts=>1.0./5.0.^((1:length(reltols)) .+ 1))
          #Dict(:alg=>RKMil(),:dts=>1.0./5.0.^((1:length(reltols)) .+ 1),:adaptive=>false)
          #Dict(:alg=>SRIW1(),:dts=>1.0./5.0.^((1:length(reltols)) .+ 1),:adaptive=>false)
          #Dict(:alg=>SRA1(),:dts=>1.0./5.0.^((1:length(reltols)) .+ 1),:adaptive=>false)
          #Dict(:alg=>SRA1())
          ]
names = ["SRIW1","EM"]#,"RKMil","SRIW1 Fixed","SRA1 Fixed","SRA1"]
wp = WorkPrecisionSet(prob,abstols,reltols,setups;numruns=10,names=names,maxiters=1e7,error_estimate=:l2)
plot(wp)

and get a complaint about no method for the cache,

julia> wp = WorkPrecisionSet(prob,abstols,reltols,setups;numruns=10,names=names,maxiters=1e7,error_estimate=:l2)
ERROR: MethodError: no method matching StochasticDiffEq.SRIW1Cache(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1})
Closest candidates are:
  StochasticDiffEq.SRIW1Cache(::var"#329#uType", ::var"#329#uType", ::var"#328#randType", ::var"#328#randType", ::var"#328#randType", ::var"#330#rateType", ::var"#330#rateType", ::var"#329#uType", ::var"#329#uType", ::var"#329#uType", ::var"#329#uType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#330#rateType", ::var"#329#uType") where {var"#328#randType", var"#329#uType", var"#330#rateType"} at /Users/duke/.julia/packages/StochasticDiffEq/QywSJ/src/caches/rossler_caches.jl:93
Stacktrace:
 [1] alg_cache(::SRIW1, ::SDDEProblem{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Tuple{Float64,Float64},Tuple{},Tuple{},true,kp,Nothing,SDDEFunction{true,typeof(kf),typeof(kg),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(kg),typeof(kh),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Nothing}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::kp, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Nothing, ::Type{T} where T, ::Type{T} where T, ::Type{T} where T, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::SDDEFunction{true,typeof(kf),typeof(kg),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, ::Float64, ::Float64, ::Type{Val{true}}) at /Users/duke/.julia/packages/StochasticDiffEq/QywSJ/src/caches/rossler_caches.jl:146
 [2] build_history_function(::SDDEProblem{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Tuple{Float64,Float64},Tuple{},Tuple{},true,kp,Nothing,SDDEFunction{true,typeof(kf),typeof(kg),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(kg),typeof(kh),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Nothing}, ::SRIW1, ::Float64, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Nothing, ::DiffEqNoiseProcess.NoiseProcess{Float64,2,Float64,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},1},typeof(DiffEqNoiseProcess.INPLACE_WHITE_NOISE_DIST),typeof(DiffEqNoiseProcess.INPLACE_WHITE_NOISE_BRIDGE),true,ResettableStacks.ResettableStack{Tuple{Float64,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},true},ResettableStacks.ResettableStack{Tuple{Float64,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},true},DiffEqNoiseProcess.RSWM{Float64},Nothing,RandomNumbers.Xorshifts.Xoroshiro128Plus}, ::UInt64, ::Bool; dt::Float64, adaptive::Bool, calck::Bool, internalnorm::Function) at /Users/duke/.julia/packages/StochasticDelayDiffEq/oh3Cs/src/utils.jl:175
...

This doesn't seem so surprising but I don't really know enough Julia to fix it yet.

A related conceptual question: is strong order being judged here by reusing the Brownian path of the reference solution?

maedoc commented 4 years ago

Actually, I have the same problem when trying to run a script outside the StochasticDelayDiffEq.jl package folder itself. In other words, I previously cloned this repo, did activate . and instantiate and then all was ok. Today I tried to make a new package and add StochasticDelayDiffEq but this produces the above no method found problem.

Is this just me not knowing enough about how to use Julia packages?

devmotion commented 4 years ago

In general it's difficult to tell without seeing your code. If you do not develop something in StochasticDelayDiffEq, the preferred way to work with it and to use it is to add StochasticDelayDiffEq to your environment.

maedoc commented 4 years ago

Thanks for the tip, in fact it seems the error was due to generating initial conditions with a step range (1:nn) which I didn't know needs to be collected before passing to the problem constructor.