Supply Chain Optimization with Python

Find the optimal locations of your manufacturing facilities to meet your customers’ demands and reduce production costs

Samir Saci
Towards Data Science

--

Supply Chain Optimization with Python
Supply Chain Network Optimization Problem — (Image by Author)

Supply chain optimization makes the best use of data analytics to find an optimal combination of factories and distribution centres to match supply and demand.

Because of the current surge in shipping costs, companies start to challenge their current footprint to adapt to the post-covid “New Normal”.

In this article, we will present a simple methodology using Linear Programming for Supply Chain Optimization considering

  • Fixed production costs of your facilities ($/Month)
  • Variable production costs per unit produced ($/Unit)
  • Shipping costs ($)
  • Customer’s demand (Units)

Should we keep outsourcing with shipping costs that have tripled in the last 12 months?

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

Summary
I. How do you design a supply chain network with Python?
1. Problem Statement
II. Results
1. Scenario 1: Initial Scenario
2. Scenario 2: Outsourcing to low costs regions
3. Scenario 3: surging shipping costs due to container shortage
III. Build your Model
1. Declare your variables, parameters and model
2. Define the objective and add constraints
3. Solve your model and analyze the results
IV. Conclusion
1. Generative AI: GPT x Supply Chain Optimization
2. Implement Sustainable Sourcing
3. Go Beyond

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

I. How do you design a supply chain network with Python?

Problem Statement

As the Head of Supply Chain Management of an international manufacturing company, you want to redefine the Supply Chain Network for the next 5 years

You must consider the recent increase in shipping costs and the forecasts of customers’ demand.

Supply Chain Network Optimization
Map of your Supply Chain Network — (Image by Author)

Your Supply Chain Network

  • 5 markets in Brazil, USA, India, Japan, Germany
  • 2 types of manufacturing facilities: low-capacity and high-capacity sites
  • Shipping costs ($/container)
  • Customer’s demand (Units/year)

Manufacturing Facility Fixed Costs

  • Capital Expenditure for the Equipment (Machines, Storage, ..)
  • Utilities (Electricity, Water, ..)
  • Factory management, administrative staff
  • Space Rental

These costs depend on the country and the type of plant.

Manufacturing Site Fixed Costs — (Image by Author)

Production Variable Costs

  • Production lines operators
  • Raw materials
Manufacturing Site Fixed Costs — (Image by Author)

For instance, the variable cost of a unit produced in Germany is 13$/Unit.

Shipping Variable Costs

  • Cost per container ($/Container)
  • Assumption: 1 container can contain 1000 units
Sea Freight Shipping Costs ($/Container) — (Image by Author)

For instance, if you want to ship a container from Germany to Japan it will cost you 1,231 ($/Container).

Manufacturing Capacity by Site

Manufacturing Site Capacity — (Image by Author)

For instance, a high-capacity factory in Brazil can produce 1,500,000 (Units/month).

Customers' demand per market

Manufacturing Site Capacity — (Image by Author)

💡 Follow me on Medium for more articles related to 🏭 Supply Chain Analytics, 🌳 Sustainability and 🕜 Productivity.

You can find the full code in this Github repository: Link
My portfolio with other projects: Samir Saci

II. Results

Let us try three scenarios

  • Scenario 1: initial parameters
  • Scenario 2: we increase the production capacity of India (x2)
  • Scenario 3: surging shipping costs due to container shortage

Scenario 1: Initial Scenario

  • Brazil plant is producing for the local market and the USA
Facilities: 1 high capacity plant
('Brazil','Brazil') = 145,000 (Units/Month)
('Brazil','USA') = 1,250,000 (Units/Month)
  • India plants produce for all countries except Brazil
Facilities: 1 high capacity plant and 1 low capacity plant
('India','Germany') = 90,000 (Units/Month)
('India','India') = 160,000 (Units/Month)
('India','Japan') = 200,000 (Units/Month)
('India','USA') = 1,550,000 (Units/Month)
  • Japan needs to produce locally because of the limited capacity of India
Facilities: 1 high capacity plant
('Japan','Japan') = 1,500,000 (Units/Month)
  • Final Costs
Total Costs = 62,038,000 ($/Month)

Scenario 2: Outsourcing to low costs regions

What if we double the size of high-capacity plants in India?

Let us try to double the size of the India High Capacity plant, assuming that it will double the fixed costs.

  • Brazil plant is still producing for the local market and the USA
