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.

  1. 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.

  2. Install the gurobipy package. You could simply use pip.

    pip install gurobipy

    Alternatively, if you use the Anaconda Python distribution, and are familiar with conda, you could use the conda command line (the -c option specifies the gurobi channel).

    conda install -c gurobi gurobi
    
  3. Download and run this simple example (mip.py) to verify your installation.


An Example

  • Solve a MIP problem ( )

    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


Back to TDMDAL Computing Page