TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Optimize Workforce Planning using Linear Programming with Python.

What is the minimum number of workers you need to absorb your workload while ensuring employee retention?

Samir Saci
TDS Archive
Published in
9 min readApr 6, 2021

--

A diagram showing different aspects of the workforce planning problem, including time constraints, tasks planning, schedule constraints, workload forecasting, and workforce planning. The diagram outlines how these factors interact to optimize workforce management with Python.
Workforce Planning Problem using Linear Programming — (Image by Author)

In today’s dynamic business environment, optimising workforce planning is crucial to meet logistic operations' fluctuating demands.

Managers must minimize the number of temporary workers hired while ensuring employee retention and adhering to local regulations.

As data scientists, how can we support operations managing workforce planning?

A solution to this problem is Linear Programming with Python, which can help minimize costs while meeting all the constraints.

This article will explore the optimization of workforce planning using linear programming with Python and analyze the results.

Summary
I. Introduction
II. Defining the Workforce Planning Problem Statement
1. Planning of Workforce resources for Inbound Operations
2. How to Size the Workforce using volumes and productivity
3. Linear Programming Problem to find the optimal solution
III. Linear Programming with PuLP
1. Prepare the parameters of your linear programming model
2. Initialize the model, define the objective and add constraints
3. Solve your model and analyze the results
4. Go Beyond by Increase Operators' Productivity
IV. Conclusion
1. Generative AI: GPT for Supply Chain Optimization
2. Statistical Approach: What is the impact of other parameters?
3. Next Steps

Introduction

A significant challenge that Distribution Center (DC) managers face is the workload fluctuation during the week.

A multi-line graph showing four variables: Orders, Lines, SKUs, and Destinations over time, indicating fluctuating trends. Each line graph visualizes the varying demands in logistics operations that must be addressed by workforce planning in order to optimize staffing levels and meet operational requirements efficiently.
Daily figures representing a large E-Commerce DC workload — (Image by Author)

The example above shows the daily variation of critical indicators that drive a warehouse's workload (#Orders, #Lines, #SKU, …).

You can see a high variation from day to day that your teams need to absorb.

Can you size your workforce efficiently using analytics?

Considering that the average productivity of workers is stable, the only solution is to adapt your resources to meet the demands of each day.

🏫 Discover 70+ case studies using data analytics for supply chain optimization 🚚 and business decision-making 🏪 in this: Cheat Sheet

Defining the Workforce Planning Problem Statement

Planning of Workforce resources for Inbound Operations

You are working with the Inbound Manager of a Distribution Center operated by a Third Party Logistics Company (3PL) for a large retailer.

His team responsibilities include

  • Unload Pallets from the Trucks
  • Scan each pallet and record the received quantity in your Warehouse Management System (WMS)
  • Put away these pallets in the Stock Area

The team’s global productivity is measured weekly (Pallets/Hour).

At the beginning of each month, transportation teams share a forecast of the number of pallets to be received daily for the next four weeks.

How can you use these forecasts to help the inbound manager estimate his future needs?

How to Size the Workforce using volumes and productivity

Based on these forecasts and your global productivity, you can estimate what resources would be needed each day

A bar chart illustrating the staff demand across seven days. The heights of the bars vary for each day, showing the fluctuating demand for workers throughout the week. The label “Staff Demand” is indicated in the top right corner of the image.
Inbound Ressources needs forecasts by day — (Image by Author)

You will use 100% of temporary workers to build your team for more flexibility.

Constraint 1: The Supply must meet the demand

If you need 31 workers on Monday, you must secure at least 31 workers.

Constraint 2: Minimum working time by worker

To ensure employee retention, you must guarantee a minimum of 5 consecutive working days per week.

Workforce sourcing can be challenging, especially if e-commerce fulfilment centres surround your DC.

Therefore, you need to ensure minimum working time for your temporary workers to be an attractive employer.

Constraint 3: Maximum working time by week

Following the local regulations, each worker must rest for 2 days after 5 consecutive working days.

A shift schedule diagram showing seven different shifts across the days of the week (Monday to Sunday). Green squares indicate working days, while yellow squares represent days off. The shifts are organized in a staggered pattern to ensure coverage throughout the week while allowing rest periods for the workers.
Planning by shift based on constraints listed above — (Image by Author)

A worker from Shift 1 will start his week on Monday and get two days off on Friday.

Her colleague from Shift 6 will start the week on Saturday and get two days off on Thursday.

Objective: Minimize the number of workers hired

Following the productivity targets fixed by your manager, you must minimize the number of workers hired.

If you do not reach this target, your P&L can be impacted because this productivity has been used to calculate the price invoiced to your customer (retailer).

How can we reach this target with all these constraints?

Linear Programming Problem to find the optimal solution

We define a Linear Programming Problem by

  • finding the optimal value of a linear function (objective function) of several variables (x[i])
  • subject to the conditions that the variables are non-negative and satisfy a set of linear inequalities (called linear constraints).

Our problem fits perfectly!

Variables
x[i]: number of temporary workers hired for shift i
Constraints
- For each day the total number of workers on-duty must be higher than the demand
- Each worker needs to work a minimum of 5 consecutive days per week- Each worker needs to have 2 days off after 5 consecutive days of workObjective functions
The total number of temporary workers hired for all shifts i = 1 … 7 should be minimal

💡 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

Linear Programming with PuLP

PuLP is a Python modelling framework for linear (LP) and Integer Programming (IP) problems maintained by the COIN-OR Foundation.

