Skip to content

Commit e4b039f

Browse files
committed
Show selected states in MatchedSystemStructure
In the printing for `MatchedSystemStructure`, add a little blue `∫` symbol to indicate variables that are set to `SelectedState`, thus making the printing suitable for matchings produced from state selection (not just pantelides).
1 parent 3b16c9c commit e4b039f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/bipartite_graph.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ end
192192
struct BipartiteAdjacencyList
193193
u::Union{Vector{Int}, Nothing}
194194
highligh_u::Union{Set{Int}, Nothing}
195-
match::Union{Int, Unassigned}
195+
match::Union{Int, Bool, Unassigned}
196196
end
197197
function BipartiteAdjacencyList(u::Union{Vector{Int}, Nothing})
198198
BipartiteAdjacencyList(u, nothing, unassigned)
@@ -213,16 +213,21 @@ function Base.show(io::IO, hi::HighlightInt)
213213
end
214214

215215
function Base.show(io::IO, l::BipartiteAdjacencyList)
216+
if l.match === true
217+
printstyled(io, "", color = :light_blue, bold = true)
218+
end
216219
if l.u === nothing
217220
printstyled(io, '', color = :light_black)
218221
elseif isempty(l.u)
219222
printstyled(io, '', color = :light_black)
220223
elseif l.highligh_u === nothing
221224
print(io, l.u)
222225
else
226+
match = l.match
227+
isa(match, Bool) && (match = unassigned)
223228
function choose_color(i)
224-
i in l.highligh_u ? (i == l.match ? :light_yellow : :green) :
225-
(i == l.match ? :yellow : nothing)
229+
i in l.highligh_u ? (i == match ? :light_yellow : :green) :
230+
(i == match ? :yellow : nothing)
226231
end
227232
if !isempty(setdiff(l.highligh_u, l.u))
228233
# Only for debugging, shouldn't happen in practice

src/systems/systemstructure.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,17 @@ function Base.getindex(bgpm::SystemStructurePrintMatrix, i::Integer, j::Integer)
441441
(i - 1 <= length(invview(bgpm.var_eq_matching))) ?
442442
invview(bgpm.var_eq_matching)[i - 1] : unassigned)
443443
elseif j == 5
444+
match = unassigned
445+
if bgpm.var_eq_matching !== nothing && i - 1 <= length(bgpm.var_eq_matching)
446+
match = bgpm.var_eq_matching[i - 1]
447+
isa(match, Union{Int, Unassigned}) || (match = true) # Selected State
448+
end
444449
return BipartiteAdjacencyList(i - 1 <= ndsts(bgpm.bpg) ?
445450
𝑑neighbors(bgpm.bpg, i - 1) : nothing,
446451
bgpm.highlight_graph !== nothing &&
447452
i - 1 <= ndsts(bgpm.highlight_graph) ?
448453
Set(𝑑neighbors(bgpm.highlight_graph, i - 1)) :
449-
nothing,
450-
bgpm.var_eq_matching !== nothing &&
451-
(i - 1 <= length(bgpm.var_eq_matching)) ?
452-
bgpm.var_eq_matching[i - 1] : unassigned)
454+
nothing, match)
453455
else
454456
@assert false
455457
end

0 commit comments

Comments
 (0)