-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polynomial Library Error #233
Comments
I wonder if it's a similar problem to this? In which case, I guess I have to find the linear dependence and rework the equations, will try that (if there's a program that would do both of those things at once for me, please let me know) Edit: I checked the rank, and it's coming up with 4 still, so maybe it's not that. |
Could you plot the fit of x_dot of your testing data? My guess is that x_dot is being fit very well, but then the integrator tries to integrate the SINDy model and goes unstable. This is a common issue, and generic polynomial SINDy models will usually be unstable in some regime. |
I'm not sure how to plot the fit if the simulation doesn't work, sorry if I'm missing something. I was working from here: Do you mean the threshold scan? If so, it works for between 0-1, but when I try to see it more finely grained, I get the same error. I could get it to work by taking out column 2 and reworking the equations though. The equations SINDy gives are not the same ones I have written, but the fit is good with degree 2, then. |
|
For STLSQ degree = 3:
then in the terminal Or I can have a go with scipy for integration tomorrow... |
If I'm understanding what you are doing, you are trying to simulate a DAE with the PySINDy functionality model.simulate (a wrapper for scipy.solve_ivp). Scipy does not handle DAEs and will give you the kind of strange and unclear messages you are now receiving. You will need to take the SINDy raw coefficient matrix and convert this into something that diffeqpy can understand as a DAE. There is an example in the Jupyter Notebook Example 9 using SymPy to handle DAEs. Regarding my last suggestion, I am saying you can plot the fit on x_dot (not on x!). In other words, model.fit(...) is working but the error you are seeing is model.simulate(...) which generates a trajectory from your model. But model.predict(...) will give you the x_dot trajectory, which can be compared visually. This is the actual thing that is being regressed on in the SINDy optimization, so it should be fitting your data to some reasonable extent. |
Thanks, I see now. Yeah, I can get it to give the right x_dot, and I can put it back into the right form to just rerun the equation. I'm not sure if it actually counts as a DAE anymore, since I lowered the order, the constraints are gone, and I removed some of the equations. But maybe there's something about the simplified equations that is still difficult for scipy solve. |
If this is not a DAE, the other obvious error that could be coming from model.simulate is if the system or numerical solver is going unstable. This is almost certainly happening with your complex system of equations because small errors in the model can cause instability. Generic polynomial models are not guaranteed to be stable. Try enforcing stability with constraints (Issue #157 has a long discussion for quadratic systems) or increasing the amount of sparsity promotion. |
Thanks! I will try it. This thread is really helpful, I wanted to look at constraints anyway, since there's many parts of this model that will already be known. |
I'm having trouble getting started with SINDy, please let me know if there is a better place to ask questions than here.
I can't get SINDy to fit my model well. If I use PolynomialLibrary, depending on the setting (degree>3) I get an ill conditioned matrix warning, then when I try to simulate, I get:
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
capi_return is NULL
Call-back cb_f_in_lsoda__user__routines failed.
When degree = 2, I just get the second error.
What might be going wrong?
The text was updated successfully, but these errors were encountered: