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 Jul 10, 2024
1 parent 2ae5939 commit 66fcd61
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 1 deletion.
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
2 changes: 2 additions & 0 deletions docs/src/manual/standard_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ The matrix-valued set types implemented in MathOptInterface.jl are:
| [`HermitianPositiveSemidefiniteConeTriangle(d)`](@ref MathOptInterface.HermitianPositiveSemidefiniteConeTriangle) | The cone of Hermitian positive semidefinite matrices, with
`side_dimension` rows and columns. |
| [`Scaled(S)`](@ref MathOptInterface.Scaled) | The set `S` scaled so that [`Utilities.set_dot`](@ref MathOptInterface.Utilities.set_dot) corresponds to `LinearAlgebra.dot` |
| [`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`. |

Check failure on line 103 in docs/src/manual/standard_form.md

View workflow job for this annotation

GitHub Actions / build

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'Frobenius'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'Frobenius'?", "location": {"path": "docs/src/manual/standard_form.md", "range": {"start": {"line": 103, "column": 231}}}, "severity": "ERROR"}
| [`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 @@ -153,4 +153,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 @@ -792,6 +792,8 @@ const LessThanIndicatorZero{T} =
MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle},
MOI.RootDetConeTriangle,
MOI.RootDetConeSquare,
MOI.FrobeniusProductPostiviveSemidefiniteConeTriangle,
MOI.LinearMatrixInequalityConeTriangle,
MOI.LogDetConeTriangle,
MOI.LogDetConeSquare,
MOI.AllDifferent,
Expand Down
26 changes: 26 additions & 0 deletions src/Utilities/results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,29 @@ function get_fallback(
f = MOI.get(model, MOI.ConstraintFunction(), ci)
return _variable_dual(T, model, attr, ci, f)
end

function set_dot(

Check warning on line 502 in src/Utilities/results.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/results.jl#L502

Added line #L502 was not covered by tests
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)) +

Check warning on line 511 in src/Utilities/results.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/results.jl#L510-L511

Added lines #L510 - L511 were not covered by tests
triangle_dot(x, y, set.side_dimension, m)
end


function set_dot(

Check warning on line 516 in src/Utilities/results.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/results.jl#L516

Added line #L516 was not covered by tests
a::AbstractVector,
set::Union{
MOI.FrobeniusProductPostiviveSemidefiniteConeTriangle,
MOI.LinearMatrixInequalityConeTriangle,
},
)
b = copy(a)
triangle_coefficients!(b, set.side_dimension, length(set.matrices))
return b

Check warning on line 525 in src/Utilities/results.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/results.jl#L523-L525

Added lines #L523 - L525 were not covered by tests
end
55 changes: 55 additions & 0 deletions src/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,61 @@ function Base.getproperty(
end
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

Check warning on line 1809 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L1808-L1809

Added lines #L1808 - L1809 were not covered by tests
end

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

Check warning on line 1813 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L1812-L1813

Added lines #L1812 - L1813 were not covered by tests
end

function dual_set_type(

Check warning on line 1816 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L1816

Added line #L1816 was not covered by tests
::Type{FrobeniusProductPostiviveSemidefiniteConeTriangle{M}},
) where {M}
return LinearMatrixInequalityConeTriangle

Check warning on line 1819 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L1819

Added line #L1819 was not covered by tests
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

Check warning on line 1836 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L1836

Added line #L1836 was not covered by tests

function dual_set(s::LinearMatrixInequalityConeTriangle)
return FrobeniusProductPostiviveSemidefiniteConeTriangle(

Check warning on line 1839 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L1838-L1839

Added lines #L1838 - L1839 were not covered by tests
s.side_dimension,
s.matrices,
)
end

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

Check warning on line 1846 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L1845-L1846

Added lines #L1845 - L1846 were not covered by tests
end

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

0 comments on commit 66fcd61

Please sign in to comment.