Solving Staff Scheduling Problem Using Linear Programming - Mach
Solving Staff Scheduling Problem Using Linear Programming - Mach
Airflow Operators
Latest:
MapReduce Algorithm
As Senior operation manager, your job is to optimize scarce resources, improve productivity,
reduce cost and maximize profit. For example, scheduling workers’ shifts for the most effective
utilization of manpower. We need to consider the various restrictions of the total working hours of
each employee, the number of shifts, shift hours, and other constraints. Such a problem can be
considered an optimization problem.
Staff or workforce scheduling is used in numerous use-cases like nurse staff scheduling in a
hospital, air flight scheduling, staff scheduling in the hotel, and scheduling of drivers. Such
schedules can be created based on various time periods like hours, days, weeks, and months.
Various organizations use spreadsheets and software. Poorly managed schedule causes
overlapping of employee allocation, no breaks between shifts. Ultimately it will cause poor
employee performance. For effective workforce scheduling, we need to consider the number of
constraints and formulate them in the right manner. Workforce scheduling will help in effective
human resource utilization, balanced timing, balanced workload, reduce employee fatigue and give
importance to individual preferences (link).
Linear programming is a mathematical model for optimizing the linear function. We can achieve the
best results using linear programming for a given specific set of constraints. Linear programming is
widely used in management and economic science problems such as production planning, network
routing, resource scheduling, and resource allocation. Linear programming can also be helpful in
scheduling human resources. Such type of problem is known as Staff Scheduling or Workforce
Scheduling problems.
Contents [ hide ]
The required number of nurses for each shift is mentioned in the below table:
Morning 09 AM-12 PM 6
Afternoon 12-03 PM 11
Evening 03-06 PM 8
Night 06-09 PM 6
There is at least 1 full-time employee we need in each shift. The full-time employee will get $150 for
9 hours shift and the part-time employee will get $45 per shift.
Initialize Model
Define Decision Variable
Define Objective Function
Define the Constraints
Solve Model
Objective Function:
Constraints 1:
x0 + y 0 ≥ 6
x0 + x 1 + y 1 ≥ 8
x1 + x2 + y2 ≥ 11
x2 + x 3 + y 3 ≥ 6
Constraints 2:
x0 ≥ 1
x1 ≥ 1
x2 ≥ 1
Initialize LP Model
In this step, we will import all the classes and functions of pulp module and create a Minimization
LP problem using LpProblem class.
Python
Python
Python
1 # Define Objective
2 model += 150 * lpSum([x[i] for i in shifts]) + 45 * lpSum([y[i] for i in shifts])
In this code, we have summed up the two variables(full-time and part-time) list values in an additive
fashion.
Python
Solve Model
In this step, we will solve the LP problem by calling solve() method. We can print the final value by
using the following for loop.
Python
Output:
fulltimeshift__0 = 1.0
fulltimeshift__1 = 1.0
fulltimeshift__2 = 1.0
fulltimeshift__3 = 0.0
parttimeshift__0 = 5.0
parttimeshift__1 = 6.0
parttimeshift__2 = 9.0
parttimeshift__3 = 5.0
Summary
In this article, we have learned about Staff Scheduling problems, Problem Formulation, and
implementation in the python PuLp library. We have solved the staff scheduling problem using a
Linear programming problem in Python. Of course, this is just a simple case study, we can add
more constraints to it and make it more complicated. In upcoming articles, we will write more on
different optimization problems and its solution using Python. You can revise the basics of
mathematical concepts in this article and learn about Linear Programming in this article.
Working with Strings in Pandas
October 16, 2020
Support Vector Machine Classification in Scikit-learn
April 2, 2021
Latest Posts
MapReduce Algorithm
Networking and Professional Development for Machine Learning Careers in the USA
Airflow Operators
MLOps Tutorial
Python Decorators
Python Generators
About Us
We love Data Science and we are here to provide you Knowledge on Machine Learning, Text Analytics,
NLP, Statistics, Python, and Big Data. We focus on simple, elegant, and easy to learn tutorials.
Resources
AWS
Big Data
Business Analytics
Data Engineering
Deep Learning
Essentials Skills
Interview
Julia
Machine Learning
Mathematics
MLOps
NLP
Optimization Techniques
Python
pandas
Recommender System
Statistics
Text Analytics
Archives
April 2024
September 2023
July 2023
March 2023
February 2023
January 2023
November 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
December 2021
September 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
December 2020
November 2020
October 2020
September 2020
DataCamp
UpGrad
Privacy Policy