Skip to content

Left-to-right expand observed equations into defaults during initialization #2861

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

Merged
merged 4 commits into from
Jul 17, 2024

Conversation

hersle
Copy link
Contributor

@hersle hersle commented Jul 15, 2024

Fixes #2859.

This slightly changes how observed equations are expanded into a map of defaults when an ODE is initialized with defaults. Before this process took rhs => lhs by default, but flipped it to lhs => rhs if rhs was a parameter (my interpretation: "if rhs is something known").

Now it instead takes lhs => rhs by default, and flips if lhs is something known. I think this makes more sense, because unlike the arbitrarily complicated rhs, lhs of an observed equation (in a simplified system) is guaranteed (?) to be something simple (e.g. 0 ~ rhs or x ~ rhs). It is therefore better to decide whether to flip based on lhs.

I am not sure I have thought of everything. But it looks like all MTK tests are passing on my computer.

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

@hersle
Copy link
Contributor Author

hersle commented Jul 15, 2024

Also, should isparameter(lhs) always fail now? There cannot be a parameter on the left side of an observed equation?

@hersle
Copy link
Contributor Author

hersle commented Jul 15, 2024

Is the failure because of SciML/ModelingToolkitStandardLibrary.jl#306?

@hersle
Copy link
Contributor Author

hersle commented Jul 15, 2024

Also trying to remove the (thought-to-be) redundant isparameter(lhs) check now.

@ChrisRackauckas
Copy link
Member

Also, should isparameter(lhs) always fail now? There cannot be a parameter on the left side of an observed equation?

Yes

@ChrisRackauckas
Copy link
Member

The tests covered all of the reasons for flipping in the first place, so if this is passing then it's no longer required. This intuitively makes more sense and is simpler too, so it seems strictly better. I can't see a system where it would fail. I believe part of this was due to dummy derivative handling, but since we greatly improved that in other ways we seem good now.

@ChrisRackauckas ChrisRackauckas merged commit 2f5c718 into SciML:master Jul 17, 2024
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot initialize well-defined ODE with defaults
2 participants