From eb0b271e461ef6c4458f82803623f696229679dc Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 17 Dec 2018 10:58:49 -0600 Subject: [PATCH] Update LQOI (#178) * Prepare for upgraded LQOI * Update REQUIRE --- REQUIRE | 2 +- src/MOIWrapper.jl | 23 ++++++++++------------- test/MOIWrapper.jl | 10 +++++++--- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/REQUIRE b/REQUIRE index fae402cb..bae80ab5 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,4 @@ julia 0.6 MathProgBase 0.5 0.8 Compat 0.33 -LinQuadOptInterface 0.4 0.5 +LinQuadOptInterface 0.5 0.6 diff --git a/src/MOIWrapper.jl b/src/MOIWrapper.jl index 7134a1b7..bf969dca 100644 --- a/src/MOIWrapper.jl +++ b/src/MOIWrapper.jl @@ -343,6 +343,11 @@ function LQOI.add_mip_starts!(model::Optimizer, columns::Vector{Int}, starts::Ve update_model!(model.inner) return end +function MOI.supports( + ::Optimizer, ::MOI.VariablePrimalStart, ::Type{MOI.VariableIndex}) + return true +end + LQOI.solve_mip_problem!(model::Optimizer) = LQOI.solve_linear_problem!(model) @@ -359,21 +364,13 @@ function LQOI.get_termination_status(model::Optimizer) if stat == :loaded return MOI.OtherError elseif stat == :optimal - return MOI.Success + return MOI.Optimal elseif stat == :infeasible - if has_dual_ray(model) - return MOI.Success - else - return MOI.InfeasibleNoResult - end + return MOI.Infeasible elseif stat == :inf_or_unbd return MOI.InfeasibleOrUnbounded elseif stat == :unbounded - if has_primal_ray(model) - return MOI.Success - else - return MOI.UnboundedNoResult - end + return MOI.DualInfeasible elseif stat == :cutoff return MOI.ObjectiveLimit elseif stat == :iteration_limit @@ -418,7 +415,7 @@ end function LQOI.get_dual_status(model::Optimizer) stat = get_status(model.inner) if is_mip(model.inner) || is_qcp(model.inner) - return MOI.UnknownResultStatus + return MOI.NoSolution else if stat == :optimal return MOI.FeasiblePoint @@ -430,7 +427,7 @@ function LQOI.get_dual_status(model::Optimizer) return MOI.FeasiblePoint end end - return MOI.UnknownResultStatus + return MOI.NoSolution end function LQOI.get_variable_primal_solution!(model::Optimizer, dest) diff --git a/test/MOIWrapper.jl b/test/MOIWrapper.jl index d1905df9..72e36103 100644 --- a/test/MOIWrapper.jl +++ b/test/MOIWrapper.jl @@ -79,9 +79,13 @@ end end @testset "ModelLike tests" begin solver = Gurobi.Optimizer() - @test MOI.get(solver, MOI.SolverName()) == "Gurobi" - + @testset "default_objective_test" begin + MOIT.default_objective_test(solver) + end + @testset "default_status_test" begin + MOIT.default_status_test(solver) + end @testset "nametest" begin MOIT.nametest(solver) end @@ -240,7 +244,7 @@ end # We should have a primal feasible solution: @test MOI.get(m, MOI.PrimalStatus()) == MOI.FeasiblePoint # But we have no dual status: - @test MOI.get(m, MOI.DualStatus()) == MOI.UnknownResultStatus + @test MOI.get(m, MOI.DualStatus()) == MOI.NoSolution end @testset "Constant objective (issue #111)" begin