Skip to content

Commit 8e55904

Browse files
committed
more tests
1 parent f09d573 commit 8e55904

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

test/infeasibility.jl

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ function test_iis()
258258
ret = ModelAnalyzer.list_of_issues(data, list[1])
259259
@test length(ret) == 1
260260
@test length(ret[].constraint) == 2
261-
@test ret[].constraint[1] == c2
262-
@test ret[].constraint[2] == c1
261+
@test Set([ret[].constraint[1], ret[].constraint[2]]) == Set([c2, c1])
263262
#
264263
buf = IOBuffer()
265264
ModelAnalyzer.summarize(
@@ -288,6 +287,11 @@ function test_iis()
288287
buf = IOBuffer()
289288
Base.show(buf, data)
290289
str = String(take!(buf))
290+
@test startswith(str, "Infeasibility analysis found 1 issues")
291+
292+
ModelAnalyzer.summarize(buf, data, verbose = true)
293+
str = String(take!(buf))
294+
@test startswith(str, "## Infeasibility Analysis\n\n")
291295
return
292296
end
293297

@@ -371,6 +375,35 @@ function test_iis_interval_left()
371375
return
372376
end
373377

378+
function test_iis_spare()
379+
model = Model(HiGHS.Optimizer)
380+
set_silent(model)
381+
@variable(model, 0 <= x <= 10)
382+
@variable(model, 0 <= y <= 20)
383+
@variable(model, 0 <= z <= 20)
384+
@constraint(model, c0, 2z <= 1)
385+
@constraint(model, c00, 3z <= 1)
386+
@constraint(model, c1, x + y <= 1)
387+
@constraint(model, c2, x + y >= 2)
388+
@objective(model, Max, x + y)
389+
optimize!(model)
390+
data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model)
391+
list = ModelAnalyzer.list_of_issue_types(data)
392+
@test length(list) == 0
393+
data = ModelAnalyzer.analyze(
394+
ModelAnalyzer.Infeasibility.Analyzer(),
395+
model,
396+
optimizer = HiGHS.Optimizer,
397+
)
398+
list = ModelAnalyzer.list_of_issue_types(data)
399+
@test length(list) == 1
400+
ret = ModelAnalyzer.list_of_issues(data, list[1])
401+
@test length(ret) == 1
402+
@test length(ret[].constraint) == 2
403+
@test Set([ret[].constraint[1], ret[].constraint[2]]) == Set([c2, c1])
404+
return
405+
end
406+
374407
end # module
375408

376409
TestInfeasibilityChecker.runtests()

0 commit comments

Comments
 (0)