I am trying to write a program to schedule a team of 8 individuals into shifts.
I want to know how to model that every individual must get at least one night shift break, and must not work two consecutive shifts. Finally, we want to ensure as close to equal numbers of night shifts and total shifts for each individual as possible.
More specifically I have the following problem:
- 8 Individuals
- 3 Shifts per day (morning, afternoon, night)
- 18 Days
I want to distribute individuals to shifts to meet the following criteria:
- There must be 3 people on each shift
- Every individual must work 1 shift per day
- Every individual must not work more than 2 shifts per day
- Every individual must get at least one night shift break, preferably two. This means that individual A can work night shift 1, but then cannot work night shift 2 (and preferably not 3), returning to night shift 4. I.e. each individual must do a maximum of 1 night shift in every 2 nights, preferably 1 night shift in every 3 night shifts.
- We should distribute these shifts as evenly as possible, especially night shifts but also the total number of shifts.
- Each individual must not work consecutive shifts (e.g. the night shift on Day 1 and the morning shift on Day 2)
I need to know how to either write these as constraints or otherwise, to include them in an objective function.
As an objective function: I have considered minimising the maximum difference in the number of night shifts, or else, minimising the maximum difference in the total number of shifts.
I need some help writing this as a mathematical model. I don't know where to start with this!