### 3.7.15. Assigning and scheduling tasks that run in parallel

modelling: assigning and scheduling tasks that run in parallel Consider a set of tasks defined by a set of subtasks, where each subtask has the following attributes:

• A start telling when the subtask starts.

• A duration giving the duration of the subtask.

• A deadline indicating the date by which the subtask must be finished.

• A person indicating which person performs the subtask.

Both the start and the person correspond to decision variables, while the duration and the deadline are integers. Since all subtasks of a same task must run in parallel, their starts, durations and deadlines are identical. Since a person can perform at most one task at each timepoint, persons assigned to the subtasks of a same task must all be distinct. We also assume that a subtask cannot be preempted.

As an instance of this pattern, consider the problem of scheduling surgical operations in a hospital. Each surgery corresponds to a task that requires a number of persons with specific skills; these persons will all work together during the operation (e.g., typically an anaesthetist, a surgeon and one or several nurses). Moreover, each person has his own calendar defining his unavailability. On the one hand, let us assume we have two anaesthetists, two surgeons and four nurses, labelled from 1 to 8. Each of them has the following unavailability over the time horizon $\left[0,24\right]$:

• The first anaesthetist is not available during the time periods $\left[0,1\right]$, $\left[5,6\right]$, and $\left[12,16\right]$.

• The second anaesthetist is not available during the time periods $\left[0,2\right]$, $\left[6,6\right]$, $\left[15,15\right]$, and $\left[22,22\right]$.

• The first surgeon is not available during the time periods $\left[0,1\right]$, $\left[8,9\right]$, and $\left[13,14\right]$.

• The second surgeon is not available during the time periods $\left[5,5\right]$, and $\left[20,21\right]$.

• The four nurses are all not available during the time periods $\left[0,0\right]$, $\left[7,7\right]$, $\left[12,12\right]$, and $\left[22,22\right]$.

On the other hand, let us suppose we have to schedule five surgery tasks, each of them requiring a specific team:

• Task ${t}_{1}$ needs one anaesthetist, one surgeon and two nurses during two consecutive time slots.

• Task ${t}_{2}$ needs one anaesthetist, one surgeon and one nurse during four consecutive time slots.

• Task ${t}_{3}$ needs one anaesthetist, two surgeons and two nurses during three consecutive time slots.

• Task ${t}_{4}$ needs one anaesthetist, one surgeon and three nurses during two consecutive time slots.

• Task ${t}_{5}$ needs one anaesthetist, one surgeon and one nurse during six consecutive time slots.

Moreover, tasks ${t}_{1}$, ${t}_{2}$, ${t}_{3}$, ${t}_{4}$ and ${t}_{5}$ must be respectively completed no later than timepoint 12, 15, 24, 24 and 24. The problem is modelled by using a two-dimensional $\mathrm{𝚐𝚎𝚘𝚜𝚝}$ constraint, where the first and second dimensions respectively correspond to the time and resource axes. For each person required by a task we create a rectangle of length corresponding to the necessary duration and of height 1 (since it requires one person). The coordinates of the lower left point of the rectangle correspond to the start of the corresponding task as well as to the person that will be assigned to the subtask (i.e., a value between 1 and 2 for an anaesthetist, a value between 3 and 4 for a surgeon, and a value between 5 and 8 for a nurse). Both the start and the person correspond to a domain variable. Each unavailability period of an anaesthetist, a surgeon and a nurse is modelled by introducing a fixed rectangle (i.e., its coordinates are set to the start of the unavailability period and to the person to which the unavailability belongs; its duration is set to the duration of the unavailability period) that prevent tasks overlapping the corresponding time period for a specific person. This leads to the following $\mathrm{𝚐𝚎𝚘𝚜𝚝}$ constraint,

A deadline constraint for a surgery starting at $o$ and of duration $d$ is modelled by a precedence constraint of the form $o+d\le \mathrm{𝑑𝑒𝑎𝑑𝑙𝑖𝑛𝑒}$. This leads to the five constraints ${o}_{1}+2\le 12$, ${o}_{2}+4\le 15$, ${o}_{3}+3\le 24$, ${o}_{4}+2\le 24$, and ${o}_{5}+6\le 24$. Finally, we break symmetry on the assignment variables corresponding to a group of similar persons. In the example, the four nurses are similar since (1) they all have exactly the same unavailability periods, and since (2) no task requires a specific nurse. For each task using more than one nurse (i.e., tasks ${t}_{1}$, ${t}_{3}$, and ${t}_{4}$) this leads to a chain of strict inequalities, i.e., ${n}_{11}<{n}_{12}$, ${n}_{31}<{n}_{32}$, and ${n}_{41}<{n}_{42}<{n}_{43}$. Figure 3.7.1 depicts a solution to the problem corresponding to the assignment $\begin{array}{ccccc}\mathrm{𝚝𝚊𝚜𝚔𝚜}\hfill & \mathrm{𝚘𝚛𝚒𝚐𝚒𝚗}\hfill & \mathrm{𝚊𝚗𝚊𝚎𝚜𝚝𝚑𝚎𝚝𝚒𝚜𝚝}\hfill & \mathrm{𝚜𝚞𝚛𝚐𝚎𝚘𝚗}\hfill & \mathrm{𝚗𝚞𝚛𝚜𝚎}\hfill \\ {t}_{1}\hfill & {o}_{1}=10\hfill & {a}_{1}=1\hfill & {s}_{1}=3\hfill & {n}_{11}=5,{n}_{12}=6\hfill \\ {t}_{2}\hfill & {o}_{2}=8\hfill & {a}_{2}=2\hfill & {s}_{2}=4\hfill & {n}_{2}=7\hfill \\ {t}_{3}\hfill & {o}_{3}=2\hfill & {a}_{3}=1\hfill & {s}_{31}=3,{s}_{32}=4\hfill & {n}_{31}=5,{n}_{32}=6\hfill \\ {t}_{4}\hfill & {o}_{4}=17\hfill & {a}_{4}=1\hfill & {s}_{4}=4\hfill & {n}_{41}=5,{n}_{42}=6,{n}_{43}=7\hfill \\ {t}_{5}\hfill & {o}_{5}=16\hfill & {a}_{5}=2\hfill & {s}_{5}=3\hfill & {n}_{5}=8\hfill \end{array}$

The entry corresponding to the keyword relaxation dimension shows how to express relaxation in the context of over-constrained problems where we have too many surgeries to schedule with respect to the number of anaesthetists, surgeons and nurses and to their unavailability periods.