Why I have to run yalmiptest before the Gurobi can work well in matlab

118 views
Skip to first unread message

R Guo

unread,
Mar 29, 2020, 12:47:49 PM3/29/20
to YALMIP
It is wired that the Gurobi solver only works well for a MPC problem after I run the yalmiptest to confirm that the Gurobi solver is available. Or if I do not run the yalmiptest to test different solvers, there will be an error message that:

"Invalid MEX-file 'C:\Program Files\gurobi901\win64\matlab\gurobi.mexw64': The specified module could not be found."
"Error in callgurobi (line 13) result = gurobi(model,model.params);"

"Error in optimizer/subsref (line 326) eval(['output = ' self.model.solver.call '(self.model);'])";

Johan Löfberg

unread,
Mar 29, 2020, 1:18:04 PM3/29/20
to YALMIP
This can only happen due to incorrectly set path.

Do you really have the gurobi binary in your path. Are you running cvx in between? (cvx destroys the path)

Mark L. Stone

unread,
Mar 29, 2020, 1:51:09 PM3/29/20
to YALMIP
Early builds of CVX 2.2 destroyed the path. B but I think the latest build of CVX 2.2 does not (but I don't give you a money back guarantee on that).

R Guo

unread,
Mar 29, 2020, 4:51:41 PM3/29/20
to YALMIP
Hi Prof. Johan,

Thanks a lot for your great reply. I add the gurobi folder as well as the subfolder in the Matlab path. 

批注 2020-03-29 224746.png

The whole error message are shown below:

批注 2020-03-29 224640.png

I am not running cvx in the program.

批注 2020-03-29 225108.png



R Guo

unread,
Mar 29, 2020, 4:52:26 PM3/29/20
to YALMIP
Hi Mark,

Thanks a lot for your kind reply. But I did not use CVX in the program...

Johan Löfberg

unread,
Mar 29, 2020, 4:59:23 PM3/29/20
to YALMIP
You have a lot of unnecessary in your path. all you need is addpath('C:\gurobi901\win64\matlab')

It's pretty obvious you messed up something with your installation. In the picture you've added c:\gurobi... to your path, but the crash talks about "Invalid MEX-file 'C:\Program Files\gurobi901\win64\matlab\gurobi.mexw64': 

My guess is you've installed gurobi, and then forcefully moved its installation directory. or something...

Anyway, you've somehow destroyed your installation

Alessandro Maria Laspina

unread,
Jan 4, 2022, 1:39:05 PM1/4/22
to YALMIP
Hello, 

I am having this issue as well and do not have CVX anymore installed (I also tried reinstalling Gurobi 9.5.0 but the same thing happens). Oddly enough, yalmiptest will detect gurobi but attempting to run the tests with it (yalmiptest('gurobi')) will not give much more information as it cannot solve several of the SDP problems.

I have made sure that the path is correct multiple times yet this still happens. I did not have the same issue installing Mosek or ECOS. 

Johan Löfberg

unread,
Jan 5, 2022, 7:30:38 AM1/5/22
to YALMIP
huh?

does gurobi work or not?

Alessandro Maria Laspina

unread,
Jan 6, 2022, 2:14:42 PM1/6/22
to YALMIP
Ok so I got it to work in the end. For some reason adding the path via the current folder window does not work (left click, add path, include all subfolders). Instead, using addpath and genpath allowed it to work. I don't know why the command works and the manual point and click operation doesn't, but it finally works. Regardless, it was working only with the tests, but without it, it did not. I believe, although don't remember 100%, that my installation with mosek had the same issue.  

TLDR: You may want to use addpath and genpath instead of left clicking and adding the path,  if you have this problem. 
Reply all
Reply to author
Forward
0 new messages