# Supply Chain Process Optimization Using Linear Programming

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

Article originally published on Medium.

Objective
Understand the analogies between supply chain optimization problems and the framework of linear programming

Introduction
A supply chain is a goal-oriented network of processes and stock points used to deliver goods and services to customers.

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

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

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)

## I. Introduction to Linear Programming (LP)

Objective
Supply Chain Analytics is used to help operations to make informed and data-driven decisions to improve the service level 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 with external and internal constraints.

I have shared in previous articles some case studies of linear programming for process optimization

In this article, I will explain the methodology I used to solve these operational issues using Linear Programing using a real operational case study.

## II. Requirements & Formulation of LP Problems

### Requirements

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

### Formulation

• 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

## III. Methodology

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

My objective is 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.

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

• Pallet transfer inside the warehouse
• Put away: put pallets on racks
• Replenishment: transfer from storage locations to ground locations Picking Location (Level 0) / Storage Locations (Level 1 to 4) — Image by Author

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

The demand is fluctuating 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 at a price of 225 euros/week
• Type 2Short team lease trucks: these trucks can be leased for one week at a price of 395 euros/week
• Type 3Shared trucks: long-term lease trucks shared with another warehouse only available WEEK 2, WEEK 4 and WEEK 6 at a price of 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 the logistic companies.

💡 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

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: number of type 1 trucks
t: number of type 2 trucks rented for the week 1
t: number of type 2 trucks rented for the week 2
t: number of type 2 trucks rented for the week 3
t: number of type 2 trucks rented for the week 4
t: number of type 2 trucks rented for the week 5
t: number of type 2 trucks rented for the week 6
t: number of type 3 trucks
t: number of type 4 trucks

💡 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 constraints are 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 in the equation
• Type 2 trucks can be rented: include t in the equation
• Type 3 trucks cannot be rented: do not include t in the equation
• Type 4 trucks cannot be rented: do not include t in the equation

The final equation after translation of the conditions is: t + t >= 5

📉
Demand constraints
(Week 1): t + t >= 5
(Week 2): t + t + t >= 7
(Week 3): t + t >= 3
(Week 4): t + t + t + t >= 5
(Week 5): t + t + t >= 10
(Week 6): t + t + t + t >= 7

We have a limited supply of Type 4 trucksRental price per type
(Type 4): t<=2

💡 Avoid conflicting conditions
At this stage, you need to ensure that the conditions do not conflict.

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

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

💡 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*225*6 + Sum(t[i]*395, i=2...7) + t*205*3 + t*200*3

Given the constraints
(Week 1): t + t >= 5
(Week 2): t + t + t >= 7
(Week 3): t + t >= 3
(Week 4): t + t + t + t >= 5
(Week 5): t + t + t >= 10
(Week 6): t + t + t + t >= 7
(Type 4): t<=2

💡 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 pretty straightforward using the library PuLP: a modelling framework for Linear (LP) and Integer Programming (IP) problems written in Python.

💡 The syntax of PuLP
Have a look at the documentation of PuLP for additional information. If you are stuck, feel free to ask questions in the comment area, we’ll try our best to help.

## Conclusion

The most important part is the problem statement. Make sure to gather all the information needed and double-check with operational teams that your understanding of the problem is right.

💡 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.

# III. 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 the approach and the assumptions you took.

### Deploy the tool on the cloud

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