AMPL Model Colaboratory¶
In order to be use AMPL on these notebook platforms you just need to following two code blocks at the beginning of your notebook:
# Install dependencies !pip install -q amplpy
# Google Colab & Kaggle integration MODULES, LICENSE_UUID = ["coin", "highs", "gokestrel"], None from amplpy import tools ampl = tools.ampl_notebook(modules=MODULES, license_uuid=LICENSE_UUID, g=globals()) # instantiate AMPL object and register magics
In the list
MODULES you can specify the AMPL solvers you want to use in your notebook.
For more information on the AMPL Modules for Python see Python Modules Documentation.
For more information on how to use
amplpy see Python API Documentation.
In these notebooks there are
%%ampl_eval cells that allow you to run AMPL code directly from the notebook.
They are equivalent to
Some notebooks require commercial solvers. You can use a free AMPL Community
Edition license with an open-source solver (e.g., HiGHS, CBC, Couenne, Ipopt, Bonmin)
or with a commercial solver from the NEOS Server as described in https://dev.ampl.com/solvers/kestrel.html.
In the list
MODULES you need to include
"gokestrel" to use the kestrel driver;
"highs" for the HiGHS solver;
"coin" for the COIN-OR solvers.
To use other commercial solvers without NEOS, your license needs to include the commercial solver (e.g., an AMPL CE commercial solver trial).