New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Large discrepacy between optimal solution and DQCP solution #2386
Comments
I just ran your example and got the same results, which I found the surprising. Maybe the DQCP --> DCP transformations applied to this problem make it hard to quantify the error of an approximate solution. If that happens then CVXPY's bisection approach could erroneously terminate early, thinking that a solution has been obtained to fairly high accuracy. I wasn't involved in the development of CVXPY's DQCP support though, so I could be wrong about this. @akshayka may be able to provide insight. |
I suspect there is something wrong with the DQCP --> DCP transformation. Using
So the bisection is using the following problem to solve the original DQCP: where By debugging the code I found that in one of the many executions of
|
This transformation is correct, the second-order constraint is |
Ok, so I must be missing something. We have the problem which will always be feasible, just pick From debugging, the bisection search is reducing the interval for |
I did some more debugging and it seems that there really is something wrong with the DQCP --> DCP transformation, in particular how it deals with expressions of Parameters. Running
we obtain |
The idea that DQCP and DPP didn't play nice together sounded familar, so I did some digging. So far I've found this point in the release notes when DPP was added in CVXPY 1.1: The original example provided by @literarycorner didn't include Parameter objects. @jcert, based on the digging you've done in the DQCP canonicalization, do you think that the same problem with parameters is causing this bug and preventing use of DPP? |
The original example provided by @literarycorner didn't include Parameter objects in its DQCP form, but the DQCP --> DCP transformation adds a Parameter to it. The modification of the DQCP example was only used to show more explicitly that expressions of Parameters are being incorrectly modified in a way that sometimes a constraint will get removed. I believe that the handling of expressions of Parameters is the source of of the bug reported by @literarycorner. By modifying
I don't know DPP, is there a reason for which expressions containing just Parameters and constants to be canonicalize? Or would this fix I found be reasonable? |
This fix seems fine, at least at first glance. Can you add some test cases and try it out, including the original problematic case? Add the tests in test_dqcp.py |
The mysterious result of @literarycorner's DQCP code comes from the same reason as @ramonfmir's issue #2165. After replacing the below two lines of "cvxpy/reductions/canonicalization.py" (line 109)
into
I could get the following correct result.
|
The canonicalization of parameters is necessary for DPP. This particular solution will not work for that reason, but your explanation is very helpful. You could apply the solution to DQCP alone potentially though. |
After further discussion it looks like there is a subtle bug due to the interactions between DPP and DQCP. IMO the best fix for now is to disable DPP when DQCP is active. But we will look into it further and prioritize a fix. |
Fixed by #2424 |
I started to experiment with quasiconvexity and DQCP by trying to solve a trivial problem.
$\min_{x} \quad \sqrt x$
$\textrm{subject to:} \quad 1 \leq x \leq 2$
The solution has to be x = 1 and p = 1.
However using cvxpy I get the following:
Optimal value of x: 1.4250764776108187
Optimal objective value: 1.193765671147742
Here is the code I used:
I am surprised by the big error. Is that to be expected when using cvxpy with DQCP or am I missing something? Can this problem be circumvented?
The text was updated successfully, but these errors were encountered: