### 2.2.3.2. Dynamic graph constraint

The purpose of a dynamic graph constraint is to enforce a condition on different subsets of variables, not known in advance. This situation occurs frequently in practice and is hard to express since one cannot use a classical constraint for which it is required to provide all variables right from the beginning. One good example of such global constraint is the $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$ constraint where one wants to force the sum of some variables to be less than or equal to a given limit. In the context of the $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$ constraint, each set of variables is defined by the height of the different tasks that overlap a given instant $i$. Since the origins of the tasks are not initially fixed, we do not know in advance which task will overlap a given instant and so, we cannot state any sum constraint initially.

A dynamic graph constraint is defined in exactly the same way as a simple graph constraint, except that we may omit the Graph property(ies) slot, and that we have to provide the two following additional slots:

• The Set slot denotes a generator of sets of vertices. Such a generator takes as argument a final graph and produces different sets of vertices. In order to have something tractable, we force the total number of generated sets to be polynomial in the number of vertices.

In practice each set of vertices is represented by a collection of items. The type of this collection corresponds either to the type of the items associated with the vertices, or to the type of a new derived collection. This is achieved by providing an expression of the form $\mathrm{\pi \pi \pi \pi }$ or $\mathrm{\pi \pi \pi \pi }$-$\mathrm{\pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$, where $\mathrm{\pi \pi \pi \pi }$ represents a formal parameter, and $\mathrm{\pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$ a declaration of a new derived collection (as specified in SectionΒ 2.2.2.1 on page 2.2.2.1).

• The Constraint(s) on sets slot provides a global constraint defined in the catalogue that has to hold for each set created by the previous generator.

We now describe the different generators of sets of vertices currently available:

• generates one single set containing all the vertices of the final graph. It is specified by a declaration of the form

where $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }$ represents all the vertices of the final graph.

• $\mathrm{\pi ’\pi ’}$ generates one set of vertices for each connected component of the final graph. These sets correspond to all the vertices of a given connected component. It is specified by a declaration of the form

$\mathrm{\pi ’\pi ’}>>\left[\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }\right]$

where $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }$ represents the vertices of a connected component of the final graph.

• generates all elementary pathsA path where all vertices are distinct is called an elementary path. of $L$ vertices of the final graph such that, discarding loops, all vertices of a path (except the last one) have no more than one successor in the final graph. It is specified by a declaration of the form

where $\mathrm{\pi \pi \pi \pi }$ represents the vertices of an elementary path, ordered according to their occurrence in the path.

• $\mathrm{\pi ―\pi ±\pi €\pi £}$ generates the non -empty sets corresponding to the predecessors of each vertex of the final graph. It is specified by a declaration of the form

$\mathrm{\pi ―\pi ±\pi €\pi £}>>\left[\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi },\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\right]$

where $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$ represents a vertex of the final graph and $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$ its predecessors.

• $\mathrm{\pi ²\pi ΄\pi ’\pi ’}$ generates the non -empty sets corresponding to the successors of each vertex of the final graph. It is specified by a declaration of the form

$\mathrm{\pi ²\pi ΄\pi ’\pi ’}>>\left[\mathrm{\pi \pi \pi \pi \pi \pi },\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }\right]$

where $\mathrm{\pi \pi \pi \pi \pi \pi }$ represents a vertex of the final graph and $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }$ its successors.

As an illustrative example of dynamic graph constraint we now consider the $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$ constraint.

EXAMPLE: The $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$$\left(\mathrm{\pi \pi °\pi \pi Ί\pi },\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }\right)$ constraint, where $\mathrm{\pi \pi °\pi \pi Ί\pi }$ is a collection of the form $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi \pi \pi \pi }-\mathrm{\pi \pi \pi \pi },\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }-\mathrm{\pi \pi \pi \pi },\mathrm{\pi \pi \pi }-\mathrm{\pi \pi \pi \pi },$ $\mathrm{\pi \pi \pi \pi \pi \pi }-\mathrm{\pi \pi \pi \pi }\right)$, and where $\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }$ is a non -negative integer, holds if, for any point the cumulated height of the set of tasks that overlap that point, does not exceed $\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }$.

The first graph constraint of $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$ enforces for each task of the $\mathrm{\pi \pi °\pi \pi Ί\pi }$ collection the equality $\mathrm{\pi \pi \pi \pi \pi \pi }+\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }=\mathrm{\pi \pi \pi }$. We focus on the second graph constraint, which uses a dynamic graph constraint described by the following items:

Arc input(s)Β Β Β Β Β Β Β :

$\mathrm{\pi \pi °\pi \pi Ί\pi }\mathrm{\pi \pi °\pi \pi Ί\pi }$

Arc generatorΒ Β Β Β Β :

$\mathrm{\pi \pi  \pi \pi ·\pi \pi Ά\pi }\beta ¦\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi \pi \pi }\mathtt{1},\mathrm{\pi \pi \pi \pi \pi }\mathtt{2}\right)$

Arc arityΒ Β Β Β Β Β Β Β Β Β :

2

Arc constraint(s)Β Β Β :

$\mathrm{\pi \pi \pi \pi \pi }\mathtt{1}.\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }>\mathtt{0}$

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β

$\mathrm{\pi \pi \pi \pi \pi }\mathtt{2}.\mathrm{\pi \pi \pi \pi \pi \pi }\beta €\mathrm{\pi \pi \pi \pi \pi }\mathtt{1}.\mathrm{\pi \pi \pi \pi \pi \pi }$

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β

