Mathematical Programming- Jupyter Notebooks


This week's notebooks focus on the use of PuLP - a Python-based mathematical programming framework. As we will not be going into detail regarding the mechanics of the algorithms used to solve mathematical programs in this module, PuLP and Solver are the only means that we will have at our disposal to solve the problems that we encounter.

Notebook 4.1 - Introduction to PuLP

In this notebook we are going to introduce a Python package called pulp (PuLP), which we can use to represent and solve optimization problems. We will be starting with the simple two-variable model that we discussed in Part 3 of this session

Notebook 4.2 - Solving the transportation model using PuLP (explicit version)

We are now going to demonstrate the use of PuLP with a slightly larger problem. For this notebook, we will be considering the explicit transportation model formulation that we discussed in Part 2 of our session.

Notebook 4.3 - Solving the transportation model using PuLP (symbolic version)

By now we have established that explicit models are not at all practical, and always good to avoid as much as possible - whether we are formulating a model using pen and paper, or with a modeling framework. This notebook demonstrates how we can implement a symbolic model using PuLP.

Notebook 4.4 - Solving Minimum Cost Flow (Transhipment) Problems using PuLP

We can now try to model a more complex problem - in this notebook we will be looking at the symbolic version of the Transhipment or Minimum Cost Flow Problem, building on top the formulation that we developed in the previous notebook.

Notebook 4.5 - Solving Minimum Cost Flow (Transhipment) Problems using NetworkX and OR-Tools

This notebook introduces two further approaches that we could use to solve the MCF model - the first involves NetworkX (which we know how to use already), while the second uses Google’s OR Tools - which has an MCF-specific solver which allows us to model problem instances without having to also build a new formulation.

Notebook 4.6 - Shortest paths using PuLP

As we discussed in the lecture, we can repurpose our MCF formulation to obtain the shortest paths in a network. This notebook demonstrates how.

Notebook 4.7 - The Knapsack Problem

We have now covered all the PuLP modeling features that we are going to need for this module. This notebook presents an implementation of our knapsack model.

Notebook 4.8 - The Covering Problem

And the final notebook for this series focuses on the covering problem. We also show how to obtain the values of specific decision variables.

Running the notebooks

You can download a zip file containing all the notebooks that we covered in this session from the link below:

Download notebooks

Next