5.43. binary_tree

DESCRIPTIONLINKSGRAPH
Origin

Derived from πšπš›πšŽπšŽ.

Constraint

πš‹πš’πš—πšŠπš›πš’_πšπš›πšŽπšŽ(π™½πšƒπšπ™΄π™΄πš‚,π™½π™Ύπ™³π™΄πš‚)

Arguments
π™½πšƒπšπ™΄π™΄πš‚πšπšŸπšŠπš›
π™½π™Ύπ™³π™΄πš‚πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš’πš—πšπšŽπš‘-πš’πš—πš,𝚜𝚞𝚌𝚌-πšπšŸπšŠπš›)
Restrictions
π™½πšƒπšπ™΄π™΄πš‚β‰₯0
π™½πšƒπšπ™΄π™΄πš‚β‰€|π™½π™Ύπ™³π™΄πš‚|
πš›πšŽπššπšžπš’πš›πšŽπš(π™½π™Ύπ™³π™΄πš‚,[πš’πš—πšπšŽπš‘,𝚜𝚞𝚌𝚌])
π™½π™Ύπ™³π™΄πš‚.πš’πš—πšπšŽπš‘β‰₯1
π™½π™Ύπ™³π™΄πš‚.πš’πš—πšπšŽπš‘β‰€|π™½π™Ύπ™³π™΄πš‚|
πšπš’πšœπšπš’πš—πšŒπš(π™½π™Ύπ™³π™΄πš‚,πš’πš—πšπšŽπš‘)
π™½π™Ύπ™³π™΄πš‚.𝚜𝚞𝚌𝚌β‰₯1
π™½π™Ύπ™³π™΄πš‚.πšœπšžπšŒπšŒβ‰€|π™½π™Ύπ™³π™΄πš‚|
Purpose

Cover the digraph G described by the π™½π™Ύπ™³π™΄πš‚ collection with π™½πšƒπšπ™΄π™΄πš‚ binary trees in such a way that each vertex of G belongs to exactly one binary tree (i.e.,Β each vertex of G has at most two children). The edges of the binary trees are directed from their leaves to their respective root.

Example
2,πš’πš—πšπšŽπš‘-1𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-2𝚜𝚞𝚌𝚌-3,πš’πš—πšπšŽπš‘-3𝚜𝚞𝚌𝚌-5,πš’πš—πšπšŽπš‘-4𝚜𝚞𝚌𝚌-7,πš’πš—πšπšŽπš‘-5𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-6𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-7𝚜𝚞𝚌𝚌-7,πš’πš—πšπšŽπš‘-8𝚜𝚞𝚌𝚌-5

The πš‹πš’πš—πšŠπš›πš’_πšπš›πšŽπšŽ constraint holds since its second argument corresponds to the 2 (i.e.,Β the first argument of the πš‹πš’πš—πšŠπš›πš’_πšπš›πšŽπšŽ constraint) binary trees depicted by FigureΒ 5.43.1.

Figure 5.43.1. The two binary trees corresponding to the Example slot
ctrs/binary_tree1
Typical
π™½πšƒπšπ™΄π™΄πš‚>0
π™½πšƒπšπ™΄π™΄πš‚<|π™½π™Ύπ™³π™΄πš‚|
|π™½π™Ύπ™³π™΄πš‚|>2
Symmetry

Items of π™½π™Ύπ™³π™΄πš‚ are permutable.

Reformulation

