5.43. balance
DESCRIPTION | LINKS | GRAPH | AUTOMATON |
- Origin
N.Β Beldiceanu
- Constraint
- Arguments
- Restrictions
- Purpose
is equal to the difference between the number of occurrence of the value that occurs the most and the value that occurs the least within the collection of variables .
- Example
-
In the first example, values and 7 are respectively used and 1 times. The corresponding constraint holds since its first argument is assigned to the difference between the maximum and minimum number of the previous occurrences (i.e.,Β ). FigureΒ 5.43.1 shows the solution associated with this first example.
Figure 5.43.1. Illustration of the first example of the Example slot: five variables , , , , respectively fixed to values 3, 1, 7, 1 and 1, and the corresponding value of
- All solutions
FigureΒ 5.43.2 gives all solutions to the following non ground instance of the constraint: , , , , , .
Figure 5.43.2. All solutions corresponding to the non ground example of the constraint of the All solutions slot
- Typical
- Symmetries
Items of are permutable.
All occurrences of two distinct values of can be swapped; all occurrences of a value of can be renamed to any unused value.
- Arg. properties
Functional dependency: determined by .
- Usage
An application of the constraint is to enforce a balanced assignment of values, no matter how many distinct values will be used. In this case one will push down the maximum value of the first argument of the constraint.
- Remark
If we do not want to use an automaton with an array of counters a possible reformulation of the constraint can be achieved in the following way. We use a constraint in order to reorder the variables of the collection and compute the difference between the longest and the smallest sequences of consecutive values.
- Counting
-
Length () 2 3 4 5 6 7 8 Solutions 9 64 625 7776 117649 2097152 43046721 Number of solutions for : domains
Length () 2 3 4 5 6 7 8 Total 9 64 625 7776 117649 2097152 43046721 Parameter value 0 9 28 185 726 8617 40328 682929 1 - 36 360 5700 75600 1342600 24272640 2 - - 80 1200 30030 611520 15350832 3 - - - 150 3150 95256 2469600 4 - - - - 252 7056 256032 5 - - - - - 392 14112 6 - - - - - - 576 Solution count for : domains
- See also
generalisation: Β ( replaced by ), Β ( replaced by ), Β ( replaced by ).
implies: .
related: Β (balanced assignment versus graph partitionning with balanced cycles), Β (balanced assignment versus graph partitionning with balanced paths), Β (balanced assignment versus graph partitionning with balanced trees), Β (no restriction on how balanced an assignment is), Β (balanced assignment versus balanced tree).
- Keywords
-
characteristic of a constraint: automaton, automaton with array of counters.
constraint arguments: pure functional dependency.
constraint type: value constraint.
- Arc input(s)
- Arc generator
-
- Arc arity
- Arc constraint(s)
- Graph property(ies)
-
- Graph class
-
- Graph model
The graph property constraints the difference between the sizes of the largest and smallest strongly connected components.
PartsΒ (A) andΒ (B) of FigureΒ 5.43.3 respectively show the initial and final graph associated with the first example of the Example slot. Since we use the graph property, we show the largest and smallest strongly connected components of the final graph.
Figure 5.43.3. Initial and final graph of the constraint
(a) (b)
- Automaton
FigureΒ 5.43.4 depicts the automaton associated with the constraint. To each item of the collection corresponds a signature variable that is equal to 1.
Figure 5.43.4. Automaton of the constraint