# 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

**used to deliver goods and**

**stock points****.**

**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

**while respecting some**

**key parameters****.**

**constraints**In this article, we will try to understand how** linear programming** fits this type of problem

**that can be implemented quickly.**

**using several real-life examples****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

**with external and internal**

**resource scarcity****.**

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

- Optimize Workforce Planning using Linear Programming with Python
- Supply Planning using Linear Programming with Python

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:

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

### Formulation

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

## 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:

- Truck or container Loading/Unloading
- Pallet transfer inside the warehouse
- Put away: put pallets on racks
- Replenishment: transfer from storage locations to ground locations

**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 1**: these trucks need to be leased for**Long-term lease trucks**at a price of**six weeks****225 euros/week**â€”**Type 2**: these trucks can be leased for one week at a price of**Short team lease trucks****395 euros/week**â€”**Type 3**trucks shared with another warehouse only available**Shared trucks: long-term lease**at a price of**WEEK 2, WEEK 4 and WEEK 6****205 euros/week**â€”**Type 4**: these trucks can be leased for the**Special price**at a discounted price of**last three weeks**with a**200 euros/week**of**maximum order quantity****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**

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]

**(integer)**

**Decision variables**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

**ðŸ’¡** T**ranslate 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
at least**5 trucks** : include t[1] in the equation**Type 1 trucks can be rented**: include t[2] in the equation**Type 2 trucks can be rented**: do not include t[8] in the equation**Type 3 trucks cannot be rented**: do not include t[9] in the equation**Type 4 trucks cannot be rented**

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

**ðŸ’¡ **A**void 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[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

**ðŸ’¡ 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****t[1]*225*6 + Sum(t[i]*395, i=2...7) + t[8]*205*3 + t[9]*200*3**

**z =**

**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

**ðŸ’¡ **P**resent 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.

You can find in this article a detailed example of implementation

**ðŸ’¡ **The s**yntax 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.

Find an example of a Streamlit web application deployed on the cloud

### 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

**on their computers.**

**without installing python**Find an example in this article