Solving Linear Programming Problems (LPPs) Using PuLP and Python

Dr. Soumen Atta, Ph.D.
The Startup
Published in
4 min readNov 29, 2020

--

In this tutorial, we will learn how to solve linear programming problems (LPPs) using PuLP and Python. At first, we learn how to install PuLP. If PuLP is already not installed in your system, then you can use the following commands to install it.

For Ubuntu, run the following command in the terminal:

pip install pulp
Installing PuLP in Ubuntu
Installing PuLP in Ubuntu

For Windows, run the following command in the command prompt (make sure that pip in your path):

pip install pulp

Example problem
Consider a chocolate manufacturing company that produces only two types of chocolates — A and B. Both the chocolates require Milk and Choco only. To manufacture each unit of A and B, the following quantities are required:

Each unit of A requires 1 unit of Milk and 3 units of Choco
Each unit of B requires 1 unit of Milk and 2 units of Choco

The company kitchen has a total of 5 units of Milk and 12 units of Choco. On each sale, the company makes a profit of

Rs 6 per unit A sold,
Rs 5 per unit B sold.

--

--

Dr. Soumen Atta, Ph.D.
The Startup

I am a Postdoctoral Researcher at the Faculty of IT, University of Jyväskylä, Finland. You can find more about me on my homepage: https://www.soumenatta.com/