Search code examples
roptimizationcvxmosekcvxr

Usign Mosek for CVXR


I have already installed 3 times Mosek. It is working in python but CVXR (r package) function installed_solvers() is not able to find MOSEK. enter image description here

I'm working on a MACos Mojave. I installed Mosek via conda comand, got an academic license, create a folder in the home directory with the name mosek and put the license file in it. Then I tested in jupyter lab the following script https://docs.mosek.com/8.1/pythonapi/design.html#hello-world-in-mosek and getting the result Solution x = 2.0 , so Mosek is working. Then I installed reticulate, use the default directory, replace it by use_python("/Users/apple/anaconda3") and use_python("/Users/apple/anaconda3/lib/python3.6") In any of them, the function installed_solvers() has found mosek. My session info is the following enter image description here

The documentation in https://cvxr.rbind.io/cvxr_examples/cvxr_using-other-solvers/ doesn't really say how to solve the problem. Somebody has found the solution? Thanks


Solution

  • I was able to replicate, and errors are unfortunately very silent. But based on the source code, https://rdrr.io/cran/CVXR/src/R/mosek-solver.R, I tried all requirements

    reticulate::py_module_available(module = "numpy")
    reticulate::py_module_available(module = "scipy.sparse")
    reticulate::py_module_available(module = "mosek")
    

    to find that I was actually missing scipy in my Python environment. After installing that, it worked as documented..

    If this doesn't help you, then try manually importing the solver:

    msk = MOSEK()
    import_solver(msk)
    

    and see where that leads to.