$\mathrm{\pi \pi \pi \pi \pi }\mathtt{1}.\mathrm{\pi \pi \pi \pi \pi \pi }\beta €\mathrm{\pi \pi \pi \pi \pi }\mathtt{2}.\mathrm{\pi \pi \pi }$

SetsΒ Β Β Β Β Β Β Β Β Β Β Β Β Β :

$\mathrm{\pi ²\pi ΄\pi ’\pi ’}>>$

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β $\left[\mathrm{\pi \pi \pi \pi \pi \pi },$

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }-\mathrm{\pi \pi \pi }\left(\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }-\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi }-\mathrm{\pi \pi \pi \pi }\right),$

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β $\left[\mathrm{\pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi }-\mathrm{\pi \pi °\pi \pi Ί\pi }.\mathrm{\pi \pi \pi \pi \pi \pi }\right)\right]\right)\right]$

Constraint(s) on sets:

$\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi }$$\left(\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi },\beta €,\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }\right)$

The second graph constraint is defined by:

• To each item of the $\mathrm{\pi \pi °\pi \pi Ί\pi }$ collection correspond two vertices of the initial graph.

• The arity of the arc constraint is 2.

• The arcs of the initial graph are constructed with the $\mathrm{\pi \pi  \pi \pi ·\pi \pi Ά\pi }$ arc generator between the $\mathrm{\pi \pi °\pi \pi Ί\pi }$ collection and the $\mathrm{\pi \pi °\pi \pi Ί\pi }$ collection. Therefore, each vertex associated with a task is linked to all the vertices related to the different tasks.

• The arc constraint that is associated with an arc between a task $\mathrm{\pi \pi \pi \pi \pi }\mathtt{1}$ and a task $\mathrm{\pi \pi \pi \pi \pi }\mathtt{2}$ is an overlapping constraint that holds if both, the duration of $\mathrm{\pi \pi \pi \pi \pi }\mathtt{1}$ is strictly greater than zero, and if the origin of $\mathrm{\pi \pi \pi \pi \pi }\mathtt{1}$ is overlapped by task $\mathrm{\pi \pi \pi \pi \pi }\mathtt{2}$.

• The set generator is $\mathrm{\pi ²\pi ΄\pi ’\pi ’}$. The final graph will consist of those tasks for which the origin is covered by at least one task and of those corresponding tasks.

• The dynamic constraint on a set forces the sum of the heights of the tasks that belong to a successor set to not exceed $\mathrm{\pi »\pi Έ\pi Ό\pi Έ\pi }$.

Parts (A) and (B) of FigureΒ 2.2.6 respectively show the initial and the final graph corresponding to the following instance:

$\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$$\left(\beta ©\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{1}\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }-\mathtt{3}\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{1},$

$\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{2}\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }-\mathtt{9}\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{2},$

$\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{3}\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }-\mathtt{10}\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{1},$

$\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{6}\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }-\mathtt{6}\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{1},$

$\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{7}\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }-\mathtt{2}\mathrm{\pi \pi \pi \pi \pi \pi }-\mathtt{3}\beta ͺ,\mathtt{8}\right).$

We label the vertices of the initial and final graph by giving the $\mathrm{\pi \pi \pi ’}$$\mathrm{\pi \pi \pi ’}$ is an implicit attribute corresponding to the position of an item within a collection that was introduced in SectionΒ 2.1.2 on page 2.1.2. of the corresponding task. On both graphs the edges are oriented from left to right. On the final graph we consider the sets that consist of the successors of the different vertices; those are the sets of tasks $\left\{1\right\}$, $\left\{1,2\right\}$, $\left\{1,2,3\right\}$, $\left\{2,3,4\right\}$ and $\left\{2,3,4,5\right\}$. Since the $\mathrm{\pi ²\pi ΄\pi ’\pi ’}$ set generator uses a derived collection that only considers the $\mathrm{\pi \pi \pi \pi \pi \pi }$ attribute of a task, these sets respectively correspond to the following collection of items:

• $\beta ©\mathrm{\pi \pi \pi }-\mathtt{1}\beta ͺ$,

• $\beta ©\mathrm{\pi \pi \pi }-\mathtt{1},\mathrm{\pi \pi \pi }-\mathtt{2}\beta ͺ$,

• $\beta ©\mathrm{\pi \pi \pi }-\mathtt{1},\mathrm{\pi \pi \pi }-\mathtt{2},\mathrm{\pi \pi \pi }-\mathtt{1}\beta ͺ$,

• $\beta ©\mathrm{\pi \pi \pi }-\mathtt{2},\mathrm{\pi \pi \pi }-\mathtt{1},\mathrm{\pi \pi \pi }-\mathtt{1}\beta ͺ$,

• $\beta ©\mathrm{\pi \pi \pi }-\mathtt{2},\mathrm{\pi \pi \pi }-\mathtt{1},\mathrm{\pi \pi \pi }-\mathtt{1},\mathrm{\pi \pi \pi }-\mathtt{3}\beta ͺ$.

The $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }$ constraint holds since, for each successors set, the corresponding constraint holds:

The $\mathrm{\pi \pi \pi }_\mathrm{\pi \pi \pi }$$\left(\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi },\mathrm{\pi ²\pi \pi },\mathrm{\pi  \pi °\pi }\right)$ constraint holds if the sum $\mathrm{\pi }$ of the variables of the $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ collection satisfies $\mathrm{\pi }\mathrm{\pi ²\pi \pi }\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$, where $\mathrm{\pi ²\pi \pi }$ is a comparison operator.