Open jackbaker1001 opened 1 year ago
In CVXPY, with Q being a parameter, the problem is DCP but not DPP.
Python 3.10.9 (main, Jan 11 2023, 15:21:40) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cvxpy as cp
>>> Q = cp.Parameter((2,2), PSD=True)
>>> x = cp.Parameter(2)
>>> cp.quad_form(x, Q).is_dpp()
False
>>> cp.quad_form(x, Q).is_dcp()
True
I believe this is because x.T @ (Qx)
(the second product of expressions) doesn't comply with the ruleset.
Looking at: https://locuslab.github.io/2019-10-28-cvxpylayers/, scroll down to the heading "The OptNet QP".
You will see it is suggested that a QP is handled like:
In cvxpy, it is more natural to use the
cp.quad_form()
function. This, however, throws errors:returns
Which is odd, because the problem does follow DPP. Indeed, if you run the problem through CVXPY (not CVXPY layers) using pure values for the Q-matrix (i.e, not a
cp.Variable
), it will solve without issue. I think the issue is related to using variables in the quad_form function.This all causes a problem because using
cp.sum_squares()
only works if your Q-matrix is positive definite. I.e, we need to pass a square root. What about positive semidefinite matrices?