Learn how to improve supply chain resilience using Python. Understand lead time variability and its impact on inventory management strategies.

In competitive industries like retail, understanding lead time variability and its impact on inventory management strategies is critical to success.
With Python, you can simulate various scenarios and identify potential risks.
Why do we need to identify these risks?
Inventory managers develop replenishment policies to minimize stock levels, reduce ordering costs, and avoid store shortages.
They need to consider the demand distribution and the lead times to replenish stores.
What’s the problem? They assume that everything goes well.
They often assume a constant lead time based on targets fixed with suppliers and logistic teams.
In this article, we will understand how process variability can significantly impact these lead times and break the resilience of your supply chain.
SUMMARY
I. Understanding the impact of Lead Time Variability
1. Demand Variability
2. Importance of Safety Stock in Inventory Management
3. Safety Stock Calculation
II. Analyzing the Reality of Lead Times for Supply Chain Resilience
1. Target Lead Times and Cut-Off Times in Logistics Operations
2. Introducing Variability to Simulate Realistic Logistics Operations
III. Simulating Supply Chain Risks with Python for Better Resilience
1. Adding Variability to Lead Times for Realistic Simulation
2. Scenarios Simulation and Root-Cause Analysis
VI. Conclusion
1. Simulate these scenarios with a Digital Twin
"What if" scenarios impact on your overvall performance
2. Generative AI for Advanced Diagnostics
Smart Agent powered by GPT for monitoring and diagnostics
3. Product Segmentation for Retail using Python
Should you focus on all items of your portfolio?
Understanding the Impact of Lead Time Variability on Inventory Management with Python
As an Inventory Manager of an international fashion retail chain, you set replenishment rules in the ERP.
Demand Variability
You have visibility of the daily fulfilled demand for each store. In this example, we will assume that the demand follows a normal distribution.

Importance of Safety Stock in Inventory Management
You implemented a continuous review policy using Order Point, Order Quantity (s, Q).
If the level is below the minimum threshold s, called safety stock, you reorder Q pieces.
Safety Stock Calculation
The safety stock is necessary to cover the demand during the replenishment and ** compensate for the volatility** of the demand.

A key element here is the replenishment lead time. If it is underestimated, you can face stock-outs in stores.
For more information,
Analyzing the Reality of Lead Times for Supply Chain Resilience
The replenishment lead time is between the order creation and the store delivery.
Target Lead Times and Cut-Off Times in Logistics Operations
When you designed replenishment rules, you used target lead times provided by the logistic teams.
A complex succession of processes Their responsibility is to ensure optimal execution of the tasks from the order creation to the store delivery,

- Step 1: Replenishment orders are created in the ERP
- Step 2: Orders are transmitted to the Warehouse Management System
- Step 3: Orders are prepared and packed by warehouse teams
- Step 4: Transportation teams organize the transportation from the distribution centre to the stores
Cut-off TimesYou have a target lead time and a cut-off time for each step.

These cut-off times can greatly impact the total lead time (LT):
- Order Reception: If an order is received after 18:00:00, it cannot be prepared the day after (+24 hours in LT)
- Truck leaving: If an order is not packed before 19:00:00, it cannot be loaded the same day (+24 hours in LT)
- Arrival at the Airport: If your shipment arrives after 00:30:00, it misses the flight (+24 hours LT)
- Landing: If your flight lands after 20:00:00, you need to wait an extra day for customs clearance (+24 hours LT)
- Store Delivery: If your trucks arrive after 16:30:00, your shipments cannot be received by store teams (+24 hours LT)
💡 Cut-Off Time Definitions
- Order Reception, Truck Leaving and Store Delivery cut-off times are usually internal constraints that may be adapted if needed.
- The airport operations and customs fix arrival at the Airport and Landing Cut-off times.
Introducing Variability to Simulate Realistic Logistics Operations
In the example below, the different steps are smoothly coordinated, and cut-off times are respected because the targets are respected.
Let’s now introduce some variability around the targets to stick more to the reality of logistic operations.
💡 ApproachIn this simulation, we will focus on something other than the root cause of this variability as we want to simulate its impact.
We can improve this approach by using a digital twin to impact process-specific parameters to stick to the real processes.
If you prefer, you can watch the video version of this article
Simulating Supply Chain Risks with Python
Adding Variability to Lead Times for Realistic Simulation
For each process, we add some variability around the target to simulate the reality of operations.

In the example below, I have simulated variations around the lead time targets using normally distributed variables.
Below are the parameters used: Lead time (minutes), COV (%)
{'Transmission': [60, 0.4], 'Pickpack': [480, 0.2], 'Loading': [90, 0.05], 'Warehouse Airport': [180, 0.15], 'Flight': [720, 0.15], 'Custom Clearance': [120, 0.3], 'Truck Preparation': [45, 0.2], 'Airport Store': [240, 0.25]}
Scenarios Simulation and Root-Cause Analysis
For the normal scenario, the total lead time is 72.5 hours.
Let us now measure ** the gap between this ideal result and** 200 scenarios simulated with variability in the lead times.

