Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Dec 13, 2023
1 parent d1417d5 commit 2203a18
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
14 changes: 10 additions & 4 deletions src/Bridges/Constraint/bridges/soc_to_psd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,22 @@ end
function MOI.Bridges.added_constraint_types(
::Type{<:RSOCtoPSDBridge{T,F,G}},
) where {T,F,G}
return Tuple{Type,Type}[(F, MOI.PositiveSemidefiniteConeTriangle), (G, MOI.Nonnegatives)]
return Tuple{Type,Type}[
(F, MOI.PositiveSemidefiniteConeTriangle),
(G, MOI.Nonnegatives),
]
end

function MOI.supports(
model::MOI.ModelLike,
attr::Union{MOI.ConstraintPrimalStart,MOI.ConstraintDualStart},
::Type{<:RSOCtoPSDBridge{T,F,G}},
) where {T,F,G}
return MOI.supports(model, attr, MOI.ConstraintIndex{F,MOI.PositiveSemidefiniteConeTriangle}) ||
MOI.supports(model, attr, MOI.ConstraintIndex{G,MOI.Nonnegatives})
return MOI.supports(
model,
attr,
MOI.ConstraintIndex{F,MOI.PositiveSemidefiniteConeTriangle},
) || MOI.supports(model, attr, MOI.ConstraintIndex{G,MOI.Nonnegatives})
end

function MOI.Bridges.map_set(
Expand Down Expand Up @@ -240,7 +246,7 @@ end

function _rsoc_to_psd_too_small_message(n)
return "Unable to bridge RotatedSecondOrderCone to PSD because the " *

Check warning on line 248 in src/Bridges/Constraint/bridges/soc_to_psd.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/Constraint/bridges/soc_to_psd.jl#L247-L248

Added lines #L247 - L248 were not covered by tests
"dimension is too small: got $n, expected >= 2."
"dimension is too small: got $n, expected >= 2."
end

function MOI.Bridges.map_function(::Type{<:RSOCtoPSDBridge{T}}, func) where {T}
Expand Down
23 changes: 13 additions & 10 deletions src/Bridges/Constraint/set_map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,40 @@ function MOI.supports_constraint(
return true
end

function MOI.Bridges.added_constrained_variable_types(::Type{<:MultiSetMapBridge})
function MOI.Bridges.added_constrained_variable_types(
::Type{<:MultiSetMapBridge},
)
return Tuple{Type}[]
end

# Attributes, Bridge acting as a model

_get(::MOI.ConstraintIndex, ::MOI.NumberOfConstraints) = 0
_get(::MOI.ConstraintIndex{F,S}, ::MOI.NumberOfConstraints{F,S}) where {F,S} = 1
function _get(::MOI.ConstraintIndex, ::MOI.ListOfConstraintIndices{F,S}) where {F,S}
function _get(
::MOI.ConstraintIndex,
::MOI.ListOfConstraintIndices{F,S},
) where {F,S}
return MOI.ConstraintIndex{F,S}[]
end
function _get(ci::MOI.ConstraintIndex{F,S}, ::MOI.ListOfConstraintIndices{F,S}) where {F,S}
function _get(
ci::MOI.ConstraintIndex{F,S},
::MOI.ListOfConstraintIndices{F,S},
) where {F,S}
return [ci]
end

function MOI.get(
bridge::MultiSetMapBridge,
attr::MOI.NumberOfConstraints
attr::MOI.NumberOfConstraints,
)::Int64
return _get(bridge.constraint, attr)
end

function MOI.get(
bridge::MultiSetMapBridge,
attr::MOI.ListOfConstraintIndices,
)
function MOI.get(bridge::MultiSetMapBridge, attr::MOI.ListOfConstraintIndices)
return _get(bridge.constraint, attr)
end


# References

function MOI.delete(model::MOI.ModelLike, bridge::MultiSetMapBridge)
Expand Down Expand Up @@ -242,7 +246,6 @@ function MOI.modify(
return
end


"""
abstract type SetMapBridge{T,S2,S1,F,G} <: MultiSetMapBridge{T,S1,G} end
Expand Down
21 changes: 11 additions & 10 deletions test/Bridges/Constraint/soc_to_psd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,13 @@ function test_RSOCtoPSD()
bridged_mock,
ci,
2,
((
MOI.VectorAffineFunction{Float64},
MOI.PositiveSemidefiniteConeTriangle,
0,
), (
MOI.VectorAffineFunction{Float64},
MOI.Nonnegatives,
0,
),
(
(
MOI.VectorAffineFunction{Float64},
MOI.PositiveSemidefiniteConeTriangle,
0,
),
(MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives, 0),
),
)
return
Expand All @@ -169,7 +167,10 @@ function test_rsoc_to_psd_dimension_2()
MOI.VectorOfVariables(x),
MOI.RotatedSecondOrderCone(2),
)
@test MOI.get(inner, MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonnegatives}()) == 1
@test MOI.get(
inner,
MOI.NumberOfConstraints{MOI.VectorOfVariables,MOI.Nonnegatives}(),
) == 1
return
end

Expand Down

0 comments on commit 2203a18

Please sign in to comment.