Mathematical Programming- Jupyter Notebooks

This week's notebooks focus on using 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.
  • Introduction to PuLP: In this notebook, we 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

  • The Transportation Problem (Explicit): We will now demonstrate the use of PuLP with a more significant problem. For this notebook, we will consider the explicit transportation model formulation discussed in Part 2 of our session.

  • The Transportation Problem (Symbolic): By now, we have established that explicit models are not practical and always sensible 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.

  • Minimum Cost Flow (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 of the formulation we developed in the previous notebook.

  • Minimum Cost Flow (Using 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 also having to build a new formulation.

  • Shortest Paths using PuLP: As discussed during the lecture, we can repurpose our MCF formulation to obtain the shortest paths in a network. This notebook demonstrates how to do this.

  • The Knapsack Problem: We have now covered all the PuLP modeling features we will need for this module. This notebook presents an implementation of our knapsack model.

  • 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