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 employees retention?

Optimize Workforce Planning using Linear Programming with Python

A significant challenge faced by Distribution Centre (DC) managers is the fluctuation of the workload during the week.

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

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 the next, you can see significant variation that your teams need to absorb.

Given that your workers' average productivity is stable, the only solution is to adapt your resources to meet daily demand.

💌 New articles straight to your inbox for free: Newsletter

Workforce Planning: Problem Statement

Scenario

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

Your team's 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 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.

Workforce Sizing

Based on these forecasts and your global productivity, you can estimate what resources would be needed each 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 on Monday, you need to secure at least 31 workers for Monday.

Constraint 2: Minimum working time by worker

To ensure employee retention, you need to guarantee at least five 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 hours for your temporary workers to be attractive employers.

Constraint 3: Maximum working time by week

In accordance with local regulations, each worker must rest for 2 days after 5 consecutive working days.

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: Minimise the number of workers hired

Following the productivity targets fixed by your manager, you must minimise 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

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!

Edit: You can find a Youtube version of this article with animations in the link below.
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 work
Objective functions
The total number of temporary workers hired for all shifts i = 1 … 7 should be minimal

Linear Programming with PuLP

PuLP is a modelling framework for Linear (LP) and Integer Programming (IP) problems written in Python.

GitHub - samirsaci/workforce-planning: Optimize Workforce Planning using Linear Programming with Python
Optimize Workforce Planning using Linear Programming with Python - samirsaci/workforce-planning

Prepare your parameters

  • Create a circular list for the days
    If you 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

Initialise the model, define the objective and add constraints

  • Initialise Model “Minimise Staffing” to minimise 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 analyse 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

Conclusion and Next Steps


Conclusion

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

However, this sizing is not satisfactory, as we have six extra man-days to add to our P&L due to Friday and Saturday.

Next Steps

Try to influence several parameters

  • The constraint of 2 days off per week?
  • What is the constraint of having consecutive days of work?
  • What is 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.

About Me

Let’s connect on LinkedIn and Twitter, I am a Supply Chain Engineer that is using data analytics to improve logistics operations and reduce costs.

If you’re looking for tailored consulting solutions to optimise your supply chain and meet sustainability goals, feel free to contact me.