Gurobi Optimizer
Gurobi Optimizer is an solver that incorporates mathematical models to make optimized decisions and supports a variety of different interfaces, such as Python, C, C++, Java, R, and more.
Using Python?
To support using other packages with Gurobi, such as numpy, we have set up a dedicated conda-based install of Gurobi for Python projects. We recommend using that version instead.
Availability
| Cluster | Module/Version |
|---|---|
| BOSE | gurobi/12.0.3 gurobi/11.0.0 |
| BGSC | Not Available |
Note: You can simply use module load gurobi to activate the most recently installed version of this software.
Environment Variables
The following environment variables are available to use in your scripts.
| Variable | Purpose |
|---|---|
| $GUROBI_HOME | Points to installation location of Gurobi files such as examples, lib, or include. |
Executables
The following list are the most common executables one may use for running Gurobi-based optimizations.
| Executable | Purpose |
|---|---|
| gurobi_cl | Gurobi's command line interface |
| gurobi.sh | Interactive Python-based shell (recommended to use our Python API module instead) |
| python3.11 script.py | Run Python-based .py scripts (recommended to use our Python API module instead) |
Gurobi Examples
MIP Model
The follow commands show examples of different ways to forumlate and solve a simple MIP model, which is one of the examples provided by Gurobi in $GUROBI_HOME/examples.
From Gurobi:
Command Line / LP File - Coins
Online Reference: Coin Tutorial
The following code is based on the above tutorial and uses the example file coins.lp from Gurobi. Through this model, you can specify the minerals required to produce coins, and find the combination that gives you the highest dollar value.
module load gurobi
cp $GUROBI_HOME/examples/data/coins.lp ./ # Copy example from Gurobi (same as above link)
gurobi_cl ResultFile=coins.sol coins.lp # Run and create a solution file
cat coins.sol # View solution file
Sample Slurm Script
#!/bin/bash
# -- SLURM SETTINGS -- #
# [..] other settings here [..]
# The following settings are for the overall request to Slurm
#SBATCH --ntasks-per-node=32 # How many CPU cores do you want to request
#SBATCH --nodes=1 # How many nodes do you want to request
# -- SCRIPT COMMANDS -- #
# Load the needed modules
module load gurobi # Load Gurobi Optimizer
gurobi_cl ResultFile=solution.sol input-file.lp
Real Example
Has your research group used Gurobi Optimizer in a project? Contact the HPC Team and we'd be glad to feature your work.
Citation
Please include the following citation in your papers to support continued development of Gurobi Optimizer.
Gurobi Optimization, LLC. (2024). Gurobi Optimizer Reference Manual. Retrieved from https://www.gurobi.com