Uploaded by charbel.saab02

Nurse Rostering Decision Support System Design Project

advertisement
Page 1 of 108
Lebanese American University
School of Engineering
Department of Industrial and Mechanical
Engineering
Design of a decision support system for solving nurse
rostering problem
INE592 PROJECT II
Spring 2025
Lea Jilwan - 202000651
Yara Naame - 202200065
Elias Elghossein - 202105819
Charbel A. Saab - 202104201
Date Report Presented: April 23, 2025
Project II Advisor: Professor Pierrette Zouein
Page 2 of 108
Table of Contents
Abstract ............................................................................................................................................ 5
I.
Introduction .............................................................................................................................. 5
II.
Problem Statement .................................................................................................................. 6
III. Standards, Codes and Constraints ............................................................................................ 6
III.1 Purpose of Nursing Standards and Codes ............................................................................. 6
III.2 Global Standards and Codes.................................................................................................. 6
III.3 Local Standards and Codes (LAU Rizk Medical Center) ......................................................... 7
IV. Literature Review ..................................................................................................................... 9
IV.1 Impact of Nurse Fatigue on Healthcare Systems .................................................................. 9
IV.2 Introduction to Nurse Rostering .........................................................................................10
IV.2.1 Definition, Importance, and Challenges .......................................................................10
IV.2.2 Practical Challenges in Hospital Settings ......................................................................10
IV.2.3 Objectives of an Effective Rostering System ................................................................11
IV.2.4 Nurse Scheduling Complexity.......................................................................................11
IV.3 Current Approaches and Techniques in Nurse Rostering ...................................................11
IV.3.1 Heuristics, Metaheuristics, and Exact Optimization Methods .....................................11
IV.3.2 Advanced Optimization and Algorithms ......................................................................11
IV.3.3 Practical Barriers to Technology Adoption in Hospitals ...............................................12
IV.4 Gaps in Current Research and Practice ...............................................................................12
V.
Methodology ..........................................................................................................................14
V.1 Data Collection .....................................................................................................................14
V.2 Main Model ..........................................................................................................................16
V.3 Augmented Models ..............................................................................................................16
V.3.1 Fairness-Augmented .....................................................................................................16
V.3.2 Preference-Augmented Model .....................................................................................16
V.4 Derived Models ....................................................................................................................17
V.4.1 Sick Leave-Responsive Model .......................................................................................17
V.4.2 Annual Leave Model ......................................................................................................17
V.5 Decision Support Tool ..........................................................................................................17
V.6 Solver and Implementation ..................................................................................................17
VI. Design .....................................................................................................................................18
Page 3 of 108
VI.1 Description of Proposed Models .........................................................................................18
VI.2 Optimization Models ...........................................................................................................20
VI.3 Model Implementation in Matlab .......................................................................................24
VI.4 Optimization Solver and Algorithm Description .................................................................41
VII. Results Analysis and Discussion..............................................................................................44
Scenario Analysis: System Infeasibility with 20 Nurses ..........................................................65
System Demand and Shift Requirements...........................................................................66
Available Capacity with 20 Nurses .....................................................................................66
Why the Shortage Cannot Be Absorbed.............................................................................67
Solver Behavior and Model Response ................................................................................67
Conclusion and Recommendations ....................................................................................68
Break-Even Analysis of Scheduling Costs .......................................................................................68
B/C Analysis ....................................................................................................................................73
Benefits.......................................................................................................................................73
Costs ...........................................................................................................................................74
Design Impacts ...............................................................................................................................74
Limitations ......................................................................................................................................77
Conclusion ......................................................................................................................................78
Appendix.........................................................................................................................................80
Meeting Minutes ........................................................................................................................81
Mind Map ...................................................................................................................................84
WBS ............................................................................................................................................85
LRC ..............................................................................................................................................85
Gantt Chart .................................................................................................................................85
Matlab Codes..............................................................................................................................86
List of Tables
Table 1: Summarizes the local and International Standards and Codes ......................................... 8
Table 2: summarizes various studies on nurse scheduling optimization, outlining their
objectives, solving methods, and the departments in which they were applied. It highlights the
diverse approaches used, ranging from Mixed-Integer Programming to Genet .......................... 13
Table 3:Input from MSU7 .............................................................................................................. 14
Page 4 of 108
Table 4: BaseModel schedule exported to Excel ........................................................................... 45
Table 5:BaseModel RN:PN ratio .................................................................................................... 45
Table 6:AugmentedModel_Fairness schedule exported to excel ................................................. 48
Table 7: AugmentedModel_Fairness RN:PN ratio......................................................................... 48
Table 8: BaseModel Vs AugmentedModel_Fairness, Total working shifts per month per nurse . 50
Table 9: Model1 Vs Model3 Fairness Gap ..................................................................................... 51
Table 10: AugmentedModel_Preferences schedule exported to excel ........................................ 52
Table 11: SickLeaveModel Current Schedule exported to excel ................................................... 54
Table 12: SickLeaveModel Updated Schedule exported to excel ................................................. 54
Table 13: BaseModel Vs SickLeaveModel Working Hours ............................................................ 55
Table 14: AnnualLeaveModel schedule ½ exported to excel ........................................................ 56
Table 15: AnnualLeaveModel schedule 2/2 exported to excel ..................................................... 57
Table 16: Models Costs.................................................................................................................. 69
Table 17: Total number of working shifts per month per RNs ...................................................... 70
Table 18:Total number of working shifts per month per PNs ....................................................... 71
Table 19: WBS of the Projcet ......................................................................................................... 85
Table 20: LRC ................................................................................................................................. 85
Table 21: Gant Chart...................................................................................................................... 86
Table List of Figures
Figure 1: Nurse Preference Scores ................................................................................................ 33
Figure 2: BaseModel Heatmap ...................................................................................................... 46
Figure 3:BaseModel Total hours per month per nurse ................................................................. 47
Figure 4:AugmentedModel_Fairness Heatmap ............................................................................ 49
Figure 5: AugmentedModel_Fairness Total working hours per month per nurse........................ 50
Figure 6: BaseModel Vs AugmentedModel_Fairness Working Shifts ........................................... 51
Figure 7: AugmentedModel_Preferences Total working hours per month per nurse.................. 52
Figure 8: exported to excel Total working hours per month per nurse ........................................ 55
Figure 9: AnnualLeaveModel Heatmap ......................................................................................... 58
Figure 10 ........................................................................................................................................ 59
Figure 11 ........................................................................................................................................ 60
Figure 12 ........................................................................................................................................ 61
Figure 13 ........................................................................................................................................ 62
Figure 14 ........................................................................................................................................ 63
Figure 15 ........................................................................................................................................ 65
Figure 16: Break-even Point .......................................................................................................... 69
Figure 17: Total number of working shifts per month per RNs..................................................... 70
Figure 18Total number of working shifts per month per PNs:...................................................... 71
Figure 19: Mind Map of the Project .............................................................................................. 84
Page 5 of 108
Abstract
Efficient nurse scheduling is a critical challenge in healthcare management, where
operational demands must be balanced with legal constraints, fairness, and staff
preferences. This project develops a comprehensive decision support system (DSS) for
optimizing nurse rostering at LAU Medical Center’s MSU7 unit. Using Mixed-Integer
Linear Programming (MILP), the system generates cost-efficient schedules while adhering
to hard constraints such as shift coverage, legal working hours, and RN-to-PN ratios. To
improve real-world applicability, augmented models were introduced to incorporate
fairness constraints, nurse shift preferences, and responsiveness to sick and annual leave
requests. A MATLAB-based graphical user interface (GUI) was developed to make the
system accessible to hospital administrators, allowing them to generate monthly and daily
schedules, enforce fairness, and handle disruptions interactively. The results demonstrate
significant improvements in workload equity, legal compliance, and operational efficiency.
A break-even and benefit-cost analysis further validated the system’s ability to reduce costs
and improve staff satisfaction, making it a scalable solution for modern healthcare
scheduling needs.
I.
Introduction
Efficient nurse scheduling is essential in healthcare management, where it directly impacts
both operational efficiency and the quality of care. At LAU Rizk Medical Center,
particularly in the MSU7 unit, the scheduling process must balance regulatory
requirements, such as work-hour restrictions and nurse-to-patient ratios, with the need to
accommodate nurse preferences, fair workload distribution, and staffing fluctuations due
to sick or annual leave.
This project develops a decision support system for optimizing nurse rostering in
the MSU7 unit, addressing these challenges through an optimization model based on
Mixed-Integer Linear Programming (MILP). The system aims to create fair and legally
compliant schedules while minimizing operational costs. To enhance its real-world
applicability, the system incorporates augmented models that account for fairness in
workload distribution, individual nurse preferences, and dynamic leave requests, ensuring
that nurses’ well-being and job satisfaction are prioritized alongside operational needs.
The goal of this system is to provide a scalable, efficient solution for nurse
scheduling that improves hospital operations, reduces burnout, and maintains high
standards of patient care. By integrating these models, this system offers a flexible, datadriven approach to nurse rostering, enhancing both administrative control and nurse
satisfaction.
Page 6 of 108
II.
Problem Statement
Conventional nurse scheduling methods often fail to reflect the real-time demands and
constraints of hospital environments, particularly within resource-limited systems like
those in Lebanon. High patient-to-nurse ratios, strict labour regulations, and limited
scheduling flexibility create operational challenges that compromise both efficiency and
staff well-being. Existing systems tend to neglect fairness, ignore individual preferences,
and are ill-equipped to adapt to disruptions such as sudden absences or planned leave.
This project addresses these limitations by designing a modular, optimization-based
scheduling system tailored to the operational realities of the MSU7 unit. The system
incorporates fairness mechanisms, leave integration, and re-optimization capabilities,
supported by an intuitive MATLAB GUI that empowers non-technical staff to generate,
adjust, and manage schedules effectively.
III.
Standards, Codes and Constraints
III.1 Purpose of Nursing Standards and Codes
Nursing standards and codes are essential to ensure high-quality, ethical, and safe care.
These guidelines set expectations for professional conduct, clinical skills, and decisionmaking processes, ensuring nurses meet the diverse healthcare needs of their patients.
Nursing standards foster public trust, accountability, and continuous growth within the
nursing profession, guiding nurses through ethical dilemmas and reinforcing professional
integrity (ICN, 2019).
III.2 Global Standards and Codes
Global organizations, such as the International Council of Nurses (ICN) and the World
Health Organization (WHO), establish fundamental standards for safe staffing, nurse wellbeing, and patient care:
1. International Council of Nurses (ICN) Standards:
The ICN emphasizes safe staffing levels that match patient acuity to provide adequate care.
It advocates for dynamic staffing systems and highlights the importance of Chief Nursing
Officers overseeing staffing strategies to ensure safe and ethical care delivery (ICN, 2020).
2. World Health Organization (WHO) Guidelines:
Page 7 of 108
The WHO stresses fatigue management, recommending rest breaks, physical activities, and
promoting sleep hygiene to mitigate risks of fatigue (WHO, 2021). WHO also emphasizes
safe work environments and the need for continuous professional development for nurses.
3. Global Fatigue Management and Safe Staffing Practices:
Both the ICN and WHO recommend dynamic staffing models that adjust to real-time data,
ensuring that staffing levels meet fluctuating patient needs and fatigue management
strategies are in place to safeguard staff well-being (ICN, 2020; WHO, 2021).
III.3 Local Standards and Codes (LAU Rizk Medical Center)
At LAU Rizk Medical Center, nurse scheduling adheres to both national regulations and
internal standards, ensuring safe and high-quality care. The following standards and
codes ensure compliance with these guidelines:
1. Shift Assignment (Acute Care Level or Nurse-to-Patient Ratio):
Each shift must be adequately staffed, with a sufficient number of nurses to meet the
required nurse-to-patient ratio based on patient acuity. This ensures safe staffing and the
delivery of appropriate care. At LAU Rizk Medical Center, at least two Registered Nurses
(RNs) and two Practical Nurses (PNs) are assigned to each shift to maintain a high standard
of care (Ministry of Public Health, Lebanon).
2. Consecutive Shifts:
To prevent nurse fatigue, LAU Rizk Medical Center prohibits the assignment of day and
night shifts on the same day, or a night shift followed by a day shift the next day. This also
includes a two-week window to prevent night shifts on Sundays followed by day shifts on
Mondays. This approach aligns with the ICN guidelines for maintaining healthy working
hours (ICN, 2020).
3. Weekly Work Hours (36-48 Hours):
Nurses at LAU Rizk Medical Center must work between 36 and 48 hours per week, in
compliance with Lebanese labor laws and ICN standards (Ministry of Public Health,
Lebanon; ICN, 2019). This ensures that nurses do not exceed these hours, preventing
fatigue and improving overall care quality. The hospital tracks total working hours and
imposes penalties for excessive overtime, aligning with ICN's fatigue management
standards (ICN, 2020).
4. Minimum Staffing (2 RNs and 2 PNs per Shift):
Page 8 of 108
Each shift at LAU Rizk Medical Center is required to have at least two RNs and two PNs
to ensure appropriate staffing levels and effective care delivery. This standard meets both
the ICN's safe staffing recommendations and the operational needs of the hospital (ICN,
2020).
5. Overtime Regulations:
Overtime is paid at 1.5 times the regular rate for hours worked beyond 42 per week, in
line with both local regulations and ICN guidelines for managing fatigue (ICN, 2020)
Table 1: Summarizes the local and International Standards and Codes
No.
Regulation/Standard
Lebanon (LAU Rizk
Medical Center)
International
WHO)
(1)
Shift Assignment (Nurseto-Patient Ratio)
Depends
department
the
Safe staffing levels
based on patient acuity
Varies by country; realtime adjustments may be
made based on patient
needs
(2)
No Consecutive Shifts
Night shifts followed by
day shifts prohibited
Night shifts followed by
day shifts prohibited
Similar policies in many
regions to prevent fatigue
(3)
Weekly Work Hours (36-48
Hours)
Nurses work 36-48 hours
per week
Fatigue
management
emphasizes
36-48
hours/week
Common practice in many
regions, with exceptions for
emergencies
(4)
Minimum Staffing
2 RNs and 2 PNs per
shift
Minimum staffing for
safe care and workload
balance
Practices vary, but many
regions aim for similar
nurse-to-patient ratios
(5)
Overtime Regulations
Overtime paid at 1.5x
regular rate beyond 42
hours per week
Limited overtime
manage fatigue
Overtime regulated with
premium pay for extra
hours
(6)
Fatigue Management
Managed
through
scheduling and wellness
programs
Dynamic
staffing
models recommended
Policies to assess
mitigate fatigue risks
(7)
Health
and
Regulations
Complies with national
safety standards
Follows international
health safety guidelines
Workplace safety and
health
assessments
mandatory in many areas
Safety
on
(ICN,
to
Notes from Other Regions
(e.g., USA, EU)
and
Page 9 of 108
Well-Being
Encouraged
mandatory
but
not
Strong focus on mental
health and support
systems
Programs increasing in
many regions, offering
counseling and wellness
resources
(8)
Employee
Programs
(9)
Training, Supervision, and
Professional Development
Continuous professional
development
is
mandatory
Lifelong learning and
upskilling emphasized
Continuous education and
career
advancement
opportunities
(10)
Shift Lengths
Up to 12 hours
Preferably
not
exceeding 12 hours
Commonly 8, 10, or 12hour shifts; shorter shifts
for fatigue management
(11)
Minimum Rest Between
Shifts
36 hours
weekly
At least 11 hours
Quick returns (<11 hours
rest) linked to increased
fatigue risks
consecutive
IV. Literature Review
IV.1 Impact of Nurse Fatigue on Healthcare Systems
Nurses play a crucial role in healthcare systems, ensuring continuous patient care.
However, nurse fatigue remains a significant concern globally, affecting both staff wellbeing and patient care quality.
Several studies have highlighted the detrimental effects of long shifts, high patient
loads, and emotional stress on nurses’ physical and mental health. For example, a study in
Finland involving 12,156 healthcare staff members found that after working four
consecutive night shifts, nurses were more likely to request sick leave (Ropponen et al.,
2019, as cited in Dall’Ora et al., 2020). Similarly, a study in England reported that 6% of
nursing shifts were lost due to sickness absence, with the majority of these absences being
short-term (Dall’Ora et al., 2020). These findings highlight the strong correlation between
night shifts and sickness absence, as nurses working more than 75% of their shifts at night
experienced significantly higher sickness rates.
Fatigue among nurses is not only a personal health issue but also impacts patient
safety, care quality, and operational efficiency. Research has shown that tired nurses are
more likely to make medication errors, leading to potential risks for patient safety (Ejebu
et al., 2021). Additionally, fatigue diminishes cognitive abilities and clinical judgment,
which are essential for safe, high-quality patient care. Fatigue also negatively affects nurse
Page 10 of 108
productivity, as it leads to slower reaction times, impaired decision-making, and increased
errors. This decrease in efficiency increases the workload on the entire team, raising
staffing costs and potentially compromising patient care quality (Ejebu et al., 2021).
Nurse fatigue also contributes to high turnover rates in healthcare settings. Studies
in the U.S. suggest that nurses working long hours are more likely to leave the profession
due to dissatisfaction with their schedules (Bae, 2023, as cited in Tsao et al., 2024). As a
result, hospitals face increased costs associated with recruitment, training, and onboarding
new staff. Addressing nurse fatigue is crucial to reducing burnout, improving retention,
and maintaining a stable, effective workforce. This, in turn, leads to better patient outcomes
and reduced healthcare costs (Maenhout & Vanhoucke, 2013).
In summary, the global concern of nurse fatigue has profound implications for
healthcare systems. It can result from various factors, including long working hours,
inadequate breaks, and disruptive shift patterns. Effective solutions to mitigate nurse
fatigue are necessary to ensure patient safety, improve nurse well-being, and optimize
healthcare system efficiency.
IV.2 Introduction to Nurse Rostering
IV.2.1 Definition, Importance, and Challenges
Nurse rostering is the process of assigning shifts to nursing staff to ensure continuous
patient care, operational efficiency, and nurse satisfaction. Effective rostering impacts
healthcare quality, nurse retention, and reduces turnover, especially in high-stakes
environments like ICUs and emergency departments. Poor scheduling leads to nurse
fatigue, compromised care, and increased turnover, worsening the global nursing shortage
(Supnithi et al., 2020; Yasmine et al., 2024; Jin et al., 2021). Optimized schedules reduce
turnover, improve morale, and maintain consistent care quality, as seen in France (Yasmine
et al., 2024).
IV.2.2 Practical Challenges in Hospital Settings
Nurse rostering faces challenges such as accommodating shift preferences, managing
patient acuity, and meeting departmental needs. Nurses prefer different shift lengths, and
balancing these with operational needs is difficult, especially to avoid nurse fatigue (Jin et
al., 2021). Patient acuity requires assigning more experienced nurses, particularly in highdependency units, while departmental requirements, like peak-hour needs in emergency
rooms, complicate rostering (Supnithi et al., 2020; Yasmine et al., 2024). Fixed models
often struggle to meet diverse demands, leading to inefficiencies.
Page 11 of 108
IV.2.3 Objectives of an Effective Rostering System
An effective system must be adaptable, compliant with regulations, and ensure workload
balance. Dynamic rostering models, including on-call systems and predictive algorithms,
manage fluctuations in staffing and reduce reliance on temporary staff (Jin et al., 2021).
Legal compliance with nurse-to-patient ratios, shift length restrictions, and rest periods
ensures both nurse well-being and patient safety. Balancing nurse preferences with
workload is crucial for job satisfaction and reducing turnover (Supnithi et al., 2020;
DeKeyser Ganz & Toren, 2014).
IV.2.4 Nurse Scheduling Complexity
The Nurse Scheduling Problem (NSP) involves balancing hard (mandatory) and soft
(desirable) constraints. Hard constraints include ensuring minimum coverage and adhering
to work-hour regulations, while soft constraints, like shift preferences, are flexible. The
NSP is NP-hard, meaning it’s computationally complex, especially in high-demand
environments like ICUs (Yasmine et al., 2024; Klyve et al., 2022). Fairness in distributing
shifts is key to reducing burnout and improving job satisfaction, though quantifying
fairness is challenging. Many systems prioritize efficiency, often neglecting fairness,
which can lead to dissatisfaction among staff (Fulcher et al., 2010; Klyve et al., 2022).
IV.3 Current Approaches and Techniques in Nurse Rostering
IV.3.1 Heuristics, Metaheuristics, and Exact Optimization Methods
The Nurse Scheduling Problem (NSP) requires advanced optimization techniques due to
its complexity. Heuristic methods, like decision trees and greedy algorithms, provide fast
but approximate solutions. Metaheuristics, including GA-PSO hybrids, Large
Neighborhood Search (LNS), and Variable Neighborhood Search (VNS), offer more
comprehensive solutions by managing both hard and soft constraints. These methods have
proven effective in balancing operational requirements and nurse preferences (Jin et al.,
2017).
The current model integrates these techniques with Mixed-Integer Linear Programming
(MILP), ensuring strict adherence to legal work hour limits and minimum nurse coverage,
while also accommodating leave requests and other dynamic factors. This combination
allows for adaptable scheduling while maintaining fairness.
IV.3.2 Advanced Optimization and Algorithms
Optimization methods like MILP and Integer Linear Programming (ILP) have become
essential in nurse rostering, especially for ensuring compliance with hospital regulations
and staffing requirements. These methods are combined with hybrid algorithms, such as
GA-PSO, to balance hard constraints and nurse preferences (Yasmine et al., 2024).
Page 12 of 108
Constraint Programming (CP) is also used to define complex constraints, providing
flexibility in scheduling while ensuring feasibility.
The MILP model improves operational efficiency and meets hospital needs by
incorporating dynamic adjustments in response to leave requests, absences, and staffing
changes. This approach ensures that schedules are optimized based on both operational and
human factors.
IV.3.3 Practical Barriers to Technology Adoption in Hospitals
Despite the potential benefits of these optimization techniques, several barriers to adoption
exist. Resistance to change among staff is a significant challenge, with concerns about
fairness and the transparency of automated scheduling systems. Training and education
programs can help overcome these concerns (O'Callahan et al., 2024).
Another challenge is the customization of optimization models to fit specific
hospital needs, including staff availability, nurse preferences, and patient demands. This
customization can be resource-intensive, particularly in hospitals with limited IT
infrastructure. Additionally, ongoing maintenance, support, and integration with existing
hospital systems are critical to ensure smooth operation and adoption.
IV.4 Gaps in Current Research and Practice
Current research in nurse rostering highlights several gaps that need attention. Many
models focus on static scheduling or short-term scheduling, failing to incorporate datadriven forecasting and real-time adjustments (Yasmine et al., 2024). The lack of integration
with operational variables like patient acuity and nurse skill sets makes it difficult to match
nurses with appropriate shifts in specialized units like ICUs. Additionally, nurse-driven
adjustments (e.g., shift swaps) are underexplored and could enhance scheduling flexibility
and nurse satisfaction.
Addressing these gaps with advanced optimization models that incorporate realtime data, nurse preferences, and staffing flexibility will improve nurse retention and
operational efficiency while enhancing patient care.
Page 13 of 108
Table 2: summarizes various studies on nurse scheduling optimization, outlining their objectives, solving methods, and
the departments in which they were applied. It highlights the diverse approaches used, ranging from Mixed-Integer
Programming to Genet
References
Objective
Solving Methods
Department
(Klyve et al.,
2023)
Minimize global
maximum fatigue score
Mixed-Integer Programming
and Constraint
Programming with a Large
Neighborhood Search
Intensive Care
Unit (ICU)
(Tsao et al.,
2024)
Maximize total
preference satisfaction
of all nurses
Several hybrids GA-PSO: GAPSO, parallel GA-PSO, and
sequence GA-PSO
Dentist Clinic in
Taiwan
(Zheng & Gong,
2021)
Minimize the weighted
sum of slack variables
corresponding to soft
constraints
Commercial integer
programming - metaheuristic variable
neighborhood search (VNS)
Gastrointestinal
surgery
department and
Chemotherapy
department
(Chen & Zeng,
2020)
Minimize total penalties
from soft constraint
violations
Decision Tree Method,
Greedy Search Algorithm,
Bat Algorithm, and Particle
Swarm Optimization
Radiology
Department
Minimize total violations
of soft constraints
Adaptive variable
neighborhood search (VNS),
Stochastic variable
neighborhood approach
Hospital
departments and
healthcare
facilities
Minimize overall
scheduling cost
Agent-Based Modeling
(ABM) and Iterated Local
Search (ILS), specifically
CNR-ILS
Federal
hospital's
Medical Surgical
Unit
(Tassopoulos et
al., 2015)
(Michael et al.,
2015)
Page 14 of 108
(Yasmine et al.,
2024)
(Supnithi et al.,
2020)
(Klyve et al.,
2024)
V.
Mixed-Integer Linear
Programming Model (MILP)
Different French
Hospital
Departments
Minimize workload
imbalances
Goal Programming
Operating room
department in a
private hospital
in Thailand
Maximize fulfillment of
personal requests and
desirable shift patterns
Department of
Integer Linear Programming,
Neonatal
Mixed Integer Linear
Intensive Care
Programming, Simulation
(DNIC) at St.
Model
Olavs Hospital
Minimize violation of
soft constraints
Methodology
V.1 Data Collection
This section outlines the methodology used to develop an optimization-based nurse
scheduling system for the MSU7 unit at LAU Medical Center. The unit comprises 22
nurses—11 registered nurses (RNs) and 11 practical nurses (PNs)—scheduled over a fourweek horizon with two 12-hour shifts per day (Day and Night). Each shift must be staffed
by a minimum of six nurses, including at least two RNs and two PNs. All constraints and
operational parameters were defined in coordination with hospital administration and
informed by a structured interview with the Chief Nursing Officer (CNO) as shown in the
table below:
Unit: MSU / 17 beds / Ratio 1:6, details are shown in Table 1
Table 3:Input from MSU7
Parameter
Value
Description
weeks
4
Scheduling horizon (4week period).
Page 15 of 108
Days
7
Days per week
(Monday–Sunday).
Shifts
2
Shift types: Day (1)
and Night (2).
hoursPerShift
12
Duration of each shift
(hours).
Nurses
22
Total nurses to
schedule.
nurseNames
"christine", "layla", "daoud",
"marylin", "rita", "valeria", "habib",
"pia maria", "cidra", "gael",
"marita","micheline","antoinette",
"amal", "wissam", "abdelhak",
"hussein", "salam", "marwan",
"jeandarc", "samir", "karavartalian"
Nurse identifiers.
nurseType
[1 1 1 1 1 1 1 1 1 1 1 , 0 0 0 0 0 0 0 0
0 0 0]
1 = RN (Registered
Nurse), 0 = PN
(Practical Nurse), (11
RN, 11 PN)
The basic salary of a
new RN, PN per month
1030$/ month, 800$/month
Basic salary
Overtime Penalty
Hourly wage + 2.5$
Used in the objective
function
▫
A total of 22 nurses must be scheduled, any variations in the number of nurses has
been addressed in the break-even section.
▫ The minimum allowed hours per nurse per month is 144 hours (36 hours/week).
▫ The maximum allowed hours per nurse per month is 192 hours (48 hours/week).
▫ 168 hours/month is the threshold beyond which overtime penalties apply (42
hours/week).
The system was built in MATLAB using mixed-integer linear programming (MILP), with
each model iteration progressively integrating additional layers of fairness, flexibility, and
responsiveness.
Page 16 of 108
V.2 Main Model
1. BaseModel
The foundation of the system is a base model that addresses all essential hard constraints.
These include:
● Shift coverage with required RN:PN ratios
● Legal working hours per week (36 to 48 hours), regular (36 to 42 hours), overtime
(42 to 48 hours)
● Overtime penalties for hours beyond 42 hours per week
● Mandatory rest rules (e.g., no night-to-day shift transitions)
The objective function minimizes the total monthly scheduling cost by accounting for base
salaries and any incurred overtime.
V.3 Augmented Models
Two augmented models were developed by building directly upon the base model to
improve fairness and nurse satisfaction.
V.3.1 Fairness-Augmented
2. AugmentedModel_Fairness
This version introduces workload fairness by ensuring that the difference in total working
hours between any two nurses does not exceed 24 hours. This constraint reduces
variability in shift distribution and promotes a more equitable working environment.
V.3.2 Preference-Augmented Model
3. AugmentedModel_Preferences
This model incorporates individual nurse shift preferences, recorded on a scale from one
to five. A weighted penalty is added to the cost function when a nurse is assigned to a
shift rated poorly. The model aims to honor staff preferences without compromising
coverage or legal constraints.
Page 17 of 108
V.4 Derived Models
To improve real-world applicability, two additional models were developed to handle both
unplanned and planned leave scenarios. These models reuse the core structure of the base
model and adapt it to specific scheduling disruptions.
V.4.1 Sick Leave-Responsive Model
4. SickLeaveModel
When a nurse requests a sick day, this model locks all prior shift assignments and reoptimizes the remaining schedule. The nurse is excluded from shifts on the specified days,
while the model maintains coverage, fairness (if applicable), and legal working conditions.
V.4.2 Annual Leave Model
5. AnnualLeaveModel
This version integrates planned leave by allowing each nurse to request up to three fullday absences during the scheduling period. The model restricts excessive clustering by
limiting leave to a maximum of four nurses per shift and ensures that all legal and
staffing constraints are satisfied.
V.5 Decision Support Tool
6. Graphical User Interface in Matlab
To facilitate practical deployment, a graphical user interface (GUI) was developed in
MATLAB for the MSU7 that enables hospital staff to generate optimized nurse schedules
with ease. It supports monthly and daily scheduling, handles sick leave disruptions, and
enforces fairness in workload distribution using MILP optimization models. The interface
is user-friendly, with clear controls and automated Excel outputs, enhancing efficiency,
transparency, and staff well-being.
V.6 Solver and Implementation
All models were implemented using MATLAB’s optimproblem framework with intlinprog
as the solver. Decision variables represent nurse-week-day-shift assignments. Expressions
and constraints were defined using optimexpr and optimconstr, respectively. The final
schedules are exported to Excel for visualization and evaluation.
Page 18 of 108
VI. Design
VI.1 Description of Proposed Models
1. BaseModel
The Base Model establishes a cost-minimizing nurse scheduling system for the MSU7
unit over a four-week horizon, assigning 22 nurses to two daily 12-hour shifts while
adhering strictly to operational and legal constraints. It ensures each shift is covered by at
least six nurses, including a minimum of two registered nurses (RNs) and two practical
nurses (PNs). The model enforces weekly working hours between 36 and 48, penalizes
overtime beyond 42 hours, and prevents unsafe scheduling practices such as double shifts
or insufficient rest between night and day shifts. Salaries are set at 6 USD/hour for RNs
and 5 USD/hour for PNs, with a 2.5 USD/hour overtime penalty. The objective function
minimizes total labour cost, including base salaries and overtime. All constraints and
assignments are implemented in MATLAB and solved using integer linear programming.
The resulting schedule is validated and exported to Excel, with compliance confirmed
through RN:PN ratios, total hours per nurse, and cost reporting.
2. AugmentedModel_Fairness
The AugmentedModel_Fairness extends the base scheduling model by incorporating a
fairness constraint that limits the difference in total hours worked between any two nurses
to a maximum of 24 hours across the scheduling period. While maintaining all core
features from the base model, such as shift coverage, legal working hours, overtime
penalties, and mandatory rest periods, this model ensures that the workload is distributed
equitably among nurses. The objective is to minimize the total cost, including base
salaries and overtime penalties. The fairness constraint helps prevent any nurse from
being overburdened, promoting a balanced workload while still meeting all staffing
requirements. The resulting schedule is solved using MATLAB’s optimization toolbox
and is exported to Excel for administrative review.
3. AugmentedModel_Preferences
The AugmentedModel_Preferences extends the base scheduling model by incorporating
nurse shift preferences into the optimization process. Nurses are asked to rate each shift
on a scale of 1 to 5, where 5 is the most preferred. The model minimizes the total
scheduling cost, which includes base salaries, overtime penalties, and a fixed penalty for
assigning nurses to shifts that are less preferred. In addition to the core constraints from
the base model (such as shift coverage, working hours, and skill-mix requirements), this
model adds a preference penalty that increases the cost whenever a nurse is assigned to a
less preferred shift. The fairness of the schedule is maintained by enforcing the same rest
period rules and shift distribution constraints. The optimization problem is solved using
Page 19 of 108
integer linear programming, and the final solution includes not only the optimized
schedule but also a preference report, which shows how well the model respects nurse
preferences. The results are exported to Excel, providing a clear and actionable schedule
along with a detailed breakdown of preference penalties.
4. SickLeaveModel
The SickLeaveModel builds on the scheduling framework by incorporating sick leave
management, allowing for dynamic re-optimization when a nurse requests time off. This
model takes the original schedule generated by the base model and identifies the specific
days a nurse is on sick leave. It locks the nurse's assignments before the start of their sick
leave, ensuring that the schedule remains unchanged for the days prior to the leave. The
model then re-optimizes the schedule from the point the sick leave begins, filling in the
nurse's shifts and maintaining all key constraints such as shift coverage, weekly hour
limits (36–48 hours), and rest rules. The re-optimization process ensures that adequate
staffing levels are maintained while also minimizing scheduling costs. The model
effectively reassigns shifts to other nurses without violating legal working hours or
overloading any individual nurse. The results are output as a revised schedule, and the
entire process is validated by preserving the integrity of the original schedule while
accommodating the nurse's sick leave. The model ensures that the affected nurse is off
duty on the requested day and redistributes shifts to other nurses to maintain proper
staffing levels. The final schedule is then exported to Excel, providing an updated
staffing plan that respects the sick leave request.
5. AnnualLeaveModel
The AnnualLeaveModel is an optimization-based nurse scheduling framework designed
to integrate planned annual leave while ensuring optimal shift coverage and compliance
with operational and legal constraints. It extends the base nurse scheduling model by
introducing dedicated variables that account for leave during both day and night shifts.
This model dynamically adjusts nurse assignments to accommodate leave requests while
enforcing critical rules:
● Each nurse is allowed exactly 3 full days of leave per month (defined as having
both day and night shifts off on the same day).
● No more than 2 full leave days are granted per nurse in any given week, ensuring
fair distribution of leave across the schedule.
● A maximum of 4 nurses may be on leave during the same shift, avoiding
understaffing.
● It prevents scheduling a nurse to work while on leave.
● The model also maintains weekly working hours between 36 and 48 hours,
applying overtime penalties if hours exceed 42 per week.
Page 20 of 108
● Additionally, it guarantees that each shift has at least 2 Registered Nurses (RNs)
and 2 Practical Nurses (PNs) assigned, preserving the critical RN:PN staffing
balance.
● Using integer programming, the model re-optimizes shift assignments to fill in for
nurses on leave while satisfying all constraints. It exports detailed schedules and
leave reports to Excel and provides visual analytics such as heatmaps and RN:PN
ratio breakdowns.
6. Graphical User Interface in Matlab
The Decision Support Tool was developed using MATLAB’s App Designer, which
provides an interface for creating interactive applications. Core functionalities were
implemented using MATLAB scripts and functions, integrated through callbacks assigned
to GUI components such as buttons, checkboxes, and input fields. Optimization routines
were executed using intlinprog for solving the MILP models that drive the scheduling
logic. Excel integration was handled through the writetable and xlswrite functions,
enabling automated export of schedules. Error handling and dynamic dialog boxes were
incorporated using conditional statements and the uialert function to ensure a smooth and
responsive user experience.
GUI integrates the codes for the BaseModel, AugmentedModel_Fairness, and
AugmentedModel_Preferences, enabling it to generate optimized schedules, enforce
fairness constraints, and accommodate nurse preferences, each of which will be discussed
in later sections.
VI.2 Optimization Models
Note: The enumeration in the mathematical models corresponds directly to the standards
and codes outlined in table1. Each numbered point in the model aligns with the respective
standard or code, ensuring that the hospital's nurse scheduling system adheres to the
established guidelines. This alignment helps maintain consistency between the operational
models and the regulatory requirements, ensuring that both the mathematical framework
and the standards work in tandem to optimize nurse scheduling while meeting all legal and
organizational standards
Page 21 of 108
VI.2.1. BaseModel.
Definitions:
Parameters:
𝑖 ∈ 𝐼: Nurses named i that belongs to I = {set of nurses}
𝑑 ∈ 𝐷: Days per week D = {1 = Monday, 2,3,4,5,6,7 = Sunday}
𝑠 ∈ 𝑆: Shifts per day S = {Day = 0, Night = 1}
𝑤 ∈ 𝑊: ∶ # Weeks in a Year W = {1,2,3,4,5,6, … .52}
𝑆𝑅𝑁 and 𝑆𝑃𝑁 are the salaries per hour for RNs and PNs, respectively.
𝐻𝑖,𝑤 is the total working hours for nurse i in week w.
𝜆𝑂𝑇 penalty of overtime working hours
𝑅𝑠 is the required number of nurses for shift s.
Auxiliary Variables :
𝑡𝑖 : 𝑡𝑦𝑝𝑒 𝑜𝑓 𝑛𝑢𝑟𝑠𝑒 𝑖. 𝑡𝑖 = 1 𝑖𝑓 𝑅𝑁 𝑎𝑛𝑑 𝑡𝑖 = 0 𝑖𝑓 𝑃𝑁
Decision Variable
𝑥𝑖,𝑤,𝑑,𝑠 : Indicates whether nurse i is assigned to shift s (Day or Night) on day d of week
w. 1 if nurse is assigned to that shift and 0 if not assigned.
𝑂𝑖,𝑤 The number of overtime hours worked by nurse i in week w (i.e., hours beyond
42/week).
Objective Function:
𝐼
𝑤
𝑚𝑖𝑛 ∑ ∑ (𝑆𝑅𝑁 × 𝐻𝑖,𝑤 + 𝑆𝑃𝑁 × 𝐻𝑖,𝑤 + 𝜆𝑂𝑇 × 𝑂𝑖,𝑤 )
𝑖=1 𝑤=1
𝑂𝑖,𝑤 = max (0, 𝐻𝑖,𝑤 − 42)
𝐷
𝑆
𝐻𝑖,𝑤 = ∑ ∑ 𝑥𝑖,𝑤,𝑑,𝑠 × 12 ∀ 𝑖, 𝑤
𝑑
Constraints:
𝑠
(5)
Page 22 of 108
1. Shift Assignment: Each shift must have enough nurses to meet the required
staffing ratio
𝐼
∑ 𝑥𝑖,𝑤,𝑑,𝑠 ≥ 𝑅𝑠 ,
(1)
∀𝑤, 𝑑, 𝑠
𝑖
2. No Consecutive Shifts:
Prohibits:
A. Day & Night shift on the same day
𝑥𝑖,𝑤,𝑑,0 + 𝑥𝑖,𝑤,𝑑,1 ≤ 1, ∀𝑖, 𝑤, 𝑑
(2)
B. Night shift on Day 1 followed by a Day shift on Day 2
𝑥𝑖,𝑤,𝑑,1 + 𝑥𝑖,𝑤,𝑑+1,0 ≤ 1, ∀𝑖, 𝑤, 𝑑
(2)
C. Night shift on Sunday followed by a Day shift on Monday (two-week window
rule).
𝑥𝑖,𝑤,7,1 + 𝑥𝑖,𝑤+1,1,0 ≤ 1, ∀𝑖, 𝑤
(2)
3. Weekly Work Hours:
A. Nurses must work between 36 and 48 hours per week in one equation:
𝐷
𝑆
36 ≤ ∑ ∑ 𝑥𝑖,𝑤,𝑑,𝑠 × 12 ≤ 48,
𝑑
∀𝑖, 𝑤
(3)
𝑠
4. Having a minimum of two RNs and PNs in each shift :
𝐼
∑ 𝑡𝑖 × 𝑥𝑖,𝑤,𝑑,𝑠 ≥ 2,
∀𝑤, 𝑑, 𝑠
(4)
𝑖
𝐼
∑(1 − 𝑡𝑖 ) 𝑥𝑖,𝑤,𝑑,𝑠 ≥ 2,
𝑖
∀𝑤, 𝑑, 𝑠
(4)
Page 23 of 108
VI.2.2. AugmentedModel_Fairness
Parameters:
𝑖 ∈ 𝐼: 𝑁𝑢𝑟𝑠𝑒𝑠 𝑛𝑎𝑚𝑒𝑑 𝑖 𝑡ℎ𝑎𝑡 𝑏𝑒𝑙𝑜𝑛𝑔 𝑡𝑜 𝐼 = {𝑠𝑒𝑡 𝑜𝑓 𝑛𝑢𝑟𝑠𝑒𝑠}
𝑗 ∈ 𝐽: 𝑁𝑢𝑟𝑠𝑒𝑠 𝑛𝑎𝑚𝑒𝑑 𝑜𝑡ℎ𝑒𝑟 𝑡ℎ𝑎𝑛 𝑖 𝑡ℎ𝑎𝑡 𝑎𝑙𝑠𝑜 𝑏𝑒𝑙𝑜𝑛𝑔 𝑡𝑜 𝑖 = {𝑠𝑒𝑡 𝑜𝑓 𝑛𝑢𝑟𝑠𝑒𝑠}. 𝑖 ≠ 𝑗
maxDiff: the difference in total hours worked between any two nurses
6.Fairness Constraint(with two inequalities to avoid absolute value): These constraints
ensure that the difference in total hours worked between any two nurses is within the
maxDiff limit.
𝑊
𝑊
|∑ 𝐻𝑖,𝑤 − ∑ 𝐻𝑗,𝑤 | ≤ 𝑚𝑎𝑥𝐷𝑖𝑓𝑓
𝑤=1
∀𝑖, 𝑗 ∈ 𝐼, ∀𝑖 ≠ 𝑗
𝑤=1
(6)
90
In our code we chose 𝑚𝑎𝑥𝐷𝑖𝑓𝑓 = 24 hours
VI.2.4. AugmentedModel_Preferences
Parameter
𝜆𝑃𝑟𝑒𝑓 is a weighted penalty for assigning nurses to shifts they don't prefer.
Decision Variable
𝑝𝑖,𝑑,𝑠,𝑤 ∈ {1,2,3,4,5}: Preference score of nurse i for a given shift (5 = most preferred).
Reflects how much nurse i prefers a specific shift s on day d of week w. Used to
penalize less-preferred assignments.
Objective Function:
𝐼
𝑤
𝑚𝑖𝑛 ∑ ∑ (𝑆𝑅𝑁 × 𝐻𝑖,𝑤 + 𝑆𝑃𝑁 × 𝐻𝑖,𝑤 + 𝜆𝑂𝑇 × 𝑂𝑖,𝑤
𝑖=1 𝑤=1
𝐷
𝑆
+ ∑ ∑ 𝜆𝑃𝑟𝑒𝑓 × (5 − 𝑝𝑖,𝑑,𝑠,𝑤 ) × 𝑥𝑖,𝑤,𝑑,𝑠 )
𝑑=1 𝑠=1
Page 24 of 108
VI.2.5. SickLeaveModel
The integration of sick leave follows the same framework as the base model, such as
respecting work hour limits, mandatory rest periods, and minimum staffing levels.
VI.2.6. AnnualLeaveModel
Decision Variable
𝑙𝑒𝑎𝑣𝑒𝑖,𝑑,𝑠,𝑤 : Indicates whether nurse i is on leave during shift s on day d in week w. 1 if
on leave and 0 if not.
𝐹𝑢𝑙𝑙𝐷𝑎𝑦𝐿𝑒𝑎𝑣𝑒𝑖,𝑑,𝑤 : Indicates whether nurse i has a full day off (both Day and Night
shifts) on day d in week w. 1 if nurse is on leave for both shifts on day d of week w and 0
otherwise.
Constraints
1. No Work During Leave:
𝑥𝑖,𝑑,𝑠,𝑤 ≤ 1 − 𝑙𝑒𝑎𝑣𝑒𝑖,𝑑,𝑠,𝑤
2. Full-Day Leave Definition:
𝐹𝑢𝑙𝑙𝐷𝑎𝑦𝐿𝑒𝑎𝑣𝑒𝑖,𝑑,𝑤 ≤ 𝑙𝑒𝑎𝑣𝑒𝑖,𝑑,𝐷𝑎𝑦,𝑤
𝐹𝑢𝑙𝑙𝐷𝑎𝑦𝐿𝑒𝑎𝑣𝑒𝑖,𝑑,𝑤 ≤ 𝑙𝑒𝑎𝑣𝑒𝑖,𝑑,𝑁𝑖𝑔ℎ𝑡,𝑤
𝐹𝑢𝑙𝑙𝐷𝑎𝑦𝐿𝑒𝑎𝑣𝑒𝑖,𝑑,𝑤 ≥ 𝑙𝑒𝑎𝑣𝑒𝑖,𝑑,𝐷𝑎𝑦,𝑤 + 𝑙𝑒𝑎𝑣𝑒𝑖,𝑑,𝑁𝑖𝑔ℎ𝑡,𝑤 − 1
3. Maximum 3 Full-Day Leaves Over 4 Weeks:
7
4
∑ ∑ 𝐹𝑢𝑙𝑙𝐷𝑎𝑦𝐿𝑒𝑎𝑣𝑒𝑖,𝑑,𝑤 = 3
𝑑=1 𝑤=1
4. No More Than 2 Full-Day Leave Per Week:
7
∑ 𝐹𝑢𝑙𝑙𝐷𝑎𝑦𝐿𝑒𝑎𝑣𝑒𝑖,𝑑,𝑤 ≤ 2
𝑑=1
5. 4 Nurses on Leave per Shift:
22
∑ 𝑙𝑒𝑎𝑣𝑒𝑖,𝑑,𝑠,𝑤 ≤ 4
𝑖=1
VI.3 Model Implementation in Matlab
VI.3.1. BaseModel
Define Parameters:
· Set the number of weeks (weeks = 4), days (days = 7), shifts (shifts = 2), and hours
per shift (hoursPerShift = 12).
Page 25 of 108
· Set the number of nurses (numNurses = 22) and required nurses per shift
(requiredNurses = 6).
· Define the salaries for Registered Nurses (RN) (salaryRN = 6) and Practical Nurses
(PN) (salaryPN = 5).
·
Set the overtime penalty (overtimePenalty = 2.5) for hours worked beyond 42 hours.
· Set the fixed penalty (fixedPenalty = 3) for shifts assigned based on nurse
preferences.
·
Identify indices for RNs (rnIndices) and PNs (pnIndices).
Auxiliary Variable:
· Nurse Type Indicator (t_i): This auxiliary variable indicates the type of nurse i: 1 if
nurse i is a Registered Nurse (RN) and 0 if Practical Nurse (PN).
Decision Variables:
1. Shift Assignment Variable:
x(i,d,s,w): Binary decision variable where 1 means nurse i is assigned to shift s (Day or
Night) on day d in week w, and 0 means they are not assigned.
2. Overtime Variable:
overtime(i,w): Tracks overtime hours worked by nurse i in week w (penalizes hours
above 42 per week).
Expression for Hours Worked
1. For each nurse i and week w:
Calculate the total hours worked by the nurse across the entire week by summing all
their shift assignments (Day or Night): H(i,w) = hoursPerShift × sum of all shifts
assigned to nurse i in week w.
Objective Function (Minimize Cost):
1. Calculate the total cost of scheduling:
Initialize cost = 0.
For each nurse i and week w: Add the base salary for the nurse based on whether they
are an RN or PN and the total hours worked by the nurse.
Page 26 of 108
Add the overtime penalty if the nurse worked beyond 42 hours in that week.
The objective is to minimize the total cost.
Constraints:
1. Weekly Hours Constraints:
Ensure each nurse works between 36 and 48 hours per week:
·
hoursWorked(i,w) ≥ 36 (minimum)
·
hoursWorked(i,w) ≤ 48 (maximum)
2. Overtime Definition:
Any hours worked beyond 42 are considered overtime:
overtime(i,w) ≥ hoursWorked(i,w) - 42.
3. Shift Coverage:
Ensure that each shift (Day or Night) has at least 6 nurses scheduled:
sum ( all nurses assigned to shift s on day d in week w )≥ requiredNurses.
4. No Double Shifts (Day + Night on Same Day):
Ensure a nurse cannot be assigned both a Day and Night shift on the same day:
x(i,d,0,w) + x(i,d,1,w) ≤ 1
5. No Night to Day Shift Transition:
Ensure a nurse does not have a Night shift followed by a Day shift on consecutive days:
x(i,d,1,w) + x(i,d+1,0,w) ≤ 1 (for each nurse i, day d, and week w).
6. No Sunday Night to Monday Day Shift:
Ensure a nurse does not have a Sunday Night shift followed by a Monday Day shift:
x(i,7,1,w) + x(i,1,0,w+1) ≤ 1 (for each nurse i and week w).
7. At Least 2 RN and 2 PN per Shift:
Ensure there are at least 2 RNs and 2 PNs per shift:
Page 27 of 108
·
sum(nurses assigned to shift s on day d in week w for RNs) ≥ 2.
·
sum(nurses assigned to shift s on day d in week w for PNs) ≥ 2.
Solve the Optimization Problem:
1. Use integer linear programming solver (intlinprog) to minimize the total cost
while satisfying all constraints.
Check Feasibility:
1. If the solver does not find a feasible solution (exit flag is not 1), print a message
indicating that no feasible solution was found and ask to review constraints or
increase staff.
2. If a feasible solution is found (exit flag is 1), proceed with the solution.
Export Results to Excel:
1. Schedule: Export the nurse schedule to an Excel file. The schedule will contain
each nurse's assignments (Day or Night) for each shift.
2. Excel Format:
·
Column 1: Week Number.
·
Column 2: Day Number.
·
Columns 3 to N: Nurse names with their assigned shifts.
Print Final Cost and RN:PN Ratio
1. Print Total Scheduling Cost: Output the total scheduling cost, including base
salaries and overtime penalties.
2. Print RN:PN Ratio: For each shift, print the number of RNs and PNs assigned,
ensuring proper staffing balance.
Explanation of MATLAB Functions Used:
find: Finds indices that match a condition (e.g., RN vs PN).
optimvar: Defines decision variables (x(i,d,s,w) for shift assignments and overtime(i,w)
for overtime hours).
optimexpr: Used to define expressions for hours worked (hoursWorked(i,w)).
Page 28 of 108
optimproblem: Defines the optimization problem with the objective to minimize the total
cost.
optimconstr: Creates constraints such as weekly hours, shift coverage, and no double
shifts.
solve: Solves the optimization problem. Usage: [sol(Structure containing the optimal
values of decision variables (e.g., sol.x, sol.overtime)), fval(Final value of the objective
function (total cost)), exitflag(Status code (e.g., 1 means solution found, 0 means max
iterations reached, -1 means infeasible)), output(Struct with diagnostic information about
the solving process (e.g., number of iterations))] = solve(prob, 'Options', opts)
optimoptions: Sets solver options. Usage: 'intlinprog'(Specifies that it is using the integer
linear programming solver.), 'Display','off'(controls verbosity)
cell: Creates an empty cell array, which can store mixed data types (text, numbers, etc.)
cellstr: Converts a string array to a cell array of character vectors
sum: Sums the elements of an array along a specified dimension.
winopen: Opens a file in its default application (only works on Windows)
writecell: Writes a cell array to an Excel file. Usage: writecell(schedule, filename)
sprintf: Formats strings. Usage: sprintf('nurse_schedule_MSU7.xlsx')
winopen: Opens a file in the default app (Windows only). Usage: winopen(filename)
fprintf: Prints formatted output to the command window. Usage: fprintf('Total Cost =
%.2f', fval)
VI.3.2. AugmentedModel_Fairness
Define Supplementary Parameters:
1. Additional Fairness Limit:
maxDiff = 24 (Maximum allowed difference in total hours worked between any two
nurses in the entire schedule).
2. Parameters Retained from the Base Model:
Page 29 of 108
The remaining parameters such as weeks, days, shifts, hoursPerShift, numNurses,
requiredNurses, salaryRN, salaryPN, and overtimePenalty are the same as in the Base
Model.
3. Auxiliary Variable Retained from the Base Model:
The auxiliary variable t_i, representing the nurse type (RN or PN), is retained from the
base model.
4. Decision Variables Retained from the Base Model:
1. Shift Assignment Variable (x(i,d,s,w)):
Same as in the Base Model, this variable determines if nurse i is assigned to shift s, day
d, and week w.
2. Overtime Variable (overtime(i,w)):
Same as in the Base Model, this variable tracks overtime worked beyond 42 hours.
Calculated Hours Worked Retained From the
1. Hours Worked Expression:
○ same as the Base Model for calculating hours worked.
4.Redefined Objective Function :
1. Base Salary Calculation:
The Base Salary calculation remains the same as in the Base Model:
·
For RN: cost = cost + salaryRN * hoursWorked(i,w)
·
For PN: cost = cost + salaryPN * hoursWorked(i,w)
2. Overtime Penalty:
The overtime penalty calculation remains the same:
cost = cost + overtimePenalty * overtime(i,w)
3. New Fairness Penalty:
To ensure fairness, the model introduces a penalty based on the maximum difference in
total hours between nurses:
Page 30 of 108
For each pair of nurses i and j:
The total hours worked by each nurse across all weeks is calculated and stored as
totalHours(i).
The fairness constraints ensure that the difference in total hours worked between any
two nurses does not exceed maxDiff.
The fairness constraint is indirectly added to the objective function by minimizing the
total cost, including the overtime penalty and fairness penalties.
5.Constraints:
1. Weekly Hours Constraints Retained from the Base Model:
Nurses must work between 36 and 48 hours per week.
2. Overtime Constraints Retained from the Base Model:
Overtime is calculated for hours worked beyond 42.
3. Shift Coverage Retained from the Base Model:
Ensure requiredNurses are scheduled for each shift (Day or Night).
4. No Double Shifts (Day + Night on Same Day) Retained from the Base Model:
Prevent assigning a nurse to both Day and Night shifts on the same day.
5. No Night-to-Day Shift Transition Retained from the Base Model:
Prevent assigning a Night shift followed by a Day shift on consecutive days.
6. No Sunday Night to Monday Day Shift Retained from the Base Model:
Prevent assigning a nurse to both Sunday night and Monday day shifts.
7. At Least 2 RNs and 2 PNs per Shift Retained from the Base Model:
Ensure at least 2 RNs and 2 PNs are assigned to each shift.
8. New Fairness Constraint:
Page 31 of 108
The Fairness Constraint ensures no nurse's total hours worked in the entire schedule
differ from another nurse's total by more than maxDiff hours: Calculate totalHours(i) for
each nurse i, representing the total hours worked across all weeks.
Fairness Constraints:
·
totalHours(i)−totalHours(j)≤maxDiff
·
totalHours(j)−totalHours(i)≤maxDiff
This ensures that no nurse works significantly more or fewer hours than another,
promoting fairness.
Solve the Optimization Problem Retained from the Base Model:
Optimization Solution:
Use integer linear programming (intlinprog) to minimize the total cost while
satisfying the fairness constraint and other shift-related constraints.
Feasibility Check Retained from the Base Model:
Feasibility Check:
If the solver does not find a feasible solution (exit flag is not 1), output a message
suggesting to review constraints or increase staff.
If the solution is feasible, output "Feasible solution found!"
Export Results to Excel Retained from the Base Model:
1. Export the Schedule:
Write the schedule to an Excel file, where each nurse's shift (Day or Night) is indicated
for each day in each week.
The file also contains the nurse names for easy identification.
Print Final Cost and RN:PN Ratios Retained from the Base Model:
1. Print Final Cost:
Print the total cost (including salaries and overtime penalties).
2. Print RN:PN Ratios:
For each shift (Day and Night), print the RN:PN ratio to ensure proper staffing.
Page 32 of 108
3. Additional Fairness Gap :
The fairness gap is calculated as the difference between the maximum and minimum
total hours worked by any nurse:
Fairness Gap=max(totalHours)−min(totalHours)
This is output as the Fairness Gap, showing how balanced the shift allocation is.
Explanation of MATLAB Functions Used :
maxDiff: Maximum hours difference between any two nurses (24)
VI.3.3. AugmentedModel_Preferences
1. Define Supplementary Parameters:
1.Additional Penalty for Preferences:
fixedPenalty = 3 (a penalty for assigning nurses to less preferred shifts).
2. Additional Preference Scores :
preferenceScores = randi([1, 5], numNurses, days, shifts, weeks).
These scores represent each nurse's preference for shifts, where 1 is the least preferred
and 5 is the most preferred. The model will attempt to minimize the assignment of nurses
to shifts they prefer less.
Page 33 of 108
Figure 1: Nurse Preference Scores
Additional Decision Variables
1. Preference Scores Variable:
preferenceScores: A randomly generated set of preference scores (1-5) for each nurse,
shift, day, and week. This is used to calculate preference penalties in the objective
function.
Calculate Hours Worked
1. Hours Worked Retained from the Base Model:
Same as the Base Model, calculate the total hours worked by each nurse for each week.
Redefined Objective Function
1. Base Salary Calculation:
Same as in the Base Model, add base salaries for each nurse based on hours worked.
2. Overtime Penalty:
Same as the Base Model, add the overtime penalty for hours worked beyond 42 per
week.
3. Additional Preference Penalty :
For each nurse i, day d, and shift s:
Calculate the preference penalty for assigning a nurse to a shift based on their
preference score:
preferencePenalty=(5−preferenceScores(i,d,s,w))×fixedPenalty
Page 34 of 108
Add this penalty to the total cost:
cost=cost+preferencePenalty×x(i,d,s,w)
The model minimizes the preference penalty, aiming to assign nurses to shifts they
prefer more.
Constraints Retained from the Base Model:
Solve the Optimization Problem Retained from the Base Model
Solve the problem using intlinprog to find the optimal schedule that minimizes total
costs while meeting all constraints.
Check Feasibility Retained from the Base Model:
Feasibility Check: Same as in the Base Model, ensure the solution is feasible, otherwise
display a message indicating no feasible solution.
Export Results to Excel Retained from the Base Model:
Export to Excel: Write the schedule and preference scores to an Excel file for easy
access and review.
Print Final Cost and RN:PN Ratios Retained from the Base Model:
1. Print the Total Cost: Same as the Base Model, print the total cost, which now
includes preference penalties.
2. RN:PN Ratio: Same as in the Base Model, output the RN:PN ratio for each
shift.
Explanation of MATLAB Functions Used :
randint: Generates random integers in a specified range.
VI.3.4. SickLeaveModel
Define Parameters:
1. Other Parameters Retained from the Base Model:
Page 35 of 108
weeks, days, shifts, hoursPerShift, requiredNurses, salaryRN, and salaryPN are
similar to those in the Base Model.
2.
Additional Load Original Schedule from Excel :
scheduleFile = "nurse_schedule_MSU7.xlsx": The Excel file containing the original
nurse schedule.
Load Original Schedule:
1. Read the Schedule Table:
Load the data from the Excel file using readtable(), which converts it into a table T.
2. Extract Nurse Names:
Extract the nurse names from the table by accessing the column headers (columns 3 to
end), as they represent the nurse names.
3. Create the Original Shift Matrix:
x_original is a binary matrix representing the original schedule. It is created as a 4D
matrix:
x_original(i,d,s,w) = 1 if nurse i works shift s on day d of week w.
Otherwise, x_original(i,d,s,w) = 0 for no shift.
Populate the matrix based on the schedule in the table.
Identify Day-Off Indexes:
1. Identify the Start Global Day :
startGlobalDay = (weekOff - 1) * 7 + min(dayOffList): This computes the global day
number (counting from 1) where the days off start, based on the weekOff and
dayOffList.
2. Find the Nurse Index:
Find the index of the nurse (nurseOff) in the nurseNames list. This index will be used to
track and reschedule the shifts for that specific nurse.
Create Optimization Variables:
1. Define Decision Variables (x):
Page 36 of 108
○ Create an optimization variable x(i,d,s,w) where 1 means that nurse i
works shift s on day d in week w, and 0 means they do not.
2. Define Overtime Variable (overtime):
○ overtime(i,w) is introduced to track overtime worked by each nurse. It is
relevant for nurses who work beyond 42 hours per week.
Objective Function Retained from the Base Model:
1. Base Salary Calculation:
The objective is to minimize total cost, which includes:
Base salary: salaryRN for Registered Nurses and salaryPN for Practical Nurses.
Total cost is calculated by multiplying each nurse's total hours worked by their hourly
salary.
2. Overtime Penalty:
The total cost also includes overtime penalties for any nurse who works more than 42
hours in a week.
Constraints Retained from the Base Model:
1. Shift Coverage:
Ensure there are at least 6 nurses per shift (Day and Night) for each day and week.
2. Weekly Hours Constraints:
Ensure that each nurse works between 36 and 48 hours per week.
3. No Double Shifts (Day + Night):
Ensure that no nurse is assigned to both a Day shift and a Night shift on the same day.
4. No Night-to-Day Shift Transition:
Ensure that a nurse does not work a Night shift followed by a Day shift on consecutive
days.
5. No Sunday Night to Monday Day:
Prevent assigning a nurse to work a Sunday night shift followed by a Monday day shift.
6. No Consecutive 48-Hour Weeks:
Page 37 of 108
Prevent assigning a nurse to two consecutive weeks where they work 48 hours each.
Additional constraints:
7. Enforce Day Off :
For the nurse taking days off (identified by nurseIdx):
Ensure that they are not scheduled for any shifts on the days off listed in dayOffList for
the week weekOff:
·
x(nurseIdx, dd, 1, weekOff) = 0 (no Day shift)
·
x(nurseIdx, dd, 2, weekOff) = 0 (no Night shift)
8. Fix Prior Assignments :
For all days before startGlobalDay, fix the original assignments by setting the
constraint:
x(i,d,s,w) = x_original(i,d,s,w).
This prevents changes to shifts that have already been assigned before the nurse’s days
off.
Solve the Optimization Problem Retained from the Base Model:
Optimization Solver:
Use intlinprog to solve the integer linear programming optimization problem. The
objective is to minimize the total cost, while satisfying all the constraints.
Check Feasibility Retained from the Base Model:
Feasibility Check:
If the solver finds a feasible solution (exitflag == 1), proceed with the updated schedule.
If not, output an error message and stop the process.
Export Results to Excel Retained from the Base Model:
Export Rescheduled Shifts:
The newly optimized schedule is exported to a new Excel file with Scheduled Leave
(SL) marked for the nurse’s days off.
Additional Shift Replacement and Overtime Analysis :
Page 38 of 108
1. Replacement Analysis:
Identify which nurse(s) replaced the nurse on their days off:
For each day off (dayOffList), check which nurse(s) were assigned to cover the Day and
Night shifts.
Compare Hours Worked Before and After:
Calculate and compare the total hours worked by each nurse before and after the
rescheduling.
Output the difference in hours to show if any nurse worked more or fewer hours than
they originally did.
Explanation of MATLAB Functions Used :
readtable: Loads the original schedule from the Excel file into a table format.
VI.3.5. AnnualLeaveModel
Define Parameters
Common Parameters Retained from the Base Model
Define Optimization Variable
1. Leave Variable (leave(i,d,s,w)):
It is a binary variable indicating if nurse i is on leave during shift s on day d in week w
2. Full Day Leave Variable (fullDayLeave(i,d,w)):
Also, a binary variable indicating if nurse i is on leave for the full day.
Calculate Hours Worked Retained from the Base Model
1. Hours Worked:
Same as the Base Model, calculate the total hours worked by each nurse for each week.
Page 39 of 108
Objective Function Retained from the Base Model
1. Base Salary Calculation:
The objective is to minimize total cost, which includes:
Base salary: salaryRN for Registered Nurses and salaryPN for Practical Nurses.
Total cost is calculated by multiplying each nurse's total hours worked by their hourly salary.
2. Overtime Penalty:
The total cost also includes overtime penalties for any nurse who works more than 42 hours in a
week.
Constraints
A) Base Model Constraints :
1. Weekly Hours Bound:
Each nurse must work between 36 and 48 hours/week
2.
Overtime Definition:
Overtime is activated only if the nurse exceeds 42 hours/week
3. Shift Coverage:
Every shift on every day must have at least 6 nurses
4. One Shift per Day:
No nurse may be assigned to both Day and Night shifts on the same day
5. No Night → Day Transitions:
A nurse cannot work a Night shift followed by a Day shift on the next day
6. No Sunday Night → Monday Day:
Prevents shift overlap between weeks
7. Minimum RN and PN Coverage:
At least 2 RNs and 2 PNs per shift
B) Leave-Specific Constraints specific to the Annual Leave model
Page 40 of 108
1. No Work During Leave:
If a nurse is on leave during a shift, they must not be assigned work:
x(i,d,s,w) ≤ 1 - leave(i,d,s,w)
2. Full-Day Leave Logic:
A full day of leave is when a nurse is on leave for both day and night shifts
Three logical rules are enforced:
●
●
●
3.
fullDayLeave ≤ leave on Day shift
fullDayLeave ≤ leave on Night shift
fullDayLeave ≥ leave(Day) + leave(Night) – 1
Exactly 3 Full Days of Leave:
Each nurse must have exactly 3 full days off in the schedule:
sum(fullDayLeave for each nurse) == 3
4.
Max 4 Nurses on Leave per Shift:
No more than 4 nurses may be on leave for the same shift:
sum(leave(:,d,s,w)) ≤ 4
5.
Max 2 Full-Day Leaves per Week:
Each nurse can only take up to 2 full leave days per week:
sum(fullDayLeave(i,:,w)) ≤ 2
Solve the Optimization Problem (Same as Base Model)
Solve the problem using intlinprog to find the optimal schedule that minimizes total costs
while meeting all constraints.
Export Results to Excel:
1. Schedule Sheet:
●
Shows Day/Night shift for each nurse across all weeks
2. Leave Sheet:
●
Indicates:
Page 41 of 108
○
○
'Full Leave' if the nurse is off both shifts
'D' or 'N' if working a shift
3. Hours & OT Sheet:
●
Calculates and exports:
○ Total hours worked each week
○ Total overtime
○ Totals per nurse
Reporting and Visualization
1. Print the Total Cost: Same as the Base Model, print the total cost, which now includes
preference penalties.
2. RN:PN Ratio: Same as in the Base Model, output the RN:PN ratio for each shift.
3. Heatmap of Weekly Hours: Shows nurse workload per week (color-coded)
Explanation of MATLAB Functions Used
heatmap: Generates visual representation of nurse workload per week
VI.4 Optimization Solver and Algorithm Description
To address the nurse scheduling problem, a Mixed-Integer Linear Programming (MILP)
model was formulated, focusing on minimizing costs by considering salaries, overtime,
and, optionally, nurse preference penalties. The optimization was solved using
MATLAB’s intlinprog solver, which is well-suited for problems involving binary
decision variables, such as assigning nurses to shifts, along with linear objectives and
constraints.
The MILP approach is particularly effective for this problem due to the binary nature of
shift assignments—where a nurse either works a shift or does not—and the linearity of
both the cost function and constraints. The intlinprog solver from MATLAB’s
Optimization Toolbox was selected for its ability to efficiently handle such problems,
ensuring optimal solutions for complex scheduling tasks.
opts = optimoptions('intlinprog', 'Display', 'off');
[sol, fval, exitflag, output] = solve(prob, 'Options', opts);
Page 42 of 108
This solver configuration enables efficient computation of the optimal schedule while
maintaining all required operational and legal constraints.
Solver Overview: intlinprog
intlinprog is MATLAB’s built-in solver dedicated to solving MILP problems. It is tailored to
efficiently find optimal or near-optimal solutions for problems involving a mix of continuous and
integer variables. In the nurse scheduling context, the decision variables are all binary—
representing whether or not a nurse is assigned to a particular shift and the objective is to
minimize total staffing costs, while satisfying numerous scheduling and labor policy constraints.
The solver operates by transforming the scheduling model, which includes both an objective
function and multiple constraints, into a mathematical form that can be interpreted and solved by
optimization algorithms.
Internal Algorithmic Structure of intlinprog
To solve MILP problems, intlinprog uses a Branch-and-Bound framework enhanced with
cutting-plane methods, LP relaxation solvers, and heuristics. These methods are briefly
explained below:
1. Branch and Bound (B&B) Algorithm
This is the fundamental algorithm used by intlinprog for solving MILPs. The solver starts by
relaxing the integer constraints, solving a related Linear Programming (LP) problem in which the
variables can take on fractional values. If the solution to the LP relaxation violates the integer
constraints (as it typically does), the problem is then branched into two or more subproblems
where one of the integer variables is fixed to a certain value (e.g., 0 or 1 for binary variables).
This process continues recursively, creating a tree of subproblems. At each node, the solver:
Solves the LP relaxation,
Compares the result to the best-known integer solution (incumbent),
Prunes subproblems that cannot yield better solutions.
This branching continues until the optimal solution is found or time/effort limits are reached.
2. Cutting Planes
Cutting planes are used to improve the LP relaxation by removing fractional solutions that are not
feasible in the integer version of the problem. These cuts tighten the feasible region of the LP
without excluding any valid integer solutions. This helps the solver to converge more quickly to
an optimal integer solution, especially when the LP relaxation yields solutions that are very far
from integrality.
3. LP Solvers: Dual and Primal Simplex
At every node in the Branch-and-Bound tree, the solver needs to solve an LP problem.
MATLAB’s intlinprog uses either:
Page 43 of 108
The Dual Simplex Method, which is efficient for warm-starts and sparse constraint systems
(common in scheduling), or
The Primal Simplex Method, more suitable when the LP relaxation is already close to optimal.
The solver dynamically chooses the more appropriate method based on the characteristics of the
problem at hand.
Heuristic Techniques to Enhance Solver Performance
In addition to the exact algorithms, intlinprog uses several heuristic methods to improve
performance, particularly for large or complex problems. These heuristics do not guarantee
optimality but are designed to quickly find good quality feasible solutions that can guide or
accelerate the Branch-and-Bound process.
Common heuristics likely used by intlinprog include:
Rounding Heuristic:
After solving an LP relaxation, the solver rounds fractional values to the nearest integer. If the
resulting solution is feasible, it can be accepted as a candidate.
Feasibility Pump:
A heuristic that alternates between minimizing constraint violations and minimizing distance to
integrality. It seeks feasible integer solutions by iteratively “nudging” fractional variables to
binary values.
Diving Heuristic:
This strategy fixes one or more fractional variables to integer values and recursively resolves the
LP, diving into promising regions of the solution space.
Local Branching:
Once a feasible solution is found, this heuristic explores its local neighborhood by limiting how
many variables are allowed to change, looking for improvements within a smaller subset of the
total space.
Node Heuristics:
These are executed at selected nodes within the Branch-and-Bound tree to find better feasible
solutions early on, which can significantly reduce the number of branches that need to be
explored.
Together, these heuristics make intlinprog robust and practical for real-world applications like
workforce scheduling, where a balance between solution quality and computational efficiency is
essential.
Page 44 of 108
Relevance to the Nurse Scheduling Problem
The nurse scheduling model involves assigning 22 nurses to multiple daily shifts over a fourweek planning horizon, under several operational and regulatory constraints. These constraints
include minimum coverage per shift, mandated rest periods between shifts, fairness in total work
hours, and overtime penalties for specific nurse categories (e.g., PNs).
These requirements make the problem:
Highly combinatorial: Due to binary variables for every nurse, day, shift, and week,
Linear in structure: All constraints and cost terms are linear,
Binary-constrained: Decision variables must be either 0 or 1.
All these characteristics fall well within the scope of problems efficiently handled by MILP
solvers such as intlinprog.
VII. Results Analysis and Discussion
1. BaseModel
Table 4 presents the optimized weekly shift schedule for 22 nurses over a 4-week period,
with each row representing a specific day and each column corresponding to a nurse. The
letters 'D' and 'N' indicate assigned Day and Night shifts respectively, while blank cells
represent off-duty days. The schedule ensures balanced staffing, adheres to shift
constraints, and minimizes total cost and overtime.
The solver runtime on MATLAB averaged 24.78 seconds, indicating that the system can
generate optimized nurse schedules efficiently and is suitable for real-time or near realtime decision-making in hospital operations.
Page 45 of 108
Table 4: BaseModel schedule exported to Excel
Total Cost: 22980$
As shown in the Table 5 the minimum required RN:PN ratio per shift is 2:2, which is
strictly enforced as per the constraints. This means that for every shift (Day or Night),
there must be at least 2 Registered Nurses and 2 Practical Nurses. This ensures that the
staffing requirements are met and that the workload is evenly distributed across the two
types of nurses.
Table 5:BaseModel RN:PN ratio
Page 46 of 108
The chart below in Figure 2 visualizes the shift coverage for each day across all shifts
(Day and Night) over a four-week period. The green color gradient indicates the number
of nurses assigned to each shift, with the highest values represented by the brightest green
color. The required staffing of 6 nurses per shift is consistently met throughout the
schedule, as shown by the uniform coverage for each day.
Figure 2: BaseModel Heatmap
As shown below in Figure 2, form the pool of 22 nurses:
•
Minimum allowed (144 hours): 0 nurses
•
Below optimal range (<168): 2 nurses worked 156 hours
•
Exactly optimal (168 hours): 2 nurses
•
Above optimal (>168): 6 nurses worked 180 hours
•
Maximum allowed (192 hours): 12 nurses
So far, the distribution is feasible, but not optimal.
Page 47 of 108
Figure 3:BaseModel Total hours per month per nurse
2. AugmentedModel_Fairness
Table 6 presents the generated schedule, detailing the distribution of shifts among the
nursing staff. The solver runtime on MATLAB averaged 35.84 seconds, indicating that
the system can generate optimized nurse schedules efficiently and is suitable for real-time
or near real-time decision-making in hospital operations.
Page 48 of 108
Table 6:AugmentedModel_Fairness schedule exported to excel
Total Cost: 23430$ (More than 450$ from Model1)
Table 7: AugmentedModel_Fairness RN:PN ratio
As shown in the chart in Figure 4, all nurses are working within the acceptable range of
144 to 192 hours per month. The distribution of hours ensures that no nurse exceeds the
maximum allowed working hours, maintaining a fair and balanced workload across the
team.
Page 49 of 108
As illustrated in the Figure 4 below, all shifts are consistently covered with 6 nurses per
day, as required. This demonstrates that the staffing levels meet the necessary coverage
for both day and night shifts, ensuring that the unit's requirements are fully satisfied.
Figure 4:AugmentedModel_Fairness Heatmap
Moreover, the generated schedule, as shown in the Table 8, continues to meet the
minimum RN:PN ratio constraint of 2:2 for each shift. This ensures that the required
staffing levels for each shift are maintained while adhering to the established rules and
guidelines.
Page 50 of 108
Figure 5: AugmentedModel_Fairness Total working hours per month per nurse
Moving Forward, the Table 9 compares the number of shifts worked by each nurse across
the BaseModel and AugmentedModel_Fairness. As shown, the BaseModel has a slightly
more varied shift distribution, whereas the AugmentedModel_Fairness optimizes the
number of shifts across nurses more evenly, providing a more balanced workload.
Table 8: BaseModel Vs AugmentedModel_Fairness, Total working shifts per month per nurse
Page 51 of 108
Figure 6: BaseModel Vs AugmentedModel_Fairness Working Shifts
Table 9: Model1 Vs Model3 Fairness Gap
Model
Min shifts
Max shifts
Fairness Gap
(Shifts)
Fairness Gap
(Hours)
BaseModel
13
16
3 shifts
36 hours
AugmentedMo
del_Fairness
14
16
2 shifts
24 hours
As shown in Figure 6 and Table 10 above, the AugmentedModel_Fairness demonstrates
a highly equitable workload distribution, with all nurses working between 14 and 16
shifts over the 4-week period. This represents a maximum deviation of only two shifts
(24 hours), compared to a 3-shift (36-hour) disparity in the BaseModel. The fairness
constraint effectively minimized workload imbalances while still meeting all operational
requirements.
3. AugmentedModel_Preferences
Table 12 presents the generated schedule, detailing the distribution of shifts among the
nursing staff.
Page 52 of 108
The solver runtime on MATLAB averaged 18.55 seconds, indicating that the system can
generate optimized nurse schedules efficiently and is suitable for real-time or near realtime decision-making in hospital operations.
Table 10: AugmentedModel_Preferences schedule exported to excel
Total Cost: 22950 $ (less than Model1 by 30$)
As shown in the chart in Figure 7, all nurses are working within the acceptable range of
144 to 192 hours per month. The distribution of hours ensures that no nurse exceeds the
maximum allowed working hours, maintaining a fair and balanced workload across the
team.
Figure 7: AugmentedModel_Preferences Total working hours per month per nurse
Page 53 of 108
Note: The preference-based penalties were used in the optimization phase to demonstrate how
nurse satisfaction can be modeled and quantified. However, this preference model is not included
in the GUI implementation, as the hospital did not provide actual preference data.
4. SickLeaveModel
Scenario Analysis
On Week 3, Day 7, Nurse Amal requested a day off as shown in Table 11. Instead of
recreating the entire schedule from scratch, this model intelligently takes the original
schedule as input and preserves all assignments that occurred before Amal’s day off
(Weeks 1 through 3, Day 6).
Then, starting from Week 3, Day 7, it re-optimizes the rest of the schedule as shown in
Table 12 while:
● Ensuring Amal is off-duty on the requested day (highlighted in red).
● Maintaining all critical constraints, such as:
1. Minimum nurse coverage per shift.
2. Required number of registered nurses (RNs).
3. Weekly hour limits (36–48 hrs).
4. Rest rules (no night-to-day shift conflicts).
● It assigns other nurses to cover Amal’s shift on that day, ensuring full staff
without overloading any nurse beyond limits.
Page 54 of 108
Table 11: SickLeaveModel Current Schedule exported to excel
Table 12: SickLeaveModel Updated Schedule exported to excel
Total Cost: 22962 $ (less than Model1 Cost by 18 $)
Even after the rescheduling, the model remains feasible. The nurses are working within
the allowed range of hours as shown in Figure 8.
Page 55 of 108
Figure 8: exported to excel Total working hours per month per nurse
Table 13 shows how the number of worked shifts changed for each nurse after
rescheduling was done to accommodate Amal’s day off on Week 3, Day 7.
Table 13: BaseModel Vs SickLeaveModel Working Hours
BaseModel
SickLeaveModel
christine layla daoud marylin rita valeria habib pia mariacidra gael marita micheline antoinette amal wissam abdelhak hussein salam marwan jeandarc samir karavartalian
180
168 156
180 192 180 156
180
180 180 168
192
192
192 192
192
192
192
192
192
192
192
180
168 168
180 180 192 156
192
180 168 168
192
192
180 192
192
192
192
192
192
192
192
0
0
12
0
-12 12
0
12
0 -12
0
0
0
-12
0
0
0
0
0
0
0
0
•
Unchanged Shifts (Δ = 0): A total of 16 nurses (out of 22) had no change in the
number of total working shifts.
•
Increased Shifts (Δ = +1): 3 nurses worked 1 extra shift compared to the original
schedule:
Page 56 of 108
o
Daoud (expected: 13, actual: 14)
o
Valeria (expected: 15, actual: 16)
o
Pia Maria (expected: 15, actual: 16)
• Decreased Shifts (Δ = -1): 3 nurses had 1 fewer shift assigned:
o
Rita (expected: 16, actual: 15)
o
Gael (expected: 15, actual: 14)
o
Amal (expected: 16, actual: 15) (intentionally reduced due to the day-off request)
After rescheduling, the distribution of shifts among the 22 nurses remained balanced,
where only 14% of nurses experienced excessive workload changes (one extra shift).
This approach aligns with best practices in nurse scheduling, which emphasize
minimizing disruptions and maintaining equitable workloads to support nurse well-being
and patient care quality.
5. AnnualLeaveModel
The nurse scheduling tool successfully generated a four-week shift plan, integrating both
operational coverage and individual leave preferences while respecting regulatory constraints as
shown in Table 14.
Table 14: AnnualLeaveModel schedule ½ exported to excel
The sheet below in Table 15 outlines the base schedule, detailing each nurse’s assigned
shift per day.
Page 57 of 108
Table 15: AnnualLeaveModel schedule 2/2 exported to excel
This enhanced view overlays approved leave requests onto the scheduling framework:
“Full Leave” is shown when a nurse is off-duty for both day and night shifts.
The leave planning enforces:
•A maximum of 3 full leave days per nurse across the month.
•No more than 2 full-day leaves in a single week, to avoid concentrated absences.
•A strict cap of 4 nurses on leave per shift, preserving shift coverage and care quality.
The following heatmap provides a clear visualization of the weekly workload per nurse:
●
Dark blue (36 hrs) represents nurses scheduled at the minimum legal workload
often due to approved leave or workload balancing.
●
Green (48 hrs) indicates full weekly engagement, maximizing resource use.
●
The model successfully avoids overscheduling:
o
No nurse exceeds the 48-hour legal maximum.
o
Several nurses (e.g., Christine, Marylin, Pia Maria, Gael) have reduced
hours in some weeks, reflecting balanced workload distribution and fair
leave allocation.
This heatmap as shown in Figure 9 provides a clear visualization of the weekly workload
per nurse:
•Dark blue (36 hrs) represents nurses scheduled at the minimum legal workload — often
due to approved leave or workload balancing.
•Green (48 hrs) indicates full weekly engagement, maximizing resource use.
•The model successfully avoids overscheduling:
-
No nurse exceeds the 48-hour legal maximum.
Page 58 of 108
-
Several nurses (e.g., Christine, Marylin, Pia Maria, Gael) have reduced hours in
some weeks, reflecting balanced workload distribution and fair leave allocation.
Figure 9: AnnualLeaveModel Heatmap
6. MATLAB Decision Support Tool
This section elaborates on the GUI functionalities, detailed workflow, internal
computational mechanisms, user experience considerations, and the technical advantages
derived from its implementation.
Detailed GUI Functionalities and Workflow
1. Monthly Scheduling Optimization:
● Monthly schedule generation begins with user activation of the "Generate
Monthly Schedule" button (Figure 10).
Page 59 of 108
Figure 10
● Upon activation, the GUI collects and compiles critical operational parameters
including the number of nurses, RN/PN ratios, hourly salary rates, required nurse
counts per shift, and overtime penalty criteria.
● The collected inputs are systematically fed into the "BaseModel" optimization
engine, utilizing MILP methodologies to determine an optimal schedule
configuration. This optimization seeks to minimize the total operational cost,
balancing salaries and potential overtime expenses while strictly adhering to
regulatory and operational constraints such as shift coverage, consecutive shift
restrictions, RN/PN ratios, and weekly working hour limits.
● The optimization outcome is visually delivered through an automated Excel
export, clearly delineating daily shift assignments (day/night) for each nurse,
enabling immediate administrative review and operational deployment.(figure 11)
Page 60 of 108
Figure 11
2. Daily Scheduling Integration:
● The GUI provides a targeted daily scheduling feature allowing users to input
specific week and day parameters through dedicated input fields to generate a
precise daily roster.
● Upon user activation via the "Generate Daily Schedule" button, the system
retrieves and displays the targeted day's shift assignments from the previously
optimized monthly schedule (Figure 12).
Page 61 of 108
Figure 12
● This functionality includes built-in validation ensuring that the daily scheduling
request is contingent upon prior monthly scheduling, thereby maintaining
operational integrity and consistency across scheduling processes.
● Daily schedules appear through an interactive dialog interface, providing detailed
shift information facilitating immediate operational decision-making and resource
management(figure 13)
Page 62 of 108
Figure 13
3. Advanced Sick Leave Integration and Re-optimization:
● The GUI incorporates sophisticated mechanisms for dynamic sick leave
management, accessible through the "Enable Sick Leave" checkbox (Figure 14).
● Users input precise sick leave details, including nurse identification, specific
week, and the corresponding days off, directly into the GUI.
● Activation of this feature triggers "SickLeaveModel" (the disruption model),
which intelligently recalculates the original schedule to accommodate the
specified sick leave, while simultaneously ensuring continuous compliance with
operational coverage and regulatory requirements.
● The resulting schedule adjustments are systematically generated and exported to
Excel, clearly documenting changes and ensuring effective administrative
oversight and communication.
Page 63 of 108
Figure 14
4. Fairness Constraint Management:
● Fairness constraints are integrated through a specific toggle control, enabling
users to define and manage the maximum allowable difference in working hours
across nursing staff (Figure 6).
● User-defined fairness parameters activate "AugmentedModel_Fairness,"
embedding fairness constraints directly within the MILP framework, enforcing
equitable distribution of shifts and workload across all nurses.
● The outcome ensures minimal deviation in workload among staff, proactively
addressing nurse fatigue, mitigating burnout, and aligning scheduling practices
with organizational standards for employee well-being.
● Fairness-compliant schedules are transparently presented through Excel reports,
enabling straightforward validation and operational review by administrative
staff.
GUI Design and User Experience Enhancements
Page 64 of 108
● The GUI structure comprises clearly delineated panels dedicated to distinct
functionalities (Monthly Scheduling, Daily Scheduling, Sick Leave Management,
and Fairness Constraints), significantly enhancing user navigation and operational
clarity
● The implementation of consistent visual elements (color schemes, button designs,
and toggles) and strategically positioned controls fosters intuitive user interaction,
minimizes potential errors, and streamlines scheduling tasks.
● Institutional branding elements of LAU Medical Center are embedded within the
GUI, promoting professional appearance and user alignment with organizational
standards.
● Interactive feedback mechanisms, including immediate success confirmations,
informative dialog boxes, and explicit error prompts, facilitate efficient user
interaction, enhance operational confidence, and provide real-time support for
task completion
Technical Advantages and Operational Impacts
● Enhanced Operational Efficiency: Automated MILP optimization reduces
manual workload significantly, freeing administrative resources for strategic
tasks.
● Equitable Workload Management: Advanced fairness constraints
systematically balance nurse workloads, enhancing job satisfaction, reducing
stress, and supporting retention.
● Real-Time Adaptability: Immediate response capabilities to operational changes
such as unexpected sick leaves enable dynamic and resilient scheduling practices.
● Ease of Accessibility: User-centric GUI design minimizes the technical expertise
required, broadening accessibility and adoption across clinical and administrative
personnel.
● Integrated Documentation and Compliance: Automated, structured Excel
exports ensure thorough documentation, regulatory compliance, and streamlined
administrative record-keeping.
Thus, the MSU7 Nurse Scheduling Tool’s MATLAB-based GUI represents a robust,
technologically sophisticated, and operationally effective solution for nurse scheduling,
significantly advancing workforce management capabilities at LAU Medical Center.
Page 65 of 108
Figure 15
VIII. Scenario Analysis: System Infeasibility with 20 Nurses
Effective workforce scheduling systems must be designed not only for optimal efficiency
under normal operating conditions but also for resilience in the face of unexpected
disruptions. One such disruption, commonly encountered in healthcare environments, is a
sudden reduction in available personnel due to factors such as resignation, disciplinary
suspension, or unplanned medical leave. In this scenario, we examine the consequences
of losing two nurses—specifically, one Registered Nurse (RN) and one Practical
Nurse (PN)—from the staffing pool. This change reduces the number of available nurses
from the standard 22 to just 20 for the entire monthly planning horizon.
Page 66 of 108
Although this drop may appear minor in absolute numbers, its effects on the overall
feasibility of the nurse scheduling system are significant. This section presents a detailed
analysis of how this reduced workforce impacts the system's ability to meet mandatory
staffing requirements, satisfy regulatory constraints, and deliver a feasible schedule
without violating hard rules.
VIII.1 System Demand and Shift Requirements
The MSU7 scheduling model operates on a 4-week planning horizon, during which
nurses are assigned to cover two 12-hour shifts per day, referred to as the day shift and
the night shift. Each week contains 7 calendar days, and thus the full planning horizon
spans:
4 weeks × 7 days/week × 2 shifts/day = 56 shifts
Each of these 56 shifts must be staffed by a minimum of 6 nurses, as mandated by
institutional policy. This fixed coverage requirement ensures that the unit maintains
baseline operational safety, quality of care, and nurse-to-patient ratios. Therefore, the
total number of individual shift assignments (or "nurse-shifts") required to
successfully complete the schedule is calculated as:
56 shifts × 6 nurses per shift = 336 nurse-shifts required per month
This value represents the absolute minimum workload needed to maintain hospital
operations. It does not yet account for additional critical constraints such as minimum
RN/PN mix, daily rest rules, or fairness requirements—each of which adds complexity to
the problem and tightens the solution space.
VIII.2 Available Capacity with 20 Nurses
To assess whether 20 nurses are sufficient to cover the required workload, we must
analyze their collective capacity under existing labor regulations. According to policy, a
nurse may work a maximum of 48 hours per week. Given that each shift is 12 hours
long, this translates to:
48 hours/week ÷ 12 hours/shift = 4 shifts per nurse per week
Over the span of 4 weeks, each nurse may therefore be assigned up to:
4 shifts/week × 4 weeks = 16 shifts per nurse
Page 67 of 108
Multiplying this capacity across all 20 nurses yields the maximum system output under
ideal conditions:
20 nurses × 16 shifts per nurse = 320 shifts available
This means that, even in the most optimistic scenario where every nurse works at the
upper legal limit, the total number of nurse-shifts available falls short of the demand:
336 required nurse-shifts − 320 available nurse-shifts = 16 shift shortfall
This 16-shift deficit presents a clear mathematical infeasibility.
VIII.3 Why the Shortage Cannot Be Absorbed
While a shortfall of 16 shifts may seem minor on the surface, it becomes an
insurmountable obstacle when considered alongside the system's rigid scheduling
constraints. These include:
•
•
•
•
Skill mix enforcement: Each shift must have a minimum of 2 Registered
Nurses and 2 Practical Nurses, ensuring that both clinical and supportive care
tasks are adequately covered. Losing one RN and one PN reduces the ability to
meet this requirement consistently across all shifts.
Rest regulations: Nurses may not be assigned both day and night shifts on the
same calendar day, nor may they be assigned a night shift followed by a day
shift on the next day, which could lead to fatigue and jeopardize safety.
Weekly hour constraints: Each nurse must work at least 36 hours/week
(equivalent to 3 shifts) and no more than 48 hours/week, limiting the scheduler's
ability to vary individual workloads excessively to fill gaps.
No buffer capacity: With only 20 nurses and all working at their maximum, the
system has zero flexibility to accommodate last-minute absences, emergency
reassignments, or balancing of workload among staff.
Due to these non-negotiable constraints, it is not mathematically or operationally
possible to generate a feasible schedule that meets all requirements using only 20 nurses.
VIII.4 Solver Behavior and Model Response
When the MSU7OVERTIME42 model is run in MATLAB with a staff count of 20, the
optimization solver (intlinprog) is unable to find a valid solution that satisfies all
constraints. The solver terminates and returns an exit flag not equal to 1, which is the
standard indicator of infeasibility in constrained optimization problems. This means that
no combination of shift assignments, no matter how aggressive, can legally and feasibly
cover all required shifts while complying with the rules encoded in the model.
Page 68 of 108
This outcome is not a limitation of the software—rather, it reflects the underlying
infeasibility of the problem itself when staff levels fall below a critical threshold.
VIII.5 Conclusion and Recommendations
The analysis above clearly demonstrates that a total nurse count of 20 is insufficient for
producing a feasible monthly schedule under the MSU7 optimization model. Even with
overtime permitted and all nurses scheduled to their maximum allowable workload of 48
hours per week, the model falls short by 16 shifts.
This finding underscores the fragility of staffing systems that operate without
redundancy. The removal of just one RN and one PN—less than 10% of the workforce—
renders the model unsolvable, leading to coverage gaps and potential regulatory
violations.
To ensure operational stability, legal compliance, and patient safety, the scheduling
system requires a minimum of 22 nurses to function effectively. Staffing below this
threshold is not recommended unless constraints are relaxed, temporary staff are added,
or coverage requirements are reduced—each of which involves trade-offs in either cost,
quality, or risk.
Output:
No feasible solution. Review constraints or increase staff.
IX. Break-Even Analysis of Scheduling Costs
To evaluate how staffing levels influence the overall cost of the schedule, a sensitivity
analysis was conducted by increasing the number of Practical Nurses (PNs) beyond the
base configuration of 22 nurses (11 Registered Nurses and 11 Practical Nurses) as shown
in Table 16. The objective was to identify the breakeven point, as shown in Figure 16
where the system achieves maximum efficiency at minimum cost, while still satisfying
all operational constraints.
Page 69 of 108
Table 16: Models Costs
Figure 16: Break-even Point
The analysis revealed that the optimal staffing level is reached at 26 total nurses, where
the monthly scheduling cost is minimized at $20,964. This represents a notable reduction
compared to the baseline cost of over $23,000 with 22 nurses.
This cost reduction is primarily attributed to improved shift assignment flexibility,
allowing the model to satisfy constraints with less reliance on costly overtime.
However, when the number of nurses is increased beyond 26, the cost begins to rise
again. This is likely due to underutilization, where surplus nurses are not consistently
assigned to shifts, leading to inefficiencies and unnecessary overhead in the schedule.
Therefore, 26 nurses represent the cost-optimal staffing configuration. It minimizes
expense while maximizing coverage and constraint satisfaction. Increasing staff beyond
this point leads to diminishing returns and inefficient use of resources.
Page 70 of 108
The graph in Figure 17 and Table 17 illustrates the number of working shifts per month
assigned to each Registered Nurse (RN) under varying total nurse counts, ranging from
22 to 29 nurses. In each case, the additional nurses are Practical Nurses (PNs).
Figure 17: Total number of working shifts per month per RNs
Table 17: Total number of working shifts per month per RNs
At the baseline level of 22 nurses, RNs are assigned between 14 to 16 shifts per month,
reflecting a high workload due to limited staffing flexibility. The system heavily depends
on RNs to meet both shift coverage and skill mix constraints, leading to uneven and
demanding schedules.
As the number of PNs increases to 23–25 nurses, a moderate decline in RN workload is
observed. However, the distribution remains relatively uneven, with some RNs still
experiencing high shift loads. This suggests that the added capacity begins to ease
scheduling pressure but is not yet sufficient to create a balanced workload.
At 26 nurses, the model achieves a significant shift: RN workloads drop and stabilize at
12 shifts per month across all RNs, indicating a uniform and equitable distribution. This
Page 71 of 108
aligns with the cost-optimal result from the previous analysis and confirms that the model
has reached an ideal balance. The system becomes flexible enough to assign more shifts
to PNs — who are less costly — without compromising coverage or RN-to-PN ratios.
This also allows better integration of leave constraints and reduces reliance on RN
overtime.
Beyond 26 nurses, the RN workload remains stable and low, but does not decrease
further. This confirms that the additional PNs offer workload stability, but no further
efficiency gains, supporting the notion of diminishing returns beyond the optimal point.
Moreover, the graph in Figure 17 and Table 17 illustrates the number of monthly working
shifts assigned to each Practical Nurse (PN) under different total staffing configurations
ranging from 22 to 29 nurses, where additional staff are exclusively PNs.
Figure 18Total number of working shifts per month per PNs:
Table 18:Total number of working shifts per month per PNs
At 22N and 23N, nearly all PNs are consistently assigned 16 shifts, the maximum
permissible under legal working hours.
There is no variation — no flexibility — and no buffer. The system is fully stretched,
relying on every PN at full capacity to cover the schedule.
With 13 PNs at 24N, the system begins to ease slightly. Some PNs drop to 15 or 14
shifts, indicating early signs of load redistribution. However, over-assignment is still
prevalent, and fairness is limited. Capacity is improving, but imbalances still dominate.
Page 72 of 108
A more varied pattern emerges at 25N. While some PNs still work up to 16 shifts, others
are assigned 12 to 14 shifts. This reflects the model’s growing ability to distribute
workload more fairly across the team. This is the first real shift toward balanced
scheduling, signalling that the system is gaining flexibility.
At 26N and 27N, these configurations mark a significant improvement. A large portion of
PNs are now assigned the ideal 12 shifts, while the rest fall between 12 and 13.
The system reaches a state of functional balance — workload is distributed fairly, and no
PN is overworked. This is the sweet spot: high fairness, high efficiency, no overassignment.
At 28N, the system achieves perfect equity: all PNs are assigned exactly 12 shifts.
There is no deviation across the board. Every nurse shares the load equally, and the
model satisfies all constraints without burdening anyone.This is the optimal configuration
in terms of fairness. A fully equitable, fatigue-free workforce model.
Interestingly, at 29N, a few PNs are once again assigned 13 shifts. While this remains
within a safe workload range, it suggests the system is beginning to redistribute shifts
unevenly again — possibly to improve coverage elsewhere. Overstaffing may lead to
model inefficiencies, where fairness gives way to internal optimization logic.
The shift assignment table offers more granularity than the earlier RN workload graph,
allowing us to observe how individual RN workloads evolve as PN capacity increases
and to assess the system’s ability to balance coverage with fairness.
At 22N (11 RNs + 11 PNs) RN workloads range from 14 to 16 shifts. All nurses exceed
the 12-shift target, with differences of +3. This reflects a highly constrained system,
where the model relies heavily on RNs to meet shift coverage and skill mix requirements.
Fairness is low, and no buffer exists to absorb leave or rest needs.
At 23N, the gradual addition of PNs, minor workload relief emerges. Some RNs work 12
shifts, but the majority remain above target.
At 24-25N, this configuration marks transition point, all RN are assigned 12 shifts
(Diff=0). The model begins to distribute shifts more equitably, and no RN is significantly
overburdened.
Fairness improves, and the system starts to meet both coverage and equity goals.
At 26N, also all nurses are assigned exactly 12 shifts, so no overtime is incurred, and the
schedule is both legally compliant and operationally optimal. And this remains with 78
and 28N. at 29N, some work 13 shifts that that might be due to the reallocation of shifts
based on on internal constraint logic and possible optimize the PN usage elsewhere
Across configurations from 22N to 29N, the shift assignments for Practical Nurses (PNs)
reveal a clear evolution in workload distribution, system flexibility, and overall
efficiency.
Page 73 of 108
At 22N, all PNs are assigned 16 shifts, which corresponds to the maximum allowable
workload without overtime. While the system remains legally compliant, it operates
under tight constraints, fully relying on every PN to meet demand with no scheduling
flexibility.
At 23N, no relief is observed — all PNs still receive 16 shifts, indicating that the
additional staff had no impact on load distribution.
By 24N, minor improvements appear as some PNs are assigned 15 shifts, showing early
signs of load redistribution. However, the imbalance persists, and PNs remain overassigned.
At 25N, a more noticeable shift begins, with several PNs receiving 14 or fewer shifts,
marking the system’s first step toward flexible and balanced scheduling.
A major change occurs at 26N and 27N, where a significant portion of PNs are assigned
12 shifts, aligning with the target workload. This indicates the system has gained enough
capacity to start assigning shifts fairly and sustainably.
At 28N, this balance is fully achieved — all PNs are assigned exactly 12 shifts,
representing perfect workload equity with no overload or underuse.
Interestingly, at 29N, a slight increase is observed again, with some PNs being assigned
13 shifts.
X.
B/C Analysis
X.1. Benefits
The nurse scheduling optimization tool developed for LAU Rizk Hospital introduces a significant
improvement in the way staff schedules are created and managed. It enhances efficiency,
promotes fair workload distribution, ensures compliance with healthcare staffing standards, and
contributes to improved care quality. Each of these aspects provides recurring value to hospital
operations, staff well-being, and patient outcomes.
Breakdown of Benefits:
1. Time Saved from Manual Scheduling
Manual scheduling of nurses can be tedious and time-consuming, especially when managing
multiple shifts across several weeks. The tool automates this process, drastically reducing the
time required to generate schedules and freeing up administrative staff for more strategic tasks.
2. Reduced Burnout and Improved Work-Life Balance
The tool ensures that nurses are not overloaded with shifts, respects mandatory rest periods, and
avoids fatiguing patterns such as consecutive night-to-day shifts. This contributes to reduced
burnout, better mental and physical well-being, and potentially lower absenteeism.
3. Better Staff Utilization
Page 74 of 108
By distributing shifts fairly across the nursing team and minimizing overtime, the tool ensures
more efficient use of available human resources. It also maintains the appropriate balance
between Registered Nurses (RNs) and Practical Nurses (PNs), which is critical for maintaining
both cost-effectiveness and quality of care.
4. Enhanced Quality of Patient Care
With consistent coverage of at least six nurses per shift, including both RNs and PNs, the tool
helps ensure that no shift is understaffed. This supports safe nurse-to-patient ratios and allows
nurses to provide attentive, timely, and high-quality care.
X.2. Costs
The tool has been designed with efficiency and accessibility in mind, allowing for deployment
without introducing financial burden or technical complexity.
1. Tool Development Cost
•
Cost: None
•
Rationale: The tool was developed internally by the student team using universityprovided software and computing resources. There were no licensing fees or external
development costs involved.
2. Operational Cost
•
Cost: Negligible
•
Rationale: The tool runs on standard computers, requires no paid software or server
infrastructure, and only minimal staff input for data entry. It can be operated seamlessly within
existing hospital workflows.
This solution represents an effective, low-barrier, and scalable approach to digital transformation
in healthcare operations. It can serve as a model for other departments and institutions aiming to
optimize workforce management through intelligent automation.
XI. Design Impacts
In evaluating the robustness and practical value of the nurse scheduling models, we assessed them
through the lens of key system quality attributes, often referred to as “-ilities.” These attributes
reflect the system's ability to meet both functional and non-functional requirements in real-world
applications. For this project, which focuses on ensuring fairness, minimizing costs, and adapting
to dynamic hospital environments, the following four “-ilities” emerged as the most critical:
Flexibility: The nurse scheduling model excels in flexibility, as it can accommodate a broad
range of staffing levels (from 22 to 29 nurses) and adapt to various operational constraints,
including RN/PN ratios, mandated rest periods, and leave policies. This flexibility ensures that
the model remains operational under both routine and emergency scenarios, with the ability to
process real-time updates seamlessly without the need for reconfiguration. As a result, the model
supports the evolving needs of the hospital and its staff.
Page 75 of 108
Equitability: Fairness is a foundational element of the model’s design. By enforcing constraints
that limit workload disparities and promote balanced shift assignments, the system ensures
equitable treatment of all nurses. This approach enhances team morale, reduces fatigue, and
supports the long-term well-being of the staff, which is critical factors for nurse retention and
overall scheduling sustainability. In essence, the model fosters a workplace environment that
prioritizes fairness and equity, which in turn strengthens the organizational culture.
Efficiency: The model demonstrates exceptional efficiency in optimizing workload distribution
while minimizing operational costs. By reducing unnecessary overtime and evenly distributing
shifts, the system ensures that staffing requirements are met without overburdening the team or
incurring excessive financial costs. This makes the model especially beneficial for hospitals
operating with limited budgets and high coverage demands, offering a balance between resource
allocation and cost-effectiveness.
Adaptability: Designed with future needs in mind, the scheduling system is highly adaptable.
Whether incorporating nurse preferences, updating fairness policies, or adjusting to changes in
shift structures, the model can easily be reconfigured to accommodate new requirements. This
adaptability allows the system to remain relevant as the hospital’s needs evolve, making it
suitable for deployment across different departments or for future scalability without requiring
significant foundational changes.
Together, these four “-ilities” underscore the strength of the proposed scheduling model as more
than just an optimization tool. The system stands as a comprehensive decision-support platform
that seamlessly integrates operational efficiency with human-centered fairness, making it a robust
solution for real-world hospital settings.
XI.1. Compliance with Standards, Codes and Constraints
Compliance of Our Models with the Standards, Codes, and Constraints
The nurse scheduling models developed for the MSU7 unit at LAU Rizk Medical Center are fully
compliant with both the local standards and global healthcare regulations, ensuring that the
staffing process adheres to ethical, operational, and legal requirements. The models have been
carefully designed to incorporate the key standards, codes, and constraints discussed at the
beginning of this report, with a focus on enhancing staffing efficiency while ensuring fair
working conditions for the nursing staff.
1. Shift Assignment and Nurse-to-Patient Ratios
The scheduling models meet the essential staffing requirements set by both national regulations
and global healthcare standards, including the Minimum Nurse-to-Patient Ratio. Each shift is
staffed with at least six nurses, including no fewer than two Registered Nurses (RNs) and two
Practical Nurses (PNs), ensuring that the required ratio is maintained throughout the schedule.
This meets the standards set by the Ministry of Public Health, Lebanon, and aligns with
recommendations from the International Council of Nurses (ICN) and the World Health
Organization (WHO).
Page 76 of 108
2. Weekly Working Hours and Overtime Constraints
To comply with labor regulations, the models enforce a Weekly Work Hour Constraint ensuring
that each nurse works between 36 and 48 hours per week, in accordance with Lebanese labor
laws and ICN guidelines. Any overtime hours worked beyond the 42-hour weekly threshold are
penalized, adhering to the established overtime pay regulations. This structure reduces the risk
of nurse fatigue and supports the overall well-being of the nursing staff, in line with
international best practices for fatigue management.
3. Consecutive Shifts and Rest Periods
The models strictly adhere to the constraints preventing consecutive shifts and ensuring
adequate rest periods for nurses. These constraints include:
•
•
•
Preventing nurses from working both day and night shifts on the same day.
Ensuring that there is sufficient rest between shifts, including mandatory rest between a
night shift and the following day shift.
Preventing night-to-day shift transitions within a 24-hour window, specifically
prohibiting night shifts on Sunday followed by day shifts on Monday.
These constraints are in full compliance with the ICN guidelines, which aim to protect nurse
health and ensure safe working conditions.
4. Fairness and Nurse Preferences
The Fairness-Augmented Model addresses workload imbalances by ensuring that the difference
in total hours worked between any two nurses does not exceed a predefined threshold, thus
promoting fairness in workload distribution. This model adheres to the ICN’s principles of
equitable workload distribution, which advocate for fair treatment of nursing staff to reduce
burnout and improve job satisfaction. The Preference-Augmented Model further aligns with the
ICN’s ethical standards, ensuring that nurses' preferences for shifts are taken into account while
still maintaining operational efficiency.
5. Leave Management
The models also comply with legal and organizational requirements related to leave
management. The Sick Leave Model ensures that a nurse’s sick leave request does not disrupt
staffing coverage, while maintaining compliance with working hour limits and shift coverage
requirements. Similarly, the Annual Leave Model respects the maximum number of full days
off, with up to three full days of leave per nurse, and limits leave to a maximum of four nurses
per shift. These features help the hospital comply with internal staffing policies and ensure that
staffing levels meet the required standards even during periods of planned or unplanned leave.
Page 77 of 108
6. Staffing Flexibility and Adaptability
To ensure continuous compliance with staffing needs and legal constraints, the models
incorporate dynamic adjustments in response to sick and annual leave, ensuring that shifts are
re-optimized without violating key constraints such as nurse-to-patient ratios, weekly working
hours, and overtime regulations. This adaptability meets the real-world operational needs of
the MSU7 unit and enhances the flexibility of the scheduling process, all while adhering to
ethical staffing guidelines.
XII. Limitations
While the nurse scheduling system developed for this project effectively handles several critical
constraints, there were a few limitations that impacted the results.
1. Consecutive 48-Hour Work Limitation: One of the key constraints in the model was to
prevent nurses from working consecutive 48-hour shifts. Unfortunately, when we
attempted to enforce this constraint, the solver returned infeasible solutions. Despite
adjusting various parameters and exploring different solver configurations, it was not
possible to fully enforce this rule within the current model. This limitation highlights the
challenge of balancing strict operational constraints with the available staffing
resources, especially when attempting to maintain feasibility across all constraints.
2. Annual Leave Constraints: Another limitation arose in the annual leave model,
specifically regarding the constraint that nurses should be allowed at least three full
days of leave within the four-week period. Initially, this constraint was formulated as
"less than or equal to 3 full days of leave," aiming to provide flexibility. However, this
formulation resulted in infeasibility within the solver, as the system failed to assign
leave to any nurses in many cases. To resolve this, we modified the constraint to allow
exactly three full days of leave per nurse, ensuring that the model could run without
infeasibility errors. While this adjustment provided a workable solution, it reduced
flexibility by restricting leave to exactly three days, rather than offering some leeway.
3. Sick Leave Constraints: The sick leave model was another area where functionality was
limited. Currently, the system supports sick leave for only one nurse at a time, meaning
it can accommodate a nurse taking several days off within a week but cannot handle
multiple nurses taking sick leave simultaneously. This limitation arose due to the way
the model was structured, which only allows for dynamic scheduling adjustments for a
single nurse at a time. Extending the model to handle multiple nurses taking sick leave
at once would require further modifications to the constraints and scheduling logic,
making it more complex.
Page 78 of 108
XIII. Conclusion
This report presented the development of an advanced nurse scheduling decision support system
tailored for the MSU7 unit at LAU Medical Center. By leveraging Mixed-Integer Linear
Programming (MILP), the system successfully generates cost-efficient, regulation-compliant
schedules that address key operational challenges such as shift coverage, RN/PN ratios, legal
hour constraints, and staff workload balance.
Beyond the foundational model, the project introduced augmented versions that enhance fairness,
integrate nurse preferences, and respond dynamically to disruptions such as sick and annual
leave. The MATLAB-based GUI further transformed the system into a practical, user-friendly
tool accessible to hospital administrators without technical expertise.
Performance evaluations demonstrated the model’s effectiveness, with consistent compliance to
all constraints, balanced workloads, and optimized costs. Moreover, an average runtime of 24.78
seconds confirms the system’s computational efficiency and real-time applicability.
Ultimately, this project provides a scalable and intelligent scheduling framework that improves
nurse satisfaction, reduces administrative burden, and enhances the overall quality of patient care.
Future work may explore integration with hospital information systems and the incorporation of
predictive analytics to anticipate staffing needs based on patient flow forecasts.
XIV.
References
American Nurses Association. (n.d.). Healthy Nurse, Healthy Nation™. Retrieved from
https://www.healthynursehealthynation.org/
American Nurses Association. (n.d.). Navigate Nursing. Retrieved from
https://www.nursingworld.org/practice-policy/work-environment/
British Columbia Nurses' Union. (n.d.). Collective Agreements. Retrieved from
https://www.bcnu.org/about-bcnu/collective-agreements
Chen, P.-S., & Zeng, Z.-Y. (2020). Developing two heuristic algorithms with metaheuristic
algorithms to improve solutions of optimization problems with soft and hard constraints:
An application to nurse rostering problems. Applied Soft Computing, 93, 106336.
https://doi.org/10.1016/j.asoc.2020.106336
Dall’Ora, C., Ball, J., Redfern, O. C., & Griffiths, P. (2020). Night work for hospital nurses and
sickness absence: A retrospective study using electronic rostering systems.
Chronobiology International, 37(9–10), 1357–1364.
https://doi.org/10.1080/07420528.2020.1806290
DeKeyser Ganz, F., & Toren, O. (2014). Israeli nurse practice environment characteristics,
retention, and job satisfaction. Israel Journal of Health Policy Research, 3(1), 1–8.
Fulcher, B., Phillips, A., & Robinson, P. (2010). Quantitative physiologically based modeling of
subjective fatigue during sleep deprivation. Journal of Theoretical Biology, 264(2), 407–
419.
Page 79 of 108
Government of Canada. (n.d.). Labour Standards. Retrieved from
https://www.canada.ca/en/employment-social-development/programs/laborstandards.html
Guo, J., & Bard, J. F. (2021). A column generation-based algorithm for midterm nurse scheduling
with specialized constraints, preference considerations, and overtime. Computers &
Operations Research, 138, 105597. https://doi.org/10.1016/j.cor.2021.105597
Harb, H., Abboud, A., Kwekha Rashid, A. S., Saad, G., Abouaissa, A., Idoughmar, L., &
AlAkkoumi, M. (2024). An intelligent optimization strategy for nurse-patient scheduling
in the Internet of Medical Things applications. Egyptian Informatics Journal, 25, 100451.
https://doi.org/10.1016/j.eij.2024.100451
HealthcareCAN. (n.d.). HealthCareCAN Wellness Resources. Retrieved from
https://www.healthcarecan.ca/wellness-resources/
Jin, S. H., Yun, H. Y., Jeong, S. J., & Kim, K. S. (2017). Hybrid and cooperative strategies using
harmony search and artificial immune systems for solving the nurse rostering problem.
Sustainability, 9, 1090. https://doi.org/10.3390/su9071090
Jin, Z., Jovaisa, T., Thomas, B., & Phull, M. (2021). Intensive care unit staffing during periods of
fluctuating bed occupancy: An alternative dynamic model. Intensive and Critical Care
Nursing, 66, 103063. https://doi.org/10.1016/j.iccn.2021.103063
Katoue, M. G., Cerda, A. A., García, L. Y., & Jakovljevic, M. (2022). Healthcare system
development in the Middle East and North Africa region: Challenges, endeavors, and
prospective opportunities. Frontiers in Public Health, 10, 1045739.
https://doi.org/10.3389/fpubh.2022.1045739
Klyve, K. K., Løyning, I. N., Melby, L. M. H., Andersson, H., & Gullhav, A. N. (2024). A
modeling framework for evaluating proactive and reactive nurse rostering strategies — A
case study from a neonatal intensive care unit. Operations Research for Health Care, 42,
100432. https://doi.org/10.1016/j.orhc.2024.100432
Klyve, K. K., Senthooran, I., & Wallace, M. (2023). Nurse rostering with fatigue modeling:
Incorporating a validated sleep model with biological variations in nurse rostering.
Health Care Management Science, 26(1), 21–45. https://doi.org/10.1007/s10729-02209613-4
Lin, C. C., Kang, J. R., Chiang, D. J., & Chen, C. L. (2015). Nurse scheduling with joint
normalized shift and day-off preference satisfaction using a genetic algorithm with
immigrant scheme. International Journal of Distributed Sensor Networks, 2015, 595419.
https://doi.org/10.1155/2015/595419
Michael, C., Jeffery, C., & David, C. (2015). Nurse preference rostering using agents and iterated
local search. Annals of Operations Research, 226(1), 443–461.
https://doi.org/10.1007/s10479-014-1701-8
O’Callahan, K., Sitters, S., & Petersen, M. (2024). ‘You make the call’: Improving radiology staff
scheduling with AI-generated self-rostering in a medical imaging department.
Page 80 of 108
Radiography (London, England), 30(3), 862–868.
https://doi.org/10.1016/j.radi.2024.03.014
Rajeswari, M., Amudhavel, J., Pothula, S., & Dhavachelvan, P. (2017). Directed bee colony
optimization algorithm to solve the nurse rostering problem. Computational Intelligence
and Neuroscience, 2017, 6563498. https://doi.org/10.1155/2017/6563498
Supnithi, T., Olapiriyakul, S., Huynh, V.-N., & Rerkjirattikal, P. (2020). A goal programming
approach to nurse scheduling with individual preference satisfaction. Mathematical
Problems in Engineering, 2020, 2379091. https://doi.org/10.1155/2020/2379091
Tassopoulos, I. X., Solos, I. P., & Beligiannis, G. N. (2015). A two-phase adaptive variable
neighborhood approach for nurse rostering. Computers & Operations Research, 60, 150–
169. https://doi.org/10.1016/j.cor.2015.02.009
Todorovic, N., & Petrovic, S. (2013). Bee colony optimization algorithm for nurse rostering.
IEEE Transactions on Systems, Man, and Cybernetics: Systems, 43(2), 467–473.
https://doi.org/10.1109/TSMCC.2013.2238546
Tsao, Y.-C., Chen, D., Hwang, F.-J., & Linh, V. T. (2024). Intelligent clinic nurse scheduling
considering nurses paired with doctors and preference of nurses. Journal of Medical
Systems, 48(1), 75. https://doi.org/10.1007/s10916-024-02092-w
Wong, T. C., Xu, M., & Chin, K. S. (2014). A two-stage heuristic approach for nurse scheduling
problem: A case study in an emergency department. Computers & Operations Research,
51, 99–110. https://doi.org/10.1016/j.cor.2014.04.010
Wu, T. H., Yeh, J. Y., & Lee, Y. M. (2015). A particle swarm optimization approach with
refinement procedure for nurse rostering problem. Computers & Operations Research,
54, 52–63. https://doi.org/10.1016/j.cor.2014.08.008
Yasmine, A., Yassine, O., Farouk, Y., & Hicham, C. (2024). Workload balancing for the nurse
scheduling problem: A real-world case study from a French hospital. Socio-Economic
Planning Sciences, 95, 102046. https://doi.org/10.1016/j.seps.2024.102046
Zheng, Z., & Gong, X. (2021). Solving real-life nurse rostering problem in a local hospital based
on spreadsheet. In Proceedings of the 2020 4th International Conference on Electronic
Information Technology and Computer Engineering (EITCE '20) (pp. 959–964).
Association for Computing Machinery. https://doi.org/10.1145/3443467.3443887
XV. Appendix
Page 81 of 108
Meeting Minutes
Meeting 1: January 23, 2025 (Thursday)
Attendees: Dr. Pierrette Zouein, Lea Jilwan, Yara Naame, Elias Elghossein, Charbel A.
Saab
•
Focus: Initial meeting to outline the focus for FYP2.
•
Key Points:
o
Discussion of FYP1 outcomes and areas for improvement, especially in
nurse scheduling optimization.
o
Dr. Zouein suggested expanding on the mathematical models from FYP1,
with a focus on improving fairness and introducing nurse preferences into
the scheduling process.
o
Agreement to build a more flexible and adaptable scheduling system,
capable of integrating real-time changes like sick leave, annual leave, and
shift swaps.
o
Emphasis on scalability and cost optimization in the new model, aiming
for a practical, real-world application.
Meeting 2: February 6, 2025 (Thursday)
Attendees: Dr. Pierrette Zouein, Lea Jilwan, Yara Naame, Elias Elghossein, Charbel A.
Saab
•
Focus: Development of the first mathematical model (Model 1).
•
Key Points:
o
Discussion of the key constraints for nurse scheduling, including the shift
assignments, required nurse ratios, and overtime penalties.
o
MATLAB implementation of Model 1 began, focusing on the basic
constraints and decision variables for nurse assignment.
o
Dr. Zouein provided feedback on the structure and suggested refining the
scheduling constraints to improve shift coverage.
o
Agreement to implement the salary-based objective function to minimize
costs.
Page 82 of 108
Meeting 3: February 20, 2025 (Thursday)
Attendees: Dr. Pierrette Zouein, Lea Jilwan, Yara Naame, Elias Elghossein, Charbel A.
Saab
•
Focus: Fairness model (Model 3) discussion and MATLAB implementation.
•
Key Points:
o
Introduction of fairness constraints to ensure equitable distribution of
shifts.
o
MATLAB work on implementing fairness gap constraints and balancing
workloads among nurses.
o
Dr. Zouein emphasized the importance of reducing workload imbalances
between nurses to improve staff well-being.
o
Agreement to implement fairness gap constraints in the scheduling model
to minimize shift disparities.
Meeting 4: March 6, 2025 (Thursday)
Attendees: Dr. Pierrette Zouein, Lea Jilwan, Yara Naame, Elias Elghossein, Charbel A.
Saab
•
Focus: Nurse preferences in scheduling (Model 4).
•
Key Points:
o
Discussion on incorporating nurse preferences into the scheduling model
to increase nurse satisfaction.
o
MATLAB work began on generating random preference scores and
incorporating preference penalties in the objective function.
o
Dr. Zouein suggested using a weighted penalty system to account for
nurses' shift preferences and improve fairness.
o
Agreement to introduce preference penalties in the objective function.
Meeting 5: March 20, 2025 (Thursday)
Attendees: Dr. Pierrette Zouein, Lea Jilwan, Yara Naame, Elias Elghossein, Charbel A.
Saab
Page 83 of 108
•
Focus: Model 2 - Handling sick leave and rescheduling in MATLAB.
•
Key Points:
o
Discussion of how to integrate sick leave management into the scheduling
system, ensuring that prior assignments are preserved while
accommodating changes.
o
MATLAB work on implementing the re-optimization process to handle sick
leave and adjust the schedule accordingly.
o
Dr. Zouein provided guidance on preserving the integrity of the original
schedule while optimizing the shifts for absent nurses.
o
Agreement to implement a re-optimization approach for managing sick
leave and its impact on the overall schedule.
Meeting 6: April 3, 2025 (Thursday)
Attendees: Dr. Pierrette Zouein, Lea Jilwan, Yara Naame, Elias Elghossein, Charbel A.
Saab
•
Focus: Annual leave management and Model 5 development in MATLAB.
•
Key Points:
o
Discussion of leave constraints and ensuring that nurses can take their
annual leave while maintaining adequate staffing levels.
o
MATLAB work on incorporating annual leave constraints and ensuring
that no more than 3 full-day leaves are taken within the 4-week period.
o
Dr. Zouein emphasized the importance of balancing leave with
operational needs and avoiding overburdening other staff members.
o
Agreement to include annual leave constraints and manage full-day leave
allocation within the scheduling tool.
Meeting 7: April 16, 2025 (Wednesday)
Attendees: Dr. Pierrette Zouein, Lea Jilwan, Yara Naame, Elias Elghossein, Charbel A.
Saab
•
Focus: Feedback session on the report.
Page 84 of 108
•
Key Points:
o
Dr. Zouein reviewed the draft report and provided constructive feedback
on the structure and clarity of the content.
o
Suggested improvements in presenting the mathematical models and
their integration with MATLAB implementation.
o
Focused on refining the final analysis, particularly the sensitivity analysis
and cost optimization sections.
o
Agreement to finalize the report with the suggested changes and prepare
for the upcoming presentation.
Mind Map
The mind map offers a visual overview of the project's key components, illustrating the logical
flow from understanding the problem to delivering the final solution. It outlines core ideas such
as requirements gathering, model development, MATLAB implementation, testing, and
reporting, helping the team stay aligned and focused throughout the project lifecycle.
Figure 19: Mind Map of the Project
Page 85 of 108
WBS
The WBS decomposes the entire project into manageable tasks distributed across a 24week timeline. It tracks progress through clearly numbered tasks (e.g., 1.0, 1.1, 2.1),
showing milestones like stakeholder meetings, model development phases, MATLAB
implementation, and final reporting. Each task includes a percentage of completion,
demonstrating project status and adherence to schedule.
Table 19: WBS of the Projcet
Week Number
Week 1
Week 2
Week 3
Week 4
Week 5
Week 6
Week 7
Week 8
Week 9
Week 10
Week 11
Week 12
Week 13
Week 14
Week 15
Week 16
Week 17
Week 18
Week 19
Week 20
Week 21
Week 22
Week 23
Week 24
Task Number
1
1.1
1.2
2
2.1
2.2
2.3
2.4
3
3.1
3.2
3.3
3.4
3.5
4
4.1
4.2
4.3
5
5.1
5.2
5.3
6
6.1
Task Description
Project Initiation - Define Project Objectives
Gather Requirements from Stakeholders
Initial Meeting with Dr. Zouein (Clarify Focus for FYP2)
Research & Model Development - Review FYP1 and Identify Key Areas
Develop Mathematical Models (Model 1, Model 2, Model 3, Model 4)
Implement Constraints (Shift Assignments, Rest Periods, etc.)
Develop Nurse Preferences Model
Develop Leave Management Model
MATLAB Implementation - Implement Model 1 in MATLAB (Main Optimization)
Implement Model 2 in MATLAB (Sick Leave and Rescheduling)
Implement Model 3 in MATLAB (Fairness Model)
Implement Model 4 in MATLAB (Preferences Model)
Implement Model 5 in MATLAB (Leave Management Model)
Test and Validate MATLAB Code
Results & Outputs - Generate Optimized Schedule
Conduct Sensitivity Analysis on Staffing Levels
Measure Fairness and Cost Efficiency
Evaluate Impact on Nurse Satisfaction
Reporting & Documentation - Draft Initial Report
Incorporate Feedback from Dr. Zouein
Finalize and Submit Report
Prepare Presentation for Stakeholders
Final Review & Evaluation - Meet with Stakeholders for Final Evaluation
Present Findings and Recommendations
% Completion
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
LRC
The LRC assigns responsibilities to team members (Yara Naame, Elias Elghossein, Lea Jilwan,
Charbel Saab) across different tasks. It maps individual and group contributions for activities
such as requirement gathering, data collection, system analysis, research, WBS drafting,
feasibility checks, and final presentation preparation. This chart ensures clarity in task
ownership and accountability.
Table 20: LRC
Task Number
Task Description
1.0
Understand Customer Requirements
1.1
Visiting LAUMCH
1.1.1
Meet with the Nurses
1.1.2
Data Collection
1.2
Problem Definition
1.2.1
Background Information
1.2.2
Current System Analysis
2.0
Designing Scheduling Solutions
2.1
Existing Research
2.2
Research Methodology
2.3
Testing Research Findings
3.0
Work Breakdown Structure
3.1
WBS Draft
4.0
Linear Responsibility Chart
5.0
Check Feasibility
Gantt Chart
Yara Naame
Elias Elghossein
Lea Jilwan Moussa
Charbel Saab
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Page 86 of 108
The Gantt chart provides a time-based visual representation of the entire project timeline,
segmented by activity. It includes phases such as project planning, model development,
MATLAB implementation, testing, reporting, and presentation. Each activity is color-coded or
labeled across 16 weeks, helping stakeholders quickly assess task durations, overlaps, and
deadlines.
Table 21: Gant Chart
Activity
Project Planning and Management
Mathematical Models Development
MATLAB Implementation
Testing and Validation
Report Writing
Final Presentation
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Matlab Codes
BaseModel
%% === PARAMETERS ===
weeks
= 4;
days
= 7;
shifts
= 2;
hoursPerShift
= 12;
numNurses
= 22;
requiredNurses = 6;
% Salarie
s
salaryRN
= 6;
salaryPN
= 5;
overtimePenalty = 2.5;
% Single penalty for hours above 42, for any nurse
% Nurse names and types
nurseNames = ["christine", "layla", "daoud", ...
"marylin", "rita", "valeria", ...
"habib", "pia maria", "cidra", ...
"gael", "marita","micheline","antoinette", "amal", "wissam", ...
"abdelhak", "hussein", "salam", "marwan", "jeandarc", "samir",
...
"karavartalian"];
nurseType = [1 1 1 1 1 1 1 1 1 1 1, ...
0 0 0 0 0 0 0 0 0 0 0]; % 1 = RN, 0 = PN
rnIndices = find(nurseType == 1);
pnIndices = find(nurseType == 0);
%% === DECISION VARIABLES ===
x = optimvar('x', numNurses, days, shifts, weeks, ...
'Type', 'integer', 'LowerBound', 0, 'UpperBound', 1);
% Overtime variable for ALL nurses (RN or PN)
Page 87 of 108
overtime = optimvar('overtime', numNurses, weeks, 'LowerBound', 0);
%% === HOURS WORKED EXPRESSION ===
hoursWorked = optimexpr(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
hoursWorked(i,w) = hoursPerShift * sum(sum(x(i,:,:,w)));
end
end
%% === OBJECTIVE FUNCTION ===
cost = 0;
for i = 1:numNurses
for w = 1:weeks
% Base hourly cost
if nurseType(i) == 1
cost = cost + salaryRN * hoursWorked(i,w);
else
cost = cost + salaryPN * hoursWorked(i,w);
end
% Overtime penalty (hours above 42)
cost = cost + overtimePenalty * overtime(i,w);
end
end
prob = optimproblem('Objective', cost, 'ObjectiveSense', 'minimize');
%% === CONSTRAINTS ===
% --- Weekly hours: 36–48 for ALL nurses --weekMin = optimconstr(numNurses, weeks);
weekMax = optimconstr(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
weekMin(i,w) = hoursWorked(i,w) >= 36;
weekMax(i,w) = hoursWorked(i,w) <= 48;
end
end
% --- Overtime definition: any hour above 42 is penalized --overtimeConstraint = optimconstr(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
overtimeConstraint(i,w) = overtime(i,w) >= hoursWorked(i,w) - 42;
end
end
% --- Shift coverage --shiftCoverage = optimconstr(days, shifts, weeks);
for d = 1:days
for s = 1:shifts
for w = 1:weeks
shiftCoverage(d,s,w) = sum(x(:,d,s,w)) >= requiredNurses;
end
Page 88 of 108
end
end
% --- No day + night same day --noSameDay = optimconstr(numNurses, days, weeks);
for i = 1:numNurses
for d = 1:days
for w = 1:weeks
noSameDay(i,d,w) = x(i,d,1,w) + x(i,d,2,w) <= 1;
end
end
end
% --- No night to day next day --noNightToDay = optimconstr(numNurses, days-1, weeks);
for i = 1:numNurses
for d = 1:(days-1)
for w = 1:weeks
noNightToDay(i,d,w) = x(i,d,2,w) + x(i,d+1,1,w) <= 1;
end
end
end
% --- No Sunday night to Monday day --noSunMon = optimconstr(numNurses, weeks-1);
for i = 1:numNurses
for w = 1:(weeks-1)
noSunMon(i,w) = x(i,7,2,w) + x(i,1,1,w+1) <= 1;
end
end
% --- At least 2 RN and 2 PN per shift --mintwoRN = optimconstr(days, shifts, weeks);
mintwoPN = optimconstr(days, shifts, weeks);
for d = 1:days
for s = 1:shifts
for w = 1:weeks
mintwoRN(d,s,w) = sum(x(rnIndices,d,s,w)) >= 2;
mintwoPN(d,s,w) = sum(x(pnIndices,d,s,w)) >= 2;
end
end
end
%% === ADD CONSTRAINTS ===
prob.Constraints.weekMin
= weekMin;
prob.Constraints.weekMax
= weekMax;
prob.Constraints.overtimeConstraint= overtimeConstraint;
% prob.Constraints.no48Consecutive
= no48Consecutive; % If using that
constraint
prob.Constraints.shiftCoverage
= shiftCoverage;
prob.Constraints.noSameDay
= noSameDay;
prob.Constraints.noNightToDay
= noNightToDay;
prob.Constraints.noSunMon
= noSunMon;
prob.Constraints.mintwoRN
= mintwoRN;
prob.Constraints.mintwoPN
= mintwoPN;
Page 89 of 108
%% === SOLVE ===
opts = optimoptions('intlinprog','Display','off');
[sol, fval, exitflag, output] = solve(prob, 'Options', opts);
%% === CHECK FEASIBILITY BEFORE ACCESSING SOLUTION ===
if exitflag ~= 1
fprintf('\n No feasible solution. Review constraints or increase
staff.\n');
% Stop or return so we don't index sol.x (which doesn't exist)
return
end
% If we reach here, exitflag == 1 => Feasible solution found, safe to use
sol.x
%% === EXPORT TO EXCEL ===
schedule = cell(weeks*days+1, 2+numNurses);
schedule(1,:) = [{'Week', 'Day'}, cellstr(nurseNames)];
row = 2;
for w = 1:weeks
for d = 1:days
schedule{row,1} = w;
schedule{row,2} = d;
for i = 1:numNurses
if sol.x(i,d,1,w)
schedule{row,2+i} = 'D';
elseif sol.x(i,d,2,w)
schedule{row,2+i} = 'N';
else
schedule{row,2+i} = '';
end
end
row = row + 1;
end
end
numRN = sum(nurseType == 1);
numPN = sum(nurseType == 0);
filename = sprintf('nurse_schedule_MSU7.xlsx');
writecell(schedule, filename);
fprintf('Schedule written to %s\n', filename);
winopen(filename);
%% === RN:PN RATIO PRINT ===
fprintf("\n--- RN:PN Ratio Per Shift ---\n");
shiftLabels = ["Day", "Night"];
for w = 1:weeks
for d = 1:days
for s = 1:shifts
numRN = sum(sol.x(rnIndices,d,s,w));
numPN = sum(sol.x(pnIndices,d,s,w));
Page 90 of 108
fprintf("Week %d, Day %d, %s Shift: RN:PN = %d:%d\n", ...
w, d, shiftLabels(s), numRN, numPN);
end
end
end
%% === FINAL COST AND STATUS ===
fprintf('\n Total Scheduling Cost = %.2f USD\n', fval);
fprintf('\n Feasible solution found.\n');
AugmentedModel_Fairness
%% === PARAMETERS ===
weeks
= 4;
days
= 7;
shifts
= 2;
hoursPerShift
= 12;
numNurses
= 22;
requiredNurses = 6;
% Salaries
salaryRN
= 6;
salaryPN
= 5;
overtimePenalty = 2.5; % Single penalty for hours above 42, for any nurse
% Fairness limit (max difference in total hours between any two nurses)
maxDiff
= 24;
% Nurse names and types
nurseNames = ["christine", "layla", "daoud", ...
"marylin", "rita", "valeria", ...
"habib", "pia maria", "cidra", ...
"gael", "marita","micheline","antoinette", "amal", "wissam", ...
"abdelhak", "hussein", "salam", "marwan", "jeandarc", "samir",
...
"karavartalian"];
% 1 = RN, 0 = PN
nurseType = [1 1 1 1 1 1 1 1 1 1 1 , ...
0 0 0 0 0 0 0 0 0 0 0];
rnIndices = find(nurseType == 1);
pnIndices = find(nurseType == 0);
%% === DECISION VARIABLES ===
% x(i,d,s,w) = 1 if nurse i works shift s on day d in week w; else 0
x = optimvar('x', numNurses, days, shifts, weeks, ...
'Type', 'integer', 'LowerBound', 0, 'UpperBound', 1);
% Overtime variable for ALL nurses (RN or PN)
% Overtime covers any hours above 42 per week.
overtime = optimvar('overtime', numNurses, weeks, 'LowerBound', 0);
%% === HOURS WORKED EXPRESSION ===
% hoursWorked(i,w) = total hours nurse i works in week w
hoursWorked = optimexpr(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
hoursWorked(i,w) = hoursPerShift * sum(sum(x(i,:,:,w)));
end
end
%% === OBJECTIVE FUNCTION ===
Page 91 of 108
% Minimizing total cost = base salary + overtime penalty
cost = 0;
for i = 1:numNurses
for w = 1:weeks
% Base hourly cost
if nurseType(i) == 1
cost = cost + salaryRN * hoursWorked(i,w);
else
cost = cost + salaryPN * hoursWorked(i,w);
end
% Overtime penalty (hours above 42)
cost = cost + overtimePenalty * overtime(i,w);
end
end
prob = optimproblem('Objective', cost, 'ObjectiveSense', 'minimize');
%% === CONSTRAINTS ===
% 1) Weekly hours: 36–48 for ALL nurses
weekMin = optimconstr(numNurses, weeks);
weekMax = optimconstr(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
weekMin(i,w) = hoursWorked(i,w) >= 36;
weekMax(i,w) = hoursWorked(i,w) <= 48;
end
end
% 2) Overtime definition: any hour above 42
overtimeConstraint = optimconstr(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
overtimeConstraint(i,w) = overtime(i,w) >= hoursWorked(i,w) - 42;
end
end
% 3) Shift coverage
shiftCoverage = optimconstr(days, shifts, weeks);
for d = 1:days
for s = 1:shifts
for w = 1:weeks
shiftCoverage(d,s,w) = sum(x(:,d,s,w)) >= requiredNurses;
end
end
end
% 4) No day+night same day
noSameDay = optimconstr(numNurses, days, weeks);
for i = 1:numNurses
for d = 1:days
for w = 1:weeks
noSameDay(i,d,w) = x(i,d,1,w) + x(i,d,2,w) <= 1;
end
end
end
% 5) No night→day next day
noNightToDay = optimconstr(numNurses, days-1, weeks);
for i = 1:numNurses
for d = 1:(days-1)
Page 92 of 108
for w = 1:weeks
noNightToDay(i,d,w) = x(i,d,2,w) + x(i,d+1,1,w) <= 1;
end
end
end
% 6) No Sunday night→Monday day
noSunMon = optimconstr(numNurses, weeks-1);
for i = 1:numNurses
for w = 1:(weeks-1)
noSunMon(i,w) = x(i,7,2,w) + x(i,1,1,w+1) <= 1;
end
end
% 7) At least 2 RNs + 2 PNs per shift
mintwoRN = optimconstr(days, shifts, weeks);
mintwoPN = optimconstr(days, shifts, weeks);
for d = 1:days
for s = 1:shifts
for w = 1:weeks
mintwoRN(d,s,w) = sum(x(rnIndices,d,s,w)) >= 2;
mintwoPN(d,s,w) = sum(x(pnIndices,d,s,w)) >= 2;
end
end
end
% 8) Fairness constraint: no nurse can exceed or fall behind another nurse
%
by more than maxDiff hours in the entire schedule.
%
First, let's define totalHours(i) = sum over weeks of hoursWorked(i,w).
totalHours = optimexpr(numNurses,1);
for i = 1:numNurses
totalHours(i) = sum(hoursWorked(i,:)); % Sum across weeks
end
fairnessCon1 = optimconstr(numNurses, numNurses);
fairnessCon2 = optimconstr(numNurses, numNurses);
for i = 1:numNurses
for j = 1:numNurses
fairnessCon1(i,j) = totalHours(i) - totalHours(j) <= maxDiff;
fairnessCon2(i,j) = totalHours(j) - totalHours(i) <= maxDiff;
end
end
%% === ADD CONSTRAINTS ===
prob.Constraints.weekMin
= weekMin;
prob.Constraints.weekMax
= weekMax;
prob.Constraints.overtimeConstraint= overtimeConstraint;
prob.Constraints.shiftCoverage
= shiftCoverage;
prob.Constraints.noSameDay
= noSameDay;
prob.Constraints.noNightToDay
= noNightToDay;
prob.Constraints.noSunMon
= noSunMon;
prob.Constraints.mintwoRN
= mintwoRN;
prob.Constraints.mintwoPN
= mintwoPN;
prob.Constraints.fairness1
= fairnessCon1;
prob.Constraints.fairness2
= fairnessCon2;
%% === SOLVE ===
opts = optimoptions('intlinprog','Display','off');
[sol, fval, exitflag, output] = solve(prob, 'Options', opts);
%% === CHECK FOR FEASIBLE SOLUTION ===
if exitflag ~= 1
Page 93 of 108
fprintf('No feasible solution. Try relaxing constraints or increasing
staff.\n');
return;
end
fprintf('Feasible solution found!\n');
fprintf('Total Scheduling Cost = %.2f USD\n', fval);
%% === EXPORT TO EXCEL ===
schedule = cell(weeks*days+1, 2+numNurses);
schedule(1,:) = [{'Week', 'Day'}, cellstr(nurseNames)];
row = 2;
for w = 1:weeks
for d = 1:days
schedule{row,1} = w;
schedule{row,2} = d;
for i = 1:numNurses
if sol.x(i,d,1,w)
schedule{row,2+i} = 'D';
elseif sol.x(i,d,2,w)
schedule{row,2+i} = 'N';
else
schedule{row,2+i} = '';
end
end
row = row + 1;
end
end
numRN = sum(nurseType == 1);
numPN = sum(nurseType == 0);
filename = sprintf('nurse_schedule_N%dPN%dRN%dfair_OT42.xlsx', numNurses,
numPN, numRN);
writecell(schedule, filename);
fprintf('Schedule written to %s\n', filename);
winopen(filename);
%% === HISTOGRAM OF HOURS WORKED ===
nurseHours = zeros(numNurses,1);
for i = 1:numNurses
nurseHours(i) = hoursPerShift * sum(sum(sum(sol.x(i,:,:,:))));
end
figure;
b = bar(nurseHours, 'FaceColor', 'flat');
xticks(1:numNurses);
xticklabels(nurseNames);
xtickangle(45);
ylabel('Total Hours Worked');
title('Total Hours per Nurse (Fairness + Overtime Above 42)');
for i = 1:numNurses
text(i, nurseHours(i)+2, num2str(nurseHours(i)),
'HorizontalAlignment','center');
end
yline(36*4, '--g', 'Min (Weekly*4=144)');
yline(48*4, '--r', 'Max (Weekly*4=192)');
% If you want the single-week lines, you can keep yline(36,'--g','Min') etc.
%% === HEATMAP (Shift Coverage) ===
coverageMatrix = zeros(weeks*days, shifts);
dayIdx = 1;
Page 94 of 108
for w = 1:weeks
for d = 1:days
for s = 1:shifts
coverageMatrix(dayIdx, s) = sum(sol.x(:,d,s,w));
end
dayIdx = dayIdx + 1;
end
end
figure;
imagesc(coverageMatrix);
colormap(turbo);
colorbar;
title('Shift Coverage Per Day');
xlabel('Shift');
ylabel('Day');
xticks([1 2]);
xticklabels({'Day','Night'});
yticks(1:(weeks*days));
yticklabels("Day " + string(1:(weeks*days)));
for i = 1:(weeks*days)
for j = 1:shifts
text(j, i, num2str(coverageMatrix(i,j)), ...
'HorizontalAlignment','center','Color','k');
end
end
set(gca, 'XTick', 0.5:1:2.5, 'YTick', 0.5:1:(weeks*days)+0.5, ...
'XColor','k','YColor','k','GridColor','k')
grid on;
set(gca,'GridAlpha',1)
%% === RN:PN RATIO PRINT ===
fprintf("\n--- RN:PN Ratio Per Shift ---\n");
shiftLabels = ["Day", "Night"];
for w = 1:weeks
for d = 1:days
for s = 1:shifts
currRN = sum(sol.x(rnIndices,d,s,w));
currPN = sum(sol.x(pnIndices,d,s,w));
fprintf("Week %d, Day %d, %s Shift: RN:PN = %d:%d\n", ...
w, d, shiftLabels(s), currRN, currPN);
end
end
end
%% === FAIRNESS GAP ===
maxWorked = max(nurseHours);
minWorked = min(nurseHours);
diffWorked = maxWorked - minWorked;
fprintf("\n📏 Fairness Gap (Max - Min) = %.2f hours\n", diffWorked);
AugmentedModel_Preferences
%% === PARAMETERS ===
weeks
= 4;
days
= 7;
Page 95 of 108
shifts
= 2;
hoursPerShift
= 12;
numNurses
= 22;
requiredNurses = 6;
% Salaries
salaryRN
= 6;
salaryPN
= 5;
overtimePenalty = 2.5;
fixedPenalty
= 3;
% Nurse names and types
nurseNames = ["christine", "layla", "daoud", "marylin", "rita", "valeria", ...
"habib", "pia maria", "cidra", "gael", "marita", "micheline", ...
"antoinette", "amal", "wissam", "abdelhak", "hussein", "salam",
...
"marwan", "jeandarc", "samir", "karavartalian"];
nurseType = [1 1 1 1 1 1 1 1 1 1 1, 0 0 0 0 0 0 0 0 0 0 0];
rnIndices = find(nurseType == 1);
pnIndices = find(nurseType == 0);
%% === DECISION VARIABLES ===
x = optimvar('x', numNurses, days, shifts, weeks, 'Type', 'integer',
'LowerBound', 0, 'UpperBound', 1);
overtime = optimvar('overtime', numNurses, weeks, 'LowerBound', 0);
%% === NURSE PREFERENCES (1-5 scale, 1=least preferred) ===
preferenceScores = randi([1,5], numNurses, days, shifts, weeks);
%% === HOURS WORKED EXPRESSION ===
hoursWorked = optimexpr(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
hoursWorked(i,w) = hoursPerShift * sum(sum(x(i,:,:,w)));
end
end
%% === OBJECTIVE FUNCTION ===
cost = 0;
for i = 1:numNurses
for w = 1:weeks
cost = cost + (salaryRN * nurseType(i) + salaryPN * (1-nurseType(i))) *
hoursWorked(i,w);
cost = cost + overtimePenalty * overtime(i,w);
for d = 1:days
for s = 1:shifts
preferencePenalty = (5 - preferenceScores(i,d,s,w)) *
fixedPenalty;
cost = cost + preferencePenalty * x(i,d,s,w);
end
end
end
end
prob = optimproblem('Objective', cost, 'ObjectiveSense', 'minimize');
%% === CONSTRAINTS ===
prob.Constraints.weekMin = hoursWorked >= 36;
prob.Constraints.weekMax = hoursWorked <= 48;
prob.Constraints.overtimeConstraint = overtime >= hoursWorked - 42;
shiftCoverage = optimconstr(days, shifts, weeks);
noSameDay = optimconstr(numNurses, days, weeks);
noNightToDay = optimconstr(numNurses, days-1, weeks);
Page 96 of 108
noSunMon = optimconstr(numNurses, weeks-1);
mintwoRN = optimconstr(days, shifts, weeks);
mintwoPN = optimconstr(days, shifts, weeks);
for w = 1:weeks
for d = 1:days
for s = 1:shifts
shiftCoverage(d,s,w) = sum(x(:,d,s,w)) >= requiredNurses;
mintwoRN(d,s,w) = sum(x(rnIndices,d,s,w)) >= 2;
mintwoPN(d,s,w) = sum(x(pnIndices,d,s,w)) >= 2;
end
for i = 1:numNurses
noSameDay(i,d,w) = sum(x(i,d,:,w)) <= 1;
end
if d < days
for i = 1:numNurses
noNightToDay(i,d,w) = x(i,d,2,w) + x(i,d+1,1,w) <= 1;
end
end
end
if w < weeks
for i = 1:numNurses
noSunMon(i,w) = x(i,7,2,w) + x(i,1,1,w+1) <= 1;
end
end
end
prob.Constraints.shiftCoverage = shiftCoverage;
prob.Constraints.noSameDay = noSameDay;
prob.Constraints.noNightToDay = noNightToDay;
prob.Constraints.noSunMon = noSunMon;
prob.Constraints.mintwoRN = mintwoRN;
prob.Constraints.mintwoPN = mintwoPN;
%% === SOLVE ===
opts = optimoptions('intlinprog','Display','off');
[sol, fval, exitflag, output] = solve(prob, 'Options', opts);
if exitflag ~= 1
fprintf('\n❌ No feasible solution found. Check constraints or
staffing.\n');
disp(output.message);
return;
end
%% === EXPORT RESULTS ===
% Monthly schedule with D/N/blank
schedule = cell(weeks * days + 1, 2 + numNurses);
schedule(1,:) = [{'Week', 'Day'}, cellstr(nurseNames)];
row = 2;
for w = 1:weeks
for d = 1:days
schedule{row,1} = w;
schedule{row,2} = d;
for i = 1:numNurses
if sol.x(i,d,1,w)
schedule{row,2+i} = 'D';
elseif sol.x(i,d,2,w)
schedule{row,2+i} = 'N';
else
Page 97 of 108
schedule{row,2+i} = '';
end
end
row = row + 1;
end
end
% Preference sheet: tidy format with nurse names included
preferenceSheet = {"Nurse", "Week", "Day", "Shift", "Preference"};
for i = 1:numNurses
for w = 1:weeks
for d = 1:days
for s = 1:shifts
shiftLabel = "Day";
if s == 2, shiftLabel = "Night"; end
preferenceSheet(end+1,:) = {nurseNames(i), w, d, shiftLabel,
preferenceScores(i,d,s,w)};
end
end
end
end
% Write to Excel (monthly schedule + preferences)
filename = 'nurse_schedule_with_preferences.xlsx';
if isfile(filename)
delete(filename);
end
writecell(schedule, filename, 'Sheet', 'Schedule');
writecell(preferenceSheet, filename, 'Sheet', 'Preferences');
fprintf('✅ Schedule and Preferences saved to %s\n', filename);
winopen(filename);
%% === FINAL COST ===
fprintf('\n💵 Total Cost: %.2f USD\n', fval);
preferencePenalty = sum((5 - preferenceScores(:)) .* fixedPenalty .*
sol.x(:));
fprintf('🌟 Total Preference Penalty: %.2f\n', preferencePenalty);
SickLeaveModel
function rescheduleAfterDayOff(nurseOff, weekOff, dayOffList)
% === PARAMETERS ===
weeks = 4;
days = 7;
shifts = 2;
hoursPerShift = 12;
requiredNurses = 6;
salaryRN = 6;
salaryPN = 5;
% === LOAD ORIGINAL SCHEDULE (Hardcoded filename) ===
scheduleFile = "nurse_schedule_MSU7.xlsx";
T = readtable(scheduleFile);
% Create nurseNames from the table (cols 3..end)
nurseNames = T.Properties.VariableNames(3:end);
Page 98 of 108
numNurses = length(nurseNames);
% Build binary matrix x_original
x_original = zeros(numNurses, days, shifts, weeks);
for r = 1:height(T)
w = T.Week(r);
d = T.Day(r);
for i = 1:numNurses
shift = T{r, 2 + i}{1}; % e.g. 'D', 'N', or ''
if strcmpi(shift, 'D')
x_original(i,d,1,w) = 1;
elseif strcmpi(shift, 'N')
x_original(i,d,2,w) = 1;
end
end
end
% === IDENTIFY DAY-OFF INDEXES ===
startGlobalDay = (weekOff - 1) * 7 + min(dayOffList);
endGlobalDay = weeks * days;
% Find the nurse index by name
nurseIdx = find(strcmp(nurseNames, nurseOff));
% === Nurse Type (Hardcoded RN=1/PN=0, 11 each) ===
nurseType = [ones(1,11), zeros(1,11)];
rnIndices = find(nurseType == 1);
% === CREATE OPTIMIZATION VARIABLES ===
x = optimvar('x', numNurses, days, shifts, weeks, ...
'Type','integer','LowerBound',0,'UpperBound',1);
% === OBJECTIVE FUNCTION (Minimize total cost) ===
cost = 0;
for i = 1:numNurses
salary = nurseType(i)*salaryRN + (1 - nurseType(i))*salaryPN;
% total hours * salary
cost = cost + salary * hoursPerShift * sum(sum(sum(x(i,:,:,:))));
end
prob = optimproblem('Objective', cost, 'ObjectiveSense', 'minimize');
% === CONSTRAINTS ===
shiftCoverage
= optimconstr(days, shifts, weeks);
mintwoRN
= optimconstr(days, shifts, weeks);
noSameDayShift
= optimconstr(numNurses, days, weeks);
noNightToDay
= optimconstr(numNurses, days-1, weeks);
noSundayToMonday
= optimconstr(numNurses, weeks-1);
weeklyHoursLower
= optimconstr(numNurses, weeks);
weeklyHoursUpper
= optimconstr(numNurses, weeks);
noTwoFullWeeks
= optimconstr(numNurses, weeks-1);
% Coverage and at least 2 RN
for d = 1:days
for s = 1:shifts
for w = 1:weeks
Page 99 of 108
shiftCoverage(d,s,w) = sum(x(:,d,s,w)) >= requiredNurses;
mintwoRN(d,s,w) = sum(x(rnIndices,d,s,w)) >= 2;
end
end
end
% No day+night same day
for i = 1:numNurses
for d = 1:days
for w = 1:weeks
noSameDayShift(i,d,w) = x(i,d,1,w) + x(i,d,2,w) <= 1;
end
end
end
% No night→day next day
for i = 1:numNurses
for d = 1:(days-1)
for w = 1:weeks
noNightToDay(i,d,w) = x(i,d,2,w) + x(i,d+1,1,w) <= 1;
end
end
end
% No Sunday night→Monday day
for i = 1:numNurses
for w = 1:(weeks-1)
noSundayToMonday(i,w) = x(i,7,2,w) + x(i,1,1,w+1) <= 1;
end
end
% Weekly hours 36–48
for i = 1:numNurses
for w = 1:weeks
hrs = hoursPerShift * sum(sum(x(i,:,:,w)));
weeklyHoursLower(i,w) = hrs >= 36;
weeklyHoursUpper(i,w) = hrs <= 48;
end
end
% No two consecutive 48-hour weeks
for i = 1:numNurses
for w = 1:(weeks-1)
hrs1 = hoursPerShift * sum(sum(x(i,:,:,w)));
hrs2 = hoursPerShift * sum(sum(x(i,:,:,w+1)));
% Summation must be <= 96 (so can't have 48 + 48)
noTwoFullWeeks(i,w) = hrs1 + hrs2 <= 96;
end
end
% === FIX PRIOR ASSIGNMENTS (for days before startGlobalDay) ===
globalDay = 1;
for w = 1:weeks
for d = 1:days
if globalDay < startGlobalDay
Page 100 of 108
for s = 1:shifts
for i = 1:numNurses
cname = sprintf('fixed_x_%d_%d_%d_%d', i,d,s,w);
prob.Constraints.(cname) = (x(i,d,s,w) ==
x_original(i,d,s,w));
end
end
end
globalDay = globalDay + 1;
end
end
% === ENFORCE DAYS OFF ===
for dd = dayOffList
prob.Constraints.(sprintf('dayoff_d%d', dd)) = x(nurseIdx, dd, 1,
weekOff) == 0;
prob.Constraints.(sprintf('nightoff_d%d', dd)) = x(nurseIdx, dd, 2,
weekOff) == 0;
end
% === ADD CONSTRAINTS ===
prob.Constraints.shiftCoverage
prob.Constraints.mintwoRN
prob.Constraints.noSameDayShift
prob.Constraints.noNightToDay
prob.Constraints.noSundayToMonday
prob.Constraints.weeklyHoursLower
prob.Constraints.weeklyHoursUpper
prob.Constraints.noTwoFullWeeks
= shiftCoverage;
= mintwoRN;
= noSameDayShift;
= noNightToDay;
= noSundayToMonday;
= weeklyHoursLower;
= weeklyHoursUpper;
= noTwoFullWeeks;
% === SOLVE ===
opts = optimoptions('intlinprog', 'Display','off');
[sol, fval, exitflag, output] = solve(prob, 'Options', opts);
% === CHECK FEASIBILITY ===
if exitflag == 1
fprintf('\n✅ Re-optimization successful. New schedule created.\n');
schedule = {};
rowOut = 2;
for gDay = startGlobalDay : (weeks * days)
w = floor((gDay - 1) / days) + 1;
d = mod(gDay - 1, days) + 1;
schedule{rowOut,1} = w;
schedule{rowOut,2} = d;
for i = 1:numNurses
if i == nurseIdx && w == weekOff && any(d == dayOffList)
schedule{rowOut,2+i} = 'SL'; % "Scheduled Leave"
else
shiftDay = sol.x(i,d,1,w);
shiftNight = sol.x(i,d,2,w);
if shiftDay == 1
schedule{rowOut,2+i} = 'D';
elseif shiftNight == 1
schedule{rowOut,2+i} = 'N';
Page 101 of 108
else
schedule{rowOut,2+i} = '';
end
end
end
rowOut = rowOut + 1;
end
schedule{1,1} = 'Week';
schedule{1,2} = 'Day';
for i = 1:numNurses
schedule{1,2+i} = nurseNames{i};
end
filename = sprintf('nurse_reschedule_%s_week%d_days%s.xlsx', ...
lower(nurseOff), weekOff, strjoin(string(dayOffList), '_'));
writecell(schedule, filename);
fprintf('📁 Trimmed updated schedule exported to: %s\n', filename);
winopen(filename);
% === REPLACEMENT + OVERTIME ANALYSIS ===
fprintf('\n🔍 Who replaced %s on day(s) off:\n', nurseOff);
for dd = dayOffList
fprintf(' Week %d, Day %d:\n', weekOff, dd);
for s = 1:shifts
assigned = find(sol.x(:,dd,s,weekOff));
shiftType = {'Day', 'Night'};
if ~isempty(assigned)
fprintf('
%s shift → %s\n', shiftType{s}, ...
strjoin(nurseNames(assigned), ', '));
end
end
end
% Compare old vs. new hours
originalHours = zeros(numNurses,1);
newHours = zeros(numNurses,1);
for i = 1:numNurses
originalHours(i) = hoursPerShift * sum(x_original(i,:,:,:),'all');
newHours(i) = hoursPerShift * sum(sol.x(i,:,:,:),'all');
end
fprintf('\n📊 Total Hours Worked (Before ➡ After):\n');
for i = 1:numNurses
delta = newHours(i) - originalHours(i);
if abs(delta) > 0
fprintf(' %s: %d ➡ %d (Δ %+d hrs)\n', nurseNames{i}, ...
originalHours(i), newHours(i), delta);
end
end
else
fprintf('\n❌ Re-optimization failed. No feasible solution or solver
stopped.\n');
end
Page 102 of 108
end
AnnualLeaveModel
%% === PARAMETERS ===
weeks
= 4;
days
= 7;
shifts
= 2;
hoursPerShift
= 12;
numNurses
= 22;
requiredNurses = 6;
% Salaries
salaryRN
= 6;
salaryPN
= 5;
overtimePenalty = 2.5;
% Nurse names and types
nurseNames = ["christine", "layla", "daoud", ...
"marylin", "rita", "valeria", ...
"habib", "pia maria", "cidra", ...
"gael", "marita","micheline","antoinette", "amal", "wissam", ...
"abdelhak", "hussein", "salam", "marwan", "jeandarc", "samir",
...
"karavartalian"];
nurseType = [1 1 1 1 1 1 1 1 1 1 1, ...
0 0 0 0 0 0 0 0 0 0 0]; % 1 = RN, 0 = PN
rnIndices = find(nurseType == 1);
pnIndices = find(nurseType == 0);
%% === DECISION VARIABLES ===
x = optimvar('x', numNurses, days, shifts, weeks, 'Type', 'integer',
'LowerBound', 0, 'UpperBound', 1);
overtime = optimvar('overtime', numNurses, weeks, 'LowerBound', 0);
leave = optimvar('leave', numNurses, days, shifts, weeks, 'Type', 'integer',
'LowerBound', 0, 'UpperBound', 1);
fullDayLeave = optimvar('fullDayLeave', numNurses, days, weeks, 'Type',
'integer', 'LowerBound', 0, 'UpperBound', 1);
%% === HOURS WORKED EXPRESSION ===
hoursWorked = optimexpr(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
hoursWorked(i,w) = hoursPerShift * sum(sum(x(i,:,:,w)));
end
end
%% === OBJECTIVE FUNCTION ===
cost = 0;
for i = 1:numNurses
for w = 1:weeks
% Base salary
rate = salaryRN * nurseType(i) + salaryPN * (1 - nurseType(i));
Page 103 of 108
cost = cost + rate * hoursWorked(i,w);
cost = cost + overtimePenalty * overtime(i,w);
end
end
prob = optimproblem('Objective', cost, 'ObjectiveSense', 'minimize');
%% === CONSTRAINTS ===
% --- Weekly hours bounds --weekMin = hoursWorked >= 36;
weekMax = hoursWorked <= 48;
% --- Overtime penalty if >42 hours --overtimeConstraint = overtime >= hoursWorked - 42;
% --- Shift coverage: at least 6 nurses per shift --shiftCoverage = optimconstr(days, shifts, weeks);
for d = 1:days
for s = 1:shifts
for w = 1:weeks
shiftCoverage(d,s,w) = sum(x(:,d,s,w)) >= requiredNurses;
end
end
end
% --- One shift per day max --noSameDay = optimconstr(numNurses, days, weeks);
for i = 1:numNurses
for d = 1:days
for w = 1:weeks
noSameDay(i,d,w) = x(i,d,1,w) + x(i,d,2,w) <= 1;
end
end
end
% --- No night to day next day --noNightToDay = optimconstr(numNurses, days-1, weeks);
for i = 1:numNurses
for d = 1:days-1
for w = 1:weeks
noNightToDay(i,d,w) = x(i,d,2,w) + x(i,d+1,1,w) <= 1;
end
end
end
% --- No Sunday night to Monday day --noSunMon = optimconstr(numNurses, weeks-1);
for i = 1:numNurses
for w = 1:weeks-1
noSunMon(i,w) = x(i,7,2,w) + x(i,1,1,w+1) <= 1;
end
end
% --- RN/PN minimum per shift --mintwoRN = optimconstr(days, shifts, weeks);
Page 104 of 108
mintwoPN = optimconstr(days, shifts, weeks);
for d = 1:days
for s = 1:shifts
for w = 1:weeks
mintwoRN(d,s,w) = sum(x(rnIndices,d,s,w)) >= 2;
mintwoPN(d,s,w) = sum(x(pnIndices,d,s,w)) >= 2;
end
end
end
%% === LEAVE CONSTRAINTS ===
% No work during leave
leaveExclusion = x <= 1 - leave;
% Full-day leave = both day & night shifts off
fullLeaveDef1 = optimconstr(numNurses, days, weeks);
fullLeaveDef2 = optimconstr(numNurses, days, weeks);
fullLeaveDef3 = optimconstr(numNurses, days, weeks);
for i = 1:numNurses
for d = 1:days
for w = 1:weeks
% Condition 1: fullDayLeave <= leave on Day shift
fullLeaveDef1(i,d,w) = fullDayLeave(i,d,w) <= leave(i,d,1,w);
% Condition 2: fullDayLeave <= leave on Night shift
fullLeaveDef2(i,d,w) = fullDayLeave(i,d,w) <= leave(i,d,2,w);
% Condition 3: fullDayLeave = 1 if both shifts are off
fullLeaveDef3(i,d,w) = fullDayLeave(i,d,w) >= leave(i,d,1,w) +
leave(i,d,2,w) - 1;
end
end
end
% Limit 3 full days off
leaveLimit = optimconstr(numNurses);
for i = 1:numNurses
leaveLimit(i) = sum(sum(fullDayLeave(i,:,:))) == 3;
end
% === Max 4 nurses on leave per shift ===
maxOnLeavePerShift = 4;
leaveCapPerShift = optimconstr(days, shifts, weeks);
for d = 1:days
for s = 1:shifts
for w = 1:weeks
leaveCapPerShift(d,s,w) = sum(leave(:,d,s,w)) <=
maxOnLeavePerShift;
end
end
end
prob.Constraints.leaveCapPerShift = leaveCapPerShift;
Page 105 of 108
% === No more than 2 full leave day per week per nurse ===
leaveSpread = optimconstr(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
fullDaysThisWeek = optimexpr(days);
for d = 1:days
fullDaysThisWeek(d) = fullDayLeave(i,d,w);
end
leaveSpread(i,w) = sum(fullDaysThisWeek) <= 2;
end
end
%% === ADD ALL CONSTRAINTS TO PROBLEM ===
prob.Constraints.weekMin
= weekMin;
prob.Constraints.weekMax
= weekMax;
prob.Constraints.overtimeConstraint = overtimeConstraint;
prob.Constraints.shiftCoverage
= shiftCoverage;
prob.Constraints.noSameDay
= noSameDay;
prob.Constraints.noNightToDay
= noNightToDay;
prob.Constraints.noSunMon
= noSunMon;
prob.Constraints.mintwoRN
= mintwoRN;
prob.Constraints.mintwoPN
= mintwoPN;
prob.Constraints.leaveExclusion
= leaveExclusion;
prob.Constraints.fullLeaveDef1
= fullLeaveDef1;
prob.Constraints.fullLeaveDef2
= fullLeaveDef2;
prob.Constraints.fullLeaveDef3
= fullLeaveDef3;
prob.Constraints.leaveLimit
= leaveLimit;
prob.Constraints.leaveCapPerShift
= leaveCapPerShift;
prob.Constraints.leaveSpread
= leaveSpread;
%% === SOLVE ===
opts = optimoptions('intlinprog', 'Display', 'off');
[sol, fval, exitflag, output] = solve(prob, 'Options', opts);
%% === EXPORT TO EXCEL ===
filename = 'nurse_schedule_and_leave.xlsx';
% === 1. Build Schedule Sheet ===
schedule = cell(weeks*days+1, 2+numNurses);
schedule(1,:) = [{'Week', 'Day'}, cellstr(nurseNames)];
row = 2;
for w = 1:weeks
for d = 1:days
schedule{row,1} = w;
schedule{row,2} = d;
for i = 1:numNurses
if sol.x(i,d,1,w)
schedule{row,2+i} = 'D';
elseif sol.x(i,d,2,w)
schedule{row,2+i} = 'N';
else
schedule{row,2+i} = '';
end
Page 106 of 108
end
row = row + 1;
end
end
% === 2. Build Leave Sheet ===
leaveSchedule = cell(weeks*days+1, 2+numNurses);
leaveSchedule(1,:) = [{'Week', 'Day'}, cellstr(nurseNames)];
row = 2;
for w = 1:weeks
for d = 1:days
leaveSchedule{row,1} = w;
leaveSchedule{row,2} = d;
for i = 1:numNurses
isDayShift = sol.x(i,d,1,w);
isNightShift = sol.x(i,d,2,w);
isFullLeave = sol.leave(i,d,1,w) && sol.leave(i,d,2,w);
if isFullLeave
leaveSchedule{row,2+i} = 'Full Leave';
elseif isDayShift
leaveSchedule{row,2+i} = 'D';
elseif isNightShift
leaveSchedule{row,2+i} = 'N';
else
leaveSchedule{row,2+i} = '';
end
end
row = row + 1;
end
end
% Export both sheets
writetable(cell2table(schedule), filename, 'Sheet', 'Schedule',
'WriteVariableNames', false);
writetable(cell2table(leaveSchedule), filename, 'Sheet', 'Leave',
'WriteVariableNames', false);
fprintf('\n📄 Schedule + Leave exported to %s\n', filename);
winopen(filename);
%% === HOURS WORKED & OVERTIME (recomputed from solution) ===
hoursWorkedFromSol = zeros(numNurses, weeks);
overtimeFromSol = zeros(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
totalShifts = sum(sum(sol.x(i,:,:,w))); % Total shifts assigned
hoursWorkedFromSol(i,w) = hoursPerShift * totalShifts;
overtimeFromSol(i,w) = max(0, hoursWorkedFromSol(i,w) - 42);
end
end
%% === EXPORT hours worked & OT to Excel ===
hoursTable = cell(numNurses+1, weeks+3); % Columns: Name, Week 1..4, Total
Hrs, OT
hoursTable(1,:) = [{'Nurse'}, ...
Page 107 of 108
arrayfun(@(w) sprintf('Week %d', w), 1:weeks, 'UniformOutput', false), ...
{'Total Hours', 'Total OT'}];
for i = 1:numNurses
hoursTable{i+1,1} = nurseNames(i);
totalHrs = 0;
totalOT = 0;
for w = 1:weeks
hrs = hoursWorkedFromSol(i,w);
ot = overtimeFromSol(i,w);
hoursTable{i+1,1+w} = hrs;
totalHrs = totalHrs + hrs;
totalOT = totalOT + ot;
end
hoursTable{i+1,end-1} = totalHrs;
hoursTable{i+1,end}
= totalOT;
end
writecell(hoursTable, filename, 'Sheet', 'Hours & OT');
fprintf('📊 Hours + OT exported to sheet "Hours & OT"\n');
%% === HOURS WORKED & OVERTIME (recomputed from solution) ===
hoursWorkedFromSol = zeros(numNurses, weeks);
overtimeFromSol = zeros(numNurses, weeks);
for i = 1:numNurses
for w = 1:weeks
totalShifts = sum(sum(sol.x(i,:,:,w))); % Total shifts assigned
hoursWorkedFromSol(i,w) = hoursPerShift * totalShifts;
overtimeFromSol(i,w) = max(0, hoursWorkedFromSol(i,w) - 42);
end
end
%% === EXPORT hours worked & OT to Excel ===
hoursTable = cell(numNurses+1, weeks+3); % Columns: Name, Week 1..4, Total
Hrs, OT
hoursTable(1,:) = [{'Nurse'}, ...
arrayfun(@(w) sprintf('Week %d', w), 1:weeks, 'UniformOutput', false), ...
{'Total Hours', 'Total OT'}];
for i = 1:numNurses
hoursTable{i+1,1} = nurseNames(i);
totalHrs = 0;
totalOT = 0;
for w = 1:weeks
hrs = hoursWorkedFromSol(i,w);
ot = overtimeFromSol(i,w);
hoursTable{i+1,1+w} = hrs;
totalHrs = totalHrs + hrs;
totalOT = totalOT + ot;
end
hoursTable{i+1,end-1} = totalHrs;
hoursTable{i+1,end}
= totalOT;
end
Page 108 of 108
writecell(hoursTable, filename, 'Sheet', 'Hours & OT');
fprintf('📊 Hours + OT exported to sheet "Hours & OT"\n');
%% === HEATMAP: Weekly Hours per Nurse ===
figure('Name', 'Weekly Hours Heatmap', 'Color', 'w');
h = heatmap(hoursWorkedFromSol, ...
'Colormap', parula, ...
'ColorLimits', [36 54], ...
'CellLabelFormat','%.0f hrs');
h.Title = '🧠 Nurse Weekly Workload (Hours)';
h.XLabel = 'Week';
h.YLabel = 'Nurse';
h.XDisplayLabels = arrayfun(@(w) sprintf('Week %d', w), 1:weeks,
'UniformOutput', false);
h.YDisplayLabels = nurseNames;
%% === RN:PN Ratio Per Shift Report ===
fprintf("\n--- RN:PN Ratio Per Shift ---\n");
shiftLabels = ["Day", "Night"];
for w = 1:weeks
for d = 1:days
for s = 1:shifts
numRN = sum(sol.x(rnIndices,d,s,w));
numPN = sum(sol.x(pnIndices,d,s,w));
fprintf("Week %d, Day %d, %s Shift → RN:PN = %d:%d\n", w, d,
shiftLabels(s), numRN, numPN);
end
end
end
%% === LEAVE SUMMARY ===
fprintf('\n📋 Full Leave Days Per Nurse:\n');
for i = 1:numNurses
totalLeave = sum(sum(sol.fullDayLeave(i,:,:)));
fprintf("Nurse %s → Full Leave Days: %d\n", nurseNames(i), totalLeave);
end
%% === FINAL COST ===
fprintf('\n💵 Total Scheduling Cost = %.2f USD\n', fval);
fprintf('✅ Feasible solution found.\n');
Download