Facilities: 1 high capacity plant
('Brazil','Brazil') = 145,000 (Units/Month)
('Brazil','USA') = 1,250,000 (Units/Month)
  • India plants produce for all countries except Brazil
Facilities: 2 high capacity and 1 low capacity plants
('India','Germany') = 90,000 (Units/Month)
('India','India') = 160,000 (Units/Month)
('India','Japan') = 1,700,000 (Units/Month)
('India','USA') = 1,550,000 (Units/Month)
  • Japan does not produce locally anymore.

Final Costs

-19.4(%) vs. Scenario 1
Total Costs = 51,352,000 ($/Month)

Scenario 3: surging shipping costs due to container shortage

What if we have container costs multiplied by 5?

  • Brazil is producing for the local market only
Facilities: 1 low capacity plant
('Brazil','Brazil') = 145,000 (Units/Month)
  • The USA started to produce for the local market, and Japan
Facilities: 1 high capacity plant
('USA','Japan') = 200,000 (Units/Month)
('USA','USA') = 1,300,000 (Units/Month)
  • India closed its low-capacity factory
Facilities: 1 high capacity plant
('India','Germany') = 90,000 (Units/Month)
('India','India') = 160,000 (Units/Month)
('India','USA') = 1,500,000 (Units/Month)
  • Japan starts to produce for its local market
Facilities: 1 high capacity plant
('Japan','Japan') = 1,500,000 (Units/Month)

Because of their limited production capacity, Japan and the USA still rely on the Indian plant.

Final Costs

Total Costs = 92,981,000 ($/Month)

Do you want to try it yourself?

This model has been implemented in a web application,

Sustainable Supply Chain Optimization [Link]

👇 Access it here,

💡 Follow me on Medium for more articles related to 🏭 Supply Chain Analytics, 🌳 Sustainability and 🕜 Productivity.

III. Build your Model

We will be using the PuLP library of Python.

PuLP is a modelling framework for Linear (LP) and Integer Programming (IP) problems written in Python and maintained by COIN-OR Foundation (Computational Infrastructure for Operations Research).

1. Declare your variables, parameters and model

  • LpMinimize: Your objective is to minimize your costs
  • lowBound =0: You cannot have negative values of units produced

2. Define the objective and add constraints

3. Solve your model and analyze the results

IV. Conclusion

Generative AI: GPT x Supply Chain Optimization

Following the trend of Generative AI with large language models (LLMs), I shared to experiment with their usage with this prototype of LangChain Agent, powered by GPT and connected to a TMS.

Supply Chain Control Tower Agent with LangChain SQL Agent [Article Link] — (Image by Author)

This agent’s performance is impressive; it can answer operational questions autonomously by querying a database and extracting the results.

What if we create a super agent for Supply Chain Optimization?

The idea would be to equip a GPT agent with

  • Advanced optimization models written in Python in a core module: Supply Chain Optimization, Sustainable Sourcing, Supply Planning
  • Documentation, articles and context to understand how to use them
Example of Architecture [Test the GPT: Link]

Let us imagine agents that can interact with the users to get data, understand the constraints and run the solution to analyse results.

For more details,

Implement Sustainable Sourcing

A similar approach can be used to select your suppliers, considering an objective function that will minimize the CO2 footprint.

Assessment of Suppliers based on Environmental Factors — (Image by Author)

Sustainable sourcing is the process of integrating social, ethical and environmental performance factors when selecting suppliers.

This involves assessing and evaluating suppliers based on sustainability criteria, such as labour rights, health and safety, environmental impact, human rights, and more.

Use data analytics to automatically select the best supplier with a mix of economic and environmental constraints

This article will discover how to use data analytics to design an optimal Supply Chain Network to minimize costs and environmental impacts.

Go Beyond

This model allows you to simulate several scenarios influencing operational and commercial parameters.

  • What if the demand explodes in India?
  • What if we have to close our plant in Brazil?
  • What if we triple the production capacity in Japan?

Scenario 3 is an example of a shipping cost surge that could push companies to switch to a more local footprint with plants producing for their local market only.

This simple model can help you get the potential of linear optimization for supply chain network optimization. We can quickly improve this model by adding constraints

Feel free to share suggestions of additional constraints to improve the model and meet the business requirements in your industry.

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.

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

References

[1] Computational Infrastructure for Operations Research, Optimization with PuLP (Documentation), Link

--

--

Top Supply Chain Analytics Writer — Follow my journey using Data Science for Supply Chain Sustainability 🌳 and Productivity ⌛