diff --git a/src/MOI_wrapper/results.jl b/src/MOI_wrapper/results.jl index 093bb8e..0e45c69 100644 --- a/src/MOI_wrapper/results.jl +++ b/src/MOI_wrapper/results.jl @@ -14,30 +14,17 @@ end function MOI.get(model::Optimizer, ::MOI.PrimalStatus) if model.inner === nothing return MOI.NO_SOLUTION - end - if state_is_optimal( + elseif state_is_optimal( model.inner.status; allow_almost = model.inner.options.allow_almost_solved, ) return MOI.FEASIBLE_POINT else - return MOI.INFEASIBLE_POINT + return MOI.UNKNOWN_RESULT_STATUS end end -function MOI.get(model::Optimizer, ::MOI.DualStatus) - if model.inner === nothing - return MOI.NO_SOLUTION - end - if state_is_optimal( - model.inner.status; - allow_almost = model.inner.options.allow_almost_solved, - ) - return MOI.FEASIBLE_POINT - else - return MOI.INFEASIBLE_POINT - end -end +MOI.get(::Optimizer, ::MOI.DualStatus) = MOI.NO_SOLUTION function MOI.get(model::Optimizer, ::MOI.ObjectiveValue) if model.inner.status == MOI.OPTIMIZE_NOT_CALLED diff --git a/test/basic.jl b/test/basic.jl index bca25d4..bf38df2 100644 --- a/test/basic.jl +++ b/test/basic.jl @@ -17,7 +17,7 @@ include("basic/gamsworld.jl") @test rand() != rand_num @test JuMP.termination_status(m) == MOI.LOCALLY_SOLVED @test JuMP.primal_status(m) == MOI.FEASIBLE_POINT - @test JuMP.dual_status(m) == MOI.FEASIBLE_POINT + @test JuMP.dual_status(m) == MOI.NO_SOLUTION @test isapprox(JuMP.value(x), 5, atol = sol_atol) @test result_count(m) == 1 @test unsafe_backend(m).inner.primal_start[1] == 3 @@ -327,8 +327,8 @@ include("basic/gamsworld.jl") println("Status: ", status) @test status == MOI.LOCALLY_INFEASIBLE @test JuMP.termination_status(m) == MOI.LOCALLY_INFEASIBLE - @test JuMP.primal_status(m) == MOI.INFEASIBLE_POINT - @test JuMP.dual_status(m) == MOI.INFEASIBLE_POINT + @test JuMP.primal_status(m) == MOI.UNKNOWN_RESULT_STATUS + @test JuMP.dual_status(m) == MOI.NO_SOLUTION @test isnan(relative_gap(m)) end diff --git a/test/conic.jl b/test/conic.jl index 7df583c..1c4a892 100644 --- a/test/conic.jl +++ b/test/conic.jl @@ -35,7 +35,7 @@ function test_simple_conic_model() optimize!(model) @test termination_status(model) == LOCALLY_SOLVED @test primal_status(model) == FEASIBLE_POINT - @test dual_status(model) == FEASIBLE_POINT + @test dual_status(model) == NO_SOLUTION @test isapprox(value.(x), [6, 8]; atol = 1e-4) @test sqrt(value(x[1])^2 + value(x[2])^2) <= 10 + 1e-4 @test isapprox(objective_value(model), 58; atol = 1e-2) @@ -64,7 +64,7 @@ function test_simple_conic_model_ipopt() optimize!(model) @test termination_status(model) == LOCALLY_SOLVED @test primal_status(model) == FEASIBLE_POINT - @test dual_status(model) == FEASIBLE_POINT + @test dual_status(model) == NO_SOLUTION @test isapprox(value.(x), [6, 8]; atol = 1e-6) @test sqrt(value(x[1])^2 + value(x[2])^2) <= 10 + 1e-6 @test isapprox(objective_value(model), 58; atol = 1e-6) diff --git a/test/fpump.jl b/test/fpump.jl index b9aada9..3451507 100644 --- a/test/fpump.jl +++ b/test/fpump.jl @@ -22,7 +22,7 @@ include("basic/gamsworld.jl") optimize!(m) @test JuMP.termination_status(m) == MOI.LOCALLY_SOLVED @test JuMP.primal_status(m) == MOI.FEASIBLE_POINT - @test JuMP.dual_status(m) == MOI.FEASIBLE_POINT + @test JuMP.dual_status(m) == MOI.NO_SOLUTION @test isapprox(JuMP.value(x), 5, atol = sol_atol) @test result_count(m) == 1 @test unsafe_backend(m).inner.primal_start[1] == 3 diff --git a/test/user_limits.jl b/test/user_limits.jl index 473238f..e11ec22 100644 --- a/test/user_limits.jl +++ b/test/user_limits.jl @@ -39,14 +39,17 @@ include("POD_experiment/FLay02H.jl") Juniper.Optimizer, DefaultTestSolver( branch_strategy = :StrongPseudoCost, - time_limit = 5, + time_limit = 1, incumbent_constr = true, )..., ), ) optimize!(m) - status = termination_status(m) - @test status == MOI.LOCALLY_SOLVED || status == MOI.TIME_LIMIT + t_status = termination_status(m) + p_status = primal_status(m) + @test dual_status(m) == NO_SOLUTION + @test (t_status, p_status) == (LOCALLY_SOLVED, FEASIBLE_POINT) || + (t_status, p_status) == (TIME_LIMIT, UNKNOWN_RESULT_STATUS) @test solve_time(m) <= 15 # it might be a bit higher than 5s end end