dynamicslab / pysindy

A package for the sparse identification of nonlinear dynamical systems from data
https://pysindy.readthedocs.io/en/latest/
Other
1.36k stars 304 forks source link

how to constrain the parameter of a term #416

Closed penguinaugustus closed 9 months ago

penguinaugustus commented 9 months ago

Hi, I am utilizing SINDy to infer ODEs and constructing a library as follows:

  feature_names = ['m','p']
  tensor_array = [[1, 1]]
  optimizer = ps.MIOSR(target_sparsity=3)
  lib = ps.GeneralizedLibrary(
      libraries = [ps.PolynomialLibrary(degree = 1), ps.PolynomialLibrary(degree = polyorder)],
      inputs_per_library = np.array([[0,0],[1,1]]),
  )

  model = ps.SINDy(feature_names=feature_names, optimizer=optimizer,feature_library=lib)
  model.fit(x=m_evaluated, t=t, u=p)

That's to say the general form of my ODE is $dm/dt = A + Bm + Cp$. My background knowledge suggests that $B$ must be negative. Is there a way to impose this constraint within SINDy when setting up the fitting problem?

I came across this example, but it doesn’t seem to address my specific issue.

Thank you very much for your time!