You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a pretty simple Quad Program which ECOS fails to solve (Returns nan) while Gurobi / OSQP manages to solver it.
I am using CVXPY to utilize ECOS.
How to reproduce
Python code to reproduce:
# General tools
import numpy as np
import scipy as sp
# Sparse
import scipy.sparse as spa
# Solvers
import cvxpy
# Code from OSQP Benchmark
class LassoExample(object):
'''
Lasso QP example
'''
def __init__(self, n, seed=1):
# Set random seed
np.random.seed(seed)
self.n = int(n) # Number of features
self.m = int(self.n * 10) # Number of data-points
self.Ad = spa.random(self.m, self.n, density=0.15,
data_rvs=np.random.randn)
self.x_true = np.multiply((np.random.rand(self.n) >
0.5).astype(float),
np.random.randn(self.n)) / np.sqrt(self.n)
self.bd = self.Ad.dot(self.x_true) + np.random.randn(self.m)
self.lambda_max = np.linalg.norm(self.Ad.T.dot(self.bd), np.inf)
self.lambda_param = (1./5.) * self.lambda_max
self.qp_problem = self._generate_qp_problem()
def _generate_qp_problem(self):
# Construct the problem
# minimize y' * y + lambda * 1' * t
# subject to y = Ax - b
# -t <= x <= t
P = spa.block_diag((spa.csc_matrix((self.n, self.n)), 2*spa.eye(self.m), spa.csc_matrix((self.n, self.n))), format='csc')
q = np.append(np.zeros(self.m + self.n), self.lambda_param * np.ones(self.n))
In = spa.eye(self.n)
Onm = spa.csc_matrix((self.n, self.m))
A = spa.vstack([spa.hstack([self.Ad, -spa.eye(self.m),
spa.csc_matrix((self.m, self.n))]),
spa.hstack([In, Onm, -In]),
spa.hstack([In, Onm, In])]).tocsc()
l = np.hstack([self.bd, -np.inf * np.ones(self.n), np.zeros(self.n)])
u = np.hstack([self.bd, np.zeros(self.n), np.inf * np.ones(self.n)])
return P, q, A, l, u, A.shape[0], A.shape[1]
lassoQp = LassoExample(3);
P, q, A, l, u, m, n = lassoQp._generate_qp_problem();
x = cvxpy.Variable(lassoQp.n + lassoQp.m + lassoQp.n);
cvxObj = cvxpy.Minimize(cvxpy.quad_form(x, P) + (x @ q));
cvxCons = [l <= A @ x, A @ x <= u];
cvxPrblm = cvxpy.Problem(cvxObj, cvxCons);
cvxRes = cvxPrblm.solve(solver = cvxpy.ECOS, verbose = True);
I am also attaching as a .txt file SCSFail.txt (Change solver into ECOS).
Additional information
It is a LASSO problem converted into QP.
Actually SCS fails other problems from OSQP Benchmark such as: Huber Fitting, SVM.
Running the same problems with OSQP or Gurobi yields a valid solution.
Specifications
2.0.7.post1
(Python PIP)Description
I have a pretty simple Quad Program which ECOS fails to solve (Returns
nan
) while Gurobi / OSQP manages to solver it.I am using
CVXPY
to utilizeECOS
.How to reproduce
Python code to reproduce:
I am also attaching as a
.txt
file SCSFail.txt (Change solver intoECOS
).Additional information
It is a LASSO problem converted into QP.
Actually SCS fails other problems from OSQP Benchmark such as: Huber Fitting, SVM.
Running the same problems with OSQP or Gurobi yields a valid solution.
Output
The text was updated successfully, but these errors were encountered: