Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 1 addition & 100 deletions test/Bridges/lazy_bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function runtests()
end

include("utilities.jl")
include("sdpa_models.jl")

function test_add_remove_has_bridges()
T = Int
Expand Down Expand Up @@ -309,106 +310,6 @@ function test_MOI_runtests_LPModel()
return
end

# Model similar to SDPA format, it gives a good example because it does not
# support a lot hence need a lot of bridges
MOI.Utilities.@model(
StandardSDPAModel,
(),
(MOI.EqualTo,),
(MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle),
(),
(),
(MOI.ScalarAffineFunction,),
(MOI.VectorOfVariables,),
()
)

function MOI.supports_constraint(
::StandardSDPAModel{T},
::Type{MOI.VariableIndex},
::Type{
<:Union{
MOI.GreaterThan{T},
MOI.LessThan{T},
MOI.EqualTo{T},
MOI.Interval{T},
MOI.ZeroOne,
MOI.Integer,
},
},
) where {T}
return false
end

function MOI.supports_constraint(
::StandardSDPAModel{T},
::Type{MOI.VectorOfVariables},
::Type{MOI.Reals},
) where {T}
return false
end

function MOI.supports_add_constrained_variables(
::StandardSDPAModel,
::Type{<:Union{MOI.Nonnegatives,MOI.PositiveSemidefiniteConeTriangle}},
)
return true
end

function MOI.supports_add_constrained_variables(
::StandardSDPAModel,
::Type{MOI.Reals},
)
return false
end

function MOI.supports(
::StandardSDPAModel{T},
::MOI.ObjectiveFunction{
<:Union{MOI.VariableIndex,MOI.ScalarQuadraticFunction{T}},
},
) where {T}
return false
end

MOI.Utilities.@model(
GeometricSDPAModel,
(),
(),
(MOI.Zeros, MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle),
(),
(),
(),
(),
(MOI.VectorAffineFunction,)
)

function MOI.supports_constraint(
::GeometricSDPAModel{T},
::Type{MOI.VariableIndex},
::Type{
<:Union{
MOI.GreaterThan{T},
MOI.LessThan{T},
MOI.EqualTo{T},
MOI.Interval{T},
MOI.ZeroOne,
MOI.Integer,
},
},
) where {T}
return false
end

function MOI.supports(
::GeometricSDPAModel{T},
::MOI.ObjectiveFunction{
<:Union{MOI.VariableIndex,MOI.ScalarQuadraticFunction{T}},
},
) where {T}
return false
end

function test_MOI_runtests_StandardSDPAModel()
model = StandardSDPAModel{Float64}()
bridged = MOI.Bridges.full_bridge_optimizer(model, Float64)
Expand Down
107 changes: 107 additions & 0 deletions test/Bridges/sdpa_models.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Copyright (c) 2017: Miles Lubin and contributors
# Copyright (c) 2017: Google Inc.
#
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

# This file implements models similar to the SDPA format. It gives a good
# example because it does not support a lot of functions, hence the need for
# a lot of bridges.

MOI.Utilities.@model(
StandardSDPAModel,
(),
(MOI.EqualTo,),
(MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle),
(),
(),
(MOI.ScalarAffineFunction,),
(MOI.VectorOfVariables,),
()
)

function MOI.supports_constraint(
::StandardSDPAModel{T},
::Type{MOI.VariableIndex},
::Type{
<:Union{
MOI.GreaterThan{T},
MOI.LessThan{T},
MOI.EqualTo{T},
MOI.Interval{T},
MOI.ZeroOne,
MOI.Integer,
},
},
) where {T}
return false
end

function MOI.supports_constraint(
::StandardSDPAModel{T},
::Type{MOI.VectorOfVariables},
::Type{MOI.Reals},
) where {T}
return false
end

function MOI.supports_add_constrained_variables(
::StandardSDPAModel,
::Type{<:Union{MOI.Nonnegatives,MOI.PositiveSemidefiniteConeTriangle}},
)
return true
end

function MOI.supports_add_constrained_variables(
::StandardSDPAModel,
::Type{MOI.Reals},
)
return false
end

function MOI.supports(
::StandardSDPAModel{T},
::MOI.ObjectiveFunction{
<:Union{MOI.VariableIndex,MOI.ScalarQuadraticFunction{T}},
},
) where {T}
return false
end

MOI.Utilities.@model(
GeometricSDPAModel,
(),
(),
(MOI.Zeros, MOI.Nonnegatives, MOI.PositiveSemidefiniteConeTriangle),
(),
(),
(),
(),
(MOI.VectorAffineFunction,)
)

function MOI.supports_constraint(
::GeometricSDPAModel{T},
::Type{MOI.VariableIndex},
::Type{
<:Union{
MOI.GreaterThan{T},
MOI.LessThan{T},
MOI.EqualTo{T},
MOI.Interval{T},
MOI.ZeroOne,
MOI.Integer,
},
},
) where {T}
return false
end

function MOI.supports(
::GeometricSDPAModel{T},
::MOI.ObjectiveFunction{
<:Union{MOI.VariableIndex,MOI.ScalarQuadraticFunction{T}},
},
) where {T}
return false
end