Prepare the parameters of your linear programming model

  • Create a circular list for the days (if you need to add five days to Friday, you will reach Wednesday)
  • List of Working Days: if day = 0 (Monday), then working days are Monday, Tuesday, Wednesday, Thursday and Friday
  • Workers off by shift for each day: if day = 0 (Monday), then workers of shift 2 (Starting Tuesday) and shift 3 (Starting Wednesday) are off

Initialize the model, define the objective and add constraints.

  • Initialize the Model “Minimize Staffing” to minimize the objective
  • Create variables x[i]: number of workers hired for shift i
  • Define objective: sum of workers hired x[i]
  • Add constraints: The sum of workers on duty (not on a day off) is higher than the minimum staff demand.

Solve your model and analyze the results

Results: Number of workers hired?

Total number of Staff = 53

Insights

0 workers hired for Thursday and Saturday shifts

Supply vs. Demand: what is the gap?

Do we have more workers than needed?

A bar and line chart showing staff demand (black bars) and staff supply (red bars) across several days of the week. A blue line, labeled “Extra Resources (right),” indicates the additional resources needed to meet the demand. The blue line peaks on one of the days, highlighting a significant gap between staff demand and supply.
Supply vs. Demand of workers per day — (Image by Author)

Insights

Friday: 1 extra worker
Saturday: 5 extra workers

In addition to optimizing your workforce allocation, you can also improve the productivity per worker following a process improvement methodology like the one presented in this article for picking.

IV. Conclusion

Our results respect the constraints, i.e. the demand is met.

However, this sizing could be more satisfying as we have six extra man days to add to our P&L because of Friday and Saturday.

How can we improve the solution?

You can try to influence multiple parameters

  • What if we have the constraint of two days off per week?
  • Is the constraint of having consecutive days of work mandatory?
  • Is the constraint of having at least five days worked per week mandatory?

Feel free to simulate these scenarios and share your results (or questions) in the comment section.

What about the productivity? Can we use data analytics to improve it?

Improve the productivity of operators with Python.

In this article, we took for granted that the operators' maximum productivity cannot be increased.

However, in another series of articles, we proved that Python cannot be used to help operators become more efficient.

Picking routes with one order picked per wave — (Image by Author)

Reducing the walking distance of operators during picking is the most effective way to increase your DC overall productivity.

It can be achieved by grouping multiple orders in a single route that maximizes the number of items picked per meter walked.

Which analytics tools are useful for this problem?

In this series of articles, we use Python to implement spatial clustering and create a pathfinding algorithm to maximize operator outputs.

For more details, start with this article

This is not the only approach.

Indeed, external factors influencing the process may impact operators' productivity.

How to find the root cause of a process inefficiency with data analytics?

Statistical Approach of Root Cause Analysis

Lean Six Sigma (LSS) is a data-driven approach to continuous improvement that follows five steps (Define, Measure, Analyze, Improve, and Control) to improve processes.

This can be used for workforce planning to target bottlenecks and analyse the productivity of teams or individual operators.

Do we have a correlation between the teams’ productivity and the day of the week?

If you believe you are in this situation, read this series of three articles.

You will find operational examples using LSS statistical methods to find the root cause of a problem or validate a hypothesis.

  • Lean Six Sigma with Python — Kruskal Wallis Test
    Assess the effectiveness of warehouse operators by comparing the productivity of two samples of operators.
  • Lean Six Sigma with Python — Logistic Regression
    How much bonus do you need to provide to warehouse operators to reach your productivity targets?
  • Lean Six Sigma with Python — Chi-Squared Test
    Find the root cause of the shortage of drivers impacting your transportation network with a statistical test.

What about the user experience and the communication with operational teams?

Generative AI: GPT for Process Optimization

Following the adoption of large language models (LLMs), I wanted to experiment with generative AI to improve the UX of analytics products.

Can we replace boring dashboards with a prompt connected to a LLM?

This started with a prototype of a Transportation Control Tower powered by GPT.

A visual representation showing the use of generative AI and large language models (LLMs) for process optimization. The image includes icons depicting data questions, generative AI processing power, SQL database integration, and user communication with AI. It symbolizes a system where analytics products are optimized using prompts connected to an LLM to replace traditional dashboards.
Supply Chain Control Tower Agent with LangChain SQL Agent [Article Link] — (Image by Author)

The outputs are quite impressive.

The GPT-powered agent can answer operational questions by autonomously querying a database of delivery shipments.

More details in the link below, 👇

What if we create a Process Optimization super agent?

A flowchart diagram showing a process where generative AI interacts with user prompts to optimize workforce planning. The diagram starts with the “Core Module” and progresses through various user prompts, asking for clarification or defining problem statements. The flow guides the user to use a model on specific variables (X, Y, Z) for optimization. The image includes a user icon and several prompts interacting with AI to refine data analysis.
Example of the Lean Six Sigma Super Agent — (Image by Author)

My strategy is to deploy GPTs equipped with

  • Python Scripts of Lean Six Sigma Tools, Workforce Planning and Process Scheduling
  • Context, articles and knowledge about warehousing and transportation processes

Imagine the support you can provide to continuous improvement engineers with an agent helping them find the right analytics tool to answer their problems.

For more information, 👇

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.

For consulting or advice on analytics and sustainable supply chain transformation, feel free to contact me via Logigreen Consulting.

If interested in Data Analytics and Supply Chain, look at my website.

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

💡 You can find a YouTube version of this article with animations in the link below,

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Samir Saci
Samir Saci

Written by Samir Saci

Top Supply Chain Analytics Writer — Case studies using Data Science for Supply Chain Sustainability 🌳 and Productivity: https://bit.ly/supply-chain-cheat

No responses yet