diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 8d4c72d..d278a23 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -5,10 +5,6 @@ const VI = MOI.VariableIndex const MOIU = MOI.Utilities -const SF = Union{MOI.VectorOfVariables, MOI.VectorAffineFunction{Float64}} -const SS = Union{MOI.Zeros, MOI.Nonnegatives, MOI.SecondOrderCone, - MOI.ExponentialCone} - struct Solution ret_val::Int primal::Vector{Float64} @@ -89,7 +85,13 @@ function MOI.supports(::Optimizer, return true end -MOI.supports_constraint(::Optimizer, ::Type{<:SF}, ::Type{<:SS}) = true +function MOI.supports_constraint(::Optimizer, + ::Type{MOI.VectorAffineFunction{Float64}}, + ::Type{<:Union{MOI.Zeros, MOI.Nonnegatives, + MOI.SecondOrderCone, + MOI.ExponentialCone}}) + return true +end function MOI.copy_to(dest::Optimizer, src::MOI.ModelLike; kws...) return MOIU.automatic_copy_to(dest, src; kws...) @@ -140,7 +142,6 @@ constrrows(instance::Optimizer, ci::CI{<:MOI.AbstractVectorFunction, <:MOI.Abstr matrix(data::ModelData, s::MOI.Zeros) = data.b, data.IA, data.JA, data.VA matrix(data::ModelData, s::Union{MOI.Nonnegatives, MOI.SecondOrderCone, MOI.ExponentialCone}) = data.h, data.IG, data.JG, data.VG matrix(instance::Optimizer, s) = matrix(instance.data, s) -MOIU.load_constraint(instance::Optimizer, ci, f::MOI.VectorOfVariables, s) = MOIU.load_constraint(instance, ci, MOI.VectorAffineFunction{Float64}(f), s) # ECOS orders differently than MOI the second and third dimension of the exponential cone orderval(val, s) = val function orderval(val, s::Union{MOI.ExponentialCone, Type{MOI.ExponentialCone}}) diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index 4fce3d1..103dc8f 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -25,34 +25,35 @@ MOIU.@model(ECOSModelData, MOI.ExponentialCone), (), (), (), # No scalar sets - (MOI.VectorOfVariables,), - (MOI.VectorAffineFunction,)) + (), (MOI.VectorAffineFunction,)) # UniversalFallback is needed for starting values, even if they are ignored by ECOS const cache = MOIU.UniversalFallback(ECOSModelData{Float64}()) const cached = MOIU.CachingOptimizer(cache, optimizer) # Essential bridges that are needed for all tests -const bridged = MOIB.Vectorize{Float64}(MOIB.NonposToNonneg{Float64}(cached)) +const bridged = MOIB.full_bridge_optimizer(cached, Float64) # SOC2 requires 1e-4 const config = MOIT.TestConfig(atol=1e-4, rtol=1e-4) @testset "Unit" begin - MOIT.unittest(MOIB.SplitInterval{Float64}(bridged), + MOIT.unittest(bridged, config, - [# Quadratic functions are not supported - "solve_qcp_edge_cases", "solve_qp_edge_cases", + [# Need https://github.com/JuliaOpt/MathOptInterface.jl/issues/529 + "solve_qp_edge_cases", # Integer and ZeroOne sets are not supported "solve_integer_edge_cases", "solve_objbound_edge_cases"]) end @testset "Continuous linear problems" begin - MOIT.contlineartest(MOIB.SplitInterval{Float64}(bridged), - config) + MOIT.contlineartest(bridged, config) +end + +@testset "Continuous quadratic problems" begin + MOIT.qcptest(bridged, config) end @testset "Continuous conic problems" begin exclude = ["sdp", "rootdet", "logdet"] - MOIT.contconictest(MOIB.GeoMean{Float64}(MOIB.RSOC{Float64}(bridged)), - config, exclude) + MOIT.contconictest(bridged, config, exclude) end