Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Apr 9, 2024
1 parent 72a3efc commit d8346c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Bridges/Constraint/bridges/complex_norm_infinity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ function bridge_constraint(
s::MOI.NormInfinityCone,
) where {T}
fi_s = MOI.Utilities.scalarize(f)
if !iszero(imag(fi_s[1]))
error(
"The epigraph variable `t` in `[t; x] in NormInfinityCone()` " *
"must be real. It is: $(fi_s[1])",
)
end
t = real(fi_s[1])
cis = MOI.ConstraintIndex{MOI.VectorAffineFunction{T},MOI.SecondOrderCone}[]
for fi in fi_s[2:end]
Expand Down
17 changes: 17 additions & 0 deletions test/Bridges/Constraint/complex_norm_infinity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ function test_runtests()
return
end

function test_imag_t()
inner = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}())
model = MOI.Bridges.Constraint.ComplexNormInfinityToSecondOrderCone{Float64}(inner)
x = MOI.add_variables(model, 2)
f_t = (1.0 + 2.0im) * x[1]
f_x = (1.0 + 2.0im) * x[2] + (3.0 + 4.0im)
f = MOI.Utilities.operate(vcat, Complex{Float64}, f_t, f_x)
@test_throws(
ErrorException(
"The epigraph variable `t` in `[t; x] in NormInfinityCone()` " *
"must be real. It is: $f_t",
),
MOI.add_constraint(model, f, MOI.NormInfinityCone(2))
)
return
end

end # module

TestConstraintComplexNormInfinityToSecondOrderCone.runtests()

0 comments on commit d8346c6

Please sign in to comment.