### 3.7.188. Phi-tree

A constraint for which one of its filtering algorithms uses a balanced binary tree in order to efficiently evaluate the maximum or minimum value of a formula over all possible subsets of tasks $\Omega$ of a given set of tasks $\Phi$. $\Phi$-trees were introduced by P. Vilím, first in the context of unary resources in [Vilim04] and in [Vilim07], and later on in the context of cumulative resources [Vilim09a], [Vilim09b]. Without loss of generality, let us sketch the main idea behind a $\Phi$-tree in the context of a cumulative resource of capacity $C$. For this purpose we follow the description given in [Vilim09a]. Given a set of tasks $\Phi$ where each task has an earliest possible start, a latest possible end, a duration and a resource consumption, assume we need to evaluate the earliest completion time over all tasks of $\Phi$ under the hypothesis that we should not exceed the maximum resource capacity $C$. Let us first introduce some notations:

• $\Omega$ denotes any non-empty subset of tasks of $\Phi$.

• ${\mathrm{𝑒𝑠𝑡}}_{\Omega }$ is the minimum over the earliest starts of the tasks in $\Omega$.

• ${e}_{\Omega }$ is the sum of the surfaces (i.e., the product of the duration by the resource consumption) of the tasks in $\Omega$.

##### Figure 3.7.51. Example of $\Phi$-tree associated with four tasks of respective duration and resource consumption $3×4$, $1×3$, $5×5$, $2×4$ and of respective earliest start 1, 3, 8, 9 under the assumption that the maximum capacity of the cumulative resource is equal to 5 A common estimation of the earliest completion time over all tasks of $\Phi$ is ${max}_{\Omega \subseteq \Phi }\left\{{\mathrm{𝑒𝑠𝑡}}_{\Omega }+⌈\frac{{e}_{\Omega }}{C}⌉\right\}$ which can be rewritten as $⌈\frac{{max}_{\Omega \subseteq \Phi }\left\{C{\mathrm{𝑒𝑠𝑡}}_{\Omega }+{e}_{\Omega }\right\}}{C}⌉$. The numerator of the last fraction is called the energy envelope of the set of tasks $\Phi$ and the purpose of a $\Phi$-tree is to evaluate this quantity efficiently. For a node $n$, let $ℒ\left(n\right)$ denote the set of leaves of the sub-tree rooted at $n$. The leaves of the $\Phi$-tree correspond to the tasks of $\Phi$ sorted from left to right by increasing earliest start. Each node $n$ of the $\Phi$-tree records both, the sum of the surfaces of the tasks in $ℒ\left(n\right)$, as well as the energy envelope of the tasks in $ℒ\left(n\right)$. The sum of the surfaces associated with a non-leave node $n$ of the tree corresponds to the sum of the surfaces of the children of $n$, while the energy envelope of $n$ is equal to the maximum between on the one hand, the energy envelop of its right child and on the other hand the sum of the energy envelop of its left child and the recorded sum of surfaces of its right child (see [Vilim09a] for a justification of these recursive formulae). Figure 3.7.51 illustrates the construction of a $\Phi$-tree associated with four given tasks.