-
Notifications
You must be signed in to change notification settings - Fork 163
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
cvxpy and cvxpylayers solutions disagree for cvxpy==1.3.0 and cvxpylayers==0.1.4 #143
Comments
I am having the same issue (with a different optimization problem):
For now I switched to cvxpy==1.2.3 |
Hi, this may be due to cvxpylayers/cvxpy defaulting to using SCS with a quadratic objective without having full support for it (which I believe may be the difference between |
With the latest versions of both
Both return [1.4, 1.7] |
In an anaconda environment with cvxpy==1.3.0 and cvxpylayers==0.1.4 I noticed that cvxpylayers and cvxpy result in different solutions for the following problem:
x = cp.Variable(2)
xc = cp.Parameter(2)
xc.value = np.array([1.0, 2.5])
xc_torch = torch.tensor([1.0, 2.5])
obj = cp.Minimize((x[0] - xc[0])**2 + (x[1] - xc[1])**2)
cons = [(x[0] - 2 * x[1] + 2) >= 0 ,
(-x[0] - 2 * x[1] + 6 >= 0),
(-x[0] + 2 * x[1] + 2) >=0]
prob = cp.Problem(obj, cons)
cvxpylayer = CvxpyLayer(problem=prob, parameters=[xc], variables=[x])
prob.solve(solver_args={"solve_method": "ECOS"})
outputs 0.8for i in prob.variables(): print(i.value)
outputs the optimal variable values: [1.4, 1.7]cvxpylayer(xc_torch, solver_args={"solve_method": "ECOS"})
outputs:The solutions agree when I use cvxpy==1.2.3, but not with cvxpy==1.3.0 (in both cases using cvxpylayers==0.1.4). Also note that the example on the github readme for cvxpylayers did not show the same issue for either cvxpy==1.2.3 or 1.3.0. I am going to stick with cvxpy==1.2.3 for now, but does anyone know what is causing this issue for cvxpy==1.3.0? Thanks!
The text was updated successfully, but these errors were encountered: