Overview

The goal of this tutorial is to give a concise introduction to using the Python interface to modeling and solving optimization problems in Gurobi. This tutorial is by no means comprehensive.

Installation

  • Go to the webpage: http://www.gurobi.com/downloads/get-anaconda
  • There are two common variants of Python - Python 2.X and Python 3.X.
  • This tutorial is for Python 3.X. So download the latest Anaconda for Python 3.X corresponding to your operating system.
  • The rest of the instructions assume that you have a windows operating system
  • Run the installation file
  • For windows installation, in the advanced installation options, make sure you check the add anaconda to the system path environmental variable option
  • Install Gurobi according to the instructions provided in the documentation: https://www.gurobi.com/documentation/
  • Install the license
  • Open a command window in the folder that contains the files setup.py. Run the command ``python setup.py install’’. If the command does not work, open the command window in administrator mode.

Python for Optimization

If you want to fast track into learning Python for optimization modeling, the following resources are useful.

  • Ted Ralph, faculty at Lehigh has very good resources on his website. If you are specifically interested in learning more about open source optimization tools with Pyton, I recommend his page on PYTHON + COINOR refer to his

  • Some of the good presentations I found on Python + Gurobi are

Example Codes

These are some basic example codes for getting you started in using gurobi with the python interface. These codes where developed based on the excellent Gurobi examples available here.