我正在尝试解决一个涉及具有7个方程的ODE系统的优化问题,以便在给定一组观察到的实验值的情况下估计10个常数。我试图使用与the one given in here类似的方法,但它会导致我遇到几个错误。有人有任何暗示吗?
#ODE system (the k's are my constants to estimate):
dy0/dt = -((k1*y0*y1)/(1+k2*y1+k3*y2))-((k5*y3*y1)/(1+k6*y1))
dy1/dt = (k1*y0*y1)/(1+k2*y1+k3*y2) - k4*y0
dy2/dt = (k1*y0*y1)/(1+k2*y1+k3*y2)
dy3/dt = (k5*y3*y1)/(1+k6*y1) - k7*y3
dy4/dt = (k5*y3*y1)/(1+k6*y1)
dy5/dt = (k8*y4*y2)/(1+k9*y2) - k10*y4
dy6/dt = (k8*y4*y2)/(1+k9*y2)
#time where observatios were taken
dtime = [0,12,24,36,48,60]
#observations for each y:
y0 = [100., 92.5, 63.75, 28.75, 13.33, 7.91]
y1 = [1., 5.416, 18.333, 23.75, 13.75, 6.666]
y2 = [1., 6.666, 9.166, 59.166, 60., 36.666]
y3 = [.0,.0,.0,.0,.0,.0]
y4 = [1.,1.,1.,1.,1.,1.]
y5 = [1.,2.0833,3.75,7.083,13.75,27.9166]
y6 = [1.,2.9166,5.384615,14.166,28.333,57.5]
版:
关于我首先提到的错误,我已修复它们,直到达到这一点:
y() takes exactly 3 arguments (8 given)
到目前为止,我所拥有的代码是(我必须为我确定包含的所有错误道歉,我一周前才开始使用Python):
import numpy as np
from scipy.integrate import odeint
from scipy.optimize import curve_fit
def f(y, t, params):
y0, y1, y2, y3, y4, y5, y6 = y
k1,k2,k3,k4,k5,k6,k7,k8,k9,k10 = params
derivs = [-((k1*y0*y1)/(1+k2*y1+k3*y2))-((k5*y3*y1)/(1+k6*y1)),
(k1*y0*y1)/(1+k2*y1+k3*y2) - k4*y0,
(k1*y0*y1)/(1+k2*y1+k3*y2),
(k5*y3*y1)/(1+k6*y1) - k7*y3,
(k5*y3*y1)/(1+k6*y1),
(k8*y4*y2)/(1+k9*y2) - k10*y4,
(k8*y4*y2)/(1+k9*y2)]
return derivs
def y(t, params, y0):
y = odeint(f, y0, t, args=(params))
return y.ravel()