Skip to content
This repository was archived by the owner on Jun 14, 2020. It is now read-only.

Commit 0fffd7f

Browse files
authored
Update to MOI v0.8 (#83)
1 parent c9b8473 commit 0fffd7f

9 files changed

Lines changed: 61 additions & 61 deletions

File tree

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
julia 0.6
2-
MathOptInterface 0.7 0.8
2+
MathOptInterface 0.8 0.9
33
Compat 0.59

src/LinQuadOptInterface.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function MOI.is_empty(m::LinQuadOptimizer)
283283
ret = ret && m.name == ""
284284
ret = ret && m.obj_type == AffineObjective
285285
ret = ret && isa(m.single_obj_var, Nothing)
286-
ret = ret && m.obj_sense == MOI.MinSense
286+
ret = ret && m.obj_sense == MOI.MIN_SENSE
287287
ret = ret && m.last_variable_reference == 0
288288
ret = ret && isempty(m.variable_mapping)
289289
ret = ret && isempty(m.variable_names)
@@ -302,9 +302,9 @@ function MOI.is_empty(m::LinQuadOptimizer)
302302
ret = ret && isempty(m.constraint_names)
303303
ret = ret && isempty(m.constraint_names_rev)
304304
ret = ret && m.objective_constant == 0.0
305-
ret = ret && m.termination_status == MOI.OptimizeNotCalled
306-
ret = ret && m.primal_status == MOI.NoSolution
307-
ret = ret && m.dual_status == MOI.NoSolution
305+
ret = ret && m.termination_status == MOI.OPTIMIZE_NOT_CALLED
306+
ret = ret && m.primal_status == MOI.NO_SOLUTION
307+
ret = ret && m.dual_status == MOI.NO_SOLUTION
308308
ret = ret && m.primal_result_count == 0
309309
ret = ret && m.dual_result_count == 0
310310
ret = ret && m.solvetime == 0.0
@@ -318,7 +318,7 @@ function MOI.empty!(m::M, env = nothing) where M<:LinQuadOptimizer
318318
m.obj_type = AffineObjective
319319
m.single_obj_var = nothing
320320
# we assume the default is minimization
321-
m.obj_sense = MOI.MinSense
321+
m.obj_sense = MOI.MIN_SENSE
322322

323323
m.last_variable_reference = 0
324324
m.variable_mapping = Dict{MathOptInterface.VariableIndex, Int}()
@@ -344,9 +344,9 @@ function MOI.empty!(m::M, env = nothing) where M<:LinQuadOptimizer
344344

345345
m.objective_constant = 0.0
346346

347-
m.termination_status = MathOptInterface.OptimizeNotCalled
348-
m.primal_status = MathOptInterface.NoSolution
349-
m.dual_status = MathOptInterface.NoSolution
347+
m.termination_status = MathOptInterface.OPTIMIZE_NOT_CALLED
348+
m.primal_status = MathOptInterface.NO_SOLUTION
349+
m.dual_status = MathOptInterface.NO_SOLUTION
350350
m.primal_result_count = 0
351351
m.dual_result_count = 0
352352

src/mockoptimizer.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ mutable struct MockLinQuadModel # <: LinQuadOptInterface.LinQuadOptimizer
6363

6464
m.sos = LinQuadSOS[]
6565

66-
m.termination_status = MOI.OptimizeNotCalled
67-
m.primal_status = MOI.NoSolution
68-
m.dual_status = MOI.NoSolution
66+
m.termination_status = MOI.OPTIMIZE_NOT_CALLED
67+
m.primal_status = MOI.NO_SOLUTION
68+
m.dual_status = MOI.NO_SOLUTION
6969

7070
m.variable_primal_solution = zeros(0)
7171
m.variable_dual_solution = zeros(0)
@@ -288,9 +288,9 @@ function set_solution!(instance::MockLinQuadOptimizer;
288288
constraint_dual = Float64[],
289289
quadratic_primal = Float64[],
290290
quadratic_dual = Float64[],
291-
termination_status = MOI.Optimal,
292-
primal_status = MOI.FeasiblePoint,
293-
dual_status = MOI.FeasiblePoint
291+
termination_status = MOI.OPTIMAL,
292+
primal_status = MOI.FEASIBLE_POINT,
293+
dual_status = MOI.FEASIBLE_POINT
294294
)
295295

296296
set_variable_primal_solution!(instance, variable_primal)
@@ -670,9 +670,9 @@ end
670670
function LQOI.get_objectivesense(instance::MockLinQuadOptimizer)
671671
s = instance.inner.sense
672672
if s == :maximize
673-
return MOI.MaxSense
673+
return MOI.MAX_SENSE
674674
else
675-
return MOI.MinSense
675+
return MOI.MIN_SENSE
676676
end
677677
end
678678

src/objective.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ MOI.supports(::LinQuadOptimizer, ::MOI.ObjectiveSense) = true
77
MOI.get(model::LinQuadOptimizer,::MOI.ObjectiveSense) = model.obj_sense
88
function MOI.set(model::LinQuadOptimizer, ::MOI.ObjectiveSense,
99
sense::MOI.OptimizationSense)
10-
if sense == MOI.MinSense
10+
if sense == MOI.MIN_SENSE
1111
change_objective_sense!(model, :min)
12-
model.obj_sense = MOI.MinSense
13-
elseif sense == MOI.MaxSense
12+
model.obj_sense = MOI.MIN_SENSE
13+
elseif sense == MOI.MAX_SENSE
1414
change_objective_sense!(model, :max)
15-
model.obj_sense = MOI.MaxSense
16-
elseif sense == MOI.FeasibilitySense
15+
model.obj_sense = MOI.MAX_SENSE
16+
elseif sense == MOI.FEASIBILITY_SENSE
1717
# we set the objective sense to :min, and the objective to 0.0
1818
change_objective_sense!(model, :min)
1919
unsafe_set!(model, MOI.ObjectiveFunction{Linear}(),
2020
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{Float64}[],
2121
0.0))
2222
model.obj_type = AffineObjective
23-
model.obj_sense = MOI.FeasibilitySense
23+
model.obj_sense = MOI.FEASIBILITY_SENSE
2424
else
2525
throw(MOI.CannotSetAttribute(MOI.ObjectiveSense,
2626
"ObjectiveSense $(sense) not recognised."))
@@ -33,10 +33,10 @@ end
3333

