Skip to content

fix: properly eliminate identically zero variables in alias_elimination!#4704

Draft
AayushSabharwal wants to merge 2 commits into
masterfrom
as/alias-elim-zero-vars
Draft

fix: properly eliminate identically zero variables in alias_elimination!#4704
AayushSabharwal wants to merge 2 commits into
masterfrom
as/alias-elim-zero-vars

Conversation

@AayushSabharwal

Copy link
Copy Markdown
Member

Stacked on top of #4703
Requires JuliaComputing/StateSelection.jl#125

After bareiss, the matrix often contains rows with a single non-zero entry. This means the corresponding variable is identically zero. However, the pass never eliminated such variables and never included them in the maybe_zeros heuristic. Thus, MTK was fine with dividing by them if present in a linear SCC it can analytically solve.

These zero variables are now discovered after the pass, eagerly removed, and substituted into all equations where they are present. The above two PRs are required infrastructure to handle the case when a differentiated variable is found to analytically be zero. In this case, the variable, all its derivatives and all integrated forms are eliminated as observed. Lower order derivatives are analytically obtained as a polynomial in t. The infrastructure is mostly to make sure initialization behaves correctly.

TODO:

  • Write tests

@AayushSabharwal AayushSabharwal force-pushed the as/alias-elim-zero-vars branch from 8b8bc98 to b5a1c7c Compare July 3, 2026 12:34
printstyled(io, k; bold = true)
println(io, ": ", v)
end
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Runic] reported by reviewdog 🐶

Suggested change
end
return
return

@baggepinnen

Copy link
Copy Markdown
Contributor

Lower order derivatives are analytically obtained as a polynomial in t

anti-derivatives?

@AayushSabharwal

Copy link
Copy Markdown
Member Author

I knew there was a term I was forgetting 😅 Thanks!

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.

2 participants