Skip to content

Commit f79d6a1

Browse files
committed
Add infeasible and unbounded tests
1 parent 9a5595e commit f79d6a1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/algorithms/Sandwiching.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,39 @@ function test_molp_2()
101101
return _test_molp(C, A, b, results, sense)
102102
end
103103

104+
function test_infeasible()
105+
model = MOA.Optimizer(HiGHS.Optimizer)
106+
MOI.set(model, MOA.Algorithm(), MOA.Sandwiching(0.0))
107+
MOI.set(model, MOI.Silent(), true)
108+
x = MOI.add_variables(model, 2)
109+
MOI.add_constraint.(model, x, MOI.GreaterThan(0.0))
110+
MOI.add_constraint(model, 1.0 * x[1] + 1.0 * x[2], MOI.LessThan(-1.0))
111+
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
112+
f = MOI.Utilities.operate(vcat, Float64, 1.0 .* x...)
113+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
114+
MOI.optimize!(model)
115+
@test MOI.get(model, MOI.TerminationStatus()) == MOI.INFEASIBLE
116+
@test MOI.get(model, MOI.PrimalStatus()) == MOI.NO_SOLUTION
117+
@test MOI.get(model, MOI.DualStatus()) == MOI.NO_SOLUTION
118+
return
119+
end
120+
121+
function test_unbounded()
122+
model = MOA.Optimizer(HiGHS.Optimizer)
123+
MOI.set(model, MOA.Algorithm(), MOA.Sandwiching(0.0))
124+
MOI.set(model, MOI.Silent(), true)
125+
x = MOI.add_variables(model, 2)
126+
MOI.add_constraint.(model, x, MOI.GreaterThan(0.0))
127+
f = MOI.Utilities.operate(vcat, Float64, 1.0 .* x...)
128+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
129+
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
130+
MOI.optimize!(model)
131+
@test MOI.get(model, MOI.TerminationStatus()) == MOI.DUAL_INFEASIBLE
132+
@test MOI.get(model, MOI.PrimalStatus()) == MOI.NO_SOLUTION
133+
@test MOI.get(model, MOI.DualStatus()) == MOI.NO_SOLUTION
134+
return
135+
end
136+
104137
end # TestSandwiching
105138

106139
TestSandwiching.run_tests()

0 commit comments

Comments
 (0)