Skip to content

Commit c262fae

Browse files
committed
Be sure to not eliminate differential variables in alias_elimination
1 parent 5aa6704 commit c262fae

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/systems/alias_elimination.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,12 @@ function alias_eliminate_graph!(graph, var_to_diff, mm_orig::SparseMatrixCLIL)
287287
diff_to_var = invview(var_to_diff)
288288
function lss!(ei::Integer)
289289
vi = pivots[ei]
290-
# the differentiated variable cannot be eliminated
291-
islowest = isnothing(diff_to_var[vi]) && isnothing(var_to_diff[vi])
292-
locally_structure_simplify!((@view mm[ei, :]), vi, ag, islowest)
290+
may_eliminate = true
291+
for v in 𝑠neighbors(graph, mm.nzrows[ei])
292+
# the differentiated variable cannot be eliminated
293+
may_eliminate &= isnothing(diff_to_var[v]) && isnothing(var_to_diff[v])
294+
end
295+
locally_structure_simplify!((@view mm[ei, :]), vi, ag, may_eliminate)
293296
end
294297

295298
# Step 2.1: Go backwards, collecting eliminated variables and substituting

0 commit comments

Comments
 (0)