The πš‹πš’πš—πšŠπš›πš’_πšπš›πšŽπšŽ constraint can be expressed in term of (1)Β a set of |π™½π™Ύπ™³π™΄πš‚| 2 reified constraints for avoiding circuit between more than one node and of (2)Β |π™½π™Ύπ™³π™΄πš‚| reified constraints and of one sum constraint for counting the trees and of (3)Β a set of |π™½π™Ύπ™³π™΄πš‚| 2 reified constraints and of |π™½π™Ύπ™³π™΄πš‚| inequalities constraints for enforcing the fact that each vertex has at most two children.

  1. For each vertex π™½π™Ύπ™³π™΄πš‚[i] (i∈[1,|π™½π™Ύπ™³π™΄πš‚|]) of the π™½π™Ύπ™³π™΄πš‚ collection we create a variable R i that takes its value within interval [1,|π™½π™Ύπ™³π™΄πš‚|]. This variable represents the rank of vertex π™½π™Ύπ™³π™΄πš‚[i] within a solution. It is used to prevent the creation of circuit involving more than one vertex as explained now. For each pair of vertices π™½π™Ύπ™³π™΄πš‚[i],π™½π™Ύπ™³π™΄πš‚[j] (i,j∈[1,|π™½π™Ύπ™³π™΄πš‚|]) of the π™½π™Ύπ™³π™΄πš‚ collection we create a reified constraint of the form π™½π™Ύπ™³π™΄πš‚[i].𝚜𝚞𝚌𝚌=π™½π™Ύπ™³π™΄πš‚[j].πš’πš—πšπšŽπš‘βˆ§iβ‰ jβ‡’R i <R j . The purpose of this constraint is to express the fact that, if there is an arc from vertex π™½π™Ύπ™³π™΄πš‚[i] to another vertex π™½π™Ύπ™³π™΄πš‚[j], then R i should be strictly less than R j .

  2. For each vertex π™½π™Ύπ™³π™΄πš‚[i] (i∈[1,|π™½π™Ύπ™³π™΄πš‚|]) of the π™½π™Ύπ™³π™΄πš‚ collection we create a 0-1 variable B i and state the following reified constraint π™½π™Ύπ™³π™΄πš‚[i].𝚜𝚞𝚌𝚌=π™½π™Ύπ™³π™΄πš‚[i].πš’πš—πšπšŽπš‘β‡”B i in order to force variable B i to be set to value 1 if and only if there is a loop on vertex π™½π™Ύπ™³π™΄πš‚[i]. Finally we create a constraint π™½πšƒπšπ™΄π™΄πš‚=B 1 +B 2 +...+B |π™½π™Ύπ™³π™΄πš‚| for stating the fact that the number of trees is equal to the number of loops of the graph.

  3. For each pair of vertices π™½π™Ύπ™³π™΄πš‚[i],π™½π™Ύπ™³π™΄πš‚[j] (i,j∈[1,|π™½π™Ύπ™³π™΄πš‚|]) of the π™½π™Ύπ™³π™΄πš‚ collection we create a 0-1 variable B ij and state the following reified constraint π™½π™Ύπ™³π™΄πš‚[i].𝚜𝚞𝚌𝚌=π™½π™Ύπ™³π™΄πš‚[j].πš’πš—πšπšŽπš‘βˆ§iβ‰ j⇔B ij . Variable B ij is set to value 1 if and only if there is an arc from π™½π™Ύπ™³π™΄πš‚[i] to π™½π™Ύπ™³π™΄πš‚[j]. Then for each vertex π™½π™Ύπ™³π™΄πš‚[j] (j∈[1,|π™½π™Ύπ™³π™΄πš‚|]) we create a constraint of the form B 1j +B 2j +...+B |π™½π™Ύπ™³π™΄πš‚|j ≀2.

See also

generalisation: πšπš›πšŽπšŽΒ (at most two childrens replaced by no restriction on maximum number of childrens).

implied by: πš™πšŠπšπš‘.

implies: πšπš›πšŽπšŽ.

specialisation: πš™πšŠπšπš‘Β (at most two childrens replaced by at most one child).

Keywords

constraint type: graph constraint, graph partitioning constraint.

final graph structure: connected component, tree, one_succ.

Arc input(s)

π™½π™Ύπ™³π™΄πš‚

Arc generator
πΆπΏπΌπ‘„π‘ˆπΈβ†¦πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš—πš˜πšπšŽπšœ1,πš—πš˜πšπšŽπšœ2)

Arc arity
Arc constraint(s)
πš—πš˜πšπšŽπšœ1.𝚜𝚞𝚌𝚌=πš—πš˜πšπšŽπšœ2.πš’πš—πšπšŽπš‘
Graph property(ies)
β€’ πŒπ€π—_𝐍𝐒𝐂𝐂≀1
β€’ 𝐍𝐂𝐂=π™½πšƒπšπ™΄π™΄πš‚
β€’ πŒπ€π—_πˆπƒβ‰€2

Graph class
𝙾𝙽𝙴_πš‚πš„π™²π™²

Graph model

We use the same graph constraint as for the πšπš›πšŽπšŽ constraint, except that we add the graph property πŒπ€π—_πˆπƒ ≀ 2, which constraints the maximum in -degree of the final graph to not exceed 2. πŒπ€π—_πˆπƒ does not consider loops: This is why we do not have any problem with the root of each tree.

PartsΒ (A) andΒ (B) of FigureΒ 5.43.2 respectively show the initial and final graph associated with the Example slot. Since we use the 𝐍𝐂𝐂 graph property, we display the two connected components of the final graph. Each of them corresponds to a binary tree. Since we use the πŒπ€π—_𝐈𝐍_𝐃𝐄𝐆𝐑𝐄𝐄 graph property, we also show with a double circle a vertex that has a maximum number of predecessors.

The πš‹πš’πš—πšŠπš›πš’_πšπš›πšŽπšŽ constraint holds since all strongly connected components of the final graph have no more than one vertex, since π™½πšƒπšπ™΄π™΄πš‚ = 𝐍𝐂𝐂 = 2 and since πŒπ€π—_πˆπƒ = 2.

Figure 5.43.2. Initial and final graph of the πš‹πš’πš—πšŠπš›πš’_πšπš›πšŽπšŽ constraint
ctrs/binary_treeActrs/binary_treeB
(a) (b)