TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Supply Chain Process Optimization Using Linear Programming

Understand how linear programming can be the most powerful tool for a supply chain continuous improvement engineer.

Samir Saci
TDS Archive
Published in
9 min readJul 22, 2022

--

A visual representation of supply chain process optimization, featuring two red forklifts unloading a large red shipping container marked ‘TEX’ on a warehouse floor. The title reads ‘Supply Chain Process Optimization,’ with a subtitle describing how linear programming can be a powerful tool for a supply chain continuous improvement engineer. The image emphasizes the importance of optimizing warehouse and logistics operations in the supply chain.
(Image by Author)

A supply chain is a goal-oriented network of processes and stock points that delivers goods and services to customers.

After more than six years of experience designing and optimising Supply Chain processes, I noticed a pattern in the types of problems I was asked to solve.

How can you use data science to optimize these processes?

They follow a similar structure, aiming to maximize (or minimize) an objective function by influencing key parameters while respecting some constraints.

Do you need examples? You’re in the right place.

In this article, we will try to understand how linear programming fits this type of problem using several real-life examples that can be implemented quickly.

SUMMARY
I. Introduction to Linear Programming
Mathematical techniques used to get an optimum solution to a problem
II. Requirements & Formulation of LP Problems
Requirements & Formulation
Conditions to apply the Linear Programming methodology
Implementation using Python
Python libraries for LP implementation
III. Methodology
Step 1: Understand the problem
Step 2: Build the model
Step 3: Solving using Python
Conclusion
III. Implement these solutions
Provide Insights
Deploy on the cloud
Share the tool using executable files (.exe)

Introduction to Linear Programming (LP)

How can you optimize Supply Chain Processes with Python?

Supply Chain Analytics helps operations make data-driven decisions to improve service and reduce costs.

In operations research, linear programming (LP) is one of the mathematical techniques used to get an optimal solution to a given operational problem, considering resource scarcity and external and internal constraints.

In previous articles, I have shared some case studies of linear programming for process optimization.

I will explain my methodology to solve these operational issues using linear programming and a genuine operational case study.

Requirements & Formulation of LP Problems

What do we need to state a problem?

Requirements of Linear Programming Problems

To apply Linear Programming for process optimization, these requirements have to be met:

  1. Problem statement: define the objective in clear mathematical terms
  2. Decision variables: quantitative input variables impacting the objective
  3. Constraints: quantitative and measurable conditions
  4. Objective function: the relationship between the objective and the input variables has to be linear

In the model, what do you need?

Formulation of Linear Programming Models

  • Decisions variables: variables that can be numeric or boolean
  • Objective function: a linear function of the variables that we want to minimize or maximize
  • Formulate the constraints: a set of equations combining the different decision variables

Let’s use a concrete example to understand.

If you prefer to watch, have a look at the video version of this article

Methodology using Linear Programming

In the case study presented below, we will introduce the methodology using the problem of warehouse fleet management.

I aim to give you a detailed recipe that can be replicated for other problems.

Step 1: Understand the problem

The operations manager of a multi-user warehouse is requesting your support to optimize the management of its fleet of reach trucks.

Two red forklifts unloading a large red shipping container labeled ‘TEX’ in a warehouse yard. The forklifts are used for material handling, specifically for tasks like loading and unloading trucks, pallet transfers, and putting away items on racks. This image illustrates the concept of warehouse fleet management and the role of reach trucks in optimizing supply chain operations.
Example of reach trucks— Image by Author

Reach trucks are material handling equipment used in warehouses for multiple applications such as:

  • Truck or container Loading/Unloading
  • Pallet transfer inside the warehouse
  • Put away: put pallets on racks
  • Replenishment: transfer from storage locations to ground locations
