1

I'm trying to solve optimization problems using cvxpy and MOSEK. Despite the fact that both packages seem to work independently, I don't manage to get them function together. Whenever I ask cvxpy to solve any problem with MOSEK, I always get the error:

AttributeError: type object 'solsta' has no attribute 'near_optimal'

What am I doing wrong?

Consider the following (minimal) code:

import cvxpy as cp

x = cp.Variable(2)
obj = cp.Minimize(x[0] + x[1])
constraints = [x >= 2]+[x<=5]
prob = cp.Problem(obj, constraints)

# Solve with MOSEK.
prob.solve(solver=cp.MOSEK,verbose=True)
print("optimal value with MOSEK:", prob.value)

As with any other optimization I've tried with MOSEK and cvxpy, the compiler crashes on this line:

prob.solve(solver=cp.MOSEK,verbose=True)

MOSEK correctly solves the problem, but there seems to be an issue in communicating the solution to cvxpy.

Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79
Miguel
  • 11
  • 1

1 Answers1

0

It looks like you installed the latest Mosek version 9 but you have a fairly old cvxpy which does not support it. Upgrade cvxpy, the latest version supports Mosek 9.

  • I just installed cvxpy using the command "conda install -c cvxgrp cvxpy", and I still get the same error. Using the installation command "conda install -c cvxgrp cvxpy=1.0.23" results in the error message "PackagesNotFoundError: The following packages are not available from current channels: - cvxpy=1.0.23". – Miguel May 29 '19 at 08:53
  • @Miguel So which exactly version of cvxpy do you currently have, and which version of Mosek do you have? – Michal Adamaszek May 29 '19 at 09:32
  • My version of Mosek is 9. My version of cvxpy is 0.4.10 (and that after I typed "conda cvxpy upgrade"!). How can I update my cvxpy? I am using anaconda and win-64. – Miguel May 29 '19 at 09:46
  • Yes, so you need cvxpy 1.0. See https://github.com/cvxgrp/cvxpy/issues/701 – Michal Adamaszek May 29 '19 at 10:07
  • It doesn't work for me, still complains the same error although I upgraded to cvxpy 1.0.31 – kkgarg Apr 11 '20 at 17:03