I implement a very simple model with susceptible-infected recovery with a stable population for a project on the idle side - this is usually a fairly simple task. But I solve bugs using PysCeS or SciPy, both of which use lsoda as the main solver. This only happens for certain parameter values, and I don't understand why. The code I use is as follows:
import numpy as np from pylab import * import scipy.integrate as spi
This results in the following error:
lsoda-- at current t (=r1), mxstep (=i1) steps taken on this call before reaching tout In above message, I1 = 500 In above message, R1 = 0.7818108252072E+04 Excess work done on this call (perhaps wrong Dfun type). Run with full_output = 1 to get quantitative information.
Usually, when I encounter such a problem, there is something completely wrong with the system of equations that I set up, but I do not see anything wrong with that. Strange, this also works if you change mu to something like 1/15550 . In case something is wrong with the system, I also implemented the model in R as follows:
require(deSolve) sir.model <- function (t, x, params) { S <- x[1] I <- x[2] R <- x[3] with ( as.list(params), { dS <- -beta*S*I/(S+I+R) - mu*S + mu*(S+I+R) dI <- beta*S*I/(S+I+R) - gamma*I - mu*I dR <- gamma*I - mu*R res <- c(dS,dI,dR) list(res) } ) } times <- seq(0,15000,by=1) params <- c( beta <- 0.50, gamma <- 1/10, mu <- 1/25550 ) xstart <- c(S = 99, I = 1, R= 0) out <- as.data.frame(lsoda(xstart,times,sir.model,params))
It also uses lsoda, but it seems to go away without a hitch. Can anyone understand what is going on in Python code?
Fomite
source share