A side view of warehouse racking, displaying five levels of storage locations. The bottom level (Level 0) is designated for picking, while Levels 1 through 4 are for storage. The image highlights the layout of pallets stored at various heights in the warehouse, emphasizing the need for efficient reach truck management to handle replenishment and put-away operations.
Picking Location (Level 0) / Storage Locations (Level 1 to 4) — Image by Author

Demand

After aligning with the different team leaders, he compiled demand forecasts for the next five weeks.

A bar chart showing fluctuating demand for reach trucks over five weeks. The chart depicts how the demand varies, with some weeks requiring more trucks than others. This visualization is part of a case study on optimizing warehouse fleet management, particularly for leasing reach trucks based on forecasted demand.
Demand for reach trucks — Image by Author

The demand fluctuates from one week to another.

Because of budget constraints, you cannot rent 10 trucks for six weeks.

Supply

This type of equipment is usually leased to have more flexibility. You have the choice between several types of trucks:

  • Type 1Long-term lease trucks: These trucks need to be leased for six weeks for 225 euros/week
  • Type 2Short team lease trucks: These trucks can be leased for one week for 395 euros/week
  • Type 3Shared trucks: Long-term lease trucks shared with another warehouse are only available WEEK 2, WEEK 4 and WEEK 6 for 205 euros/week
  • Type 4Special price: These trucks can be leased for the last three weeks at a discounted price of 200 euros/week with a maximum order quantity of 2 trucks

These conditions are realistic. Indeed, leasing companies are adapting their offers to reduce the costs for logistics companies.

💡 TIP: You can’t solve a problem you don’t understand.
At this stage make sure that you have gathered all the information needed to frame the problem.
After data collection and processing, spend some time presenting your vision to the key stakeholders. It’s a good practice to get confirmation that your understanding is correct.

Step 2: Build the model

Problem Statement
The operations manager asked for your support to answer the following question.

How many reach trucks should I rent, for each type, to cover the needs for the next six weeks?

Decision variables
They will be integers because you can only rent full trucks.

Reach trucks types
types = [Type 1, Type 2, Type 3, Type 4]
Decision variables (integer)
t[1]: number of type 1 trucks
t[2]: number of type 2 trucks rented for the week 1
t[3]: number of type 2 trucks rented for the week 2
t[4]: number of type 2 trucks rented for the week 3
t[5]: number of type 2 trucks rented for the week 4
t[6]: number of type 2 trucks rented for the week 5
t[7]: number of type 2 trucks rented for the week 6
t[8]: number of type 3 trucks
t[9]: number of type 4 trucks

💡 TIP: You need to translate the conditions into mathematical equations
Constraints are not always straightforward, therefore you need to adapt them to fit with the framework of LP.
Because Type 2 trucks can be rented at any time we will need to create six variables for the six weeks.

Demand Constraints
The first constraint is related to the demand. Each week, you need to ensure that you have enough trucks.

Let me use the example of the first week to explain the process

  • We need 5 trucks at least
  • Type 1 trucks can be rented: include t[1] in the equation
  • Type 2 trucks can be rented: include t[2] in the equation
  • Type 3 trucks cannot be rented: do not include t[8] in the equation
  • Type 4 trucks cannot be rented: do not include t[9] in the equation

The final equation after translation of the conditions is: t[1] + t[2] >= 5

Demand constraints
(Week 1): t[1] + t[2] >= 5
(Week 2): t[1] + t[3] + t[8] >= 7
(Week 3): t[1] + t[4] >= 3
(Week 4): t[1] + t[5] + t[8] + t[9] >= 5
(Week 5): t[1] + t[6] + t[9] >= 10
(Week 6): t[1] + t[7] + t[8] + t[9] >= 7

Additional constraints
We have a limited supply of Type 4 trucks

Rental price per type
(Type 4): t[4]<=2

💡 TIP: avoid conflicting conditions
At this stage, you need to make sure that the conditions are not conflicting. If this happens, you

Objective Function
This is the total rental cost for the six weeks of operations, the sum of the number of reach trucks per type multiplied by the unit rental price.

Objective functions
(Type 1): P1 = t[1] * 225 * 6
(Type 2): P2 = Sum ( t[i] * 395, i = 2 ... 7)
(Type 3): P3 = t[8] * 205 * 3
(Type 4): P4 = t[9] * 200 * 3
(Objective): z = P1 + P2 + P3 + P4

💡 TIP: Check the linearity
If you want to use linear programming tools, you need to make sure that this function is linear.

Summarize the LP problem.

Minimize 
z =
t[1]*225*6 + Sum(t[i]*395, i=2...7) + t[8]*205*3 + t[9]*200*3
Given the constraints
(Week 1): t[1] + t[2] >= 5
(Week 2): t[1] + t[3] + t[8] >= 7
(Week 3): t[1] + t[4] >= 3
(Week 4): t[1] + t[5] + t[8] + t[9] >= 5
(Week 5): t[1] + t[6] + t[9] >= 10
(Week 6): t[1] + t[7] + t[8] + t[9] >= 7
(Type 4): t[4]<=2

💡 TIP: present the problem
Use this mathematical presentation of the problem to confirm with operational teams that you understood well their request.

Step 3: Solving using Python

The implementation is straightforward. It uses the PuLP library, a Python modelling framework for linear (LP) and Integer Programming (IP) problems.

You can find in this article a detailed example of the implementation

💡 TIP: syntax of PuLP
Have a look at the documention of PuLP for additional information.

Conclusion

The most important part is the problem statement.

Gather all the information needed and double-check with operational teams to ensure that your understanding of the problem is correct.

💡 TIP: Problem Complexity
You can add as many constraints as you want. However, it can happen that the problem cannot be solved because of conflicting constraints.

🏫 Discover 70+ case studies using data analytics for supply chain optimization 🚚 and business optimization 🏪 in this: Cheat Sheet

Next steps

What can you do with these models?

Share insights with operational teams.

Run the model locally on your computer and present the solutions to the teams, explaining your approach and assumptions.

Deploy the tool on the cloud.

Implement the solution in a web application and deploy it on the cloud. Other users can run it, change the parameters and update the data.

A dashboard interface for Sustainable Supply Chain Optimization, displaying charts related to production costs and environmental footprint. The pie chart shows production costs split between four sites in different countries (USA, India, Brazil), while the bar chart compares unit, variable, and fixed costs. The tool allows users to minimize costs and environmental impact in supply chain operations by adjusting parameters like water usage and energy consumption.
Sustainable Supply Chain Optimization App — [Link]
An interface for an ABC Analysis and Pareto Chart application. The left side explains the process of categorizing inventory based on transaction data, with items ranked by their importance. The right side shows an automated ABC classification chart that categorizes products into Class A, B, and C based on turnover and demand variability. The application helps prioritize high-value items in supply chain management.
ABC Analysis & Pareto Chart App — [Link]

Share the tools using an executable file (.exe)

You can embed the script in an executable file that will take the data from an Excel file. Thus, other colleagues can use your model without installing Python on their computers.

Find an example in this article.

Implement Performance KPIs

Measure the impact of your improvements on the overall performance of your distribution network.

About Me

Let’s connect on Linkedin and Twitter; I am a Supply Chain Engineer using data analytics to improve logistics operations and reduce costs.

For consulting or advice on analytics and sustainable supply chain transformation, feel free to contact me via Logigreen Consulting.

If you are interested in Data Analytics and Supply Chain, look at my website.

💌 New articles straight in your inbox for free: Newsletter
📘 Your complete guide for Supply Chain Analytics: Analytics Cheat Sheet

--

--

Samir Saci
Samir Saci

Written by Samir Saci

Top Supply Chain Analytics Writer — Case studies using Data Science for Supply Chain Sustainability 🌳 and Productivity: https://bit.ly/supply-chain-cheat

Responses (1)