Results are split into four categories:
- All cut-off times are respected: lead times are very close to 72.5 hours
- +24 h: 1 cut-off time missed
- +48 h: 2 cut-off times missed
💡 Cut-off times impactBecause of these 24-hour time windows between two cut-off times a two-hour delay in a process can be transformed into 24 hours at the delivery.
Root-Cause AnalysisWe are lucky that only 2 out of 5 cut-offs have been missed. Let us now deep dive into each leg of transportation to find the root causes.
Loading Lead Time

For 20 scenarios, we missed the cut-off time for loading (19:00:00) mainly because of delays during the pick and pack.
💡 Impact of the delay tolerance per processOrder transmission: It takes an average of 1 hour to transmit an order, but we have up to 3 hours before the cut-off time (300% of average).
Therefore, the probability of missing this cut-off time is very low.
Lead Time Take-off

We have the same 20 scenarios with large delays (24+ hours). Therefore, the transportation from the warehouse did not cause any late arrival at the airport.
💡 Focus on Warehouse OperationsWe can see that the performance of the first leg from the central warehouse to the airport is mainly impacted by the loading lead time.
The performance management process should be focused on
- Preparation capacity: How many orders can be prepared per day?
- Invoicing process: Make sure your parcels can be loaded as soon as they are packed.
Lead Time Custom Clearance

We have now scenarios with 48+ hours, and additional scenarios with 24+ hours. Because of delays due to the flight time several shipments arrived after the clearance cut-off.
End-To-End Analysis

In the last graph, we analyse the total delivery lead time:
- Above the red line: >96h of LT because of 3 cut-offs missed
- Above the orange line: >72h of LT because of 2 cut-offs missed
- Above the yellow line: >48h of LT because of 1 cut-off missed
- Above the green line: All the cut-offs have been respected
We can see in the red plot that the store delivery cut-off impacted several scenarios and added 24+ hours.
💡 Adapt your cut-off timesSuppose you have any delays only due to the last-mile delivery or your trucks arriving a few minutes after the delivery cut-off time.
In that case, you can discuss with store operations to adapt it or arrange morning deliveries.
Conclusion
In this example, we showed that target lead times are not guaranteed.
These scenarios with late deliveries disrupt the supply chain and drain the operational teams’ energy.
How could we simulate these scenarios for the whole distribution chain?
Simulate these scenarios with a Digital Twin
A digital twin is a digital replica of a physical object or system.
A Supply Chain digital twin is a computer model representing various components and processes involved in the supply chain, such as warehouses, transportation networks, and production facilities.

Instead of setting arbitrary process lead times that we generated using a normal distribution, you can simulate variability in actual process parameters.
- Preparation lead time: What would be the impact of a 20% reduction of your warehouse workforce?
- Transportation Lead Time: What would be the impact of having two drivers per truck?
- Shipping lead time: What would be the impact of a pre-invoicing process?
You can then translate Business or operational initiatives into parameters that will influence the behaviour of your model.
For each scenario, you can manipulate the parameter linked to the initiative and see how much your overall performance will decrease.
This digital twin can then be used to
-
Simulate volume growth or perform stress tests on your distribution network. Are we ready to absorb a 50% sales increase next Black Friday?
-
Evaluate several solutions designed by your continuous improvement team: What if we deliver from local warehouses close to the stores?
For more details,
What is a Supply Chain Digital Twin?
Have you heard about Generative AI?
Generative AI for Advanced Diagnostic
In November 2022, OpenAI released the first version of ChatGPT.
For supply chain analytics, generative AI has become an opportunity to improve the user experience.
![Supply Chain Control Tower Agent with LangChain SQL Agent [Article Link] - (Image by Author)](https://towardsdatascience.com/wp-content/uploads/2022/08/0uI4ef1hZyHWM-CaS.png)
In this article, I share my explorative journey of LLMs used to boost Supply Chain Analytics.

The Supply Chain Analyst" is ** a custom GPT agent designed to automate supply chain analytics tasks and interact with users** using natural language.
I have also shared a case study that I designed with LangChain, a smart agent connected to a TMS database that can answer operational questions.

You want to implement similar solutions?
More details in these two articles,
Create GPTs to Automate Supply Chain Analytics
Leveraging LLMs with LangChain for Supply Chain Analytics – A Control Tower Powered by GPT
Should you focus your attention on your whole product portfolio? Probably no.
Product Segmentation for Retail with Python
Monitoring shipments requires resources, energy, and time, which can become exponential during peak periods.
As you have limited resources, you should prioritize your focus based on the importance of the shipment.
How can you do that?
You want to ensure that essential items with high turnover do not face any stock-out.
Product segmentation refers to the activity of grouping products that have similar characteristics.

It will be our sales volume distribution, demand variability and delivery lead time.
- Focus on advanced monitoring for high-value products
- Automated simple rules for the other
For more information, check this article
About Me
Let’s connect on Linkedin and Twitter. I am a Supply Chain Engineer who uses 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