-
Notifications
You must be signed in to change notification settings - Fork 134
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
Symmetricity of SDP #31
Comments
Do the constraints need to be symmetric? e.g. |
I've always added a symmetry constraint, and SCS has worked fine. But I was looking through the SCS code, and something struck me as a little odd. The code for projecting a matrix X onto the PSD cone actually projects (X + X')/2 onto the PSD cone. So it's not assuming that X is symmetric. But if X is not constrained to be symmetric, then the PSD cone is not self-dual. On R^{nxn}, the dual of symmetric PSD matrices is matrices Y such that Y+Y' is PSD. So I'm not sure what's going on. Maybe it would be better if PSD cones had dimension n*(n+1)/2, i.e. only the lower triangular entries. @bodono what do you think? I probably have misunderstood something. |
What CVXOPT does is assume that in
the rows of |
@SteveDiamond is right, basically the cone of symmetric positive semi-definite cones is not self-dual in R^{n x n}, so the Moreau decomposition of any point into a member of the PSD cone and the dual of the PSD cone will end up with a non-symmetric part. SCS projects the dual variables onto the cone, so it ends up with a primal variable that might not be symmetric. I noticed this very early on when I was implementing the PSD cone. The right way to fix it is to make the PSD cone explicitly a subset of R^{n x (n+1)/2}. The reason I don't do this is because I wanted to use the same input format as sedumi, which unfortunately uses n x n. There are two ways we could think about fixing this:
Thoughts? |
FWIW, Mosek, the only commercial SDP solver, enforces symmetry by only accepting the lower triangle of matrix coefficients: http://docs.mosek.com/7.1/pythonapi/Semidefinite_optimization.html. Input format and algorithmic implementation are two distinct issues. My vote would be for doing it the "right" way algorithmically so that it's impossible to create a nonsymmetric solution. You can always transform the user's input if they want to provide the problem in |
first, a mathematical aside: @bodono, I was somewhat surprised/confused at first by your assertion that "the cone of symmetric positive semi-definite cones is *not *self-dual in R^{n x n}", so I'd like to give a very concrete example to help posterity understand what's going on. I'm going to call symmetric positive semi-definite SPSD in what follows, for clarity. The SPSD cone is self-dual in S^n, but not in R^{n x n}. Self-duality in S^n means that "Among all symmetric X and Y, Tr(X,Y) >= 0 for any Y PSD <=> X is PSD". Non-self-duality in R^{n x n} means "There is some asymmetric X for which Tr(X,Y) >= 0 for I agree with Miles that it's important to make it impossible to create a problem for which SCS returns an asymmetric solution. Is there a good way to detect asymmetric problems and to symmetrize them inside SCS? The cvxpy solution right now is to add constraints to enforce symmetry of PSD On Fri, Jan 2, 2015 at 7:50 AM, Miles Lubin notifications@github.com
Madeleine Udell |
Here's a more concrete proposal. Suppose we have the (standard conic form) minimize c'*x and we know that x[i]==x[j] at any solution. Well then we can symmetrize A A[:,i] <- (A[:,i] + A[:,j])/2 and the set of solutions to the problem is preserved. But now there is This kind of preprocessing could be imposed by any modeling layer that But this columnwise procedure is a little unnatural, because the problem On Fri, Jan 2, 2015 at 12:52 PM, Madeleine Udell madeleine.udell@gmail.com
Madeleine Udell |
I don't want to have any sort of data cleaning or preparation inside of SCS (besides the normalization, which can actually be done 'matrix-free' anyway). The reason being that the code treats the cones and the linear systems entirely separately, so that you can add any new cones you like, or swap in a new linear system solver very easily. In fact you can run SCS without having access to the data directly, just an oracle that supplies Ax and A'x for input x. So the options are to do nothing and just assume that the input data matrix A respects the symmetry (or enforces a symmetry constraint as cvxpy does), or change the input format to only supply the lower triangular part of the primal variable. I prefer the second option, but it is a breaking API change so is pretty drastic. |
@bodono, data cleaning and preprocessing user input is quite a well accepted practice. User models typically have many variables that can easily be eliminated, constraints that are redundant, or coefficients that can be improved by logical implication. These tricks are especially useful for relaxations of integer programming-type problems, but still for LPs a speedup between 40% and 400% would not be surprising see here and here. I'd argue that these techniques are underutilized by conic solvers. |
@bodono, what problem exactly is SCS solving? looking at KV's example from the top of this thread, minimize Y[1,1] SCS gives the answer Y = [0 1; -1 .586]. it's clear that there is no symmetric S such that -Y + S = 0, so it seems like SCS isn't solving the problem the documentation claims to solve, ie that S is in the SDP cone with SDP cone defined as { X | min(eig(X)) >= 0, X = X^T }. Is it solving the problem with the asymmetric definition of SDP cone, ie SDP cone defined as { X | min(eig(X+X')) >= 0 }? |
For what we're calling the primal problem it essentially uses the asymmetric version of the PSD cone, for the dual problem it's the symmetric definition. This doesn't really make sense from a user standpoint, so it should definitely change. |
It might be fine, so long as the documentation makes it clear that that's Actually, that would allow you to solve problems involving only the minimize c'*x where K might include some symmetric PSD cones (and no asymmetric ones) minimize -b'_y (so now K^* has some asymmetric PSD cones in it, and no symmetric ones) and Have I understood this correctly? On Tue, Jan 6, 2015 at 6:59 AM, bodono notifications@github.com wrote:
Madeleine Udell |
Technically the PSD cone is R^{n x n} is a different cone to Sn, and I don't think it's really useful to use the R^{n x n} one. How difficult would it be for Convex.jl or cvxpy to use a vector of length n x (n+1)/2 instead of n^2 for PSD cone variables? |
It would be very easy for cvxpy to use a vector of length n x (n+1)/2 On Wed, Jan 7, 2015 at 3:35 AM, bodono notifications@github.com wrote:
|
Yes, I think that would work fine for us too. Just to clarify: as far as I understand, this is only a change in the size On Wed, Jan 7, 2015 at 3:28 PM, Steven Diamond notifications@github.com
Madeleine Udell |
A and b would have to change since the number of rows in A is equal to the sum of the sizes of all the cones, and we're making the PSD cones go down to size n(n+1)/2 instead of n^2. Any constraints on the upper triangular part of the semidefinite variable would have to be converted to constraints on the lower triangular part, so the structure would change too. Also cvxpy (and possibly cvx and Convex.jl?) would be able to drop the explicit |
this raises an interesting point. right now we'd allow users to say minimize y (where x, y, z, and w are variables). if we remove the upper triangular the easiest way to deal with this is still to add extra equality how does this extra constraint affect the dual variables? how would we we could also do some kind of variable/constraint preprocessing to reduce ---------- Forwarded message ---------- A and b would have to change since the number of rows in A is equal to the — Madeleine Udell |
That problem is unbounded in either case, right? If you add z>=0 to the problem your point stands. In that case you would have to, as you say, introduce the equality constraint z==y, and pass three variables (x,z,w) into the S_2 cone constraint. To get the dual variable to the original problem I think you would just do an affine combination of the dual variables from the equality constraint and the symmetric semidefinite dual variable. Interestingly this would end up with a non-symmetric dual variable if I'm doing it right. This seems like the correct approach from the parser, because the user will (generally) expect that [x y; z w] in SemidefiniteCone will enforce the constraint that z==y, and you guys will take care of that in the background. |
Yes, it looks like the equality constraint adds an skew symmetric part to That's very strange. I'm worried we'd be violating our contract with users On Fri, Jan 9, 2015 at 8:07 AM, bodono notifications@github.com wrote:
Madeleine Udell |
FYI, both sedumi and sdpt3 also return skew symmetric duals. |
I've pushed a new branch, symmetric_sdp, that has the interface change to specify semidefinite variables of size n * (n+1) / 2 (and no longer supporting n^2 sizes). It appears to work... |
Unless we(SCS.jl) are doing something wrong, it seems possible that SCS can return semi-definite matrices that are not symmetric.
Is there a reason why it is possible for SDP matrices to not be symmetric?
The README seems to say
positive semidefinite cone { X | min(eig(X)) >= 0, X = X^T }
in which case the matrix should be symmetric.
Here is the data in raw format:
The text was updated successfully, but these errors were encountered: