Topic outline

  • Gurobi Installation guide

    For optimization, we’ll use the Gurobi Solver, one of the best solvers available. Gurobi is a commercial product but offers free academic licenses. It has a Python API that can be used from within Python code. The reference manual is here: http://www.gurobi.com/documentation/8.1/refman/index.html


    Since many seem to have problems installing Gurobi, we made this step-by-step guide.


    Step 1: Make a Gurobi account

    Go to http://www.gurobi.com/index , make a new account and register (might not work with Safari browser). Wait for a confirmation email, confirm and set a password. Log-in with your email and newly set password. 


    Step 2: Get Gurobi license

    Gurobi is a licensed product, however it offers a free academic license. This setup is the reason why each student has to request a license individually. Aalto cannot do that in bulk on your behalf. Once you have an account and are logged-in, you need to request a license. On the front page, click on "get Gurobi". 


    Then click "Academic Licenses"


    Tick both boxes and click "Request License". The next page will show your license details. KEEP THIS PAGE OPEN!


    Step 3: Get the Gurobi Optimizer 

    Once you have an account and a license, you need to download the Gurobi Optimizer. This is a "real" program, not just a Python package. Click and open the "Get Gurobi" button (top right) in a new tab. DONT CLOSE THE LICENSE WINDOW. You will see the familiar Download Center, but this time click "Gurobi Optimzer".


    Accept the End User License Agreement on the next page. Download the latest version of Gurobi depending on your system (Windows, MacOS, Linux).


    Step 4: Install Gurobi Optimizer

    Before opening the downloaded file, ensure that you are connected to the Aalto network! This is how Gurobi verifies that you eligible for the academic license. Either you are physically on the Aalto premise and connected to the Aalto wifi, or you use the Aalto VPN to connect to the Aalto network remotely. 

    Open the downloaded file and run the installation. Once the installation is finished a terminal window will open. If not, you need to open the Gurobi optimizer manually, which should trigger the terminal window to open. Obviously, this will look different on Windows, MacOS and Linux, but it will look something like this:

     

    Since you followed these instructions, your Gurobi License window is still open (right?). Copy the license without the grbgetkey part (only the actual key). Paste it into the terminal. Either pasting will trigger the process or you need to press enter. The installer will verify your license. 

    Next, it will ask you to specify a directory for storing your key. I highly recommend to specify nothing and simply keep the default directory. Just hit enter. If you feel like hackerman/hackergirl, decide to  change the directory and stuff doesn't work later: no support from our end. 


    The installer will run and output at some point [Process completed]. Congrats, you are not done yet! 


    Step 5: Install the Gurobi Python package 

    So far, you have only installed the actual Gurobi optimisation software on your machine. In this course, however, we want to use Gurobi in Python. Therefore you need to install the Gurobi Python package. In this guide, I'll only discuss how to install the package with Anaconda. If you prefer another package manager you are probably able to install a package yourself. 

    Go to https://www.gurobi.com/documentation/8.1/quickstart_mac/installing_the_anaconda_py.html and read the instructions. If you don't have Anaconda yet (or Python, really?), set it up. The internet is full of guides for this step. Once you have Anaconda running, open a Terminal. 

    First add the Gurobi channel so that conda knows where to look for the package: 

    conda config --add channels http://conda.anaconda.org/gurobi

    Next, install the Gurobi package:

    conda install gurobi


    Step 6: Verify that things work

    A simple of checking that Gurobi works is to create a new Jupyter notebook (.ipynb file) and to import the Gurobi libraries. Just type


    Into a new cell and run it. If this works, Gurobi is properly installed. Congrats! Now you are done!