Skip to content
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

SCS fails to find solution under infinite linear bounds #161

Open
stephane-caron opened this issue Jan 16, 2023 · 0 comments
Open

SCS fails to find solution under infinite linear bounds #161

stephane-caron opened this issue Jan 16, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@stephane-caron
Copy link
Member

Converting disabled box bounds (i.e. coordinates at $-\infty$ for a lower or $+\infty$ for an upper bound) using the internal linear_from_box_inequalities function will result in new linear inequalities $G', h'$ where some values in $h'$ can be $\pm\infty$.

The qpSWIFT interface, for instance, does not handle this correctly, with the solver returning None (no solution) for problems that have solutions.

Reproduction steps

Here is an example reproducing this issue:

import numpy as np

from qpsolvers import solve_qp

M = np.array([[1.0, 2.0, 0.0], [-8.0, 3.0, 2.0], [0.0, 1.0, 1.0]])
P = np.dot(M.T, M)  # this is a positive definite matrix
q = np.dot(np.array([3.0, 2.0, 3.0]), M)
G = np.array([[4.0, 2.0, 0.0], [-1.0, 2.0, -1.0]])
h = np.array([np.inf, -2.0])
A = np.array([1.0, 1.0, 1.0]).reshape((1, 3))
b = np.array([1.0])
lb = np.array([-0.5, -0.4, -0.5])
ub = np.array([1.0, 1.0, 1.0])

x_cvx = solve_qp(P, q, G, h, lb=lb, ub=ub, solver="cvxopt")
print(f"CVXOPT solution: {x_cvx}")

x_scs = solve_qp(P, q, G, h, lb=lb, ub=ub, solver="scs")
print(f"SCSsolution: {x_scs}")

Outcome:

python bug_scs.py                                                                                                                       ✔  38s 
CVXOPT solution: [ 0.32941177 -0.4         0.87058824]
/home/nelson/src/qpsolvers/qpsolvers/conversions/warnings.py:35: UserWarning: Converted P to scipy.sparse.csc.csc_matrix
For best performance, build P as a scipy.sparse.csc_matrix rather than as a numpy.ndarray
  warnings.warn(
/home/nelson/src/qpsolvers/qpsolvers/conversions/warnings.py:35: UserWarning: Converted G to scipy.sparse.csc.csc_matrix
For best performance, build G as a scipy.sparse.csc_matrix rather than as a numpy.ndarray
  warnings.warn(
/home/nelson/src/qpsolvers/qpsolvers/solvers/scs_.py:246: UserWarning: SCS returned -6: UNBOUNDED_INACCURATE
  warnings.warn(
SCSsolution: None
@stephane-caron stephane-caron added the bug Something isn't working label Jan 16, 2023
stephane-caron added a commit that referenced this issue Jan 16, 2023
stephane-caron added a commit that referenced this issue Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant