Skip to content

Commit

Permalink
Add set for low-rank constrained SDP
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 8, 2023
1 parent d48ac54 commit ebf663d
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/src/background/duality.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ and similarly, the dual is:

The scalar product is different from the canonical one for the sets
[`PositiveSemidefiniteConeTriangle`](@ref), [`LogDetConeTriangle`](@ref),
[`RootDetConeTriangle`](@ref).
[`RootDetConeTriangle`](@ref),
[`FrobeniusProductPostiviveSemidefiniteConeTriangle`](@ref) and
[`LinearMatrixInequalityConeTriangle`](@ref).

If the set ``C_i`` of the section [Duality](@ref) is one of these three cones,
then the rows of the matrix ``A_i`` corresponding to off-diagonal entries are
Expand Down
3 changes: 2 additions & 1 deletion docs/src/manual/standard_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ The matrix-valued set types implemented in MathOptInterface.jl are:
| [`NormSpectralCone(r, c)`](@ref MathOptInterface.NormSpectralCone) | ``\{ (t, X) \in \mathbb{R}^{1 + r \times c} : t \ge \sigma_1(X), X \mbox{ is a } r\times c\mbox{ matrix} \}``
| [`NormNuclearCone(r, c)`](@ref MathOptInterface.NormNuclearCone) | ``\{ (t, X) \in \mathbb{R}^{1 + r \times c} : t \ge \sum_i \sigma_i(X), X \mbox{ is a } r\times c\mbox{ matrix} \}`` |
| [`HermitianPositiveSemidefiniteConeTriangle(d)`](@ref MathOptInterface.HermitianPositiveSemidefiniteConeTriangle) | The cone of Hermitian positive semidefinite matrices, with
`side_dimension` rows and columns. |
| [`FrobeniusProductPostiviveSemidefiniteConeTriangle(d, A)`](@ref MathOptInterface.FrobeniusProductPostiviveSemidefiniteConeTriangle) | The cone of positive semidefinite matrices, with `side_dimension` rows and columns and their Frobenius inner product with the matrices in `A`. |
| [`LinearMatrixInequalityConeTriangle(d, A)`](@ref MathOptInterface.LinearMatrixInequalityConeTriangle) | The cone of vector `y` and symmetric `C`, with `side_dimension` rows and columns such that ``\sum_i y_i A_i + C`` is positive semidefinite. |

Some of these cones can take two forms: `XXXConeTriangle` and `XXXConeSquare`.

Expand Down
2 changes: 2 additions & 0 deletions docs/src/reference/standard_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,6 @@ LogDetConeTriangle
LogDetConeSquare
RootDetConeTriangle
RootDetConeSquare
FrobeniusProductPostiviveSemidefiniteConeTriangle
LinearMatrixInequalityConeTriangle
```
2 changes: 2 additions & 0 deletions src/Utilities/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ const LessThanIndicatorZero{T} =
MOI.ScaledPositiveSemidefiniteConeTriangle,
MOI.RootDetConeTriangle,
MOI.RootDetConeSquare,
MOI.FrobeniusProductPostiviveSemidefiniteConeTriangle,
MOI.LinearMatrixInequalityConeTriangle,
MOI.LogDetConeTriangle,
MOI.LogDetConeSquare,
MOI.AllDifferent,
Expand Down
25 changes: 25 additions & 0 deletions src/Utilities/results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,19 @@ function set_dot(
return x[1] * y[1] + x[2] * y[2] + triangle_dot(x, y, set.side_dimension, 2)
end

function set_dot(
x::AbstractVector,
y::AbstractVector,
set::Union{
MOI.FrobeniusProductPostiviveSemidefiniteConeTriangle,
MOI.LinearMatrixInequalityConeTriangle,
},
)
m = length(set.matrices)
return LinearAlgebra.dot(view(x, 1:m), view(y, 1:m)) +
triangle_dot(x, y, set.side_dimension, m)
end

"""
dot_coefficients(a::AbstractVector, set::AbstractVectorSet)
Expand Down Expand Up @@ -633,3 +646,15 @@ function dot_coefficients(a::AbstractVector, set::MOI.LogDetConeTriangle)
triangle_coefficients!(b, set.side_dimension, 2)
return b
end

function set_dot(
a::AbstractVector,
set::Union{
MOI.FrobeniusProductPostiviveSemidefiniteConeTriangle,
MOI.LinearMatrixInequalityConeTriangle,
},
)
b = copy(a)
triangle_coefficients!(b, set.side_dimension, length(set.matrices))
return b
end
55 changes: 55 additions & 0 deletions src/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,61 @@ function triangular_form(set::RootDetConeSquare)
return RootDetConeTriangle(set.side_dimension)
end

"""
FrobeniusProductPostiviveSemidefiniteConeTriangle{M}(side_dimension::Int, matrices::Vector{M})
Given `m` symmetric matrices `A_1`, ..., `A_m` given in `matrices`, the frobenius inner
product of positive semidefinite matrices is the convex cone:
``\\{ ((\\langle A_1, X \\rangle, ..., \\langle A_m, X \\rangle, X) \\in \\mathbb{R}^{m + d(d+1)/2} : X \\text{ postive semidefinite} \\}``,
where the matrix `X` is represented in the same symmetric packed format as in
the [`PositiveSemidefiniteConeTriangle`](@ref).
"""
struct FrobeniusProductPostiviveSemidefiniteConeTriangle{M} <: AbstractVectorSet
side_dimension::Int
matrices::Vector{M}
end

function dimension(s::FrobeniusProductPostiviveSemidefiniteConeTriangle)
return length(s.matrices) + s.side_dimension^2
end

function dual_set(s::FrobeniusProductPostiviveSemidefiniteConeTriangle)
return LinearMatrixInequalityConeTriangle(s.side_dimension, s.matrices)
end

function dual_set_type(
::Type{FrobeniusProductPostiviveSemidefiniteConeTriangle{M}},
) where {M}
return LinearMatrixInequalityConeTriangle
end

"""
LinearMatrixInequalityConeTriangle{M}(side_dimension::Int, matrices::Vector{M})
Given `m` symmetric matrices `A_1`, ..., `A_m` given in `matrices`, the linear
matrix inequality cone is the convex cone:
``\\{ ((y, C) \\in \\mathbb{R}^{m + d(d+1)/2} : \\sum_{i=1}^m y_i A_i + C \\text{ postive semidefinite} \\}``,
where the matrix `C` is represented in the same symmetric packed format as in
the [`PositiveSemidefiniteConeTriangle`](@ref).
"""
struct LinearMatrixInequalityConeTriangle{M} <: AbstractVectorSet
side_dimension::Int
matrices::Vector{M}
end

dimension(s::LinearMatrixInequalityConeTriangle) = length(s.matrices) + s.side_dimension^2

function dual_set(s::LinearMatrixInequalityConeTriangle)
return FrobeniusProductPostiviveSemidefiniteConeTriangle(
s.side_dimension,
s.matrices,
)
end

function dual_set_type(::Type{LinearMatrixInequalityConeTriangle{M}}) where {M}
return FrobeniusProductPostiviveSemidefiniteConeTriangle
end

"""
SOS1{T<:Real}(weights::Vector{T})
Expand Down

0 comments on commit ebf663d

Please sign in to comment.