Skip to content

Commit

Permalink
Update to MOI v0.9.15 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored May 14, 2021
1 parent 29f3b13 commit 773b979
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 151 deletions.
136 changes: 0 additions & 136 deletions Manifest.toml

This file was deleted.

2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"

[compat]
MathOptInterface = "0.9.6"
MathOptInterface = "0.9.21"
julia = "1"

[extras]
Expand Down
30 changes: 16 additions & 14 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ mutable struct Optimizer <: MOI.AbstractOptimizer
y::Vector{Cdouble}
z_computed::Bool

is_setup::Bool

silent::Bool
options::Dict{Symbol,Any}
function Optimizer(; kwargs...)
optimizer = new(C_NULL, C_NULL, 0.0, 1, Cdouble[], Int[], Tuple{Int, Int, Int}[], Int[], C_NULL, 0, Int[],
Int[], Cdouble[], true, true, Cdouble[], true,
false, Dict{Symbol, Any}())
false, false, Dict{Symbol, Any}())
for (key, value) in kwargs
MOI.set(optimizer, MOI.RawParameter(key), value)
end
Expand Down Expand Up @@ -64,6 +66,7 @@ function MOI.empty!(optimizer::Optimizer)
optimizer.y_valid = true
empty!(optimizer.y)
optimizer.z_computed = false
optimizer.is_setup = false
end

function MOI.is_empty(optimizer::Optimizer)
Expand Down Expand Up @@ -181,16 +184,9 @@ function MOI.supports(
return true
end

function MOI.supports_constraint(
::Optimizer, ::Type{MOI.VectorOfVariables}, ::Type{MOI.Reals})
return false
end
MOI.supports_add_constrained_variables(::Optimizer, ::Type{MOI.Reals}) = false
const SupportedSets = Union{MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle}
function MOI.supports_constraint(
::Optimizer, ::Type{MOI.VectorOfVariables},
::Type{<:SupportedSets})
return true
end
MOI.supports_add_constrained_variables(::Optimizer, ::Type{<:SupportedSets}) = true
function MOI.supports_constraint(
::Optimizer, ::Type{MOI.ScalarAffineFunction{Cdouble}},
::Type{MOI.EqualTo{Cdouble}})
Expand Down Expand Up @@ -339,12 +335,18 @@ end


function MOI.optimize!(m::Optimizer)
if !isempty(m.lpdvars)
m.lpcone = CreateLPCone(m.dsdp)
LPCone.SetDataSparse(m.lpcone, m.nlpdrows, length(m.b) + 1, m.lpdvars, m.lpdrows, m.lpcoefs)
# TODO in MOI v0.10, remove the `is_setup` flag
# and do this in `MOI.Utilities.final_touch`.
if !m.is_setup
if !isempty(m.lpdvars)
m.lpcone = CreateLPCone(m.dsdp)
LPCone.SetDataSparse(m.lpcone, m.nlpdrows, length(m.b) + 1, m.lpdvars, m.lpdrows, m.lpcoefs)
end

Setup(m.dsdp)
m.is_setup = true
end

Setup(m.dsdp)
Solve(m.dsdp)

m.x_computed = false
Expand Down
13 changes: 13 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Test
using MathOptInterface

const MOI = MathOptInterface
Expand Down Expand Up @@ -30,6 +31,18 @@ const config = MOIT.TestConfig(atol=1e-2, rtol=1e-2)
"solve_singlevariable_obj", "solve_constant_obj",
"solve_affine_deletion_edge_cases",
"solve_with_upperbound",
# Expression: MOI.get(model, MOI.TerminationStatus()) == MOI.INFEASIBLE
# Evaluated: MathOptInterface.OPTIMAL == MathOptInterface.INFEASIBLE
"solve_farkas_equalto_lower",
"solve_farkas_equalto_upper",
"solve_farkas_variable_lessthan",
"solve_farkas_variable_lessthan_max",
"solve_farkas_greaterthan",
"solve_farkas_interval_upper",
"solve_farkas_lessthan",
"solve_farkas_interval_lower",
# TODO should work when SDP is complete
"solve_qp_zero_offdiag",
# `NumberOfThreads` not supported.
"number_threads",
# `TimeLimitSec` not supported.
Expand Down

0 comments on commit 773b979

Please sign in to comment.