The increasing_nvalue Constraint Nicolas Beldiceanu, Fabien Hermennier, Xavier Lorca and Thierry Petit LINA CNRS UMR 6241 CPAIOR 2010
Initial Motivation Def: nvalue( N , X) holds iff variable N is equal to the number of distinct values assigned to the variables in X. Example : ( 3 , < 6 , 8 , 6 , 8 , 1 , 8 >) nvalue is NP-Hard nvalue occurs in many problems (e.g., domination in graphs, assignment ), some of them involve variable symmetry (e.g., entropy ) Is nvalue still NP-Hard if we impose x 0 ≤ x 1 ≤ … ≤ x n ? 2
Outline Definition GAC Algorithm Time Complexity and Reformulation Experiments Generalization of increasing_nvalue 3
Outline Definition GAC Algorithm Time Complexity and Reformulation Experiments Generalization of increasing_nvalue 4
Definition Def: increasing_nvalue ( N , X) holds iff : Variable N is equal to the number of distinct values assigned to the variables in X x 0 ≤ x 1 ≤ … x n Example : ( 3 , < 6 , 6 , 8 , 8 , 1 , 8 >) violates increasing_nvalue ( 3 , < 1 , 6 , 6 , 8 , 8 , 8 >) satisfies increasing_nvalue 5
Definition Def [Pesant CP01]: Given X = [ x 0, x 1, … x n ] a sequence of variables, a stretch on X is a maximum length subsequence S of X such that any consecutive pair of variables in S are equal. Example: < 6 , 6 , 8 , 8 , 1 , 8 , 8 , 8 > contains 4 stretches: < 6 , 6 >, < 8 , 8 >, < 1 >, and < 8 , 8 , 8 > 6
Definition increasing_nvalue : Since x 0 ≤ x 1 ≤ … ≤ x n the number of distinct values is equal to the number of stretches: Example: < 1 , 6 , 6 , 8 , 8 , 9 , 9 , 9 > contains 4 distinct values: < 1 >, < 6 , 6 >, < 8 , 8 >, and < 9 , 9 , 9 > 7
Definition increasing_nvalue : Since x 0 ≤ x 1 ≤ … ≤ x n-1 the number of distinct values is equal to the number of stretches: Example: < 1 , 6 , 6 , 8 , 8 , 9 , 9 , 9 > contains 4 distinct values: < 1 >, < 6 , 6 >, < 8 , 8 >, and < 9 , 9 , 9 > GAC algorithm : basically, estimate the minimum (resp. maximum) number of stretches if value v is assigned to x i 8
Outline Definition GAC Algorithm Time Complexity and Reformulation Experiments Generalization of increasing_nvalue 9
GAC Algorithm Compute the min. number of stretches of values Value 4 for x 2 : 9 s min [ x 2 …x 7 ] = 3 6 5 4 1 X 3 X 4 X 5 X 6 X 7 X 0 X 1 X 2 10
GAC Algorithm Compute the max. number of stretches of values Value 4 for x 2 : 9 s max [ x 2 …x 7 ] = 4 6 5 4 1 X 3 X 4 X 5 X 6 X 7 X 0 X 1 X 2 11
GAC Algorithm Filtering N from variables in X 1. Remove values violating necessarily constraints x 0 ≤ x 1 , …, x n-2 ≤ x n-1 : keep only well-ordered values 2. Compute min. and max. number of stretches of x 0 3. Compare with D( N ) 12
GAC Algorithm (1) Remove all the values 9 that are not well-ordered 6 5 4 1 X 3 X 4 X 5 X 6 X 7 X 0 X 1 X 2 13
GAC Algorithm (1) Remove all the values 9 that are not well-ordered 6 5 (2) Variable x 0 : 4 • value 4: 1 s min(4) [ x 0 …x 7 ] = 3 X 3 X 4 X 5 X 6 X 7 X 0 X 1 X 2 s max(4) [ x 0 …x 7 ] = 4 • value 6: s min(6) [ x 0 …x 7 ] = 2 s max(6) [ x 0 …x 7 ] = 2 14
GAC Algorithm (1) Remove all the values 9 that are not well-ordered 6 5 (2) Variable x 0 : 4 • value 4: 1 s min(4) [ x 0 …x 7 ] = 3 X 3 X 4 X 5 X 6 X 7 X 0 X 1 X 2 s max(4) [ x 0 …x 7 ] = 4 ⇒ SMIN = 2, SMAX = 4 • value 6: ⇒ Compare [SMIN,SMAX] with D( N ) s min(6) [ x 0 …x 7 ] = 2 s max(6) [ x 0 …x 7 ] = 2 15
GAC Algorithm Compare [SMIN, SMAX] with D(N) : Obvious: remove from D(N) values not in [SMIN, SMAX] An issue remains : If D(N) ⊂ [SMIN, SMAX] ? 16
GAC Algorithm Main theoretical contribution of the paper: To any k within [SMIN, SMAX] corresponds an assignment of values to variables in X As a consequence, increasing_nvalue has a solution ⇔ D(N) ∩ [SMIN, SMAX] ≠ ∅ 17
Intuition of the Result Properties on the max. and min. number of stretches ⇒ Given two values v 1 and v 2 in D( x i ) [s min(v1) , s max(v1) ] ∪ [s min(v2) , s max(v2) ] never has holes 18
Intuition of the Result ⇒ Given two values v 1 and v 2 in D( x i ) [s min(v1) , s max(v1) ] ∪ [s min(v2) , s max(v2) ] never has holes ⇒ Extreme case : 9 • value 9 : 6 s min(9) [ x 0 …x 7 ] = 1 s max(9) [ x 0 …x 7 ] = 1 5 4 • value 1 : 1 s min(1) [ x 0 …x 7 ] = 2 X 3 X 4 X 5 X 6 X 7 X 0 X 1 X 2 s max(1) [ x 0 …x 7 ] = 5 19
GAC Algorithm Filtering variables in X from N 1. Compute for each well-ordered value in D(x i ) the minimum and maximum number of stretches in the prefix [ x 0 , …, x i ] and in the suffix [ x i , …, x n-1 ] sequences. 2. Aggregate information and compare with the current domain of N 20
GAC Algorithm prefix (1) Remove values 9 that are not well-ordered 6 ? 5 (2) Value 5 for x 4 : p min [ x 0 …x 4 ] = 2 4 p max [ x 0 …x 4 ] = 2 1 s min [ x 4 …x 7 ] = 2 X 3 X 4 X 5 X 6 X 7 X 0 X 1 X 2 s max [ x 4 …x 7 ] = 3 suffix 21
GAC Algorithm (1) Remove values 9 that are not well-ordered 6 ? 5 (2) Value 5 for x 4 : p min [ x 0 …x 4 ] = 2 4 p max [ x 0 …x 4 ] = 2 1 s min [ x 4 …x 7 ] = 2 X 3 X 4 X 5 X 6 X 7 X 0 X 1 X 2 s max [ x 4 …x 7 ] = 3 (3) Aggregate prefix and suffix information: s min [ x 0 …x 7 ] = 3 (i.e., 2+2-1) s max [ x 0 …x 7 ] = 4 (i.e., 2+3-1) Compare [s min , s max ] with D(N) 22
GAC Algorithm From properties on min. and max. v in D( x i ) is GAC ⇔ D(N) ∩ [s min , s max ] ≠ ∅ 23
Outline Definition GAC Algorithm Time Complexity and Reformulation Experiments Generalization of Increasing NValue 24
Time Complexity For each value : compute p min , p max , s min , s max Compute values from previous (resp. next) variable i+1 (resp. i-1) 25
Time Complexity For each value : compute p min , p max , s min , s max Compute values from previous (resp. next) variable i+1 (resp. i-1) Use of sparse matrix : Iterate by scanning D( x i ) in increasing or decreasing order Values not in domain = default value (0 or n) Cumulated min on consecutive p min , p max , …= O (1) for each ⇒ Overall time complexity in O ( Σ D( x i )) 26
Reformulations of Increasing NValue Automaton * : O (n( ∪ D(xi)) 3 ) (space O(( ∪ D(xi)) 3 ) transitions) N =2 D( x i ) = [6..8] * Described in ( pdf version ): http://www.emn.fr/x-info/sdemasse/gccat/ 27
Outline Definition GAC Algorithm Time Complexity and Reformulation Experiments Generalization of increasing_nvalue 28
Experiments: unary tests Unary tests in CHOCO : enforcing GAC ( 200 variables, 200 values, 20% holes in domains ) With increasing_nvalue : 100% instances OK 0,1s medium time per instance With an automaton ( regular constraint) : 10% intances OK ( 90% memory overflow ) 2,8s medium time per solved instance 29
Experiment: entropy Source: VM4 is waiting Entropy : Optimize allocation of VMs into clusters (i.e., minimize the number of physical machines WN i ) Final configuration 30
Experiment: entropy Model overview: One variable per VM Its domain is the number of available physical machines WN nvalue on VM’s modelizes the number of machines used Use of increasing_nvalue as an implicit constraint Many WN’s have the same characteristics increasing_nvalue can be set on equivalence classes 31
Experiment: entropy 32
Outline Definition GAC Algorithm Time Complexity and Reformulation Experiments Generalization of increasing_nvalue 33
Generalization of Increasing NValue Goal: identify a class of sliding constraint for which GAC can be performed with a time complexity which depends only on the sum of domain sizes Generalization of the notion of stretch 34
Generalization of Increasing Nvalue (2) Def: Given X = [ x 0, x 1, … x n ] a sequence of variables and C a binary constraint, a C-stretch on X is a maximum length subsequence S of X such that: Either | S | = 1 (one single variable) and Either the interpretation C ( x i , x i ) is true ( universal constraint ) or false ( complementary of the universal constraint ) Or C is neither true nor false and C ( x i , x i ) holds Or | S | > 1 and C holds on any consecutive pair of variables in S . Example : < 6 , 6 , 8 , 8 , 1 , 10 , 8 , 8 , 8 , 1 > contains 3 ≤ -stretches: < 6 , 6 , 8 , 8 >, < 1 , 10 >, < 8 , 8 , 8 >, < 1 > 35
Generalization of Increasing Nvalue (3) Def: In SeqBin( N ,X, C , B ), N is a domain variable, X is a sequence of variables [x 0 ,x 1 ,…,x n-1 ] C is a binary constraint, B is a binary constraint. The constraint SeqBin* holds iff: (1) For all i in [0,n-2]: B( x i ,x i+1 ) holds, (2) N is the number of C-stretches in X. * For more details see: Beldiceanu, Lorca, Petit, “A GAC algorithm for a class of counting constraints”, TR10/1/INFO, École des Mines de Nantes, 2010. 36
Generalization of Increasing Nvalue (4) Thanks to SeqBin , GAC in O ( Σ D( x i )) for constraints such as change (N,X,binary constraint C) smooth increasing_among … Conclusion : even if automata (e.g., regular , cost_regular , …) can be used for different purpose (e.g., filtering , reformulation to linear constraints , computing constraint violation , generating implied constraints ), in the context of filtering, it is still worth trying to identify classes of global constraints for which a generic algorithm performs better ( memory is the key bottleneck for some automata ) 37
Recommend
More recommend