Skip to content

fix: [AI] fix bug caused by duplicate alias equations from eliminate_perfect_aliases!#4523

Merged
AayushSabharwal merged 3 commits into
masterfrom
as/alias-elimination-tiebreaker
May 13, 2026
Merged

fix: [AI] fix bug caused by duplicate alias equations from eliminate_perfect_aliases!#4523
AayushSabharwal merged 3 commits into
masterfrom
as/alias-elimination-tiebreaker

Conversation

@AayushSabharwal
Copy link
Copy Markdown
Member

The commit messages describe this pretty well. I'm trying to get Claude to write a test.

@AayushSabharwal AayushSabharwal marked this pull request as ready for review May 12, 2026 09:49
@AayushSabharwal AayushSabharwal force-pushed the as/alias-elimination-tiebreaker branch from 3f53de6 to 34b1cf8 Compare May 12, 2026 09:55
AayushSabharwal and others added 3 commits May 13, 2026 11:43
When all variables in an alias group have equal state_priority (common
for rotation matrix elements), findmax on equal values returned the
first element in insertion order rather than the physics variable.
For R[i,j] alias groups of ~18 variables, the physics variable
(body₊frame_a₊R[i,j]) has vtd=Int and appears in ~9 equations, while
visualization shape variables appear in only 1. Picking a shape variable
as target and then eliminating the physics variable causes structural
singularity in Pantelides. Fix: when priorities are tied, prefer the
variable with the most equation appearances.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ect_aliases!

When a sticky (high state_priority) non-target variable is directly
aliased
to a zero-priority variable in the same group, the c1/c2 removal check
correctly keeps the equation (c1 ≠ c2). After the substitution loop
rewrites that zero-priority variable to the group target, the surviving
equation becomes structurally identical to the direct alias between the
sticky variable and the target — a redundant duplicate. Multiple such
duplicates over-constrain the bipartite graph and cause Pantelides to
fail
on downstream acceleration variables.

Fix: after the substitution loop, scan surviving candidate equations for
pairs with the same (v_a, v_b) variable endpoints and remove all but the
first. This is O(n) in the number of candidate alias equations.

The equation-count tiebreaker in pick_alias_target is retained as a
secondary heuristic to prefer targets that already have derivative
chains
in var_to_diff, reducing unnecessary var_derivative! calls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AayushSabharwal AayushSabharwal force-pushed the as/alias-elimination-tiebreaker branch from 34b1cf8 to dbfd91b Compare May 13, 2026 06:18
@AayushSabharwal AayushSabharwal merged commit 8b82464 into master May 13, 2026
103 of 127 checks passed
@AayushSabharwal AayushSabharwal deleted the as/alias-elimination-tiebreaker branch May 13, 2026 11:31
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.

1 participant