我正在为一个闲置的项目实施一个非常简单的易感感染恢复模型,该模型具有稳定的人口——通常是一项非常微不足道的任务。但是我在使用 PysCeS 或 SciPy 时遇到了求解器错误,它们都使用 lsoda 作为其底层求解器。这只发生在参数的特定值上,我不知道为什么。我正在使用的代码如下:
import numpy as np
from pylab import *
import scipy.integrate as spi
#Parameter Values
S0 = 99.
I0 = 1.
R0 = 0.
N0 = S0 + I0 + R0
PopIn= (S0, I0, R0, N0)
beta= 0.50
gamma=1/10.
mu = 1/25550.
t_end = 15000.
t_start = 1.
t_step = 1.
t_interval = np.arange(t_start, t_end, t_step)
#Solving the differential equation. Solves over t for initial conditions PopIn
def eq_system(PopIn,t):
'''Defining SIR System of Equations'''
#Creating an array of equations
Eqs= np.zeros((3))
Eqs[0]= -beta * (PopIn[0]*PopIn[1]/PopIn[3]) - mu*PopIn[0] + mu*PopIn[3]
Eqs[1]= (beta * (PopIn[0]*PopIn[1]/PopIn[3]) - gamma*PopIn[1] - mu*PopIn[1])
Eqs[2]= gamma*PopIn[1] - mu*PopIn[2]
return Eqs
SIR = spi.odeint(eq_system, PopIn, t_interval)
这会产生一个错误:
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.7732042715460E+04
Excess work done on this call (perhaps wrong Dfun type).
Run with full_output = 1 to get quantitative information.
但是,将“mu”(目前是 1/70 年,一个相当常见的预期寿命值)更改为 26550 或 22550 不会产生此类错误,尽管 25550 和 22550 之间的某些值似乎会出现。
我对为什么这种组合特别会产生错误感到有些困惑。有人有一些见识吗?