cvxgrp / scs

Splitting Conic Solver
MIT License
553 stars 136 forks source link

Unconstrained quadratic problem throws validation error #239

Closed hongkai-dai closed 1 year ago

hongkai-dai commented 1 year ago

Specifications

Problem description

When I have an un-constrained quadratic problem, my A matrix has zero rows. Then scs_validate function will throw this error https://github.com/cvxgrp/scs/blob/186b67cbff0272c3cd6a1c37180cc428179e9ab1/src/scs.c#L711-L715

I can think of these possible workaround

  1. For an un-constrained QP, I can solve the linear system of equations P * x = -c, so I don't have to invoke SCS.
  2. I can convert the quadratic cost to a rotated Lorentz cone constraint (second-order cone constraint) and a linear cost.
  3. I can put a trivial linear constraint 0 * x = 0 in Ax+s = b.

I am writing a wrapper in Drake that can call SCS. Ideally I would like to call SCS for whatever convex optimization problem using the same API, so workaround 1 above isn't an ideal solution. Would you suggest a better solution? Is it OK that SCS can natively support un-constrained QP? Thanks a lot!

bodono commented 1 year ago

Hi @hongkai-dai . Yes, SCS expects there to be an A matrix, although we could remove that it would probably require a fair amount of work. My suggestion would be to handle unconstrained cases directly in the wrapper, since it should be relatively straightforward (assuming the linear system can be solved) and much faster/more accurate than an iterative method like SCS.

hongkai-dai commented 1 year ago

Thanks a lot @bodono , I will handle the unconstrained case in a separate routine in our wrapper.