3434
function __assert_objective__(model::LinQuadOptimizer,
3535
attribute::MOI.ObjectiveFunction{F}) where F
36-
if MOI.get(model, MOI.ObjectiveSense()) == MOI.FeasibilitySense
36+
if MOI.get(model, MOI.ObjectiveSense()) == MOI.FEASIBILITY_SENSE
3737
# it doesn't make sense to set an objective for a feasibility problem
3838
throw(MOI.CannotSetAttribute(attribute, "Cannot set $(attribute) when" *
39-
" MOI.ObjectiveSense is MOI.FeasibilitySense."))
39+
" MOI.ObjectiveSense is MOI.FEASIBILITY_SENSE."))
4040
elseif !(F in supported_objectives(model))
4141
throw(MOI.UnsupportedAttribute(attribute))
4242
end

src/solve.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function MOI.optimize!(model::LinQuadOptimizer)
1515
fill!(model.variable_dual_solution, NaN)
1616
fill!(model.constraint_primal_solution, NaN)
1717
fill!(model.constraint_dual_solution, NaN)
18-
model.primal_status = MOI.NoSolution
19-
model.dual_status = MOI.NoSolution
18+
model.primal_status = MOI.NO_SOLUTION
19+
model.dual_status = MOI.NO_SOLUTION
2020
model.primal_result_count = 0
2121
model.dual_result_count = 0
2222

@@ -35,31 +35,31 @@ function MOI.optimize!(model::LinQuadOptimizer)
3535
model.primal_status = get_primal_status(model)
3636
model.dual_status = get_dual_status(model)
3737

