Skip to content

Commit 1b6973c

Browse files
committed
Keep invview for var_matching valid in pss
Previously we could introduce inconsistent assignments, which caused the invview to be wrong after the return from pss.
1 parent 03d8b04 commit 1b6973c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/bipartite_graph.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ end
6363
function Base.setindex!(m::Matching{U}, v::Union{Integer, U}, i::Integer) where {U}
6464
if m.inv_match !== nothing
6565
oldv = m.match[i]
66-
isa(oldv, Int) && (m.inv_match[oldv] = unassigned)
66+
if isa(oldv, Int)
67+
@assert m.inv_match[oldv] == i
68+
m.inv_match[oldv] = unassigned
69+
end
6770
isa(v, Int) && (m.inv_match[v] = i)
6871
end
6972
return m.match[i] = v

src/structural_transformation/partial_state_selection.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ function pss_graph_modia!(structure::SystemStructure, var_eq_matching, varlevel,
8686
filter!(eq -> invview(ict.graph.matching)[eq] === unassigned, to_tear_eqs)
8787
tearEquations!(ict, solvable_graph.fadjlist, to_tear_eqs, BitSet(to_tear_vars),
8888
nothing)
89+
for var in to_tear_vars
90+
var_eq_matching[var] = unassigned
91+
end
8992
for var in to_tear_vars
9093
var_eq_matching[var] = ict.graph.matching[var]
9194
end

0 commit comments

Comments
 (0)