Skip to content

Commit

Permalink
Merge pull request #23 from JuliaOpt/bl/moi8
Browse files Browse the repository at this point in the history
Update to MOI v0.8
  • Loading branch information
blegat authored Dec 18, 2018
2 parents 9ecd36d + 6dc745a commit 7424e2f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 0.6
MathOptInterface 0.7 0.8
MathOptInterface 0.8 0.9
Compat 1.0.1
2 changes: 1 addition & 1 deletion src/load.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include("constraint.jl")

function MOIU.allocate(optimizer::SOItoMOIBridge, ::MOI.ObjectiveSense, sense::MOI.OptimizationSense)
# To be sure that it is done before load(optimizer, ::ObjectiveFunction, ...), we do it in allocate
optimizer.objsign = sense == MOI.MinSense ? -1 : 1
optimizer.objsign = sense == MOI.MIN_SENSE ? -1 : 1
end
function MOIU.allocate(::SOItoMOIBridge, ::MOI.ObjectiveFunction, ::Union{MOI.SingleVariable, MOI.ScalarAffineFunction}) end

Expand Down
20 changes: 10 additions & 10 deletions src/mock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ MockSDOptimizer{T}() where T = MockSDOptimizer{T}(0,
(::MockSDOptimizer) -> begin end,
false,
false,
MOI.OptimizeNotCalled,
MOI.NoSolution,
MOI.NoSolution,
MOI.OPTIMIZE_NOT_CALLED,
MOI.NO_SOLUTION,
MOI.NO_SOLUTION,
BlockMatrix{T}(Matrix{T}[]),
BlockMatrix{T}(Matrix{T}[]),
T[])
Expand All @@ -71,9 +71,9 @@ function MOI.empty!(mock::MockSDOptimizer{T}) where T
mock.constraint_coefficients = Vector{Tuple{T, Int, Int, Int}}[]
mock.hasprimal = false
mock.hasdual = false
mock.terminationstatus = MOI.OptimizeNotCalled
mock.primalstatus = MOI.NoSolution
mock.dualstatus = MOI.NoSolution
mock.terminationstatus = MOI.OPTIMIZE_NOT_CALLED
mock.primalstatus = MOI.NO_SOLUTION
mock.dualstatus = MOI.NO_SOLUTION
mock.X = BlockMatrix{T}(Matrix{T}[])
mock.Z = BlockMatrix{T}(Matrix{T}[])
mock.y = T[]
Expand Down Expand Up @@ -167,7 +167,7 @@ function MOIU.mock_optimize!(mock::MockSDOptimizer, termstatus::MOI.TerminationS
end
# Default termination status
function MOIU.mock_optimize!(mock::MockSDOptimizer, primdual...)
MOIU.mock_optimize!(mock, MOI.Optimal, primdual...)
MOIU.mock_optimize!(mock, MOI.OPTIMAL, primdual...)
end
function MOIU.mock_optimize!(mock::MockSDOptimizer, termstatus::MOI.TerminationStatusCode)
MOI.set(mock, MOI.TerminationStatus(), termstatus)
Expand All @@ -179,7 +179,7 @@ function MOIU.mock_primal!(mock::MockSDOptimizer, primstatus::MOI.ResultStatusCo
MOIU.mock_varprimal!(mock, varprim...)
end
# Default primal status
MOIU.mock_primal!(mock::MockSDOptimizer, varprim::Vector) = MOIU.mock_primal!(mock, MOI.FeasiblePoint, varprim)
MOIU.mock_primal!(mock::MockSDOptimizer, varprim::Vector) = MOIU.mock_primal!(mock, MOI.FEASIBLE_POINT, varprim)
function MOIU.mock_primal!(mock::MockSDOptimizer)
# No primal solution
mock.hasprimal = false
Expand All @@ -206,7 +206,7 @@ function MOIU.mock_dual!(mock::MockSDOptimizer, dualstatus::MOI.ResultStatusCode
end
# Default dual status
function MOIU.mock_dual!(mock::MockSDOptimizer, conduals...)
status = !mock.hasprimal || MOI.get(mock, MOI.PrimalStatus()) == MOI.InfeasiblePoint ? MOI.InfeasibilityCertificate : MOI.FeasiblePoint
status = !mock.hasprimal || MOI.get(mock, MOI.PrimalStatus()) == MOI.INFEASIBLE_POINT ? MOI.INFEASIBILITY_CERTIFICATE : MOI.FEASIBLE_POINT
MOIU.mock_dual!(mock, status, conduals...)
end
function MOIU.mock_dual!(mock::MockSDOptimizer)
Expand All @@ -223,7 +223,7 @@ function MOIU.mock_condual!(mock::MockSDOptimizer{T}, y::Vector{T}) where T
mock.Z = BlockMatrix{T}(map(n -> zeros(T, abs(n), abs(n)), mock.blkdims))
# FIXME shouldn't Z be defined as the opposite i.e. Z = C - sum y_i A_i >= 0
# instead of sum y_i A_i - C <= 0 ?
if mock.dualstatus != MOI.InfeasibilityCertificate
if mock.dualstatus != MOI.INFEASIBILITY_CERTIFICATE
# Infeasibility certificate is a ray so we only take the homogeneous part
# FIXME:check that this is also done IN MOIU.MockOptimizer
for (α, blk, i, j) in mock.objective_coefficients
Expand Down
14 changes: 7 additions & 7 deletions test/contconic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
[70.2006, -7.0, -2.0, 4.0]))
MOIT.lin2vtest(cached_mock_optimizer, config)
MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
MOI.Infeasible,
MOI.InfeasiblePoint,
MOI.INFEASIBLE,
MOI.INFEASIBLE_POINT,
[-0.5, 0.5]))
MOIT.lin3test(cached_mock_optimizer, config)
MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
MOI.Infeasible,
MOI.InfeasiblePoint,
MOI.INFEASIBLE,
MOI.INFEASIBLE_POINT,
[-1.0]))
MOIT.lin4test(cached_mock_optimizer, config)
end
Expand All @@ -45,8 +45,8 @@
[-1.4142, 1.0, -0.7071, -1.0, -0.3536, 1.0, 0.7071, -0.3536]))
MOIT.soc2ptest(MOIB.SOCtoPSD{Float64}(cached_mock_optimizer), config)
MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
MOI.Infeasible,
MOI.InfeasiblePoint,
MOI.INFEASIBLE,
MOI.INFEASIBLE_POINT,
[-1.0, 1.0, -0.5, 1.0, -0.5]))
MOIT.soc3test(MOIB.SOCtoPSD{Float64}(cached_mock_optimizer), config)
MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
Expand All @@ -64,7 +64,7 @@
[5183.15, 5182.44, -1.4142, 1.0, -0.1768, 1.0, -0.3536, -0.1768]))
MOIT.rotatedsoc1vtest(MOIB.RSOCtoPSD{Float64}(cached_mock_optimizer), config)
MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
MOI.Infeasible,
MOI.INFEASIBLE,
tuple(),
[141.088, -47.8864, 47.5533, -46.2201]))
MOIT.rotatedsoc2test(MOIB.RSOCtoPSD{Float64}(cached_mock_optimizer), config)
Expand Down
12 changes: 6 additions & 6 deletions test/contlinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@
MOIT.linear7test(cached_mock_optimizer, config)

MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
MOI.Infeasible,
MOI.INFEASIBLE,
tuple(),
[1.0]))
MOIT.linear8atest(cached_mock_optimizer, config)
MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
MOI.DualInfeasible,
(MOI.InfeasibilityCertificate, [[0.7709], [0.2291], [0.3126]])))
MOI.DUAL_INFEASIBLE,
(MOI.INFEASIBILITY_CERTIFICATE, [[0.7709], [0.2291], [0.3126]])))
MOIT.linear8btest(cached_mock_optimizer, config)
MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
MOI.DualInfeasible,
(MOI.InfeasibilityCertificate, [[0.5], [0.5]])))
MOI.DUAL_INFEASIBLE,
(MOI.INFEASIBILITY_CERTIFICATE, [[0.5], [0.5]])))
MOIT.linear8ctest(cached_mock_optimizer, config)
MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
[[29.0909], [36.3636], [4.5455], [0.0], [0.0001]],
Expand All @@ -117,7 +117,7 @@
[-1.0, 0.0]))
MOIT.linear11test(cached_mock_optimizer, config)
MOIU.set_mock_optimize!(mock, (mock) -> MOIU.mock_optimize!(mock,
MOI.Infeasible,
MOI.INFEASIBLE,
tuple(),
[1.0, 3.0]))
MOIT.linear12test(cached_mock_optimizer, config)
Expand Down

0 comments on commit 7424e2f

Please sign in to comment.