Difference between revisions of "Gurobi/Note"

From ScientificComputing
Jump to: navigation, search
(Installing the R,Matlab and Python interfaces locally)
Line 2: Line 2:
  
 
===Matlab interface===
 
===Matlab interface===
For using the Matlab interface, you would need to add the path to the Gurobi Matlab package, using the Matlab command <tt>addpath</tt>
+
For using the Matlab interface, you would need to load your favorite Matlab and Gurobi module and then add the path to the Gurobi Matlab package, using the Matlab command <tt>addpath</tt>:
  
 
  addpath('/cluster/apps/gurobi/__VERSION__/x86_64/matlab')
 
  addpath('/cluster/apps/gurobi/__VERSION__/x86_64/matlab')
  
where <tt>__VERSION__</tt> needs to be replace with the Gurobi version that you would like to use.
+
where <tt>__VERSION__</tt> needs to be replace with the Gurobi version for which you loaded the corresponding module.
 +
 
 +
Please find below an example to use the Matlab interface with Gurobi 9.0.0:
 +
 
 +
[sfux@eu-login-47 test1]$ cp /cluster/apps/gurobi/9.0.0/x86_64/examples/matlab/mip1.m .
 +
[sfux@eu-login-47 test1]$ module load new gcc/4.8.2 gurobi/9.0.0 matlab/R2017b
 +
[sfux@eu-login-47 test1]$ matlab -nodisplay -nojvm -singleCompThread
 +
MATLAB is selecting SOFTWARE OPENGL rendering.
 +
 +
                                                            < M A T L A B (R) >
 +
                                                  Copyright 1984-2017 The MathWorks, Inc.
 +
                                                  R2017b (9.3.0.713579) 64-bit (glnxa64)
 +
                                                            September 14, 2017
 +
 +
 
 +
To get started, type one of these: helpwin, helpdesk, or demo.
 +
For product information, visit www.mathworks.com.
 +
 
 +
>> addpath('/cluster/apps/gurobi/9.0.0/x86_64/matlab')
 +
>> mip1
 +
          status: 'OPTIMAL'
 +
      versioninfo: [1x1 struct]
 +
          runtime: 0.0014
 +
          objval: 3
 +
                x: [3x1 double]
 +
            slack: [2x1 double]
 +
    poolobjbound: 3
 +
            pool: [1x2 struct]
 +
          mipgap: 0
 +
        objbound: 3
 +
        objboundc: 3
 +
        itercount: 0
 +
    baritercount: 0
 +
        nodecount: 0
 +
 +
x 1
 +
y 0
 +
z 1
 +
Obj: 3.000000e+00
 +
>>
 +
 
 +
If you would like to install the Gurobi Matlab interface permanently, then it is sufficient to create a file <tt>$HOME/matlab/startup.m</tt> that contains the <tt>addpath</tt> command. Matlab will on startup automatically check the startup.m file.

Revision as of 09:59, 28 November 2019

Gurobi provides different interfaces (Python, Matlab, R) that can be used. Please find below instructions on how to install the interfaces locally for any version of Python, Matlab or R.

Matlab interface

For using the Matlab interface, you would need to load your favorite Matlab and Gurobi module and then add the path to the Gurobi Matlab package, using the Matlab command addpath:

addpath('/cluster/apps/gurobi/__VERSION__/x86_64/matlab')

where __VERSION__ needs to be replace with the Gurobi version for which you loaded the corresponding module.

Please find below an example to use the Matlab interface with Gurobi 9.0.0:

[sfux@eu-login-47 test1]$ cp /cluster/apps/gurobi/9.0.0/x86_64/examples/matlab/mip1.m .
[sfux@eu-login-47 test1]$ module load new gcc/4.8.2 gurobi/9.0.0 matlab/R2017b
[sfux@eu-login-47 test1]$ matlab -nodisplay -nojvm -singleCompThread
MATLAB is selecting SOFTWARE OPENGL rendering.

                                                           < M A T L A B (R) >
                                                 Copyright 1984-2017 The MathWorks, Inc.
                                                 R2017b (9.3.0.713579) 64-bit (glnxa64)
                                                           September 14, 2017

 
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
 
>> addpath('/cluster/apps/gurobi/9.0.0/x86_64/matlab')
>> mip1
          status: 'OPTIMAL'
     versioninfo: [1x1 struct]
         runtime: 0.0014
          objval: 3
               x: [3x1 double]
           slack: [2x1 double]
    poolobjbound: 3
            pool: [1x2 struct]
          mipgap: 0
        objbound: 3
       objboundc: 3
       itercount: 0
    baritercount: 0
       nodecount: 0 

x 1
y 0
z 1
Obj: 3.000000e+00
>> 

If you would like to install the Gurobi Matlab interface permanently, then it is sufficient to create a file $HOME/matlab/startup.m that contains the addpath command. Matlab will on startup automatically check the startup.m file.