-
-
Notifications
You must be signed in to change notification settings - Fork 232
Strengthen alias elimination #1635
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you test the example
x ~ 0
D(x) ~ x - y
get eliminated as expected? What about
D(z) ~ 0
if we eliminate D(z)
away, then we won't have z
as an observed variable as no initial condition would be provided for it.
may_eliminate &= isnothing(diff_to_var[v]) && isnothing(var_to_diff[v]) | ||
end | ||
locally_structure_simplify!((@view mm[ei, :]), vi, ag, may_eliminate) | ||
locally_structure_simplify!((@view mm[ei, :]), vi, ag, var_to_diff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make sure that variables that are marked irreducible to not be eliminated away? See
isirreducible(var) && continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
irreducible values are not included in the linear subsystem, so they should not be eliminated.
BTW, remember to run |
The CI failures https://github.com/SciML/ModelingToolkit.jl/runs/6804925627?check_suite_focus=true#step:6:1540 look legitimate. Are you sure they still eliminate the same number of variables as the number of equations to keep the system balanced? |
Previously, we would only alias eliminate variables that do not occur differentiated. This was unnecessarily restricted for systems such as ``` x ~ 0 D(x) ~ x - y ``` where alias elimination is now able to determine that `x` and `y` are aliases. While this is the main point of the PR, this does improve alias elimination in some of the tests, causing tearing order to change. Previously we had a suboptimality in tearing where an equation assigned to an scc in which it is not able to solve a variable would not be reconsidered in another scc. Fix that also, to make sure the tests keep working.
@@ -37,17 +37,57 @@ end | |||
|
|||
function tear_graph_modia(structure::SystemStructure; varfilter = v -> true, | |||
eqfilter = eq -> true) | |||
# It would be possible here to simply iterate over all variables and attempt to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we split this to another PR?
Previously, we would only alias eliminate variables that do not occur
differentiated. This was unnecessarily restricted for systems such as
where alias elimination is now able to determine that
x
andy
arealiases.
While this is the main point of the PR, this does improve alias elimination
in some of the tests, causing tearing order to change. Previously we had
a suboptimality in tearing where an equation assigned to an scc in which it
is not able to solve a variable would not be reconsidered in another scc.
Fix that also, to make sure the tests keep working.