From e6e906da0b7e1c44c67f62f481c9b69538bf7e62 Mon Sep 17 00:00:00 2001 From: joaquimg Date: Tue, 27 May 2025 20:38:08 -0700 Subject: [PATCH 1/2] Fix print of Infeasibility analysis --- src/infeasibility.jl | 50 +++++++++++++++++++++---------------------- test/infeasibility.jl | 11 ++++++++++ 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/infeasibility.jl b/src/infeasibility.jl index 2dab25d..ba3eba3 100644 --- a/src/infeasibility.jl +++ b/src/infeasibility.jl @@ -541,32 +541,32 @@ end # API -function ModelAnalyzer._summarize(io::IO, ::Type{InfeasibleBounds{T}}) where {T} +function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleBounds}) return print(io, "# InfeasibleBounds") end function ModelAnalyzer._summarize( io::IO, - ::Type{InfeasibleIntegrality{T}}, -) where {T} + ::Type{<:InfeasibleIntegrality}, +) return print(io, "# InfeasibleIntegrality") end function ModelAnalyzer._summarize( io::IO, - ::Type{InfeasibleConstraintRange{T}}, -) where {T} + ::Type{<:InfeasibleConstraintRange}, +) return print(io, "# InfeasibleConstraintRange") end -function ModelAnalyzer._summarize(io::IO, ::Type{IrreducibleInfeasibleSubset}) +function ModelAnalyzer._summarize(io::IO, ::Type{<:IrreducibleInfeasibleSubset}) return print(io, "# IrreducibleInfeasibleSubset") end function ModelAnalyzer._verbose_summarize( io::IO, - ::Type{InfeasibleBounds{T}}, -) where {T} + ::Type{<:InfeasibleBounds}, +) return print( io, """ @@ -595,8 +595,8 @@ end function ModelAnalyzer._verbose_summarize( io::IO, - ::Type{InfeasibleIntegrality{T}}, -) where {T} + ::Type{<:InfeasibleIntegrality}, +) return print( io, """ @@ -626,8 +626,8 @@ end function ModelAnalyzer._verbose_summarize( io::IO, - ::Type{InfeasibleConstraintRange{T}}, -) where {T} + ::Type{<:InfeasibleConstraintRange}, +) return print( io, """ @@ -657,7 +657,7 @@ end function ModelAnalyzer._verbose_summarize( io::IO, - ::Type{IrreducibleInfeasibleSubset}, + ::Type{<:IrreducibleInfeasibleSubset}, ) return print( io, @@ -687,9 +687,9 @@ end function ModelAnalyzer._summarize( io::IO, - issue::InfeasibleBounds{T}, + issue::InfeasibleBounds, model, -) where {T} +) return print( io, ModelAnalyzer._name(issue.variable, model), @@ -702,9 +702,9 @@ end function ModelAnalyzer._summarize( io::IO, - issue::InfeasibleIntegrality{T}, + issue::InfeasibleIntegrality, model, -) where {T} +) return print( io, ModelAnalyzer._name(issue.variable, model), @@ -719,9 +719,9 @@ end function ModelAnalyzer._summarize( io::IO, - issue::InfeasibleConstraintRange{T}, + issue::InfeasibleConstraintRange, model, -) where {T} +) return print( io, ModelAnalyzer._name(issue.constraint, model), @@ -748,9 +748,9 @@ end function ModelAnalyzer._verbose_summarize( io::IO, - issue::InfeasibleBounds{T}, + issue::InfeasibleBounds, model, -) where {T} +) return print( io, "Variable: ", @@ -764,9 +764,9 @@ end function ModelAnalyzer._verbose_summarize( io::IO, - issue::InfeasibleIntegrality{T}, + issue::InfeasibleIntegrality, model, -) where {T} +) return print( io, "Variable: ", @@ -782,9 +782,9 @@ end function ModelAnalyzer._verbose_summarize( io::IO, - issue::InfeasibleConstraintRange{T}, + issue::InfeasibleConstraintRange, model, -) where {T} +) return print( io, "Constraint: ", diff --git a/test/infeasibility.jl b/test/infeasibility.jl index cde2582..4d5b7c0 100644 --- a/test/infeasibility.jl +++ b/test/infeasibility.jl @@ -64,6 +64,8 @@ function test_bounds() str = String(take!(buf)) @test contains(str, " : ") @test contains(str, " !<= ") + ModelAnalyzer.summarize(buf, data, verbose = false) + ModelAnalyzer.summarize(buf, data, verbose = true) return end @@ -114,6 +116,8 @@ function test_integrality() @test contains(str, " : [") @test contains(str, "; ") @test contains(str, "], ") + ModelAnalyzer.summarize(buf, data, verbose = false) + ModelAnalyzer.summarize(buf, data, verbose = true) return end @@ -137,6 +141,9 @@ function test_binary() @test ModelAnalyzer.variable(ret[], model) == x @test ModelAnalyzer.values(ret[]) == [0.5, 0.8] @test ModelAnalyzer.set(ret[]) == MOI.ZeroOne() + buf = IOBuffer() + ModelAnalyzer.summarize(buf, data, verbose = false) + ModelAnalyzer.summarize(buf, data, verbose = true) return end @@ -188,6 +195,8 @@ function test_range() @test contains(str, " : [") @test contains(str, "; ") @test contains(str, "], !in ") + ModelAnalyzer.summarize(buf, data, verbose = false) + ModelAnalyzer.summarize(buf, data, verbose = true) return end @@ -405,6 +414,8 @@ function test_iis() ModelAnalyzer.summarize(buf, data, verbose = true) str = String(take!(buf)) @test startswith(str, "## Infeasibility Analysis\n\n") + ModelAnalyzer.summarize(buf, data, verbose = false) + ModelAnalyzer.summarize(buf, data, verbose = true) return end From 242737c83f5aea6fd747ba74357844846b1408b9 Mon Sep 17 00:00:00 2001 From: joaquimg Date: Tue, 27 May 2025 20:45:28 -0700 Subject: [PATCH 2/2] format --- src/infeasibility.jl | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/infeasibility.jl b/src/infeasibility.jl index ba3eba3..dcb13ad 100644 --- a/src/infeasibility.jl +++ b/src/infeasibility.jl @@ -545,17 +545,11 @@ function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleBounds}) return print(io, "# InfeasibleBounds") end -function ModelAnalyzer._summarize( - io::IO, - ::Type{<:InfeasibleIntegrality}, -) +function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleIntegrality}) return print(io, "# InfeasibleIntegrality") end -function ModelAnalyzer._summarize( - io::IO, - ::Type{<:InfeasibleConstraintRange}, -) +function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleConstraintRange}) return print(io, "# InfeasibleConstraintRange") end @@ -563,10 +557,7 @@ function ModelAnalyzer._summarize(io::IO, ::Type{<:IrreducibleInfeasibleSubset}) return print(io, "# IrreducibleInfeasibleSubset") end -function ModelAnalyzer._verbose_summarize( - io::IO, - ::Type{<:InfeasibleBounds}, -) +function ModelAnalyzer._verbose_summarize(io::IO, ::Type{<:InfeasibleBounds}) return print( io, """ @@ -685,11 +676,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._summarize( - io::IO, - issue::InfeasibleBounds, - model, -) +function ModelAnalyzer._summarize(io::IO, issue::InfeasibleBounds, model) return print( io, ModelAnalyzer._name(issue.variable, model), @@ -700,11 +687,7 @@ function ModelAnalyzer._summarize( ) end -function ModelAnalyzer._summarize( - io::IO, - issue::InfeasibleIntegrality, - model, -) +function ModelAnalyzer._summarize(io::IO, issue::InfeasibleIntegrality, model) return print( io, ModelAnalyzer._name(issue.variable, model),