# 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:

BTW: you can even ask ChatGPT to write models for you! If it makes mistakes you can ask for help in our new Discourse Forum!

## Contents¶

- Getting Started
- Modules
- Highlights
- AMPL Bin Packing Problem with GCG
- AMPL Capacitated p-Median Problem with GCG
- AMPL Christmas Model created by ChatGPT
- AMPL Model Colaboratory Template
- Logistic Regression with amplpy
- N-Queens
- Optimize your Christmas Tree to Global Optimality
- Quick Start using Pandas dataframes
- Quick Start using lists and dictionaries
- Robust Linear Programming with Ellipsoidal Uncertainty
- Simple sudoku solver using logical constraints (with GUI)

- Lectures
- Authors
- Christian Valente (4 notebooks)
- Filipe Brandão (15 notebooks)
- Gleb Belov (6 notebooks)
- Gyorgy Matyasfalvi (9 notebooks)
- Juan Jesús Losada del Olmo (1 notebook)
- Jurgen Lentz (2 notebooks)
- Marcos Dominguez Velad (17 notebooks)
- Mikhail (1 notebook)
- Nicolau Santos (3 notebooks)
- Sarah Wells (1 notebook)
- Yimin Wang (2 notebooks)
- Contribution Guide

## Notebooks¶

### AMPL - solve multiple models in parallel¶

Description: Solve multiple AMPL models in parallel in Python with amplpy and the multiprocessing modules.

Author: Nicolau Santos (3 notebooks) <nfbvs@ampl.com>

### AMPL - spreadsheet handling with amplxl¶

Description: Basic example of reading/writing data into/from a .xlsx spreadsheet with amplxl

Author: Nicolau Santos (3 notebooks) <nfbvs@ampl.com>

### AMPL Bin Packing Problem with GCG¶

Description: Dantzig-Wolfe decomposition for Bin Packing Problem with GCG

### AMPL Capacitated p-Median Problem with GCG¶

Description: Dantzig-Wolfe decomposition for Capacitated p-Median Problem with GCG

### AMPL Christmas Model created by ChatGPT¶

Description: Christmas model generated by ChatGPT

### AMPL Model Colaboratory Template¶

Description: Basic notebook template for the AMPL Colab repository

### Book Example: Economic equilibria¶

Description: economic model using complementarity conditions from Chapter 19 AMPL book

### Book Example: Transshipment problem¶

Description: book example with general transshipment model (net1.mod)

### Book Example: diet¶

Description: book example autogenerated using diet.mod, diet.dat, and diet.run

### Book Example: prod¶

Description: book example autogenerated using prod.mod, prod.dat, and prod.run

Author: N/A

### Book Example: steel¶

Description: book example autogenerated using steel.mod, steel.dat, and steel.run

Author: N/A

### Book Example: transp¶

Description: book example autogenerated using transp.mod, transp.dat, and transp.run

Author: N/A

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

Description: Scheduling model with the Constraint Programming

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

Author: Gleb Belov (6 notebooks) <gleb@ampl.com>

### Capacity expansion of power generation¶

Description: Models the extensive form of a deterministic multi-stage capacity expansion problem. In this model we can have multiple resources of the same type which have identical properties. The model can be further developed into a stochastic one.

### Diet lecture¶

Description: Diet case study

Tags: ampl-only, ampl-lecture

### Diet model with Google Sheets¶

Description: Diet model using Google Sheets

### Dual-Donor Organ Exchange problem¶

Description: Most transplants from living donors require only one donor for each procedure. There are, however, exceptions, including dual-graft liver transplantation, bilateral living-donor lobar lung transplantation, and simultaneous liver-kidney transplantation. For each of these procedures, grafts from two compatible living donors are transplanted. As such, these procedures are more involved from an organizational perspective than those with only one donor. Unfortunately, one or both of the donors can often be biologically incompatible with the intended recipient, precluding the transplantation.

Author: Mikhail (1 notebook) <mail@solverytic.com>

### Dynamic routing example¶

Description: Example of interactive optimization with GUI using AMPL and Google Maps

### Efficient Frontier with Google Sheets¶

Description: Efficient Frontier example using Google Sheets

### Employee Scheduling Optimization¶

Description: Employee scheduling model from the Analytical Decision Modeling course at the Arizona State University.

### Financial Portfolio Optimization with amplpy¶

Description: Financial Portfolio Optimization with amplpy and amplpyfinance

### Google Hashcode 2022¶

Description: Google Hashcode 2022 Practice Problem

### Hospitals-Residents MIP¶

Description: hospitals-residents problem with ties problem solved with ampl and highs

### Hydrothermal Scheduling Problem with Conic Programming¶

Description: Hydrothermal Scheduling Problem using Second-Order Cones

