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
11 changes: 10 additions & 1 deletion src/Bridges/Constraint/soc_to_psd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ function MOIB.inverse_adjoint_map_function(
end

"""
The `RSOCtoPSDBridge` transforms the second order cone constraint ``\\lVert x \\rVert \\le 2tu`` with ``u \\ge 0`` into the semidefinite cone constraints
The `RSOCtoPSDBridge` transforms the second order cone constraint
``\\lVert x \\rVert \\le 2tu`` with ``u \\ge 0`` into the semidefinite cone
constraints
```math
\\begin{pmatrix}
t & x^\\top\\\\
x & 2uI
\\end{pmatrix} \\succeq 0
```

Indeed by the Schur Complement, it is positive definite iff
```math
\\begin{align*}
Expand Down Expand Up @@ -179,6 +182,12 @@ end

function MOIB.map_function(::Type{<:RSOCtoPSDBridge{T}}, func) where {T}
scalars = MOIU.eachscalar(func)
if length(scalars) < 3
error(
"Unable to bridge RotatedSecondOrderCone to PSD because the ",
"dimension is too small: got $(length(scalars)), expected >= 3.",
)
end
h = MOIU.operate!(*, T, scalars[2], convert(T, 2))
return _SOCtoPSDaff(T, scalars[[1; 3:length(scalars)]], h)
end
Expand Down
16 changes: 16 additions & 0 deletions test/Bridges/Constraint/soc_to_psd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ function test_RSOCtoPSD()
return
end

# TODO(odow): we should fix this so it does not error.
function test_rsoc_to_psd_dimension_2()
inner = MOI.Utilities.Model{Float64}()
model = MOI.Bridges.Constraint.RSOCtoPSD{Float64}(inner)
x = MOI.add_variables(model, 2)
@test_throws(
ErrorException,
MOI.add_constraint(
model,
MOI.VectorOfVariables(x),
MOI.RotatedSecondOrderCone(2),
),
)
return
end

end # module

TestConstraintSOCtoPSD.runtests()