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
7 changes: 4 additions & 3 deletions src/Bridges/Bridges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ MOIU.@model(AllBridgedConstraints,
(),
(MOI.Interval,),
(MOI.SecondOrderCone, MOI.RotatedSecondOrderCone, MOI.GeometricMeanCone,
MOI.PositiveSemidefiniteConeSquare,
MOI.LogDetConeTriangle, MOI.RootDetConeTriangle),
(),
(),
(MOI.ScalarAffineFunction,),
(MOI.SingleVariable,),
(MOI.ScalarAffineFunction, MOI.ScalarQuadraticFunction),
(MOI.VectorOfVariables,),
(MOI.VectorAffineFunction,))
(MOI.VectorAffineFunction, MOI.VectorQuadraticFunction))
"""
fullbridgeoptimizer(model::MOI.ModelLike, ::Type{T}) where T

Expand Down
5 changes: 5 additions & 0 deletions src/Utilities/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,11 @@ function promote_operation(::typeof(/), ::Type{T},
::Type{T}) where T
MOI.ScalarAffineFunction{T}
end
function promote_operation(::typeof(/), ::Type{T},
::Type{MOI.ScalarQuadraticFunction{T}},
::Type{T}) where T
MOI.ScalarQuadraticFunction{T}
end

function operate!(::typeof(/), ::Type{T}, f::MOI.SingleVariable,
α::T) where T
Expand Down
36 changes: 32 additions & 4 deletions test/bridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ end
# Model not supporting RotatedSecondOrderCone
MOIU.@model(NoRSOCModel,
(),
(MOI.EqualTo, MOI.GreaterThan, MOI.LessThan, MOI.Interval),
(MOI.EqualTo, MOI.GreaterThan, MOI.LessThan),
(MOI.Zeros, MOI.Nonnegatives, MOI.Nonpositives, MOI.SecondOrderCone,
MOI.ExponentialCone, MOI.PositiveSemidefiniteConeTriangle),
(),
(MOI.SingleVariable,),
(MOI.ScalarAffineFunction,),
(MOI.ScalarAffineFunction, MOI.ScalarQuadraticFunction),
(MOI.VectorOfVariables,),
(MOI.VectorAffineFunction,))
(MOI.VectorAffineFunction, MOI.VectorQuadraticFunction))

@testset "LazyBridgeOptimizer" begin
mock = MOIU.MockOptimizer(NoRSOCModel{Float64}())
Expand All @@ -150,7 +150,7 @@ MOIU.@model(NoRSOCModel,
MOIT.copytest(bridgedmock, NoRSOCModel{Float64}())
end

# Test that RSOCtoPSD is used instead of RSOC+SOCtoPSD as it is a shortest path
# Test that RSOCtoPSD is used instead of RSOC+SOCtoPSD as it is a shortest path.
@testset "Bridge selection" begin
MOI.empty!(bridgedmock)
@test !(MOI.supports_constraint(bridgedmock, MOI.VectorAffineFunction{Float64}, MOI.LogDetConeTriangle))
Expand All @@ -160,6 +160,34 @@ MOIU.@model(NoRSOCModel,
@test bridgedmock.dist[(MathOptInterface.VectorOfVariables, MathOptInterface.RotatedSecondOrderCone)] == 1
end

@testset "Supports" begin
fullbridgedmock = MOIB.fullbridgeoptimizer(mock, Float64)
for F in [MOI.SingleVariable, MOI.ScalarAffineFunction{Float64},
MOI.ScalarQuadraticFunction{Float64}]
@test MOI.supports_constraint(fullbridgedmock, F,
MOI.Interval{Float64})
end
for F in [MOI.VectorOfVariables, MOI.VectorAffineFunction{Float64},
MOI.VectorQuadraticFunction{Float64}]
@test MOI.supports_constraint(fullbridgedmock, F,
MOI.PositiveSemidefiniteConeSquare)
@test MOI.supports_constraint(fullbridgedmock, F,
MOI.GeometricMeanCone)
end
for F in [MOI.VectorOfVariables, MOI.VectorAffineFunction{Float64}]
# The bridges in this for loop do not support yet
# VectorQuadraticFunction. See TODO's for the reason.
# TODO: Missing vcat for quadratic for supporting quadratic.
@test MOI.supports_constraint(fullbridgedmock, F,
MOI.RotatedSecondOrderCone)
# TODO: Det bridges need to use MOIU.operate to support quadratic.
@test MOI.supports_constraint(fullbridgedmock, F,
MOI.LogDetConeTriangle)
@test MOI.supports_constraint(fullbridgedmock, F,
MOI.RootDetConeTriangle)
end
end

@testset "Combining two briges" begin
fullbridgedmock = MOIB.fullbridgeoptimizer(mock, Float64)
mock.optimize! = (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!(mock, [1, 1, 0, 1, 1, 0, 1, √2])
Expand Down
3 changes: 3 additions & 0 deletions test/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@
@test MOIU.promote_operation(*, Float64,
MOI.ScalarAffineFunction{Float64},
MOI.ScalarAffineFunction{Float64}) == MOI.ScalarQuadraticFunction{Float64}
@test MOIU.promote_operation(/, Float64,
MOI.ScalarQuadraticFunction{Float64},
Float64) == MOI.ScalarQuadraticFunction{Float64}
end
fx = MOI.SingleVariable(x)
fy = MOI.SingleVariable(y)
Expand Down