From 1e76d382507277f7d65359c8f7c6a4855dc4ffc2 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 16 Mar 2026 14:20:37 +1300 Subject: [PATCH 1/3] [Test] add a new test for solving a multiobjective problem --- src/Test/test_multiobjective.jl | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/Test/test_multiobjective.jl b/src/Test/test_multiobjective.jl index d8b64735e9..6e5df47e47 100644 --- a/src/Test/test_multiobjective.jl +++ b/src/Test/test_multiobjective.jl @@ -379,3 +379,49 @@ function test_multiobjective_vector_nonlinear_modify( end version_added(::typeof(test_multiobjective_vector_nonlinear_modify)) = v"1.19.0" + +function test_multi_objective_solve_and_objective_value( + model::MOI.ModelLike, + ::Config{T}, +) where {T} + F = MOI.VectorAffineFunction{T} + @requires _supports(config, MOI.optimize!) + @requires MOI.supports(model, MOI.ObjectiveFunction{F}()) + x = MOI.add_variables(model, 3) + MOI.add_constraint.(model, x, MOI.Interval(zero(T), one(T))) + f = sum(one(T) * x[i] for i in 1:3) + MOI.add_constraint(model, f, MOI.LessThan(T(2))) + g = MOI.Utilities.vectorize([ + T(3) * x[1], + T(3) * x[1] + T(1) * x[2] + T(2) * x[3], + ]) + MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE) + MOI.set(model, MOI.ObjectiveFunction{typeof(g)}(), g) + MOI.optimize!(model) + @test MOI.get(model, MOI.ResultCount()) > 0 + for i in 1:MOI.get(model, MOI.ResultCount()) + y = MOI.Utilities.eval_variables(model, g) do xi + return MOI.get(model, MOI.VariablePrimal(i), xi) + end + @test isapprox(MOI.get(model, MOI.ObjectiveValue()), y) + end + return +end + +function setup_test( + ::typeof(test_multi_objective_solve_and_objective_value), + model::MOIU.MockOptimizer, + ::Config{T}, +) where {T} + MOIU.set_mock_optimize!( + model, + mock -> MOIU.mock_optimize!( + mock, + MOI.OPTIMAL, + (MOI.FEASIBLE_POINT, T[1, 0, 1]), + ), + ) + return +end + +version_added(::typeof(test_multiobjective_vector_nonlinear_modify)) = v"1.50.0" From 3b079b84e711be885bf9ff516bf55b61d22578d1 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 16 Mar 2026 14:33:45 +1300 Subject: [PATCH 2/3] Update --- src/Test/test_multiobjective.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Test/test_multiobjective.jl b/src/Test/test_multiobjective.jl index 6e5df47e47..6a4aec7bc1 100644 --- a/src/Test/test_multiobjective.jl +++ b/src/Test/test_multiobjective.jl @@ -424,4 +424,6 @@ function setup_test( return end -version_added(::typeof(test_multiobjective_vector_nonlinear_modify)) = v"1.50.0" +function version_added(::typeof(test_multi_objective_solve_and_objective_value)) + return v"1.50.0" +end From b5ee88c705f6a39ce2696b35eaeb2a7bffc35f2c Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 16 Mar 2026 15:18:21 +1300 Subject: [PATCH 3/3] Update --- src/Test/test_multiobjective.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Test/test_multiobjective.jl b/src/Test/test_multiobjective.jl index 6a4aec7bc1..b8f2a63539 100644 --- a/src/Test/test_multiobjective.jl +++ b/src/Test/test_multiobjective.jl @@ -382,7 +382,7 @@ version_added(::typeof(test_multiobjective_vector_nonlinear_modify)) = v"1.19.0" function test_multi_objective_solve_and_objective_value( model::MOI.ModelLike, - ::Config{T}, + config::Config{T}, ) where {T} F = MOI.VectorAffineFunction{T} @requires _supports(config, MOI.optimize!)