# 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?

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

*Article originally published on Medium. *

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.

## I. Workforce Planning: Problem Statement

### 1. Scenario

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

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

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.

### 2. Workforce Sizing

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

**. Workforce sourcing can be challenging especially if your DC is surrounded by e-commerce fulfilment centres.**

**5 consecutive working days per week**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).

### 3. Linear Programming Problem

We define a Linear Programming Problem by finding the

the optimal value of a linear function ** (objective function)** of several variables

**, subject to the conditions that the variables are non-negative and satisfy a**

**(x[i])****.**

**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

## II. Linear Programming with PuLP

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

### 1. Prepare your parameters

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

### 2. Initialize the model, define the objective and add constraints

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

### 3. 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?

Insights

Friday: 1 extra worker

Saturday: 5 extra workers

## III. Conclusion and Next Steps

1. Conclusion

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 to our P&L because of Friday and Saturday.

### 2. Next Steps

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.

## References

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