Optimize Workforce Planning using Linear Programming with Python | by Samir Saci | Towards Data Science

A major challenge faced by Distribution Center (DC) managers is the fluctuation of the workload during the week.
In the example below, you can see 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 demand of each day.
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 to Stock Area
The team’s global productivity is measured each week 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.
Based on these forecasts and your global productivity you can estimate what would be the resources needed each day
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 employees retention, you need to guarantee a minimum of 5 consecutive working days per week. Workforce sourcing can be challenging especially if your DC is surrounded by e-commerce fulfilment centres.
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 needs to rest 2 days after 5 consecutive working days.
A worker from Shift 1 will start his week Monday and get 2 days off on Friday. Her colleague from Shift 6 will start the week 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).
We define a Linear Programming Problem by finding thethe 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!
Edit: You can find a Youtube version of this article with animations in the link below.
Variablesx[i]: number of temporary workers hired for shift iConstraints- 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 functionsThe total number of temporary workers hired for all shifts i = 1 ... 7 should be minimal
PuLP is a modelling framework for Linear (LP) and Integer Programming (IP) problems written in Python maintained by COIN-OR Foundation (Computational Infrastructure for Operations Research).
You can find the full code in this Github repository: Link.My portfolio with other projects: Samir Saci
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 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 minimum staff demand
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?
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.
www.samirsaci.com
Our results are respecting the constraints i.e. the demand is met. However, this sizing is not satisfying as we have 6 extra man days to add in our P&L because of Friday and Saturday.
Try to influence several parameters
The constraint of 2 days off per week?
The constraint of having consecutive days of work?
The constraint of having a minimum of 5 days worked per week?
You can try these scenarios and share your results (or questions) in the comment section.
Please feel free to contact me, I am willing to share and exchange on topics related to Data Science and Supply Chain.My Portfolio: https://samirsaci.com
[1] Computational Infrastructure for Operations Research, Optimization with PuLP (Documentation), Link