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
4 changes: 1 addition & 3 deletions src/atoms/MultiplyAtom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ real_convert(::Type{T}, x::AbstractVector) where {T} = SPARSE_VECTOR{T}(x)

function new_conic_form!(context::Context{T}, x::MultiplyAtom) where {T}
if curvature(x) == NotDcp()
error(
"[MultiplyAtom] multiplication of two non-constant expressions is not DCP compliant",
)
throw(DCPViolationError())
end
if x.children[1].size == (1, 1) || x.children[2].size == (1, 1)
# scalar multiplication
Expand Down
4 changes: 3 additions & 1 deletion src/dcp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# http://web.stanford.edu/~boyd/papers/disc_cvx_prog.html
#############################################################################

struct DCPViolationError <: Exception end
# This is a subtype of MOI.UnsupportedError so that non-DCP
# errors trigger the correct paths in MOI.Test for Convex.Optimizer.
struct DCPViolationError <: MOI.UnsupportedError end

function Base.showerror(io::IO, ::DCPViolationError)
return print(
Expand Down
3 changes: 1 addition & 2 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ function test_runtests()
MOI.VariableBasisStatus,
MOI.ObjectiveBound,
],
);
exclude = ["hs071"], # HS071 is not convex
),
)
return
end
Expand Down
8 changes: 2 additions & 6 deletions test/test_atoms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -660,15 +660,11 @@ function test_MultiplyAtom()
Variable(2, 2) * Variable(3, 3)
)
@test_throws(
ErrorException(
"[MultiplyAtom] multiplication of two non-constant expressions is not DCP compliant",
),
DCPViolationError,
_test_atom(_ -> Variable(2)' * Variable(2), ""),
)
@test_throws(
ErrorException(
"[MultiplyAtom] multiplication of two non-constant expressions is not DCP compliant",
),
DCPViolationError,
_test_atom(_ -> Variable() * Variable(), ""),
)
return
Expand Down
Loading