2

I am trying to solve an optimization problem that involves an ODE system with 7 equations, in order to estimate 10 constants given a set of observed experimental values. I have tried to use a similar approach as the one given in here, but it conducts me to several errors. Does anyone has any hint?

#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]

EDITION:

About the errors that I firstly mentioned, I have fixed them until I reach this point:

y() takes exactly 3 arguments (8 given)

So far, the code that I have is (I must apologize for all the errors that I am sure it contains, I just started using Python a week ago):

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()
Community
  • 1
  • 1
Mau
  • 131
  • 10
  • What are the "several errors"? Please list them. – Sabuncu Feb 18 '16 at 20:34
  • 1
    Check this out, I think this will make your live a whole lot easier: http://symfit.readthedocs.io/en/latest/fitting_types.html#ode-fitting – tBuLi Oct 23 '16 at 17:15

0 Answers0