cvxgrp / dccp

A CVXPY extension for convex-concave programming
123 stars 31 forks source link

Can this library solve any convex-concave problem? #77

Open zhumingpassional opened 2 years ago

zhumingpassional commented 2 years ago

Good work.

Can this library solve any convex-concave problem? For example, there are non-convex constraints:

(x + y)^2 -x^2 - y^2 - (x^2 + y^2) ^ (3/2) <= 0, where (x + y)^2 is convex, and -x^2 - y^2 - (x^2 + y^2) ^ (3/2) is concave

-x^2 - y^2 + 100 <= 0

Is obtained solution globally optimal?

Is there any paper to describe the algorithm/method?

Thank you very much.

stephenpboyd commented 2 years ago

Yes, the paper is at https://web.stanford.edu/~boyd/papers/dccp.html.

On Mar 24, 2022, at 2:45 AM, Ming Zhu @.***> wrote:

Good work.

Can this library solve any convex-concave problem? For example, there are non-convex constraints:

(x + y)^2 -x^2 - y^2 - (x^2 + y^2) ^ (3/2) <= 0

-x^2 - y^2 + 100 <= 0

Yes, of course. Just read the documentation.

Is obtained solution globally optimal?

Ans no, of course not. Again, please read the documentation and the paper.

Is there any paper to describe the algorithm/method?

See above.

Thank you very much.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

xinyueshen commented 2 years ago

Hi @zhumingpassional, for the specific constraints that you mentioned, DCCP can handle them as long as you write them as (x + y)^2 <= x^2 + y^2 + (x^2 + y^2) ^ (3/2) and 100 <= x^2 + y^2.

zhumingpassional commented 2 years ago

@stephenpboyd @xinyueshen

Thanks for your reply and valuable suggestions.

Can CVXPYgen generate C code for embedded applications when using cvxpy and dccp?

Is the generated C code faster than the python code?

xinyueshen commented 2 years ago

Hi @zhumingpassional, thanks for the questions, but DCCP currently does not work with CVXPYgen.

zhumingpassional commented 2 years ago

Will CVXPYgen support DCCP in the near future? I really hope it can.

Thanks.

zhumingpassional commented 2 years ago

1) Does DCCP support all models?

I use DCCP to solve a convex-concave problem, whose constraint is: (x + y)^2 <= x^2 + y^2 + (x^2 + y^2) ^ (3/2) # I used cvxpy.power(, 3/2) It does not work. It raise errors: " cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically: The following constraints are not DCP: 0.0 <= power(var4[0], 2.0) + power(var5[0], 2.0) , because the following subexpressions are not: |-- 0.0 <= power(var4[0], 2.0) + power(var5[0], 2.0)"

However, if I revise the constraint as (x + y)^2 <= x^2 + y^2 + (x^2 + y^2) ^ (2), # I used cvxpy.power(, 2) It works.

Does this library only support the power function where the parameter should be integer? I am not sure.

2) Initialize a feasible solution by users.

If I used the second model so that it works. Sometimes, DCCP cannot obtain a solution. Is it because it cannot obtain a feasible solution using the method in your paper? If I use other methods to get an initial solution, does DCCP provide the interface to support it?

Hope to get your reply. Thanks very much.

stephenpboyd commented 2 years ago

Read the documentation, which is very clear about what expressions and constraints are accepted. It is easy to handle yours, by simply rewriting it in the correct form.

On Apr 1, 2022, at 12:14 AM, Ming Zhu @.***> wrote:

I use DCCP to solve a convex-concave problem, whose constraint is: (x + y)^2 <= x^2 + y^2 + (x^2 + y^2) ^ (3/2) # I used cvxpy.power(, 3/2) It does not work. It raise errors: " cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically: The following constraints are not DCP: 0.0 <= power(var4[0], 2.0) + power(var5[0], 2.0) , because the following subexpressions are not: |-- 0.0 <= power(var4[0], 2.0) + power(var5[0], 2.0)"

However, if I revise the constraint as (x + y)^2 <= x^2 + y^2 + (x^2 + y^2) ^ (2), # I used cvxpy.power(, 2) It works.

Does this library only support the power function where the parameter should be integer? I am not sure.

Hope to get your reply. Thanks very much.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

xinyueshen commented 2 years ago

@zhumingpassional For the first question, the following code should work.

[(x + y) ** 2 <= x ** 2 + y ** 2 + cp.power(z, 3), z == cp.norm(cp.vstack([x, y]))]

For the second question, yes, you can initialize the variables by setting their values before calling DCCP to solve, and then DCCP will use the initialization that you provide. The code is simply like the following.

x.value = 1
y.value = 2
z.value = 3
prob.solve(method="dccp")
zhumingpassional commented 2 years ago

@stephenpboyd @xinyueshen Thank you very much for your valuable reply. Excellent work! I will read the document carefully.