diff --git a/src/atoms/MultiplyAtom.jl b/src/atoms/MultiplyAtom.jl index 6e9bf9f27..e6c2e20d1 100644 --- a/src/atoms/MultiplyAtom.jl +++ b/src/atoms/MultiplyAtom.jl @@ -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 diff --git a/src/dcp.jl b/src/dcp.jl index 86e9b863c..653c75fca 100644 --- a/src/dcp.jl +++ b/src/dcp.jl @@ -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( diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index 38299d45f..8a4e4b207 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -44,8 +44,7 @@ function test_runtests() MOI.VariableBasisStatus, MOI.ObjectiveBound, ], - ); - exclude = ["hs071"], # HS071 is not convex + ), ) return end diff --git a/test/test_atoms.jl b/test/test_atoms.jl index 1243f8a3f..f198c7a02 100644 --- a/test/test_atoms.jl +++ b/test/test_atoms.jl @@ -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