38-
if model.primal_status in [MOI.FeasiblePoint, MOI.InfeasiblePoint]
38+
if model.primal_status in [MOI.FEASIBLE_POINT, MOI.INFEASIBLE_POINT]
3939
get_variable_primal_solution!(model, model.variable_primal_solution)
4040
get_linear_primal_solution!(model, model.constraint_primal_solution)
4141
if has_quadratic(model)
4242
get_quadratic_primal_solution!(model, model.qconstraint_primal_solution)
4343
end
4444
model.primal_result_count = 1
45-
elseif model.primal_status == MOI.InfeasibilityCertificate
45+
elseif model.primal_status == MOI.INFEASIBILITY_CERTIFICATE
4646
get_unbounded_ray!(model, model.variable_primal_solution)
4747
model.primal_result_count = 1
4848
end
49-
if model.dual_status in [MOI.FeasiblePoint, MOI.InfeasiblePoint]
49+
if model.dual_status in [MOI.FEASIBLE_POINT, MOI.INFEASIBLE_POINT]
5050
get_variable_dual_solution!(model, model.variable_dual_solution)
5151
get_linear_dual_solution!(model, model.constraint_dual_solution)
5252
if has_quadratic(model)
5353
get_quadratic_dual_solution!(model, model.qconstraint_dual_solution)
5454
end
5555
model.dual_result_count = 1
56-
elseif model.dual_status == MOI.InfeasibilityCertificate
56+
elseif model.dual_status == MOI.INFEASIBILITY_CERTIFICATE
5757
get_farkas_dual!(model, model.constraint_dual_solution)
5858
get_farkas_dual_bounds!(model, model.variable_dual_solution)
5959
model.dual_result_count = 1
6060
end
6161

