I am trying to solve stochastic delay differential equations in Julia. I was not successful in figuring out the Syntax from the manual, so I tried to run some examples. Running the example from here:
function hayes_modelf(du, u, h, p, t)
τ, a, b, c, α, β, γ = p
du .= a .* u .+ b .* h(p, t - τ) .+ c
end
function hayes_modelg(du, u, h, p, t)
τ, a, b, c, α, β, γ = p
du .= α .* u .+ γ
end
h(p, t) = (ones(1) .+ t);
tspan = (0.0, 10.0)
pmul = [1.0, -4.0, -2.0, 10.0, -1.3, -1.2, 1.1]
padd = [1.0, -4.0, -2.0, 10.0, -0.0, -0.0, 0.1]
prob = SDDEProblem(hayes_modelf, hayes_modelg, [1.0], h, tspan, pmul;
constant_lags = (pmul[1],));
sol = solve(prob, RKMil())
threw an error that confused me. Julia complains:
ERROR: LoadError: MethodError: no method matching default_algorithm(::SDDEProblem{Vector{Float64}, Tuple{Float64, Float64}, Tuple{Float64}, Tuple{}, true, Vector{Float64}, Nothing, SDDEFunction{true, SciMLBase.FullSpecialize, typeof(hayes_modelf), typeof(hayes_modelg), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, typeof(hayes_modelg), typeof(h), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing})
Closest candidates are:
default_algorithm(::SciMLBase.AbstractSDEProblem{uType, tType, isinplace, ND}; kwargs...) where {uType, tType, isinplace, ND}
@ DifferentialEquations ~/.julia/packages/DifferentialEquations/nHZ7l/src/sde_default_alg.jl:1
default_algorithm(::SciMLBase.AbstractDAEProblem{uType, duType, tType, isinplace}; kwargs...) where {uType, duType, tType, isinplace}
@ DifferentialEquations ~/.julia/packages/DifferentialEquations/nHZ7l/src/dae_default_alg.jl:1
default_algorithm(::SciMLBase.AbstractDDEProblem{uType, tType, lType, isinplace}; kwargs...) where {uType, tType, lType, isinplace}
@ DifferentialEquations ~/.julia/packages/DifferentialEquations/nHZ7l/src/dde_default_alg.jl:1
...
My code is prefaced with using DifferentialEquations
and solving DDEs and ODEs works as expected.
What I can gather from this is the following: The solve function expects a different kind of object as the problem, my prob is an SDDEProblem but it expects something like a SciMLBse.AbstractSDEProblem(?)
I am unsure if I am missing something or if I should open an issue on their GitHub. Any help would be greatly appreciated!
I tried to solve a SDDE using the DifferentialEquations.jl library in Julia. Since I am just running an example I expected the solve() function to return an array of elements that approximate the actual solution to the Hayes-model (or one particular realization of it, to be more precise).
Instead of returning that, Julia complains about the format of the prob object. I do not understand why, since I am just running an example.
This is because you need a different package for the delayed differential equations. using StochasticDelayDiffEq
should do the trick.