From 1af9448e0357b96125f2070a7e6a2bd7851f31df Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 15 Aug 2022 08:46:58 +1200 Subject: [PATCH 1/4] Fix handling of {Primal,Dual}Status --- src/MOI_wrapper/results.jl | 19 +++---------------- test/user_limits.jl | 9 ++++++--- 2 files changed, 9 insertions(+), 19 deletions(-) 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/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 From ad6dac55f8713e72ee08c97729e8c1cd9b32aadb Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 15 Aug 2022 09:13:47 +1200 Subject: [PATCH 2/4] Fix tests --- test/conic.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From dc26a56366e90e3a3eae587f1b758c03ed30ecc2 Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 15 Aug 2022 10:17:10 +1200 Subject: [PATCH 3/4] Fix tests --- test/basic.jl | 4 ++-- test/fpump.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/basic.jl b/test/basic.jl index bca25d4..e450ecb 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 @@ -328,7 +328,7 @@ include("basic/gamsworld.jl") @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.dual_status(m) == MOI.NO_SOLUTION @test isnan(relative_gap(m)) end 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 From f99ab6164d36ae61698b43e1f198b6f4d372beb0 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 15 Aug 2022 11:24:26 +1200 Subject: [PATCH 4/4] Update basic.jl --- test/basic.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/basic.jl b/test/basic.jl index e450ecb..bf38df2 100644 --- a/test/basic.jl +++ b/test/basic.jl @@ -327,7 +327,7 @@ 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.primal_status(m) == MOI.UNKNOWN_RESULT_STATUS @test JuMP.dual_status(m) == MOI.NO_SOLUTION @test isnan(relative_gap(m)) end