# AMPL Model Colaboratory¶

AMPL Model Colaboratory is a collection of AMPL models in Jupyter Notebooks
that run on platforms such as **Google Colab**, **Kaggle**, **Gradient**, and **AWS SageMaker**.
[See our Highlights]

You can use the **Christmas notebook** written by ChatGPT to get started:

## Getting Started¶

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.

Note

In these notebooks there are `%%ampl_eval`

cells that allow you to run AMPL code directly from the notebook.
They are equivalent to `ampl.eval("""cell content""")`

.

Warning

**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).

## Notebooks¶

### AMPL Christmas Model created by ChatGPT¶

### AMPL Model Colaboratory Template¶

### Book Example: Economic equilibria¶

### Book Example: Transshipment problem¶

### Book Example: diet¶

### Book Example: prod¶

### Book Example: steel¶

### Book Example: transp¶

### CP-style scheduling model with the *numberof* operator, solved by a MIP solver¶

*numberof*operator, solved with a MIP solver. New MIP solver drivers based on the [MP library](https://amplmp.readthedocs.io/) enable CP-style modeling.

### Capacity expansion of power generation¶

### Diet lecture¶

### Diet model with Google Sheets¶

### Efficient Frontier with Google Sheets¶

### Financial Portfolio Optimization with amplpy¶

### Google Hashcode 2022¶

### Hospitals-Residents MIP¶

### Jupyter Notebook Integration¶

### Largest small polygon¶

### Multicommodity transportation problem¶

### N-Queens¶

### Network design with redundancy¶

### Nonlinear transportation model¶

### Nonlinear transportation problem example¶

### Optimization Methods in Finance: Chapter 3¶

### Pattern Enumeration¶

### Pattern Generation¶

### Pricing and target-market¶

### Production model¶

### Quick Start using Pandas dataframes¶

### Quick Start using lists and dictionaries¶

### Roll Cutting - Revision 1 & 2¶

### Simple sudoku solver using logical constraints (with GUI)¶

*alldiff*operator and as a MIP. Note that the CP formulation is more natural but it needs a solver supporting logical constraints or a MIP solver with automatic reformulation support (see [here](https://amplmp.readthedocs.io/) for more information).

### Solving a nonogram puzzle¶

**nonogram.mod**,

**nonogram.dat**and

**nonogram.run**.