Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions src/MOI_wrapper/results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test/conic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/fpump.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions test/user_limits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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