Crossposted on Mathematics SE
I have a convex objective function and a convex constraint of the form $y^2/x + z \leq 1$ on the domain $x \geq 0$. But I'm not sure how to encode this constraint in a way that cvxpy will accept it. It seems to be rejecting it because it can't convince itself that the constraint is convex.
Here is a simple example code
import numpy as np
import cvxpy as cp
n = 5
x = cp.Variable(n)
xtarget = np.random.normal(0, 1, n)
A = np.random.normal(0, 1, [n, n])
B = np.random.normal(0, 1, [n, n])
y = A @ x
z = B @ x
obj = cp.sum_squares(xtarget - x)
constraints = [x>= 0, y ** 2 / x + z <= 1]
prob = cp.Problem(cp.Minimize(obj), constraints)
prob.solve()
This gives the error:
DCPError: Problem does not follow DCP rules. Specifically:
The following constraints are not DCP
I have tried to replace y ** 2 / x + z <= 1
with cp.multiply(y ** 2, cp.pos_inv(x)) + z <= 1
so that it know that $x$ variable is non-negative. It still gives me the DCP error.
Is there a way to reformulate the problem such that it satisfies the DCP rules?