It seems the implementation of `ode23` in Julia is still too basic, so 
there isn't a way of passing the parameters through to the function.

In Julia 0.4 you will be able to make a type that behaves like a function 
which can store its own parameters to get round this problem.

There is also the Sundials.jl package which has more sophisticated solvers, 
as far as I understand.

Here is a slightly revised version of the code. I changed the definition of 
N to include R -- is that correct?

using ODE

function SIR(t, x, p)
    
    S, I, R = x 
    β, γ = p
    N = S + I + R
    
    dS = -β*S*I/N
    dI = β*S*I/N - γ*I
    dR = γ*I
    
    [dS,dI,dR]
end

# Initialise model
tspan = linspace(0,500,101)
x0 = Float64[9999, 1, 0]
params = [0.1, 0.05]

# Run model
tout, yout = ode23( (t, x) -> SIR(t, x, params), x0, tspan)
 

Reply via email to