'I can't transform a non-DPP problem to a DPP problem
I am trying to solve a convex problem in parallel by using cvxpy and cvxpylayer. But I get "Problem must be DPP" error.
Here is a a part of my code.
lmbd = cp.Parameter(value= np.dot(z, s) / (2 * np.dot(z, A) @ z))
z = cp.Variable(s.shape[0]) s is vector and A is matrix
objective = cp.Minimize(cp.power(lmbd,2) * cp.quad_form(z, A) - lmbd * cp.matmul(z.T, s))
print(objective.is_dcp(dpp=True)) "This gives False. Objective is not DPP"
constraint = [cp.sum(z) == 1, z >= 0]
prob = cp.Problem(objective, constraint)
print(prob.is_dcp(dpp=True)) "This also gives False. Problem is not DPP"
cvxpylayer = CvxpyLayer(prob, parameters=[lmbd], variables=[z])
Then I tried to tranform this non-DPP objective to DPP by following instructions on https://web.stanford.edu/~boyd/papers/pdf/diff_cvxpy.pdf paper.
Here is new code:
c = cp.Variable()
y = cp.Variable()
objective = cp.Minimize(y - lmbd * cp.matmul(z.T, s))
print(objective.is_dcp(dpp=True)) "Objective DPP now."
constraint = [ cp.sum(z) == 1 , z >= 0 , c == cp.sum_squares(z @ A), y == lmbd * c ]
prob = cp.Problem(objective, constraint)
print(prob.is_dcp(dpp=True)) "But problem still not DPP."
cvxpylayer = CvxpyLayer(prob,parameters=[lmbd], variables=[A,s,c,y])
I managed to transform objective function to DPP. But problem not. Can you help me about that ? Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
