Skip to content

Commit 190563b

Browse files
fix: HACK: handle incorrect result from linear_expansion when using symbolic arrays
1 parent 17d4e33 commit 190563b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/structural_transformation/utils.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,18 @@ function find_eq_solvables!(state::TearingState, ieq, to_rm = Int[], coeffs = no
218218
all_int_vars = true
219219
coeffs === nothing || empty!(coeffs)
220220
empty!(to_rm)
221+
222+
vars_buffer = Set()
221223
for j in 𝑠neighbors(graph, ieq)
222224
var = fullvars[j]
223225
isirreducible(var) && (all_int_vars = false; continue)
224226
a, b, islinear = linear_expansion(term, var)
225227
a, b = unwrap(a), unwrap(b)
228+
vars!(vars_buffer, b)
229+
if islinear && isequal(a, 0) && var in vars_buffer
230+
islinear = false
231+
end
232+
empty!(vars_buffer)
226233
islinear || (all_int_vars = false; continue)
227234
a = ModelingToolkit.fold_constants(a)
228235
b = ModelingToolkit.fold_constants(b)

0 commit comments

Comments
 (0)