amplpy#

AMPL - solve multiple models in parallel#

multiproc.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Solve multiple AMPL models in parallel in Python with amplpy and the multiprocessing modules.

AMPL Bin Packing Problem with GCG#

bpp.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Dantzig-Wolfe decomposition for Bin Packing Problem with GCG

AMPL Capacitated p-Median Problem with GCG#

cpmp.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Dantzig-Wolfe decomposition for Capacitated p-Median Problem with GCG

AMPL Christmas Model created by ChatGPT#

AMPL Development Tutorial 1/6 – Capacitated Facility Location Problem#

AMPL Development Tutorial 2/6 – Stochastic Capacitated Facility Location Problem#

AMPL Development Tutorial 3/6 – Benders Decomposition via AMPL scripting#

3_benders_stoch_floc.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: In this third installment of our six-part series, we continue our exploration by addressing the complexities introduced by the stochastic programming formulation presented in part two.

AMPL Development Tutorial 4/6 – Benders Decomposition via PYTHON scripting#

4_benders_in_python_stoch_floc.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: In this fourth installment of our six-part series, we advance our exploration by demonstrating how to adapt our AMPL script for use with AMPL’s Python API.

AMPL Development Tutorial 5/6 – Parallelizing Subproblem Solves in Benders Decomposition#

5_benders_parallel_stoch_floc.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: In the fifth installment of our six-part series, we delve deeper by showing how to evolve our Benders decomposition Python script from a serial execution to one that solves subproblems in parallel.

AMPL Development Tutorial 6/6 – Implementing Benders Decomposition with ampls#

6_benders_ampls_stoch_floc.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: This concluding notebook in our six-part series delves into enhancing the efficiency of our decomposition algorithm by utilizing AMPL Solver Libraries (ampls).

AMPL Model Colaboratory Template#

colab.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Basic notebook template for the AMPL Colab repository

Aircrew trainee scheduling with seniority constraints#

Balanced Task Assignment with Inverse Cost Scaling#

Bilevel Markets#

bilevel_markets.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: A notebook that presents a comprehensive mathematical formulation of strategic bidding in electricity markets using bilevel optimization and its equivalent single-level Mathematical Program with Equilibrium Constraints (MPEC) obtained through Karush-Kuhn-Tucker (KKT) transformation.

Bilevel Optimization Introduction#

bilevel_introduction.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: A notebook as a gentle introduction to Bilevel Optimization and how to reformulate to Single Level using KKT conditions and Complementarity using AMPLPy and MP with a simple Stackelberg model

Containers scheduling#

containers_scheduling.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Scheduling model for harbor operations. It is a problem with dependences between containers, which should be dispatch the fastest possible. We are using the MP solver interfaces to model a complex system using techniques from Constraint Programming, such as indicator constraints, and logical or and forall operators. After the model is written, a couple instances are presented and Highs/Gurobi MIP solvers are used to tackle the problem.

Debugging Model Infeasibility#

debug_infeas.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: This notebook offers a concise guide on troubleshooting model infeasibility using AMPL’s presolve feature and other language capabilities.

Demand prediction and Optimization with scikit-learn & Amplpy#

Diet and Other Input Models: Minimizing Costs#

diet_case_study.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Diet case study, Chapter 2 from the AMPL book adapted to Python

Diet model with Google Sheets#

Dynamic routing example#

Dynamic_routing_example.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Example of interactive optimization with GUI using AMPL and Google Maps
Tags: amplpy, gui

Efficient Frontier with Google Sheets#

efficient_frontier.ipynb Open In Colab
Description: Efficient Frontier example using Google Sheets

Employee Scheduling Optimization#

Employee_Scheduling.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Employee scheduling model from the Analytical Decision Modeling course at the Arizona State University.

Financial Portfolio Optimization with amplpy#

amplpyfinance_vs_amplpy.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Financial Portfolio Optimization with amplpy and amplpyfinance

Google Hashcode 2022#

Hospitals-Residents MIP#

hospitals_residents.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: hospitals-residents problem with ties problem solved with ampl and highs

Hydrothermal Scheduling Problem with Conic Programming#

Introduction to Linear and Integer Programming#

intro_to_linear_programming.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Basic introduction to linear programming and AMPL via a lemonade stand example

