Jupyter Notebooks
Note
This feature is currently in beta status.

Introduction

GAMS Jupyter Notebooks allow to use notebook technology in combination with GAMS. If you just want to learn GAMS there are probably better ways doing this. Notebooks allow you to combine GAMS and Python. The former works great with well structured data and optimization models, while the latter is very rich in features to retrieve, manipulate, and visualize data that comes in all sort of ways. Combining GAMS and Python in a notebook it is relatively easy to tell an optimization story with text, data, graphs, math, and models.

Getting Started

The first step in getting started with GAMS Jupyter Notebooks is to make your Python 3 installation aware of the GAMS Python API collection described in the Getting started section of the API tutorial. We recommend to follow the steps below which are specifically tailored for getting started with GAMS Jupyter notebooks. While any Python >=3.7 installation is supported, we recommend the use of Anaconda or Miniconda Python distributions.

In addition to the GAMS Python API collection, the packages jupyterlab, matplotlib, pandas, and tabulate are required in order to enable GAMS Jupyter Notebooks and to run the provided examples which are located in apifiles/Python/jupyter_examples. The following code section shows how to create and set up a Miniconda Python environment for GAMS Jupyter notebooks:

Windows:

conda create -n gmsjupyter python=3.8 jupyterlab pandas tabulate matplotlib
conda activate gmsjupyter
cd C:\GAMS\41\apifiles\Python\api_38
REM Perhaps a environment variable needs to be set: set SETUPTOOLS_USE_DISTUTILS=stdlib
python setup.py install (In case of permission problems run the following instead: python setup.py build -b %TEMP%\build install)
cd C:\jupyter (or another directory that should be used for your notebooks)
jupyter notebook (this will start the jupyter notebook server)

Linux:

conda create -n gmsjupyter python=3.8 jupyterlab pandas tabulate matplotlib
conda activate gmsjupyter
cd ~/gams/gams33.1_linux_x64_64_sfx/apifiles/Python/api_38
# Perhaps a environment variable needs to be set: export SETUPTOOLS_USE_DISTUTILS=stdlib
python setup.py install (In case of permission problems run the following instead: python setup.py build -b $TMPDIR/build install)
cd ~/jupyter (or another directory that should be used for your notebooks)
jupyter notebook (this will start the jupyter notebook server)

macOS:

conda create -n gmsjupyter python=3.8 jupyterlab pandas tabulate matplotlib
conda activate gmsjupyter
# Perhaps a environment variable needs to be set: export SETUPTOOLS_USE_DISTUTILS=stdlib
python /Library/Frameworks/GAMS.framework/Resources/apifiles/Python/api_38/setup.py build -b $TMPDIR/build install
cd  ~/jupyter (or another directory that should be used for your notebooks)
jupyter notebook (this will start the jupyter notebook server)

The notebooks Millco.ipynb and Introduction.ipynb located in apifiles/Python/jupyter_examples are good starting points to get familiar with Jupyter notebooks and GAMS. The remainer of this section gives the dialog of the Introduction.ipynb notebook.

Tutorial

Introduction