You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am having some trouble using SINDy-PI. I used the following system of equations to generate data. I conducted 10 runs of this system of ODEs with different initial conditions
After generating data from these 10 runs, my goal is to use SINDy-PI to recover the equations mentioned earlier. Below is the code utilized to achieve this task.
Reproducing code example:
importnumpyasnpfromscipy.integrateimportsolve_ivpimportmatplotlib.pyplotaspltimportpysindyaspsimportrandom"""Data generation"""nbdata=10# Parameters for CHO growth modelmumax=0.035# h^-1Klysis=4*10**(-2) # h^-1Yxg=9.23*10**7# cell/mmolmg=8*10**(-13) # mmol/cell*h 1.1*10**(-14)Ylg=1.6# ///Kg=1# mMKl=150# mMkdmax=0.01# h^-1kmu=0.01# h^-1parameter_cell_growth=(mumax, Klysis, Yxg, mg, Ylg, Kg, Kl, kdmax, kmu)
defCHO_growth(t, z, mumax, Klysis, Yxg, mg, Ylg, Kg, Kl, kdmax, kmu):
Xv, Xd, G, L=zmu=mumax* (G/(Kg+G)) * (Kl/(Kl+L))
kd=kdmax* (kmu/(mu+kmu))
dXv= (mu-kd)*XvdXd=kd*Xv-Klysis*XddG= ((-mu/Yxg)-mg)*XvdL=-Ylg*((-mu/Yxg)-mg)*Xvreturn [ dXv, dXd, dG, dL]
#Timedt=1T=180t=np.arange(0, T+dt, dt)
t_span= (t[0], t[-1])
data=[]
timing=[]
foriinrange(nbdata):
Xvinit=random.uniform(1*10**8, 2*10**8)
Xdinit=random.uniform(5*10**5, 5*10**6)
Ginit=random.uniform(20, 35)
Linit=0CI=[Xvinit, Xdinit, Ginit, Linit]
sol=solve_ivp(CHO_growth, t_span, CI, t_eval=t, args=parameter_cell_growth, dense_output=True, method="Radau", max_step=1)
data.append(sol.y.T)
timing.append(sol.t)
"""SINDy-PI"""# Initialize custom SINDy library so that we can have x_dot inside it. library_functions= [
lambdax: x,
lambdax, y: x*y,
lambdax: x**2,
lambdax, y, z: x*y*z,
lambdax, y: x*y**2,
lambdax: x**3,
lambdax, y, z, w: x*y*z*w,
lambdax, y, z: x*y*z**2,
lambdax: x**4,
lambdax, y: x**3*y,
lambdax, y: x**2*y**2,
lambdax, y: x*y**3,
]
# library function names includes both # the x_library_functions and x_dot_library_functions namesx_dot_library_functions= [lambdax: x]
function_names= [
lambdax: x,
lambdax, y: x+y,
lambdax: x+x,
lambdax, y, z: x+y+z,
lambdax, y: x+y+y,
lambdax: x+x+x,
lambdax, y, z, w: x+y+z+w,
lambdax, y, z: x+y+z+z,
lambdax: x+x+x+x,
lambdax, y: x+x+x+y,
lambdax, y: x+x+y+y,
lambdax, y: x+y+y+y,
lambdax: x,
]
# Need to pass time base to the library so can build the x_dot library from xsindy_library=ps.SINDyPILibrary(
library_functions=library_functions,
x_dot_library_functions=x_dot_library_functions,
t=t,
function_names=function_names,
include_bias=False,
)
# I specify some index for the submodel [Xv, Xd, G, L, Xv_dot, Xd_dot, G_dot, L_dot]sindy_opt=ps.SINDyPI(model_subset=[0,1,2,3,55,56,57,58],threshold=0.001,max_iter=200000,normalize_columns=True,tol=1*10**(-8))
model=ps.SINDy(
optimizer=sindy_opt,
feature_library=sindy_library,
differentiation_method=ps.FiniteDifference(drop_endpoints=True),
feature_names=["Xv", "Xd", "G", "L"],
)
model.fit(data, t=timing, multiple_trajectories=True)
model.print()
Error message:
My issue lies in SINDy's failure to retrieve my original equations. I acknowledge that some parameters are very close to zero, which may contribute to the problem. However, it also fails to identify a model that closely resembles the equations mentioned earlier. The results obtained from the code are as follows:
And if I set the SINDy-PI optimizer flag normalize_columns to False the solver fail and set all the coef to 0.
I attempted to address the issue by reducing the order of my library, starting from a polynomial order of 6 and progressively lowering it to 4. However, this adjustment does not seem to have resolved the problem.
I wanted to explore some examples of SINDy-PI usage, but I'm encountering challenges finding Python implementations for system of ODEs. Most available code examples are in MATLAB. Is there a particular reason I should consider using MATLAB code instead ?
PySINDy/Python version information:
PySINDy version : 1.7.5
Python version : 3.11.8
The text was updated successfully, but these errors were encountered:
Hello,
I am having some trouble using SINDy-PI. I used the following system of equations to generate data. I conducted 10 runs of this system of ODEs with different initial conditions
here is a plot of one of the runs :
After generating data from these 10 runs, my goal is to use SINDy-PI to recover the equations mentioned earlier. Below is the code utilized to achieve this task.
Reproducing code example:
Error message:
My issue lies in SINDy's failure to retrieve my original equations. I acknowledge that some parameters are very close to zero, which may contribute to the problem. However, it also fails to identify a model that closely resembles the equations mentioned earlier. The results obtained from the code are as follows:
Xv = -0.011 G_dot + 0.007 L_dot
Xd = 0.000
G = -0.004 G_dot + 0.002 L_dot
L = 0.000
Xv_dot = -0.046 G_dot + 0.029 L_dot
Xd_dot = -0.002 G_dot + 0.001 L_dot
G_dot = -0.060 L_dot
L_dot = -0.097 G_dot
And if I set the SINDy-PI optimizer flag normalize_columns to False the solver fail and set all the coef to 0.
I attempted to address the issue by reducing the order of my library, starting from a polynomial order of 6 and progressively lowering it to 4. However, this adjustment does not seem to have resolved the problem.
I wanted to explore some examples of SINDy-PI usage, but I'm encountering challenges finding Python implementations for system of ODEs. Most available code examples are in MATLAB. Is there a particular reason I should consider using MATLAB code instead ?
PySINDy/Python version information:
PySINDy version : 1.7.5
Python version : 3.11.8
The text was updated successfully, but these errors were encountered: