Optimize Workforce Planning using Linear Programming with Python

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

Samir Saci
Towards Data Science

--

Optimize Workforce Planning using Linear Programming 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.

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

This article will explore optimising workforce planning using Linear Programming with Python and analyze the results.

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

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 major challenge that Distribution Center (DC) managers face is the workload fluctuation during the week.

Graphs representing a large E-Commerce Warehouse daily workload
Daily figures representing a large E-Commerce DC workload — (Image by Author)

The example below shows the daily variation of key indicators that will drive your workload (#Orders, #Lines, #SKU, …).

From one day to another, you can see a high variation that needs to be absorbed by your teams.

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

II. Defining the Workforce Planning Problem Statement

Planning of Workforce resources for Inbound Operations

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

Your 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 Stock Area

The team’s global productivity is measured weekly in (Pallets/Hour). At the beginning of each month, your colleagues from the transportation team share a forecast of the number of pallets to be received every day for the next 4 weeks.

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

Inbound ressources needs of workers by day
Inbound Ressources needs forecasts by day — (Image by Author)

For more flexibility, you will use 100% of temporary workers to build your team.

Constraint 1: The Supply must meet the demand

If you need 31 workers Monday, you need to secure at least 31 workers for Monday.

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.

Warehouse operarators planning by shift based on external constraints
Planning by shift based on constraints listed above — (Image by Author)

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

Her colleague from Shift 6 will start the week on Saturday and get 2 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).

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.
My portfolio with other projects: Samir Saci

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

II. Linear Programming with PuLP

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).

Prepare the parameters of your linear programming model

  • Create a circular list for the days (if you need to add 5 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: 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?

Supply vs. Demand of workers per day — (Image by Author)

Insights

Friday: 1 extra worker
Saturday: 5 extra workers

Go Beyond by boosting the productivity of operators

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 is not satisfying as we have 6 extra man days to add to our P&L because of Friday and Saturday.

Generative AI: GPT for Process Optimization

Following the adoption of large language models (LLMs), I started experimenting with designing a LangChain Agent connected to a TMS.

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.

What if we create a Process Optimization super agent?

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 you can help continuous improvement engineers, team leaders and warehouse managers with an agent to find the right analytics tool, perform it on datasets uploaded and provide answers.

For more information,

Statistical Approach: What is the impact of other parameters?

Lean Six Sigma (LSS) is a stepwise approach to continuous improvement following 5 steps (Define, Measure, Analyze, Improve and Control) to improve processes.

This approach can be used for workforce planning to target bottlenecks and analyse teams' or individual operators’ productivity.

I have a series of three articles in which I share three operational cases using LSS statistical methods to solve a problem:

  • 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.

Next Steps

Try to influence several parameters

  • What if we have the constraint of 2 days off per week?
  • The constraint of having consecutive days of work?
  • The constraint of having at least 5 days worked per week?

You can try these scenarios and share your results (or questions) in the comment section.

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 ⌛