Description

From the Gurobi product description page:
“The Gurobi Optimizer is a state-of-the-art solver for mathematical programming. It includes the following solvers: linear programming solver (LP solver), quadratic programming solver (QP solver), quadratically constrained programming solver (QCP solver), mixed-integer linear programming solver (MILP solver), mixed-integer quadratic programming solver (MIQP solver), and mixed-integer quadratically constrained programming solver (MIQCP solver).

The solvers in the Gurobi Optimizer were designed from the ground up to exploit modern architectures and multi-core processors, using the most advanced implementations of the latest algorithms.”

Availability

Gurobi is installed for all Flux services.

Accessing Gurobi

To see which versions of Gurobi are available, use

$ module available gurobi

To use Gurobi, use

$ module load gurobi

to load the default version, or specify one of the versions shown with module available.

Running Gurobi interactively

Gurobi comes with a modified Python shell that can be used to experiment interactively with models and specifications. This is invoked as gurobi.sh, and an example of its use can be found on the vendor web site under the Quick Start Guide: Interactive Shell section. To exit the interactive Gurobi, use the quit() command, or Ctrl-D.

$ gurobi.sh
Python 2.7.2 (default, Nov 21 2011, 12:59:35) 
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Gurobi Interactive Shell (linux64), Version 5.6.3
Copyright (c) 2013, Gurobi Optimization, Inc.
Type "help()" for help

gurobi> quit()

Running Gurobi in batch

The usual way to run Gurobi,however, is by putting commands into a file and then running gurobi_cl.

One of the example files is coins.lp. To run that on Flux, you would copy the file to your current directory and run it.

$ cp ${GUROBI_HOME}/examples/data/coins.lp ./
$ gurobi_cl ./coins.lp

Gurobi Optimizer version 5.6.3 build v5.6.3rc2 (linux64)
Copyright (c) 2013, Gurobi Optimization, Inc.

Read LP format model from file ./coins.lp
Reading time = 0.01 seconds
(null): 4 rows, 9 columns, 16 nonzeros
Optimize a model with 4 rows, 9 columns and 16 nonzeros
Found heuristic solution: objective -0
Presolve removed 1 rows and 5 columns
Presolve time: 0.00s
Presolved: 3 rows, 4 columns, 9 nonzeros
Variable types: 0 continuous, 4 integer (0 binary)

Root relaxation: objective 1.134615e+02, 4 iterations, 0.00 seconds

    Nodes    |    Current Node    |     Objective Bounds      |     Work
 Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time

     0     0  113.46154    0    1   -0.00000  113.46154     -      -    0s
H    0     0                     113.4500000  113.46154  0.01%     -    0s

Explored 0 nodes (4 simplex iterations) in 0.00 seconds
Thread count was 12 (of 12 available processors)

Optimal solution found (tolerance 1.00e-04)
Best objective 1.134500000000e+02, best bound 1.134500000000e+02, gap 0.0%

To save the results to the file coins.sol, you would add the ResultFile= option to the command line, to make the command

$ gurobi_cl ResultFile=coins.sol ./coins.lp

Running Gurobi from PBS

Running Gurobi from PBS is exactly the same as running in batch, except that you must create the PBS script, put the gurobi_cl command in that, and then submit the job.

We have a limited number of Gurobi licenses available, so please note that you must request licenses using the gres keyword when requesting resources. To request Gurobi licenses, you would use gres=gurobi:1 on the #PBS -l line.
Here is an example PBS file.

####  PBS preamble
#PBS -N python_test
#PBS -M uniqname@umich.edu
#PBS -m abe

#PBS -l procs=1,mem=1gb
#PBS -l gres=gurobi:1
#PBS -j oe
#PBS -V

#PBS -A example_flux
#PBS -l qos=flux
#PBS -q flux

####  End PBS preamble
#  Print the assigned nodes
if [ "x${PBS_NODEFILE}" != "x" ] ; then
   cat $PBS_NODEFILE   # print the CPUs when running with PBS
fi

# Change to the PBS working directory
cd $PBS_O_WORKDIR

#  Put your job commands after this line
gurobi_cl ResultFile=coins.sol ./coins.lp