Skip to content

Commit 682d4b7

Browse files
authored
Improve IIS log (#41)
* Improve IIS log * test new lines
1 parent 2a9241d commit 682d4b7

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

ext/ModelAnalyzerJuMPExt/ModelAnalyzerJuMPExt.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ function ModelAnalyzer._name(ref::MOI.ConstraintIndex, model::JuMP.GenericModel)
4040
return "$jump_ref"
4141
end
4242

43+
function ModelAnalyzer._show(ref::MOI.ConstraintIndex, model::JuMP.GenericModel)
44+
jump_ref = JuMP.constraint_ref_with_index(model, ref)
45+
io = IOBuffer()
46+
show(io, jump_ref)
47+
return String(take!(io))
48+
end
49+
4350
"""
4451
variable(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel)
4552

src/Infeasibility/summarize.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,13 @@ function ModelAnalyzer._verbose_summarize(
248248
issue::IrreducibleInfeasibleSubset,
249249
model,
250250
)
251-
return print(
252-
io,
253-
"Irreducible Infeasible Subset: ",
254-
join(map(x -> ModelAnalyzer._name(x, model), issue.constraint), ", "),
255-
)
251+
print(io, "Irreducible Infeasible Subset: ")
252+
for constraint in issue.constraint
253+
println(io)
254+
print(io, " ")
255+
print(io, ModelAnalyzer._show(constraint, model))
256+
end
257+
return
256258
end
257259

258260
function ModelAnalyzer.list_of_issues(data::Data, ::Type{InfeasibleBounds})

src/ModelAnalyzer.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ function _name(ref, ::Nothing)
219219
return "$ref"
220220
end
221221

222+
function _show(ref::MOI.ConstraintIndex, model)
223+
return _name(ref, model)
224+
end
225+
222226
include("Numerical/Numerical.jl")
223227
include("Feasibility/Feasibility.jl")
224228
include("Infeasibility/Infeasibility.jl")

test/test_Infeasibility.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,8 @@ function test_iis_spare()
572572
iis = ModelAnalyzer.constraints(ret[], model)
573573
@test length(iis) == 2
574574
@test Set(iis) == Set([c2, c1])
575+
io = IOBuffer()
576+
ModelAnalyzer.summarize(io, ret[1], verbose = true, model = model)
575577
return
576578
end
577579

0 commit comments

Comments
 (0)