Skip to content

Commit d31ba21

Browse files
committed
Update
1 parent df9b3f1 commit d31ba21

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

test/algorithms/Chalmet.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,23 @@ function test_vector_of_variables_objective()
206206
return
207207
end
208208

209+
function test_too_many_objectives()
210+
P = Float64[1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0]
211+
model = MOA.Optimizer(HiGHS.Optimizer)
212+
MOI.set(model, MOA.Algorithm(), MOA.Chalmet())
213+
x = MOI.add_variables(model, 4)
214+
MOI.add_constraint.(model, x, MOI.GreaterThan(0.0))
215+
MOI.add_constraint.(model, x, MOI.LessThan(1.0))
216+
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
217+
f = MOI.Utilities.operate(vcat, Float64, P * x...)
218+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
219+
@test_throws(
220+
ErrorException("Chalmet requires exactly two objectives"),
221+
MOI.optimize!(model),
222+
)
223+
return
224+
end
225+
209226
end
210227

211228
TestChalmet.run_tests()

test/algorithms/EpsilonConstraint.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,23 @@ function test_vector_of_variables_objective()
467467
return
468468
end
469469

470+
function test_too_many_objectives()
471+
P = Float64[1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0]
472+
model = MOA.Optimizer(HiGHS.Optimizer)
473+
MOI.set(model, MOA.Algorithm(), MOA.EpsilonConstraint())
474+
x = MOI.add_variables(model, 4)
475+
MOI.add_constraint.(model, x, MOI.GreaterThan(0.0))
476+
MOI.add_constraint.(model, x, MOI.LessThan(1.0))
477+
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
478+
f = MOI.Utilities.operate(vcat, Float64, P * x...)
479+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
480+
@test_throws(
481+
ErrorException("EpsilonConstraint requires exactly two objectives"),
482+
MOI.optimize!(model),
483+
)
484+
return
485+
end
486+
470487
end
471488

472489
TestEpsilonConstraint.run_tests()

test/algorithms/Hierarchical.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ function test_knapsack()
3636
P = Float64[1 0 0 0; 0 1 1 0; 0 0 1 1; 0 1 0 0]
3737
model = MOA.Optimizer(HiGHS.Optimizer)
3838
MOI.set(model, MOA.Algorithm(), MOA.Hierarchical())
39+
@test MOI.supports(model, MOA.ObjectivePriority(1))
3940
MOI.set.(model, MOA.ObjectivePriority.(1:4), [2, 1, 1, 0])
41+
@test MOI.supports(model, MOA.ObjectiveWeight(1))
4042
MOI.set.(model, MOA.ObjectiveWeight.(1:4), [1, 0.5, 0.5, 1])
43+
@test MOI.supports(model, MOA.ObjectiveRelativeTolerance(1))
4144
MOI.set(model, MOA.ObjectiveRelativeTolerance(1), 0.1)
4245
MOI.set(model, MOI.Silent(), true)
4346
x = MOI.add_variables(model, 4)

0 commit comments

Comments
 (0)