gurobi solver not detected

139 views
Skip to first unread message

Ayub Afridi

unread,
Jun 9, 2021, 5:32:03 AM6/9/21
to YALMIP
hello dear johan, i have installed gurobi9.1 in my pc and i have already added its path to matlab and sytem variables, but once i select the solver gurobi in yalmip model, it says no solver found

Johan Löfberg

unread,
Jun 9, 2021, 5:39:58 AM6/9/21
to YALMIP
You don't have it in your path, or you have installed the wrong binary

>> addpath(genpath('C:\gurobi912\win64'))
>> which gurobi -all
C:\gurobi912\win64\matlab\gurobi.mexw64
C:\gurobi912\win64\matlab\gurobi.m       % Shadowed

Ayub Afridi

unread,
Jun 9, 2021, 6:13:58 AM6/9/21
to YALMIP
i have tried the steps that you have mentioned, still it shows NaN result now
i am using a simple YALMIP model just to test my solver, for cplex it is working and showing correct results, but no other solver is detected
specailly gurobi 

Johan Löfberg

unread,
Jun 9, 2021, 6:31:45 AM6/9/21
to YALMIP
Prove it. Show that you add it to your path as above, make a dir of that directory to show us that you actually added the correct path, then show what you get when you search for it (and for extra credit, how us what binary your system is using by running mexext too), and finally solve a small problem and show that you really get the solver not found flag

Ayub Afridi

unread,
Jun 9, 2021, 6:51:48 AM6/9/21
to YALMIP
okay, i have take some pictures from the path of MATLAB, and also the command that you have provided me to run into matlab to add gurobi.
please have a look, i have attached a zip file so inisde are 3 pictures
Documents.zip

Johan Löfberg

unread,
Jun 9, 2021, 7:12:09 AM6/9/21
to YALMIP
YALMIP has no issue finding gurobi here, so your claim about it missing is not correct.

I would guess you aren't looking at the diagnostic output thus failing to see complaints about missing licenses or unexpected crashes, or that you simply try to solve an infeasible prolem or something like that. Don't send pictures, simply copy the output

>> sdpvar x
>> optimize(x>=0,x,sdpsettings('solver','gurobi'))
ans = 

  struct with fields:

    yalmipversion: '20210331'
    matlabversion: '9.9.0.1524771 (R2020b) Update 2'
       yalmiptime: 0.5143
       solvertime: 0.1817
             info: 'Successfully solved (GUROBI)'
          problem: 0


Ayub Afridi

unread,
Jun 9, 2021, 7:49:21 AM6/9/21
to YALMIP
yalmipversion: '20210331'
    matlabversion: '9.0.0.341360 (R2016a)'
       yalmiptime: NaN
       solvertime: NaN
             info: 'Unknown problem in solver (Turn on 'debug' in sdpsettings) (Invalid MEX-file 'C:\gurobi912\win6…'
          problem: 9

Johan Löfberg

unread,
Jun 9, 2021, 7:58:41 AM6/9/21
to YALMIP
as it says in the info (turn on debug and you will see it printed clearly): you have installed the wrong version or something, as it complains about the mex file

Johan Löfberg

unread,
Jun 9, 2021, 8:05:19 AM6/9/21
to YALMIP
the only way to get that error if you have the wrong version

>> which gurobi -all
C:\gurobi912\win64\matlab\gurobi.mexw64
C:\gurobi912\win64\matlab\gurobi.m       % Shadowed
>> mexext

mexw64


or if your windows path isn't correctly setup

>> s = evalc('!path');
>> ~isempty(strfind(s,'C:\gurobi912\win64\bin'))

ans =

  logical

   1


onsdag 9 juni 2021 kl. 13:49:21 UTC+2 skrev ayubaf...@gmail.com:

Ayub Afridi

unread,
Jun 9, 2021, 8:08:30 AM6/9/21
to YALMIP
this is logical answer i get, the version of yalmip, matlab and gurobi is mentioned in above message
>> which gurobi -all
C:\gurobi912\win64\matlab\gurobi.mexw64
C:\gurobi912\win64\matlab\gurobi.m       % Shadowed
>> mexext

mexw64

>> s = evalc('!path');
>> ~isempty(strfind(s,'C:\gurobi912\win64\bin'))

ans =

     0

Johan Löfberg

unread,
Jun 9, 2021, 8:12:17 AM6/9/21
to YALMIP
so you have failed to add the path to windows. back to the gurobi installation notes (or restart since I think that is required after installing gurobi, but then it told you that)

i.e. not a yalmip or matlab issue, but a failed gurobi installation

Ayub Afridi

unread,
Jun 9, 2021, 8:21:06 AM6/9/21
to YALMIP
thank you very much i understood your point of view, you are doing alot help to me. actually i tested the installation according to the notes, but i will make sure again what actually the problem is, gurobi test shows the proper installation but here i think it might be the compatability issue?

Johan Löfberg

unread,
Jun 9, 2021, 8:26:06 AM6/9/21
to YALMIP
no it is simply a missing environment variable in windows

you can easily test that by going to the directory and then run our code, and gurobi will work

>>cd('C:\gurobi912\win64\bin')
Reply all
Reply to author
Forward
0 new messages