Qustions about Gurobi and Mosek set up

I have install the cvx, mosek and gurobi with with licenses, respectively.

1.For mosek, I installed it in “C:\Program Files\Mosek” and the academic license was in “C:\Users\LA\mosek\mosek.lic”.
I have added to path and checked the mosekdiag, it showed,

Matlab version : 9.11.0.1837725 (R2021b) Update 2
Architecture : PCWIN64
mosekopt path : C:\Program Files\Mosek\9.3\toolbox\R2015a\mosekopt.mexw64
MOSEK version : 9.3.16
Test linear solve: Success
mosekopt works OK. You can use MOSEK in MATLAB.

But after I re-run the cvx_setup, although the installed mosek can be found, the version of it is 9.1.9, not the installed 9.3.16 that shown in mosekdiag. I am confused why it’s that. Below is the part of output of the cvx_setup.

6 solvers initialized (* = default):
Gurobi 9.00 {cvx}\gurobi\w64
Mosek 9.1.9 {cvx}\mosek\w64
Mosek_2 9.1.9 C:\Program Files\Mosek\9.3\toolbox\R2015a
Mosek_3 9.1.9 C:\Program Files\Mosek\9.3\toolbox\R2015a

  • SDPT3 4.0 {cvx}\sdpt3
    SeDuMi 1.3.4 {cvx}\sedumi

2.For gurobi, I installed it in “C:\Program Files\gurobi951” and the academic license was in “C:\Users\LA\gurobi.lic”. I have set the environment variable for license and have run the C:\Program Files\gurobi951\win64\matlab*gurobi_setup.m* file in matlab, it showed

gurobi_setup

The MATLAB interface for Gurobi 9.5.1 has been installed.

The directory
C:\Program Files\gurobi951\win64\matlab
has been added to the MATLAB path.
To use Gurobi regularly, you must save this new path definition.
To do this, type the command
savepath
at the MATLAB prompt. Please consult the MATLAB documentation
if necessary.

savepath

Then, I re-run the cvx_setup, the command window showed,

Setting CVX paths…already set!
Searching for solvers…Warning: env argument deprecated, use params. instead

postion:cvx_gurobi
postion: cvx_gurobi
postion: cvx_setup (Line 83)
Warning: env argument deprecated, use params. instead
postion:cvx_gurobi
postion: cvx_gurobi
postion: cvx_setup (Line 83)
5 shims found.
6 solvers initialized (* = default):
Gurobi 9.00 {cvx}\gurobi\w64
Mosek 9.1.9 {cvx}\mosek\w64
Mosek_2 9.1.9 C:\Program Files\Mosek\9.3\toolbox\R2015a
Mosek_3 9.1.9 C:\Program Files\Mosek\9.3\toolbox\R2015a

  • SDPT3 4.0 {cvx}\sdpt3
    SeDuMi 1.3.4 {cvx}\sedumi
    3 solvers skipped:
    GLPK
    Could not find a GLPK installation.
    Gurobi_2 unknown C:\Program Files\gurobi951\win64\matlab
    params.OutputFlag must be a scalar
    Gurobi_3 unknown C:\Program Files\gurobi951\win64\matlab
    params.OutputFlag must be a scalar

Why the gurobi that I installed was skipped? Did I do something wrong?

It looks like Mosek_2 or Mosek_3 is your Mosek 9.3.16. So you can set
cvx_solver Mosek_2,(and cvx_save_prefs if you want), and it ought to use that.

Mosek 9.1.9 is included with CVX 2.2. So instead of the preceding, you could either rename the cvx/mosek directory to something else, or just delete it. Then re-run cvx_setup, and whatever version of Mosek is in your MATLABpath will be the only Mosek version under CVX.

I don’t know what is going on with Gurobi. If Gurobi is installed under MATLAB, it should be usable from CVX after cvx_setup is performed. I don’t know why you got the warnings for Gurobi (but I am running MATLAB 2019b, not 2021b). Can you solve problems in CVX using Gurobi?

The proof of the pudding for what solver version you are actually using under CVX is the solver output. For instance, if you run cvx_setup when the Mosek version is 9.3.16, that is the Mosek version that CVX claims to call. But if you subsequently install Mosek 9.3.17 without re-running cvx_setup, CVX will say it is calling Mosek 9.3.16, but if you look at the solver output, you will see that 9.3.17 was actually used (the auto-updating won’t work if you ever go to Mosek 9.4 or 10.0), because they will be in a different directory).

Mark, thanks! I delete the mosek in cvx directory and the version is corrected. I acutually used it under CVX and 9.3.16 is called in output. But, as I use “cvx_solver mosek” command, I think if I use “cvx_solver mosek_2” or “cvx_solver mosek_3” without deleting the mosek in cvx, it should call 9.3.16 as well. Never mind, it was solved. Thanks again!

Below is the output that I call mosek_2 without deleting mosek in cvx.

Calling Mosek_2 9.1.9: 131530 variables, 32947 equality constraints
For improved efficiency, Mosek_2 is solving the dual problem.

MOSEK Version 9.3.16 (Build date: 2022-3-2 13:37:03)
Copyright © MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

As for gurobi, it can be used, but the 9.0.0 in cvx is called. The gurobi_2 can’t be used, as the installed 9.5.1 was skipped. I am still trying to figure out why.

I suggest you delete or rename the gurobi included with CVX 2.2 Then re-run cvx_setup. Then CVX hopefully will only find your gurobi 9.5.1, presuming it is in your MATLABpath. You can also try doing that in a new MATLAB session.

Thanks! I will try it.

Hi bewater, I encountered this problem yesterday. It seemed that it’s the Gurobi’s the version leads to this problem.Just change it to version 9.1.2 or older (9.5.0 also has this problem). However you may also run 9.5.1 by cvx if you try to change some source codes of cvx. For me I changed the cvx_setup(after row83 I change tsolve(2)'s state, %it maybe tsolve(3) or tsolve(4) on your machine) and file(cvx_run_solver).Ok, it’s too complicated, the best and most easy way is ‘change the version of Gurobi’. A hard problem really! Hope this can help you.

Thanks Tommy! I will try it!