Skip to content

Commit f51297c

Browse files
authored
Merge pull request #1842 from Keno/kf/pssrobust
pss: Handle the case where variables don't appear in graph
2 parents 01d595a + 1780e3a commit f51297c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/structural_transformation/partial_state_selection.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,15 @@ function partial_state_selection_graph!(structure::SystemStructure, var_eq_match
116116
end
117117

118118
varlevel = map(1:ndsts(graph)) do var
119-
level = 0
119+
graph_level = level = 0
120120
while var_to_diff[var] !== nothing
121121
var = var_to_diff[var]
122122
level += 1
123+
if !isempty(𝑑neighbors(graph, var))
124+
graph_level = level
125+
end
123126
end
124-
level
127+
graph_level
125128
end
126129

127130
inv_varlevel = map(1:ndsts(graph)) do var
@@ -135,7 +138,7 @@ function partial_state_selection_graph!(structure::SystemStructure, var_eq_match
135138

136139
# TODO: Should pantelides just return this?
137140
for var in 1:ndsts(graph)
138-
if var_to_diff[var] !== nothing
141+
if varlevel[var] !== 0
139142
var_eq_matching[var] = unassigned
140143
end
141144
end

0 commit comments

Comments
 (0)