62-
if MOI.get(model, MOI.ObjectiveSense()) == MOI.MaxSense
62+
if MOI.get(model, MOI.ObjectiveSense()) == MOI.MAX_SENSE
6363
model.constraint_dual_solution *= -1
6464
model.variable_dual_solution *= -1
6565
end
@@ -151,7 +151,7 @@ function MOI.get(model::LinQuadOptimizer, ::MOI.ConstraintDual, index::SVCI{<: L
151151
column = get_column(model, model[index])
152152
# the variable reduced cost is only the constraint dual if the bound is active,
153153
# or it might be a dual ray
154-
if model.dual_status == MOI.InfeasibilityCertificate
154+
if model.dual_status == MOI.INFEASIBILITY_CERTIFICATE
155155
return model.variable_dual_solution[column]
156156
else
157157
set = MOI.get(model, MOI.ConstraintSet(), index)

test/contconic.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ end
2323
function set_lin3test_solutions!(solver)
2424
# SOLVE 1
2525
LQOI.set_solution!(solver,
26-
termination_status = MOI.Infeasible,
27-
primal_status = MOI.NoSolution,
28-
dual_status = MOI.InfeasibilityCertificate,
26+
termination_status = MOI.INFEASIBLE,
27+
primal_status = MOI.NO_SOLUTION,
28+
dual_status = MOI.INFEASIBILITY_CERTIFICATE,
2929
variable_primal = [NaN],
3030
constraint_primal = [NaN, NaN],
3131
variable_dual = [NaN],

test/contlinear.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ end
198198
function set_linear8atest_solutions!(solver)
199199
# SOLVE 1
200200
LQOI.set_solution!(solver,
201-
termination_status = MOI.Infeasible,
202-
primal_status = MOI.NoSolution,
203-
dual_status = MOI.InfeasibilityCertificate,
201+
termination_status = MOI.INFEASIBLE,
202+
primal_status = MOI.NO_SOLUTION,
203+
dual_status = MOI.INFEASIBILITY_CERTIFICATE,
204204
variable_dual = [NaN, NaN],
205205
constraint_dual = [-0.5]
206206
)
@@ -210,9 +210,9 @@ end
210210
function set_linear8btest_solutions!(solver)
211211
# SOLVE 1
212212
LQOI.set_solution!(solver,
213-
termination_status = MOI.DualInfeasible,
214-
primal_status = MOI.InfeasibilityCertificate,
215-
dual_status = MOI.NoSolution,
213+
termination_status = MOI.DUAL_INFEASIBLE,
214+
primal_status = MOI.INFEASIBILITY_CERTIFICATE,
215+
dual_status = MOI.NO_SOLUTION,
216216
variable_primal = [2.0, 1.0],
217217
constraint_primal = [NaN]
218218
)
@@ -222,9 +222,9 @@ end
222222
function set_linear8ctest_solutions!(solver)
223223
# SOLVE 1
224224
LQOI.set_solution!(solver,
225-
termination_status = MOI.DualInfeasible,
226-
primal_status = MOI.InfeasibilityCertificate,
227-
dual_status = MOI.NoSolution,
225+
termination_status = MOI.DUAL_INFEASIBLE,
226+
primal_status = MOI.INFEASIBILITY_CERTIFICATE,
227+
dual_status = MOI.NO_SOLUTION,
228228
variable_primal = [1.0, 1.0],
229229
constraint_primal = [NaN]
230230
)
@@ -295,9 +295,9 @@ end
295295
function set_linear12test_solutions!(solver)
296296
# SOLVE 1
297297
LQOI.set_solution!(solver,
298-
termination_status = MOI.Infeasible,
299-
primal_status = MOI.NoSolution,
300-
dual_status = MOI.InfeasibilityCertificate,
298+
termination_status = MOI.INFEASIBLE,
299+
primal_status = MOI.NO_SOLUTION,
300+
dual_status = MOI.INFEASIBILITY_CERTIFICATE,
301301
variable_dual = [2/3, 0.0],
302302
constraint_dual = [-1/3, -1.0]
303303
)

test/ex.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ for solver in solvers
3333
@test JuMP.hasresultvalues(m)
3434

3535
@test JuMP.terminationstatus(m) == MOI.Success
36-
@test JuMP.primalstatus(m) == MOI.FeasiblePoint
36+
@test JuMP.primalstatus(m) == MOI.FEASIBLE_POINT
3737

3838
JuMP.resultvalue(x)
3939
JuMP.resultvalue(y)

test/intlinear.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
function set_knapsacktest_solutions!(solver)
22
# SOLVE 1
33
LQOI.set_solution!(solver,
4-
termination_status = MOI.Optimal,
5-
primal_status = MOI.FeasiblePoint,
6-
dual_status = MOI.NoSolution,
4+
termination_status = MOI.OPTIMAL,
5+
primal_status = MOI.FEASIBLE_POINT,
6+
dual_status = MOI.NO_SOLUTION,
77
variable_primal = [1.0, 0.0, 0.0, 1.0, 1.0],
88
constraint_primal = [9.0]
99
)
@@ -13,9 +13,9 @@ end
1313
function set_int1test_solutions!(solver)
1414
# SOLVE 1
1515
LQOI.set_solution!(solver,
16-
termination_status = MOI.Optimal,
17-
primal_status = MOI.FeasiblePoint,
18-
dual_status = MOI.NoSolution,
16+
termination_status = MOI.OPTIMAL,
17+
primal_status = MOI.FEASIBLE_POINT,
18+
dual_status = MOI.NO_SOLUTION,
1919
variable_primal = [4.0, 5.0, 1.0],
2020
constraint_primal = [10.0, 15.0]
2121
)
@@ -25,17 +25,17 @@ end
2525
function set_int3test_solutions!(solver)
2626
# SOLVE 1
2727
LQOI.set_solution!(solver,
28-
termination_status = MOI.Optimal,
29-
primal_status = MOI.FeasiblePoint,
30-
dual_status = MOI.NoSolution,
28+
termination_status = MOI.OPTIMAL,
29+
primal_status = MOI.FEASIBLE_POINT,
30+
dual_status = MOI.NO_SOLUTION,
3131
variable_primal = [1.0, -0.0, -0.0, -0.0, -0.0, 1.0, -0.0, -0.0, -0.0, -0.0, -0.0],
3232
constraint_primal = [0.9875]
3333
)
3434
# SOLVE 2
3535
LQOI.set_solution!(solver,
36-
termination_status = MOI.Optimal,
37-
primal_status = MOI.FeasiblePoint,
38-
dual_status = MOI.NoSolution,
36+
termination_status = MOI.OPTIMAL,
37+
primal_status = MOI.FEASIBLE_POINT,
38+
dual_status = MOI.NO_SOLUTION,
3939
variable_primal = [1.0, -0.0, -0.0, -0.0, -0.0, 1.0, -0.0, -0.0, -0.0, -0.0, -0.0],
4040
constraint_primal = [0.9875]
4141
)

0 commit comments

Comments
 (0)