Skip to content

Commit fd5b2f0

Browse files
authored
[Bridges] error in RSOCtoPSD when dimension is 2 (#1763)
1 parent f1856f5 commit fd5b2f0

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/Bridges/Constraint/soc_to_psd.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,16 @@ function MOIB.inverse_adjoint_map_function(
120120
end
121121

122122
"""
123-
The `RSOCtoPSDBridge` transforms the second order cone constraint ``\\lVert x \\rVert \\le 2tu`` with ``u \\ge 0`` into the semidefinite cone constraints
123+
The `RSOCtoPSDBridge` transforms the second order cone constraint
124+
``\\lVert x \\rVert \\le 2tu`` with ``u \\ge 0`` into the semidefinite cone
125+
constraints
124126
```math
125127
\\begin{pmatrix}
126128
t & x^\\top\\\\
127129
x & 2uI
128130
\\end{pmatrix} \\succeq 0
129131
```
132+
130133
Indeed by the Schur Complement, it is positive definite iff
131134
```math
132135
\\begin{align*}
@@ -179,6 +182,12 @@ end
179182

180183
function MOIB.map_function(::Type{<:RSOCtoPSDBridge{T}}, func) where {T}
181184
scalars = MOIU.eachscalar(func)
185+
if length(scalars) < 3
186+
error(
187+
"Unable to bridge RotatedSecondOrderCone to PSD because the ",
188+
"dimension is too small: got $(length(scalars)), expected >= 3.",
189+
)
190+
end
182191
h = MOIU.operate!(*, T, scalars[2], convert(T, 2))
183192
return _SOCtoPSDaff(T, scalars[[1; 3:length(scalars)]], h)
184193
end

test/Bridges/Constraint/soc_to_psd.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,22 @@ function test_RSOCtoPSD()
150150
return
151151
end
152152

153+
# TODO(odow): we should fix this so it does not error.
154+
function test_rsoc_to_psd_dimension_2()
155+
inner = MOI.Utilities.Model{Float64}()
156+
model = MOI.Bridges.Constraint.RSOCtoPSD{Float64}(inner)
157+
x = MOI.add_variables(model, 2)
158+
@test_throws(
159+
ErrorException,
160+
MOI.add_constraint(
161+
model,
162+
MOI.VectorOfVariables(x),
163+
MOI.RotatedSecondOrderCone(2),
164+
),
165+
)
166+
return
167+
end
168+
153169
end # module
154170

155171
TestConstraintSOCtoPSD.runtests()

0 commit comments

Comments
 (0)