Tags: amplpy, conic, second-order-cone, quadratic-cone, nonlinear-programming, scheduling, engineering, power-generation, geothermal-energy, hydropower

Author: Gleb Belov (6 notebooks) <gleb@ampl.com>

### Introduction to Linear and Integer Programming¶

Description: Basic introduction to linear programming and AMPL via a lemonade stand example

### Introduction to Mathematical Optimization¶

Description: Basic introduction to optimization and AMPL via unconstrained optimization

### Jupyter Notebook Integration¶

Description: Jupyter Notebook Integration with amplpy

### Largest small polygon¶

Description: lecture about models for the Largest Small Polygon Problem

### Logistic Regression with amplpy¶

Description: Logistic regression with amplpy using exponential cones

### Multicommodity transportation problem¶

Description: Multicommodity transportation model with binary variables

### N-Queens¶

Description: How can N queens be placed on an NxN chessboard so that no two of them attack each other?

Author: Gleb Belov (6 notebooks) <gleb@ampl.com>

### NFL Team Rating¶

Description: NFL Team Rating problem from the Analytical Decision Modeling course at the Arizona State University.

### Network Linear Programs¶

Description: Basic introduction to network linear programms and AMPL via max flow and shortest path problems

### Network design with redundancy¶

Description: Design of an electricity transportation network provides enough redundancy, so that a break of one component does not prevent any user from receiving electricity. The approach also works for similar distribution networks and can potentially be used in the design of military logistic networks.

Tags: electric-grid, military

### Nonlinear transportation model¶

Description: book example autogenerated using nltransd.mod, nltrans.dat, and nltrans.run

### Nonlinear transportation problem example¶

Description: book example autogenerated using nltransd.mod, nltrans.dat, and nltrans.run

### Optimization Methods in Finance: Chapter 3¶

Description: Optimization Methods in Finance: Bond Dedication Problem.

### Optimize your Christmas Tree to Global Optimality¶

Description: Optimize the placement of ornaments on a christmas tree.

### Pattern Enumeration¶

Description: Pattern enumeration example with amplpy

### Pattern Generation¶

Description: Pattern generation example with amplpy

### Plot feasible region¶

Description: Plot the feasible region and optimal solution for a simple two variable model using AMPL’s Python API.

### Pricing and target-market¶

Description: Formulate a pricing optimization and target-market problem as a MILP.

### Production Model¶

Description: Basic introduction to AMPL’s indexed entities and the Pygwalker Python package via a lemonade stand example

### Production model¶

Description: generic model for production problem

### Quick Start using Pandas dataframes¶

Description: Quick Start using Pandas dataframes to load and retrieve data

### Quick Start using lists and dictionaries¶

Description: Quick Start using lists and dictionaries to load and retrieve data

### Robust Linear Programming with Ellipsoidal Uncertainty¶

Description: AMPL Modeling Tips #6: Robust Linear Programming

Author: Gleb Belov (6 notebooks) <gleb@ampl.com>

### Roll Cutting - Revision 1 & 2¶

Description: Pattern tradeoff example with amplpy

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

Description: Simple sudoku model with two formulations: as a Constraint Programming problem using the

*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).### Solution check: discontinuous objective function¶

Description: Pathological examples to illustrate MP solution checker and settings

Author: Gleb Belov (6 notebooks) <gleb@ampl.com>

### Solving a nonogram puzzle¶

Description: Model for solving nonogram puzzles autogenerated using

**nonogram.mod**,**nonogram.dat**and**nonogram.run**.### Solving simple stochastic optimization problems with AMPL¶

Description: Examples of the Sample Average Approximation method and risk measures in AMPL

Author: Nicolau Santos (3 notebooks) <nfbvs@ampl.com>

### Steel industry problem¶

Description: model for steel production problem

### Stochastic Capacitated Facility Location Problem¶

Description: This notebook illustrates modeling a stochastic facility location problem using a mixed-integer programming approach. Facility location decisions are pivotal, typically requiring substantial investments that have far-reaching social, economic, and environmental consequences.

### Sudoku Generator¶

Description: Generate Sudoku boards with unique solution via iterative method and mip formulation.

### Transportation problem¶

Description: an AMPL model for the transportation problem

Tags: ampl-only, ampl-lecture

### Travelling Salesman Problem with subtour elimination¶

Description: this example shows how to solve a TSP by eliminating subtours using amplpy and ampls

### Unit Commitment for Electrical Power Generation¶

Description: This notebook illustrates the power generation problem using AMPL. The original version featured the Gurobi solver. By default, this notebook uses the HiGHS and CBC solvers.

### VPSolver: Cutting & Packing Problems¶

Description: Solving cutting & packing problems using arc-flow formulations

### amplpy setup & Quick Start¶

Description: amplpy setup and quick start