A Quick-Start Guide
Gurobi is an industry-leading optimization solver. gurobipy
is its Python interface, which enables you to call Gurobi solvers from Python. You will use both these tools in RSM8423 (Optimizing Supply Chain Management and Logistics). This guide aims to get you started with Gurobi via gurobypy
.
Installation
Follow the steps below to install Gurobi and gurobipy
. As a side note, thegurobipy
package itself ships with a size-limited Gurobi trial license which can solve models with up to 2000 variables and 2000 constraints. Therefore, you could skip the step 1 below if the optimization problems you plan to solve are within the limit.
Follow a 5-step instruction here to download and install the Gurobi Optimizer (version 10 with Academic Named-User License).
Important: To activate the academic license (step 5), your computer must be connected to the UofT network.
Install the
gurobipy
package. You could simply usepip
.pip install gurobipy
Alternatively, if you use the Anaconda Python distribution, and are familiar with
conda
, you could use theconda
command line (the-c
option specifies thegurobi
channel).conda install -c gurobi gurobi
Download and run this simple example (mip.py) to verify your installation.
An Example
-
This Python notebook walks you through the steps to formulate and solve a simple MIP (Mixed-Integer Programming) problem. This is the same example as in Gurobi’s official document.
Resources
- Resources for Academic Users (including video tutorials on MIP and LP problems)
- Gurobi Python Quickstart Examples (three examples to get you started with
gurobipy
) - Jupyter Notebook Modeling Examples (business case studies)
- Gurobi Examples List (official examples from Gurobi)
- Gurobi Python API Overview and Details (
gurobipy
reference manual)
Back to TDMDAL Computing Page