Skip to content

Commit

Permalink
Update to LQOI 0.6 (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Dec 21, 2018
1 parent eb0b271 commit 5f3a7c4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.6
MathProgBase 0.5 0.8
Compat 0.33
LinQuadOptInterface 0.5 0.6
LinQuadOptInterface 0.6 0.7
60 changes: 30 additions & 30 deletions src/MOIWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ end
function LQOI.get_objectivesense(model::Optimizer)
sense = model_sense(model.inner)
if sense == :maximize
return MOI.MaxSense
return MOI.MAX_SENSE
elseif sense == :minimize
return MOI.MinSense
return MOI.MIN_SENSE
else
error("Invalid objective sense: $(sense)")
end
Expand Down Expand Up @@ -362,72 +362,72 @@ end
function LQOI.get_termination_status(model::Optimizer)
stat = get_status(model.inner)
if stat == :loaded
return MOI.OtherError
return MOI.OTHER_ERROR
elseif stat == :optimal
return MOI.Optimal
return MOI.OPTIMAL
elseif stat == :infeasible
return MOI.Infeasible
return MOI.INFEASIBLE
elseif stat == :inf_or_unbd
return MOI.InfeasibleOrUnbounded
return MOI.INFEASIBLE_OR_UNBOUNDED
elseif stat == :unbounded
return MOI.DualInfeasible
return MOI.DUAL_INFEASIBLE
elseif stat == :cutoff
return MOI.ObjectiveLimit
return MOI.OBJECTIVE_LIMIT
elseif stat == :iteration_limit
return MOI.IterationLimit
return MOI.ITERATION_LIMIT
elseif stat == :node_limit
return MOI.NodeLimit
return MOI.NODE_LIMIT
elseif stat == :time_limit
return MOI.TimeLimit
return MOI.TIME_LIMIT
elseif stat == :solution_limit
return MOI.SolutionLimit
return MOI.SOLUTION_LIMIT
elseif stat == :interrupted
return MOI.Interrupted
return MOI.INTERRUPTED
elseif stat == :numeric
return MOI.NumericalError
return MOI.NUMERICAL_ERROR
elseif stat == :suboptimal
return MOI.OtherLimit
return MOI.OTHER_LIMIT
elseif stat == :inprogress
return MOI.OtherError
return MOI.OTHER_ERROR
elseif stat == :user_obj_limit
return MOI.ObjectiveLimit
return MOI.OBJECTIVE_LIMIT
end
return MOI.OtherError
return MOI.OTHER_ERROR
end

function LQOI.get_primal_status(model::Optimizer)
stat = get_status(model.inner)
if stat == :optimal
return MOI.FeasiblePoint
return MOI.FEASIBLE_POINT
elseif stat == :solution_limit
return MOI.FeasiblePoint
return MOI.FEASIBLE_POINT
elseif (stat == :inf_or_unbd || stat == :unbounded) && has_primal_ray(model)
return MOI.InfeasibilityCertificate
return MOI.INFEASIBILITY_CERTIFICATE
elseif stat == :suboptimal
return MOI.FeasiblePoint
return MOI.FEASIBLE_POINT
elseif is_mip(model.inner) && get_sol_count(model.inner) > 0
return MOI.FeasiblePoint
return MOI.FEASIBLE_POINT
else
return MOI.NoSolution
return MOI.NO_SOLUTION
end
end

function LQOI.get_dual_status(model::Optimizer)
stat = get_status(model.inner)
if is_mip(model.inner) || is_qcp(model.inner)
return MOI.NoSolution
return MOI.NO_SOLUTION
else
if stat == :optimal
return MOI.FeasiblePoint
return MOI.FEASIBLE_POINT
elseif stat == :solution_limit
return MOI.FeasiblePoint
return MOI.FEASIBLE_POINT
elseif (stat == :inf_or_unbd || stat == :infeasible) && has_dual_ray(model)
return MOI.InfeasibilityCertificate
return MOI.INFEASIBILITY_CERTIFICATE
elseif stat == :suboptimal
return MOI.FeasiblePoint
return MOI.FEASIBLE_POINT
end
end
return MOI.NoSolution
return MOI.NO_SOLUTION
end

function LQOI.get_variable_primal_solution!(model::Optimizer, dest)
Expand Down
6 changes: 3 additions & 3 deletions test/MOIWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ end
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(.-item_values, x), 0.0))
MOI.optimize!(m)

@test MOI.get(m, MOI.TerminationStatus()) == MOI.SolutionLimit
@test MOI.get(m, MOI.TerminationStatus()) == MOI.SOLUTION_LIMIT
# We should have a primal feasible solution:
@test MOI.get(m, MOI.PrimalStatus()) == MOI.FeasiblePoint
@test MOI.get(m, MOI.PrimalStatus()) == MOI.FEASIBLE_POINT
# But we have no dual status:
@test MOI.get(m, MOI.DualStatus()) == MOI.NoSolution
@test MOI.get(m, MOI.DualStatus()) == MOI.NO_SOLUTION
end

@testset "Constant objective (issue #111)" begin
Expand Down

0 comments on commit 5f3a7c4

Please sign in to comment.