I’m trying to solve an ODE system in Julia for the first time and I’ve encountered an error that I don’t understand. I’m just trying to solve a simple SEIR model with some arbitrary parameter values and initial conditions. Here’s my code:
using DifferentialEquations
function SEIR(t,y,pars)
β, σ, M = pars
S, E, I, R = y
dS = -β*S*I
dE = β*S*I - σ*E
dI = σ*E - M*I
dR = M*I
return dS, dE, dI, dR
end
#Initial Conditions: S(0) = 0.950, E(0) = 0.0125, I(0) = 0.0125, R(0) = 0.0250
#tspan = [0,5.0]
#Parameters: β = 0.20, σ = 0.25, M = 0.23
prob = ODEProblem(g = SEIR, u0 = (0.950, 0.0125, 0.0125, 0.0250), tspan = (0.0,5.0), parameters = (0.2, 0.25, 0.23))
sol = solve(prob, Tsit5(),reltol = 1e-8, abstol = 1e-8)
This is giving the following error:
ERROR: LoadError: MethodError: no method matching ODEProblem(; sys=SEIR, u0map=(0.95, 0.0125, 0.0125, 0.025), tspan=(0.0, 5.0), parammap=(0.2, 0.25, 0.23))
Closest candidates are:
ODEProblem(::DiffEqBase.AbstractODEFunction, ::Any, ::Any, ::Any...; kwargs...) at C:\Users\Michael\.julia\packages\DiffEqBase\elwdl\src\problems\ode_problems.jl:71
ODEProblem(::ModelingToolkit.AbstractODESystem, ::Any...; kwargs...) at C:\Users\Michael\.julia\packages\ModelingToolkit\v15TO\src\systems\diffeqs\abstractodesystem.jl:238
ODEProblem(::ReactionSystem, ::Union{Number, AbstractArray}, ::Any) at C:\Users\Michael\.julia\packages\ModelingToolkit\v15TO\src\systems\reaction\reactionsystem.jl:489 got unsupported keyword arguments "sys", "u0map", "tspan", "parammap"
It looks like it doesn’t recognize ODEProblem
, but I’m just going by this tutorial: Ordinary Differential Equations · DifferentialEquations.jl. Is my syntax wrong? Or is there some other package I need to install?