A simple problem does not follow DCP Rules. Any suggestions?

449 views
Skip to first unread message

Shahnewaz Sakib

unread,
Nov 23, 2020, 4:50:30 PM11/23/20
to cvxpy

I have two variables p1, and p2. I am trying to minimize the ratio (p2/ 1 - p1) such that 0 <= p1 <= 1 and 0 <= p2 <= 1. I have the following code:

import cvxpy as cp
import numpy as np

p1 = cp.Variable()
p2 = cp.Variable()

constraints = [0 <= p1,
               p1 <= 1,
               0 <= p2,
               p2 <= 1]

obj = cp.Minimize(p2 * cp.inv_pos(1 - p1))

prob = cp.Problem(obj, constraints)

prob.solve()

It shows 'DCPError: Problem does not follow DCP rules.' So, I tried prob.solve(qcp = True). It still shows the same error. Can anyone suggest me what modifications I need to make so that this problem can be solved by CVXpy?

Thanks!

Steven Diamond

unread,
Nov 23, 2020, 8:11:59 PM11/23/20
to cvxpy
The rewriting below passes the DQCP checks, though the solve fails.

import cvxpy as cp
import numpy as np

# z1 = 1 - p1
z1 = cp.Variable(nonneg=True)
p2 = cp.Variable()

constraints = [0 <= z1,
               z1 <= 1,
               0 <= p2,
               p2 <= 1]

expr = p2 /z1
obj = cp.Minimize(expr)

prob = cp.Problem(obj, constraints)

prob.solve(qcp=True)
Reply all
Reply to author
Forward
0 new messages