# Quadratic optimisation with $\ell_1$ constraints with CVXPY

Crossposted on Mathematics SE

I seek to minimize a convex quadratic objective subject to linear and $$\ell_1$$-based equality constraints. When I turn to CVXPY, an error is raised indicating that it does not follow DCP rules. In what ways would it violate DCP? Naively, I thought this would be a common problem so would be handled by CVXPY out of the box.

import cvxpy as cp
import numpy as np

n = 5
A = np.random.randn(n, n)
E = np.eye(n)
w = cp.Variable(n)
problem = np.Problem(
[
A.T @ w == 0,
cp.norm(w, 1) == 1
]
prob.solve()

• When software misbehaves, it is good practice to always copy-paste all details from the log that might be relevant to debugging the issue. Oct 4 at 8:06
• Also, np.Problem should be cp.Problem, you are missing a right parenthesis before the last line, and prob.solve() should be problem.solve() Oct 4 at 16:55
• Is $w$ supposed to be nonnegative? Oct 5 at 13:33

cp.norm(w, 1) == 1 is a nonlinear equality constraint, hence violates DCP rules. It is a non-convex constraint.
Note that cp.norm(w, 1) <= 1 is a DCP-compliant convex constraint. But cp.norm(w, 1) >= 1 is non-convex, and is non-DCP-compliant.