eason
eason

Reputation: 151

The objective is not DCP

I try to solve the convex problem on page 20 presented in this paper

enter image description here

In my opinion, the objective is convex.

cvxpy version 1.1.18

prob is DCP: False

it reports

xception has occurred: DCPError Problem does not follow DCP rules. Specifically: The objective is not DCP. Its following subexpressions are not: 0.004 / (power(var1[0], 0.5) + power(var1[0], 0.5)) 0.004 / (power(var11, 0.5) + power(var11, 0.5))

enter image description here

my code is

K = 1000
KK = 500
delta = 1/(1000)*2
a = cp.Variable(KK)
b = cp.Variable(KK+1,nonneg=True)
tau = cp.Variable((KK,7))
print('create problem')
print('cvx version')
print(cp.__version__)
prob = cp.Problem(cp.Minimize(cp.sum([2*delta/(cp.sqrt(b[i])+cp.sqrt(b[i+1])) for i in range(KK)])),
          [...])

a concise example reports the same problem

import copy as cp

# A non-DCP problem.
K=5
x=cp.Variable(K+1)
prob = cp.Problem(\
    cp.Minimize( cp.sum([1/(cp.sqrt(x[i]) +cp.sqrt(x[i+1])) for i in range(K)]) )\
        ,[x>=25,x<=100])
print( "prob is DCP:", prob.is_dcp())
print('be solving  by cvxpy')
try:
    prob.solve()
except Exception as e:
    print(e)

Upvotes: 1

Views: 2596

Answers (1)

Michal Adamaszek
Michal Adamaszek

Reputation: 966

Use cp.inv_pos(u) instead of 1/u.

Upvotes: 2

Related Questions