Introduction to Mathematical Optimization#

intro_to_optimization.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Basic introduction to optimization and AMPL via unconstrained optimization

Jupyter Notebook Integration#

magics.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Jupyter Notebook Integration with amplpy

Largest small polygon#

largest_small_polygon.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: lecture about models for the Largest Small Polygon Problem

Logistic Regression with amplpy#

Multi-Objective Knapsack Problem with AMPLPY#

knapsack.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: knapsack problem using multiple objectives, setting objective-specific options

N-Queens#

nqueens.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: How can N queens be placed on an NxN chessboard so that no two of them attack each other?

NFL Team Rating#

NFL_Team_Rating.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: NFL Team Rating problem from the Analytical Decision Modeling course at the Arizona State University.

Network Linear Programs#

network.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Basic introduction to network linear programms and AMPL via max flow and shortest path problems

Optimal Power Flow with AMPL and Python - Bus Injection Model (BIM)#

Optimal Power Flow with AMPL and Python - Bus Injection Model (BIM) with controllable-phase shifting transformers and tap-changing transformers#

Optimal Power Flow with AMPL and Python - DC Power Flow#

Optimal Power Flow with AMPL and Python - conventional Power Flow#

Optimal Power Flow with AMPL and Python - data management#

Optimization Methods in Finance: Chapter 3#

finance_opt_example_3_1.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Optimization Methods in Finance: Bond Dedication Problem.

Optimize your Christmas Tree to Global Optimality#

Optimizing Procurement and Sales Strategies for a Retail Chain with Supplier Payment Schemes#

Optimizing the number of staff in a chain of stores#

P-Median problem#

p_median.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: this notebook states the p-median problem with a simple example, and a MIP formulation in amplpy. The problem is parametrized with a class, so it is easier to sample and replicate experiments. A graphical solution is plotted.

Pattern Enumeration#

pattern_enumeration.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Pattern enumeration example with amplpy

Pattern Generation#

pattern_generation.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Pattern generation example with amplpy

Power System Optimization with Amplpower package#

ampl_power.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: this notebook uses amplpower package to solver opf problems

Predicting and Optimizing Avocado Sales with Python + Amplpy#

predict_avocado.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: In this notebook, we explore a real-world example of demand estimation and supply optimization using a Kaggle dataset on avocado sales. We start by training a machine learning model to estimate demand and then formulate and solve an optimization model in AMPL to maximize revenue while minimizing waste and transportation costs.

Pricing Optimization (Price Elasticity of Demand)#

Production Model: lemonade stand example#

production_model.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Basic introduction to AMPL’s indexed entities and the Pygwalker Python package via a lemonade stand example

Quick Start using Pandas dataframes#

pandasdiet.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Quick Start using Pandas dataframes to load and retrieve data

Quick Start using lists and dictionaries#

nativediet.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Quick Start using lists and dictionaries to load and retrieve data

Roll Cutting - Revision 1 & 2#

pattern_tradeoff.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Pattern tradeoff example with amplpy

Simple sudoku solver using logical constraints (with GUI)#

sudoku.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
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://mp.ampl.com/) for more information).

Solving simple stochastic optimization problems with AMPL#

newsvendor.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Examples of the Sample Average Approximation method and risk measures in AMPL

Sudoku Generator#

sudoku_gen.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Generate Sudoku boards with unique solution via iterative method and mip formulation.

Unit Commitment Problem with AMPL and Python - Power Grid Lib#

pglib_uc.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Generic notebook to solve Unit Commitment problems with AMPL and Python using the Power Grid Lib model and test instances.

Unit Commitment for Colombia’s Energy Market#

unit_commitment_colombia.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: Unit Commitment and Reserve Co-Optimization in the Colombian Market.

Unit Commitment for Electrical Power Generation#

unit_commitment.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
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.

Vehicle Routing Problem with Fair Profits and Time Windows (VRP-FPTW)#

vrp_fptw.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: This notebook implements and solves the Vehicle Routing Problem with Fair Profits and Time Windows (VRP-FPTW), a realistic and recent extension of the classical VRP problem.

amplpy setup & Quick Start#

quickstart.ipynb Open In Colab Open In Deepnote Open In Kaggle Open In Gradient Open In SageMaker Studio Lab
Description: amplpy setup and quick start