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

Given 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 requesting the subtask to finish no later than a given date.

• A person indicating which person performs the subtask.

Both the start and the person correspond to discrete decision variables, while the duration and the deadline are integers. Since all subtasks of a same task must run in parallel, their start, duration and deadline 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 an 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 its own calendar defining its unavailability. On the one hand, let us assume we have two anaesthetists, two surgeons and four nurses that are 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 operation 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 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 (i.e., 1 since it requires one person). The coordinates of the leftmost lower 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,

$\mathrm{𝚐𝚎𝚘𝚜𝚝}$$\left(2,$

 $〈\mathrm{𝚘𝚒𝚍}-1$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈{o}_{1},{a}_{1}〉,$ $\mathrm{𝚘𝚒𝚍}-2$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈{o}_{1},{s}_{1}〉,$ $\mathrm{𝚘𝚒𝚍}-3$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈{o}_{1},{n}_{11}〉,$ $\mathrm{𝚘𝚒𝚍}-4$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈{o}_{1},{n}_{12}〉,$ $\mathrm{𝚘𝚒𝚍}-5$ $\mathrm{𝚜𝚒𝚍}-4$ $𝚡-〈{o}_{2},{a}_{2}〉,$ $\mathrm{𝚘𝚒𝚍}-6$ $\mathrm{𝚜𝚒𝚍}-4$ $𝚡-〈{o}_{2},{s}_{2}〉,$ $\mathrm{𝚘𝚒𝚍}-7$ $\mathrm{𝚜𝚒𝚍}-4$ $𝚡-〈{o}_{2},{n}_{2}〉,$ $\mathrm{𝚘𝚒𝚍}-8$ $\mathrm{𝚜𝚒𝚍}-3$ $𝚡-〈{o}_{3},{a}_{3}〉,$ $\mathrm{𝚘𝚒𝚍}-9$ $\mathrm{𝚜𝚒𝚍}-3$ $𝚡-〈{o}_{3},{s}_{31}〉,$ $\mathrm{𝚘𝚒𝚍}-10$ $\mathrm{𝚜𝚒𝚍}-3$ $𝚡-〈{o}_{3},{s}_{32}〉,$ $\mathrm{𝚘𝚒𝚍}-11$ $\mathrm{𝚜𝚒𝚍}-3$ $𝚡-〈{o}_{3},{n}_{31}〉,$ $\mathrm{𝚘𝚒𝚍}-12$ $\mathrm{𝚜𝚒𝚍}-3$ $𝚡-〈{o}_{3},{n}_{32}〉,$ $\mathrm{𝚘𝚒𝚍}-13$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈{o}_{4},{a}_{4}〉,$ $\mathrm{𝚘𝚒𝚍}-14$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈{o}_{4},{s}_{4}〉,$ $\mathrm{𝚘𝚒𝚍}-15$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈{o}_{4},{n}_{41}〉,$ $\mathrm{𝚘𝚒𝚍}-16$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈{o}_{4},{n}_{42}〉,$ $\mathrm{𝚘𝚒𝚍}-17$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈{o}_{4},{n}_{43}〉,$ $\mathrm{𝚘𝚒𝚍}-18$ $\mathrm{𝚜𝚒𝚍}-6$ $𝚡-〈{o}_{5},{a}_{5}〉,$ $\mathrm{𝚘𝚒𝚍}-19$ $\mathrm{𝚜𝚒𝚍}-6$ $𝚡-〈{o}_{5},{s}_{5}〉,$ $\mathrm{𝚘𝚒𝚍}-20$ $\mathrm{𝚜𝚒𝚍}-6$ $𝚡-〈{o}_{5},{n}_{5}〉,$ $\mathrm{𝚘𝚒𝚍}-21$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈0,1〉,$ $\mathrm{𝚘𝚒𝚍}-22$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈5,1〉,$ $\mathrm{𝚘𝚒𝚍}-23$ $\mathrm{𝚜𝚒𝚍}-5$ $𝚡-〈12,1〉,$ $\mathrm{𝚘𝚒𝚍}-24$ $\mathrm{𝚜𝚒𝚍}-3$ $𝚡-〈0,2〉,$ $\mathrm{𝚘𝚒𝚍}-25$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈6,2〉,$ $\mathrm{𝚘𝚒𝚍}-26$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈15,2〉,$ $\mathrm{𝚘𝚒𝚍}-27$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈22,2〉,$ $\mathrm{𝚘𝚒𝚍}-28$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈0,3〉,$ $\mathrm{𝚘𝚒𝚍}-29$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈8,3〉,$ $\mathrm{𝚘𝚒𝚍}-30$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈13,3〉,$ $\mathrm{𝚘𝚒𝚍}-31$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈5,4〉,$ $\mathrm{𝚘𝚒𝚍}-32$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚡-〈20,4〉,$ $\mathrm{𝚘𝚒𝚍}-33$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈0,5〉,$ $\mathrm{𝚘𝚒𝚍}-34$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈7,5〉,$ $\mathrm{𝚘𝚒𝚍}-35$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈12,5〉,$ $\mathrm{𝚘𝚒𝚍}-36$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈22,5〉,$ $\mathrm{𝚘𝚒𝚍}-37$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈0,6〉,$ $\mathrm{𝚘𝚒𝚍}-38$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈7,6〉,$ $\mathrm{𝚘𝚒𝚍}-39$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈12,6〉,$ $\mathrm{𝚘𝚒𝚍}-40$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈22,6〉,$ $\mathrm{𝚘𝚒𝚍}-41$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈0,7〉,$ $\mathrm{𝚘𝚒𝚍}-42$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈7,7〉,$ $\mathrm{𝚘𝚒𝚍}-43$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈12,7〉,$ $\mathrm{𝚘𝚒𝚍}-44$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈22,7〉,$ $\mathrm{𝚘𝚒𝚍}-45$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈0,8〉,$ $\mathrm{𝚘𝚒𝚍}-46$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈7,8〉,$ $\mathrm{𝚘𝚒𝚍}-47$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈12,8〉,$ $\mathrm{𝚘𝚒𝚍}-48$ $\mathrm{𝚜𝚒𝚍}-1$ $𝚡-〈22,8〉〉,$ $〈\mathrm{𝚜𝚒𝚍}-1$ $𝚝-〈0,0〉$ $𝚕-〈1,1〉,$ $\mathrm{𝚜𝚒𝚍}-2$ $𝚝-〈0,0〉$ $𝚕-〈2,1〉,$ $\mathrm{𝚜𝚒𝚍}-3$ $𝚝-〈0,0〉$ $𝚕-〈3,1〉,$ $\mathrm{𝚜𝚒𝚍}-4$ $𝚝-〈0,0〉$ $𝚕-〈4,1〉,$ $\mathrm{𝚜𝚒𝚍}-5$ $𝚝-〈0,0〉$ $𝚕-〈5,1〉,$ $\mathrm{𝚜𝚒𝚍}-6$ $𝚝-〈0,0〉$ $𝚕-〈6,1〉〉\right)$.

A deadline constraint for an operation 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 ${o}_{1}=10$, ${a}_{1}=1$, ${s}_{1}=3$, ${n}_{11}=5$, ${n}_{12}=6$, ${o}_{2}=8$, ${a}_{2}=2$, ${s}_{2}=4$, ${n}_{2}=7$, ${o}_{3}=2$, ${a}_{3}=1$, ${s}_{31}=3$, ${s}_{32}=4$, ${n}_{31}=5$, ${n}_{32}=6$, ${o}_{4}=17$, ${a}_{4}=1$, ${s}_{4}=4$, ${n}_{41}=5$, ${n}_{42}=6$, ${n}_{43}=7$, ${o}_{5}=16$, ${a}_{5}=2$, ${s}_{5}=3$, ${n}_{5}=8$.

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 operations to schedule with respect to the number of anaesthetists, surgeons and nurses and to their unavailability periods.