Supply Planning using Linear Programming with Python

Where do you need to allocate your stock to meet customers demand and reduce your transportation costs?

Need Help?
Subscribed! Error
Supply Planning using Linear Programming with Python

Supply planning is the process of managing the inventory produced by manufacturing to fulfil the requirements created from the demand plan.

Your target is to balance supply and demand in a manner to ensure the best service level at the lowest cost.

In this article, we will present a simple methodology to use Integer Linear Programming to answer a complex Supply Planning Problem, considering:

  • Inbound Transportation Costs from the Plants to the Distribution Centers (DC) ($/Carton)
  • Outbound Transportation Costs from the DCs to the final customer ($/Carton)
  • Customer Demand (Carton)

πŸ’Œ New articles straight to your inbox for free: Newsletter

πŸ’‘
SUMMARY
I. Scenario
As a Supply Planning manager, you need to optimize inventory allocation to reduce transportation costs.
II. Build your Model
1. Declare your decision variables
What are you trying to decide?
2. Declare your objective function
What do you want to minimize?
3. Define the constraints
What are the limits on resources?
4. Solve the model and prepare the results
What are the results of your simulation?
III. Conclusion & Next Steps

Scenario


Problem Statement

As a Supply Planning manager at a mid-sized manufacturing company, you received feedback that distribution costs are too high.

Based on the analysis of the Transportation Manager, this is mainly due to the stock allocation rules.

In some cases, your customers are not shipped by the closest distribution centre, which impacts your freight costs.

Your Distribution Network

  • 2 plants producing products with infinite capacity
  • 2 distribution centres that receive finished goods from the two plants and deliver them to the final customers
  • 200 stores (delivery points)

To simplify the comprehension, let’s introduce some notations

Mathematical notations for the supply planning problem. Symbols represent the plants, distribution centers, and stores. Variables such as the quantity of products shipped and transportation c

Store Demand
What is the demand per store?

A detailed formula defining the demand of store 𝑝 p as 𝐷 𝑝 = demand (cases) of store 𝑝 D p ​ =demand (cases) of store p

You can download the dataset here.

Transportation Costs

Our main goal is to reduce the total transportation costs.

A formula describing the quantity 𝐼 𝑛 𝑝 I np ​ shipped from plant 𝑛 n to distribution center (DC) 𝑝 p, and quantity 𝑄 𝑛 𝑝 Q np ​ shipped from DC 𝑛 n to store 𝑝 p used for the supply

This includes inbound shipments (from the plants to the DCs) and outbound shipments (from the DCS to the stores).

A formula detailing the inbound and outbound transportation costs: 𝐼 𝐢 𝑛 𝑝 IC np ​ = inbound transportation cost between plant 𝑛 n and distribution center (DC) 𝑝 p. 𝑂 𝐢 𝑛 𝑝 OC np ​
Which Plant i and Distribution n should I chose to produce and deliver 100 units to Store p at the lowest cost?

Let us start with some visualisations.

A box plot comparing outbound transportation costs between two distribution centers (D1 and D2). D1 shows a lower median cost compared to D2, indicating that more products should be directed
Box Plot of Outbound Cost by Distribution Center β€” (Image by Author)
πŸ’‘
We can see on the box plot above that the D1 distribution of Unit Cost has a median value lower than D2. We can expect that the model will direct a major part of the flow through D1.

Build your Model

We will use the PuLP library in Python.

PuLP is a modelling framework for Linear (LP) and Integer Programming (IP) problems written in Python.

Declare your decision variables.

What are you trying to decide?

This image defines the variables we are using in the supply planning problem with Python. 𝐼 𝑛 , 𝑝 I n,p ​ : Quantity shipped from plant 𝑛 n to distribution center 𝑝 p. 𝑄 𝑛 , 𝑝 Q n,p ​

We want to decide the quantity of Inbound and Outbound transportation.

Declare your objective function

What do you want to minimise?

The formula shows the objective function of the linear programming model used for supply planning: 𝑇 𝐢 TC: Total transportation cost. The sum represents the cost of transporting goods from

We want to minimise the inbound and outbound transportation costs.

Define the constraints

What are the limits on resources that will determine your feasible region?

This image introduces the demand constraints for stores: The total quantity shipped to each store from the distribution centers must meet or exceed the store’s demand. This ensures that no st

Supply from DCs must meet per-store demand

This image describes the flow conservation constraint for this supply planning problem: The total quantity shipped from plants to a distribution center must equal the total quantity shipped f

We don’t build any stock in the X-Docking platforms.

Solve the model and prepare the results

It is time to run the optimisation.

Result

The model takes the cheapest route for Inbound by linking P2 to D1 (resp., P1 to D2).

As expected, more than 90% of outbound traffic passes through D1 to minimise outbound costs.

163 stores are delivered by D10 store is delivered by the two warehouses together
Do you want to implement it?
πŸ”—
You can find the full code in this Github repository: Link

Conclusion

πŸ’‘
If you have any question, feel free to here: Ask Your Question

This methodology allows you to perform large-scale optimization by implementing simple rules.

You will typically avoid having a store not delivered via the optimal route.

The model presented here can be easily improved by adding operational constraints:

  • Production Costs in Plants ($/Case)
  • Maximal X-Docking Capacity in Distribution Centres (Cartons)

But also by improving the cost structure by adding

  • Fixed/Variable Costs Structures in Distribution Centres ($)
  • Fixed + Variable Transportation Costs Structure y = (Ax +b)

The only limit you will find is the linearity of the constraints and the objective functions.

YOU CAN’T

  • Implement a non-linear production costs rule = f(Cases) to simulate the economies of scale during the production process.
  • Implement a non-linear (by range) transportation costs rule of total shipment size.

As soon as you try to touch the linearity of the objective function or the constraints, you leave the beautiful world of linear programming and face the pain of non-linear optimisation.

This is what we did in this article.

Procurement Process Optimization with Python | Samir Saci
Use non-linear programming to find the optimal ordering policy that minimizes capital, transportation and storage costs

About Me

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

If you’re looking for tailored consulting solutions to optimise your supply chain and meet sustainability goals, please contact me.

Need Help?