Skip to content

Commit 8d47389

Browse files
committed
tearing: Heuristically attempt to assign equations with single solvable first
This changes to tearing to give priority to any equation <-> variable pairs where a particular equation only has one matchable variable. These are easy, becuse, if the equation is part of the final matching at all, we know which variable they need to be matched to and by matching them first, we can avoid accidentally assigning these variables to another equation, which would necessarily increase the number of torn states.
1 parent bf3551e commit 8d47389

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/structural_transformation/bipartite_tearing/modia_tearing.jl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,22 @@ function tearEquations!(ict::IncrementalCycleTracker, Gsolvable, es::Vector{Int}
3232
end
3333
end
3434
end
35-
for eq in es # iterate only over equations that are not in eSolvedFixed
36-
vs = Gsolvable[eq]
37-
if check_der
38-
# if there're differentiated variables, then only consider them
39-
try_assign_eq!(ict, vs, v_active, eq, isder)
40-
if has_der[]
41-
has_der[] = false
42-
continue
35+
# Heuristic: As a first pass, try to assign any equations that only have one
36+
# solvable variable.
37+
for only_single_solvable in (true, false)
38+
for eq in es # iterate only over equations that are not in eSolvedFixed
39+
vs = Gsolvable[eq]
40+
((length(vs) == 1) only_single_solvable) && continue
41+
if check_der
42+
# if there're differentiated variables, then only consider them
43+
try_assign_eq!(ict, vs, v_active, eq, isder)
44+
if has_der[]
45+
has_der[] = false
46+
continue
47+
end
4348
end
49+
try_assign_eq!(ict, vs, v_active, eq)
4450
end
45-
try_assign_eq!(ict, vs, v_active, eq)
4651
end
4752

4853
return ict

0 commit comments

Comments
 (0)