Nurse Rostering with Genetic Algorithms

In recent years genetic algorithms have emerged as a useful tool for the heuristic solution of complex discrete optimisation problems. In particular there has been considerable interest in their use in tackling problems arising in the areas of scheduling and timetabling. However, the classical genetic algorithm paradigm is not well equipped to handle constraints and successful implementations usually require some sort of modification to enable the search to exploit problem specific knowledge in order to overcome this shortcoming. This paper is concerned with the development of a family of genetic algorithms for the solution of a nurse rostering problem at a major UK hospital. The hospital is made up of wards of up to 30 nurses. Each ward has its own group of nurses whose shifts have to be scheduled on a weekly basis. In addition to fulfilling the minimum demand for staff over three daily shifts, nurses' wishes and qualifications have to be taken into account. The schedules must also be seen to be fair, in that unpopular shifts have to be spread evenly amongst all nurses, and other restrictions, such as team nursing and special conditions for senior staff, have to be satisfied. The basis of the family of genetic algorithms is a classical genetic algorithm consisting of n-point crossover, single-bit mutation and a rank-based selection. The solution space consists of all schedules in which each nurse works the required number of shifts, but the remaining constraints, both hard and soft, are relaxed and penalised in the fitness function. The talk will start with a detailed description of the problem and the initial implementation and will go on to highlight the shortcomings of such an approach, in terms of the key element of balancing feasibility, i.e. covering the demand and work regulations, and quality, as measured by the nurses' preferences. A series of experiments involving parameter adaptation, niching, intelligent weights, delta coding, local hill climbing, migration and special selection rules will then be outlined and it will be shown how a series of these enhancements were able to eradicate these difficulties. Results based on several months' real data will be used to measure the impact of each modification, and to show that the final algorithm is able to compete with a tabu search approach currently employed at the hospital. The talk will conclude with some observations as to the overall quality of this approach to this and similar problems.


Overview
• Introduction to the Nurse Scheduling Problem and corresponding IP.
• Introduction to the standard genetic algorithm.
• Application of the genetic algorithm to the nurse scheduling problem.
• Limitations of the standard approach.
• Enhancements of the standard approach.
• Final results and comparison.
• Future scope of research.
Electronic copy available at: https://ssrn.com/abstract=2832070 The Nurse Scheduling Problem Objective: • To create weekly schedules on ward basis.
• To satisfy working contracts and to have fair schedules.
• To take as many nurses' requests into account as possible.

Decomposition:
1. Ensuring that nurses present can cover the overall demand.
2. Scheduling the days and/or nights a nurse works.
3. Splitting the day shifts into early and late shifts.
The demand is covered for every grade on every day: Genetic Algorithms (GAs) • A Heuristic based on the principles of natural evolution and 'survival of the fittest'.

Population:
The GA works with many solutions at the same time. New Solutions inherit good parts from old solutions.

Coding:
Transformation of variables into chromosomes such that genetic operators can be applied to solutions.

Fitness:
The fitter a solution, the more likely it will contribute to new solutions. Based on the target function.

Selection:
Rank-based: Individuals (solutions) are ranked according to fitness. The higher the rank the more likely an individual is chosen as a parent.

Crossover:
Combining parts of parent individuals (cut and paste) to create new solutions: 'Building Block Hypotheses'.

Mutation:
Random change of a single bit of an individual.
Replacement: 'Elitist' Strategy, i.e. the best X% of the old solutions are kept. The rest are replaced.

Application of the GA to the Scheduling Problem
Proposed Coding: • Each individual represents a full one week schedule.
• It is a string of n elements, n being the number of nurses.
• Each element is the index of the shift pattern worked by a nurse.
Crossover gives some nurses the shifts worked in one parent solution and the remainder those worked in the other parent.
Mutation changes the worked shift of one nurse.
Dealing with constraints: • Implement constraints into the coding.
• Design a repair operator.
• Add a penalty to an infeasible solution's objective function value.
Electronic copy available at: https://ssrn.com/abstract=2832070 New target function: 28.6% feasible solutions. Average objective value of the best feasible solutions 38.2 (Branch and Bound ≈ 11).

Parameter Optimisation and Dynamic Weights
Parameters to be set: • Population size (100 -2000).
• Type of penalty function and its weight (linear, quadratic).
A higher penalty does not necessarily increase the number of feasible solutions.
Dynamic penalty weight: • Dynamic penalties based on the quality of the best solution so far.
• The less feasible the best solution, the higher the penalty weight, to force the population closer to a feasible region.
• Once the best solution is feasible, the weight drops to a fixed low value v to encourage improvement of the solution quality.
• For each generation the new penalty weight is calculated as follows, where q is the number of violated constraints by the top solution and α is a preset severity parameter: The quality and feasibility of solutions is improved by approx. 10%.

Sub-Population, Special Crossover and Migration
Idea: • 'Building Block Hypothesis' is only valid for problems with no or low epistacity.
• BUT the Nurse Scheduling Problem is highly epistatic due to the penalty function approach.
• Epistacity is present if the sum of the fitness of the single elements is bigger than the total fitness of the string.
• No/low epistacity means that if all single elements of a solution are good, then so is the whole solution.
[Davidor Y, Epistasis Variance: A Viewpoint on GA-Hardness, in Foundations of Genetic Algorithms, p 23ff, 1991.] Introduction of sub-populations and separate fitness functions: • Have a separate population for each grade and for each combination of grades.
• Each sub-population follows an appropriate fitness function.
• In higher level sub-populations, parents are drawn from the population itself and from appropriate lower level populations.
• Then theses parents perform a suitable grade-based crossover.
• Have one additional and larger 'main' population which draws its parents from all others and has the original objective as fitness function.
• Populations 4-7 perform 50% uniform and 50% grade-based crossover. In the case of grade-based crossover the parents are picked from niches 1-3 and combined accordingly.
In the case of grade-based crossover the parents are picked from niches 1-7 and combined accordingly.

Results:
• Feasibility and solution quality more than doubled.
• Loss of information due to limited choice.
The later can be eradicated by the use of migration, i.e. by allowing individuals to change sub-populations over time.

Incentives and Local Search/Repair
Idea: • Remaining problems due to a day/night-shift imbalance.
• Once the wrong nurses are on days/nights the GA cannot sort it out.
• Look ahead and reward solutions with a 'future' potential, i.e. balanced solutions.
Balanced Solutions: • A balanced solution has either both a day surplus and a day shortage or both a night surplus and a night shortage of nurses.
• An unbalanced solution has either both a day surplus and a night shortage or vice versa. Incentives/Disincentives:

Days
• Balanced solutions receive a bonus towards their objective function value (incentive).
Balanced but less fit solutions rank higher than unbalanced solutions.
Local Search/Repair: • Take a balanced solution and use a first fit descending heuristic by cycling through each nurses' shift patterns.
• Better solutions are immediately accepted and the search is continued from there.

Results:
• Disincentives immediately improve solution quality.
• Incentives improve solution quality when used with local search/repair.

Delta Coding and Swaps
Delta Coding: • Idea: Seed the genetic algorithm with a population from within a hypercube around a previous good solution. [Whitley D, Delta Coding: An Iterative Search Strategy for Genetic Algorithms, in Foundations of Genetic Algorithms 2 59ff, 1993.] Does not work for a discontinuous solution space. Swaps: • Allow to swap worked shifts between nurses with the same qualification and working hours, as long as the sum of all their satisfied requests improves.
Swaps are time expensive but offer a slight improvement in solution quality.