dynamicslab / pysindy

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

state terms and control term feature libraries #375

Closed Fakasht10 closed 9 months ago

Fakasht10 commented 1 year ago

Is your feature request related to a problem? Please describe. I am trying to fit a system identification model using PySINDy where I want different feature libraries for the state variables and the control inputs. Specifically, I want to use a polynomial feature library for the state variables and a custom feature library for the control inputs. However, when I concatenate these two libraries and fit the model, I'm getting unwanted interaction terms between the state variables and control inputs in the derived model.

Describe the solution you'd like I would like to have an option in PySINDy to specify different feature libraries for the state variables and the control inputs and impose constraints such that the state variables and control inputs do not interact when the model is fitted. In other words, the model should only consider the features specified in the respective libraries for the state variables and control inputs without considering cross-interactions.

Describe alternatives you've considered I have tried manually specifying a custom feature library that only contains the desired features (state variable and control functions). However, this approach is less flexible and requires the user to manually specify all the desired features, which might not be practical for more complex models.

Additional context This feature would be particularly useful for system identification problems where the user has specific knowledge about the system and wants to impose certain constraints on the model structure. For example, in my case, I know that the state variable should only appear linearly and the control inputs should have specific interactions. Having this feature would allow users to incorporate their domain knowledge into the model fitting process more effectively.

Jacob-Stevens-Haas commented 1 year ago

GeneralizedLibrary is the solution here. It allows you to specify a list of libraries and use the inputs_per_library argument to tell it which features (indices of the combined x and u) are used in which library.

Take care to read the docs for the version of pysindy you're using. The current master branch changes the type for inputs_per_library to list of lists. See #306

Fakasht10 commented 1 year ago

Thank you for the reply, Jacob, I will try to figure it out. I am far from a Python expert, just been trying to figure out how to set up my problem with limited success. Would you be available for a consultation, I can pay you for consultation to help me set up my problem, I seem to be getting poor output compared to data and trying to make it not overfit the data and give physical results. Thank you. Aleksey

On Mon, Jul 24, 2023 at 4:59 PM Jacob Stevens-Haas @.***> wrote:

GeneralizedLibrary is the solution here. It allows you to specify a list of libraries and use the inputs_per_library argument to tell it which features (indices of the combined x and u) are used in which library.

Take care to read the docs for the version of pysindy you're using. The current master branch changes the type for inputs_per_library to list of lists. See #306 https://github.com/dynamicslab/pysindy/issues/306

— Reply to this email directly, view it on GitHub https://github.com/dynamicslab/pysindy/issues/375#issuecomment-1648605745, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5BAFM7S4OTU37E4YRBMGPLXR3O4JANCNFSM6AAAAAA2WC7RFQ . You are receiving this because you authored the thread.Message ID: @.***>

Jacob-Stevens-Haas commented 1 year ago

Sorry for the slow reply. Generally I'm happy to consult; why don't you start a discussion, describing your problem? If it's too big and involved, I may not have the time to help you, but if it's simple enough, I may be able to help you for free. If it's in between, we can email about a paid consultation.

If you're just looking for a more detailed example of what I described in my last post, I can do that here.

Fakasht10 commented 1 year ago

No problem Jacob, let me gather the information about my problem and the files I created when trying to solve the problem myself and I will create a new discussion. Regards Aleksey

On Sat, Jul 29, 2023 at 5:56 PM Jacob Stevens-Haas @.***> wrote:

Sorry for the slow reply. Generally I'm happy to consult; why don't you start a discussion https://github.com/dynamicslab/pysindy/discussions, describing your problem. If it's too big and involved, I may not have the time to help you, but if it's simple enough, I may be able to help you for free. If it's in between, we can email about a paid consultation.

— Reply to this email directly, view it on GitHub https://github.com/dynamicslab/pysindy/issues/375#issuecomment-1656922794, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5BAFMYVKKBLLUIJZFBH4SLXSWBKRANCNFSM6AAAAAA2WC7RFQ . You are receiving this because you authored the thread.Message ID: @.***>