Skip to content

Commit 9691bb4

Browse files
authored
Fix print of Infeasibility analysis (#34)
* Fix print of Infeasibility analysis * format
1 parent 8ba404c commit 9691bb4

File tree

2 files changed

+31
-37
lines changed

2 files changed

+31
-37
lines changed

src/infeasibility.jl

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -541,32 +541,23 @@ end
541541

542542
# API
543543

544-
function ModelAnalyzer._summarize(io::IO, ::Type{InfeasibleBounds{T}}) where {T}
544+
function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleBounds})
545545
return print(io, "# InfeasibleBounds")
546546
end
547547

548-
function ModelAnalyzer._summarize(
549-
io::IO,
550-
::Type{InfeasibleIntegrality{T}},
551-
) where {T}
548+
function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleIntegrality})
552549
return print(io, "# InfeasibleIntegrality")
553550
end
554551

555-
function ModelAnalyzer._summarize(
556-
io::IO,
557-
::Type{InfeasibleConstraintRange{T}},
558-
) where {T}
552+
function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleConstraintRange})
559553
return print(io, "# InfeasibleConstraintRange")
560554
end
561555

562-
function ModelAnalyzer._summarize(io::IO, ::Type{IrreducibleInfeasibleSubset})
556+
function ModelAnalyzer._summarize(io::IO, ::Type{<:IrreducibleInfeasibleSubset})
563557
return print(io, "# IrreducibleInfeasibleSubset")
564558
end
565559

566-
function ModelAnalyzer._verbose_summarize(
567-
io::IO,
568-
::Type{InfeasibleBounds{T}},
569-
) where {T}
560+
function ModelAnalyzer._verbose_summarize(io::IO, ::Type{<:InfeasibleBounds})
570561
return print(
571562
io,
572563
"""
@@ -595,8 +586,8 @@ end
595586

596587
function ModelAnalyzer._verbose_summarize(
597588
io::IO,
598-
::Type{InfeasibleIntegrality{T}},
599-
) where {T}
589+
::Type{<:InfeasibleIntegrality},
590+
)
600591
return print(
601592
io,
602593
"""
@@ -626,8 +617,8 @@ end
626617

627618
function ModelAnalyzer._verbose_summarize(
628619
io::IO,
629-
::Type{InfeasibleConstraintRange{T}},
630-
) where {T}
620+
::Type{<:InfeasibleConstraintRange},
621+
)
631622
return print(
632623
io,
633624
"""
@@ -657,7 +648,7 @@ end
657648

658649
function ModelAnalyzer._verbose_summarize(
659650
io::IO,
660-
::Type{IrreducibleInfeasibleSubset},
651+
::Type{<:IrreducibleInfeasibleSubset},
661652
)
662653
return print(
663654
io,
@@ -685,11 +676,7 @@ function ModelAnalyzer._verbose_summarize(
685676
)
686677
end
687678

688-
function ModelAnalyzer._summarize(
689-
io::IO,
690-
issue::InfeasibleBounds{T},
691-
model,
692-
) where {T}
679+
function ModelAnalyzer._summarize(io::IO, issue::InfeasibleBounds, model)
693680
return print(
694681
io,
695682
ModelAnalyzer._name(issue.variable, model),
@@ -700,11 +687,7 @@ function ModelAnalyzer._summarize(
700687
)
701688
end
702689

703-
function ModelAnalyzer._summarize(
704-
io::IO,
705-
issue::InfeasibleIntegrality{T},
706-
model,
707-
) where {T}
690+
function ModelAnalyzer._summarize(io::IO, issue::InfeasibleIntegrality, model)
708691
return print(
709692
io,
710693
ModelAnalyzer._name(issue.variable, model),
@@ -719,9 +702,9 @@ end
719702

720703
function ModelAnalyzer._summarize(
721704
io::IO,
722-
issue::InfeasibleConstraintRange{T},
705+
issue::InfeasibleConstraintRange,
723706
model,
724-
) where {T}
707+
)
725708
return print(
726709
io,
727710
ModelAnalyzer._name(issue.constraint, model),
@@ -748,9 +731,9 @@ end
748731

749732
function ModelAnalyzer._verbose_summarize(
750733
io::IO,
751-
issue::InfeasibleBounds{T},
734+
issue::InfeasibleBounds,
752735
model,
753-
) where {T}
736+
)
754737
return print(
755738
io,
756739
"Variable: ",
@@ -764,9 +747,9 @@ end
764747

765748
function ModelAnalyzer._verbose_summarize(
766749
io::IO,
767-
issue::InfeasibleIntegrality{T},
750+
issue::InfeasibleIntegrality,
768751
model,
769-
) where {T}
752+
)
770753
return print(
771754
io,
772755
"Variable: ",
@@ -782,9 +765,9 @@ end
782765

783766
function ModelAnalyzer._verbose_summarize(
784767
io::IO,
785-
issue::InfeasibleConstraintRange{T},
768+
issue::InfeasibleConstraintRange,
786769
model,
787-
) where {T}
770+
)
788771
return print(
789772
io,
790773
"Constraint: ",

test/infeasibility.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ function test_bounds()
6464
str = String(take!(buf))
6565
@test contains(str, " : ")
6666
@test contains(str, " !<= ")
67+
ModelAnalyzer.summarize(buf, data, verbose = false)
68+
ModelAnalyzer.summarize(buf, data, verbose = true)
6769
return
6870
end
6971

@@ -114,6 +116,8 @@ function test_integrality()
114116
@test contains(str, " : [")
115117
@test contains(str, "; ")
116118
@test contains(str, "], ")
119+
ModelAnalyzer.summarize(buf, data, verbose = false)
120+
ModelAnalyzer.summarize(buf, data, verbose = true)
117121
return
118122
end
119123

@@ -137,6 +141,9 @@ function test_binary()
137141
@test ModelAnalyzer.variable(ret[], model) == x
138142
@test ModelAnalyzer.values(ret[]) == [0.5, 0.8]
139143
@test ModelAnalyzer.set(ret[]) == MOI.ZeroOne()
144+
buf = IOBuffer()
145+
ModelAnalyzer.summarize(buf, data, verbose = false)
146+
ModelAnalyzer.summarize(buf, data, verbose = true)
140147
return
141148
end
142149

@@ -188,6 +195,8 @@ function test_range()
188195
@test contains(str, " : [")
189196
@test contains(str, "; ")
190197
@test contains(str, "], !in ")
198+
ModelAnalyzer.summarize(buf, data, verbose = false)
199+
ModelAnalyzer.summarize(buf, data, verbose = true)
191200
return
192201
end
193202

@@ -405,6 +414,8 @@ function test_iis()
405414
ModelAnalyzer.summarize(buf, data, verbose = true)
406415
str = String(take!(buf))
407416
@test startswith(str, "## Infeasibility Analysis\n\n")
417+
ModelAnalyzer.summarize(buf, data, verbose = false)
418+
ModelAnalyzer.summarize(buf, data, verbose = true)
408419
return
409420
end
410421

0 commit comments

Comments
 (0)