问题描述
我需要求解一个微分方程组,并且我有一个返回dx / dt和du / dt的函数,但是我需要添加u在区间[0,1]中的约束。我怎样才能做到这一点?到目前为止,我一直在使用scipy.integrate的odeint来解决它。这是模型:
def model_case_1(z,t,Kmax):
'''The input z corresponds to the current state of the system,z = [x,u,m]
(x is the population,u is the resistance rate and m whether there is treatment or not).
t is the current time.
Kmax corresponds to the unkNown parameter.
'''
x,u= z
if t>0:
m=1
else:
m=0
dxdt = x*(r*(1-x//(Kmax*(1-u)))-m//(k+b*u)-d)
dudt = sigma*(m*b//((k+b*u)**2)-r*x//(Kmax*(1-u)**2))
return [dxdt,dudt]
然后我估计Kmax并用以下公式求解ODE:
y = odeint(model_case_1,[x0,u0],teval,args=(Kmax0,))
但是,当然,我得到的u值大于1,这是不可能的。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)