diff --git a/src/Test/UnitTests/solve.jl b/src/Test/UnitTests/solve.jl index 3c58b69f56..0ff5f5d994 100644 --- a/src/Test/UnitTests/solve.jl +++ b/src/Test/UnitTests/solve.jl @@ -79,3 +79,19 @@ function solve_objbound_edge_cases(model::MOI.ModelLike, config::TestConfig) end end unittests["solve_objbound_edge_cases"] = solve_objbound_edge_cases + +function solve_unbounded_model(model::MOI.ModelLike, config::TestConfig) + MOI.empty!(model) + x = MOI.add_variables(model, 5) + MOI.set( + model, + MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), + MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(1.0, x), 0.0) + ) + MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE) + if config.solve + MOI.optimize!(model) + @test MOI.get(model, MOI.TerminationStatus()) == MOI.DUAL_INFEASIBLE + end +end +unittests["solve_unbounded_model"] = solve_unbounded_model diff --git a/test/Test/unit.jl b/test/Test/unit.jl index 11051277ea..b978c67bbb 100644 --- a/test/Test/unit.jl +++ b/test/Test/unit.jl @@ -41,7 +41,8 @@ end "solve_time", "solve_zero_one_with_bounds_1", "solve_zero_one_with_bounds_2", - "solve_zero_one_with_bounds_3" + "solve_zero_one_with_bounds_3", + "solve_unbounded_model" ]) MOI.empty!(model) end @@ -329,6 +330,15 @@ end MOIT.solve_zero_one_with_bounds_2(mock, config) MOIT.solve_zero_one_with_bounds_3(mock, config) end + + @testset "solve_unbounded_model" begin + MOIU.set_mock_optimize!(mock, + (mock::MOIU.MockOptimizer) -> begin + MOIU.mock_optimize!(mock, MOI.DUAL_INFEASIBLE) + end + ) + MOIT.solve_unbounded_model(mock, config) + end end @testset "modifications" begin