Code related to the paper "Human-centered algorithmic physician scheduling in hospitals"
About the study:
The study intends to detect potential for improvement in scheduling doctors in hospitals. For this purpose, an algorithm is developed utilizing Constraint Programming, to schedule doctors in the surgical department and Munich's hospital rechts der Isar (MRI). The primary goal of the algorithm is to maximize the fulfilment of doctor preferences, i.e. preferences regarding off-days and specific jobs on specific shifts.
Functionality of the code The steps necessary to assign doctors in the surgical department are described in detail in the source code via comments. For any related questions feel free to contact Natalie Wagner ([email protected]) or Charlotte Haid ([email protected]). The code consists of eight steps that are as follows:
- Input data definition
- Model creation via cp_model.CpModel()
- Decision variable creation via model.NewBoolVar()
- General constraints generation via model.Add()
- Specific constraints generation via model.Add()
- Objective formulation and maximization via model.Maximize()
- Problem solver application via solver = cp_model.CpSolver() and solver.Solve(model)
- Solution (output) printing
To schedule doctors of the surgical department at MRI for any chosen month, the following steps are necessary:
- Define minimum and maximum number of shifts per doctor or assign priorities to each doctor by defining them in the employee_priorities, whereby higher priorities indicate doctors to be assigned to more shifts than others. Scale the following variables, arrays, and matrices to the number of doctors to be scheduled:
number_employees _max_shifts_per_employee and min_shifts_per_employee _ employee_availability_matrix_wholedays qualification_matrix employee_offdays_preference_matrix
- Scale the following variables, arrays, and matrices to the number of days of the considered month:
number_weekdays number_weekendholidays day_shift_matrix employee_availability_matrix_wholedays employee_offdays_preference_matrix
- Define the entries of the day-shift-matrix acccording to the types of days of the considered month, i.e. the distribution of weekdays, weekends, and public holidays within the month. Enter the data (Note: to input data more easily, especially into big matrices, it is suggested to add extra lines of comment in the code, containing indices of days and doctors).
-
minimum and maximum number of shifts per doctor into max_shifts_per_employee and min_shifts_per_employee
-
doctor availabilities into employee_availability_matrix_wholedays
-
doctor qualifications into employee_qualification_matrix
-
doctor off-day preferences into employee_offdays_preference_matrix
-
doctor job preferences into employee_jobs_preference_matrix
The output of the code is as follows:
- Employee-job-calculation matrix and job restrictions
- Overall schedule
- Number of each shift per employee
- Number of working hours per employee
- Total off-day preference score (number of total fulfilled preferences for off-days = first part of the objective)
- Individual off-day preference score per employee
- Maximum individual off-day preference per employee (= number of submitted off-day preferences)
- Individual and total percentage of fulfilled off-day preferences
- Total job preference score (number of total fulfilled preferences for jobs = second part of the objective)
- Individual job preference score per employee
- Maximum individual job preference score per employee (= number of submitted job preferences)
- Individual and total percentage of fulfilled job preferences
- Individual schedule of each employee
- Overview of total number and percentage of fulfilled off-day and job preferences