Skip to content

Commit df9b3f1

Browse files
committed
Improve test coverage
1 parent 657ea54 commit df9b3f1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/algorithms/Lexicographic.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function test_knapsack()
2727
model = MOA.Optimizer(HiGHS.Optimizer)
2828
MOI.set(model, MOA.Algorithm(), MOA.Lexicographic())
2929
@test MOI.supports(model, MOA.LexicographicAllPermutations())
30+
@test MOI.supports(model, MOA.ObjectiveRelativeTolerance(1))
3031
MOI.set(model, MOA.LexicographicAllPermutations(), false)
3132
MOI.set(model, MOA.ObjectiveRelativeTolerance(1), 0.1)
3233
MOI.set(model, MOI.Silent(), true)
@@ -175,6 +176,27 @@ function test_warn_all_permutations()
175176
return
176177
end
177178

179+
function test_knapsack_time_limit()
180+
P = Float64[1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0]
181+
model = MOA.Optimizer(HiGHS.Optimizer)
182+
MOI.set(model, MOA.Algorithm(), MOA.Lexicographic())
183+
MOI.set(model, MOA.LexicographicAllPermutations(), false)
184+
MOI.set(model, MOA.ObjectiveRelativeTolerance(1), 0.1)
185+
MOI.set(model, MOI.Silent(), true)
186+
x = MOI.add_variables(model, 4)
187+
MOI.add_constraint.(model, x, MOI.GreaterThan(0.0))
188+
MOI.add_constraint.(model, x, MOI.LessThan(1.0))
189+
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
190+
f = MOI.Utilities.operate(vcat, Float64, P * x...)
191+
f.constants[4] = 1_000.0
192+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
193+
MOI.add_constraint(model, sum(1.0 * x[i] for i in 1:4), MOI.LessThan(2.0))
194+
MOI.set(model, MOI.TimeLimitSec(), 0.0)
195+
MOI.optimize!(model)
196+
@test MOI.get(model, MOI.TerminationStatus()) == MOI.TIME_LIMIT
197+
return
198+
end
199+
178200
end
179201

180202
TestLexicographic.run_tests()

0 commit comments

Comments
 (0)