13.07.2015 Views

The Deviation Constraint - Université catholique de Louvain

The Deviation Constraint - Université catholique de Louvain

The Deviation Constraint - Université catholique de Louvain

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>The</strong> <strong>Deviation</strong> <strong>Constraint</strong>Pierre Schaus 1 , Yves Deville 1 , Pierre Dupont 1 , Jean-Charles Régin 21 Université <strong>catholique</strong> <strong>de</strong> <strong>Louvain</strong>, Belgium{pschaus, y<strong>de</strong>, pdupont}@info.ucl.ac.be2 ILOG, Franceregin@ilog.frAbstract. This paper introduces DEVIATION, a soft global constraint toobtain balanced solutions. A violation measure of the perfect balancecan be <strong>de</strong>fined as the L p norm of the vector variables minus their mean.SPREAD constraints the sum of square <strong>de</strong>viations to the mean [5, 7] i.e. theL 2 norm. <strong>The</strong> L 1 norm is consi<strong>de</strong>red here. Neither criterion subsumes theother but the <strong>de</strong>sign of a propagator for L 1 is simpler. We also show thata propagator for DEVIATION runs in O(n) (with respect to the number ofvariables) against O(n 2 ) for SPREAD.1 IntroductionWe consi<strong>de</strong>r the Balanced Aca<strong>de</strong>mic Curriculum Problem (BACP) [1] as a motivatingexample. <strong>The</strong> goal is to assign a period to each course in a way that theprerequisite relationships are satisfied and the aca<strong>de</strong>mic load of each period isbalanced. This last constraint makes BACP a <strong>Constraint</strong> Optimization Problemwhere the objective is to maximize the balancing property.In BACP the mean m of a solution is a constant of the problem since theload of each course and the number of periods are given. A hard balancingconstraint would impose all periods to take a same load m. This often resultsin an over-constrained problem without solution. For a set of variables X ={X 1 , X 2 , ..., X n } and a given fixed mean m, a violation measure of the perfectbalance property can be <strong>de</strong>fined as the L p -norm of the vector [X − m] withX = [X 1 , X 2 , ..., X n ], m = [m, m, ..., m] such that ∑ ni=1 X i = n.m. <strong>The</strong> L p -norm of [X − m] is <strong>de</strong>fined as ( ∑ ni=1 |X i − m| p ) 1 pwith p ≥ 0.Following the scheme proposed by Régin et al. [6] to soften global constraints,we <strong>de</strong>fine a violation of the perfect balance constraint as a cost variable L p inthe global balance constraint: soft-balance(X , m, L p ) constraint holds if andonly if L p -norm([X − m]) = L p and ∑ ni=1 X i = n.m.<strong>The</strong> interpretation of the violation to the mean for some specific norms isgiven below.• L 0 : |{X ∈ X |X ≠ m}| is the number of values different from the mean.• L 1 : ∑ X∈X|X − m| is the sum of <strong>de</strong>viations from the mean.• L 2 : ∑ X∈X (X − m)2 is the sum of square <strong>de</strong>viations from the mean.• L ∞ : max X∈X |X − m| is the maximum <strong>de</strong>viation from the mean.


Note that none of these balance criteria subsumes the others. For instance,the minimization of L 1 does not imply in general a minimization of criterionL 2 . This is illustrated on the following example. Assume a constraint problemwith four solutions given in Table 1. <strong>The</strong> most balanced solution <strong>de</strong>pends onthe chosen norm. Each solution exhibits a mean of 100 but each one optimizesa different norm.sol. num. solution L 0 L 1 L 2 L ∞1 100 100 100 100 30 170 2 140 9800 702 60 80 100 100 120 140 4 120 4000 403 70 70 90 110 130 130 6 140 3800 304 71 71 71 129 129 129 6 174 5046 29Table 1. Illustration showing that no balance criterion <strong>de</strong>fined by the norm L 0, L 1,L 2 or L ∞ subsumes the others. <strong>The</strong> smallest norm is indicated in bold character. Forexample, solution 2 is the most balanced according to L 1.<strong>The</strong> norm L ∞ has already been used in two previous works [2, 4] to solveBACP. SPREAD is a constraint for L 2 [5, 7]. A constraint for L 0 can easily beimplemented using an ATLEAST(i, [X 1 , ..., X n ], m) constraint for |{X ∈ X |X ≠m}| ≤ i and a SUM([X 1 , ..., X n ], n.m) constraint to ensure a mean of m. In thispaper, a global constraint and its propagators for the L 1 norm with fixed meanis presented. This constraint is formulated in the following <strong>de</strong>finition:Definition 1. A set of finite domain integer variables X = {X 1 , X 2 , ..., X n },one mean value m and one interval variable D are given.<strong>The</strong> constraint DEVIATION(X , m, D) states that the collection of values takenby the variables of X exhibits an arithmetic mean m and a sum of <strong>de</strong>viations tom of D. More formally, DEVIATION(X , m, D) holds if and only ifn.m =n∑X i and D =i=1n∑|X i − m|.For the constraint to be consistent, n × m must be an integer. As a consequencen × D is also an integer.i=1Outline of the paper:Section 2 mainly reviews preliminaries notions relative to constraint programmingsuch as filtering, domain-consistency and bound-consistency. We also <strong>de</strong>finesome useful notations. Section 3 motivates the need of a global filtering algorithmfor DEVIATION in terms of filtering. Section 4 explains the propagatorsnarrowing the domain of D. This filtering makes use of the minimization andmaximization of the sum of <strong>de</strong>viations. <strong>The</strong> minimization is solved in linear2


time. <strong>The</strong> maximization is proved to be N P-complete; however, an approximatedupper bound can be calculated in linear time as well. Section 5 <strong>de</strong>scribesthe filtering algorithm from m and D to the variables X . <strong>The</strong> i<strong>de</strong>a is similar to abound consistency filtering algorithm for a SUM constraint but including the sumof <strong>de</strong>viations constraint. Section 6 shows that our propagators do not achievebound-consistency. Section 7 gives a relaxation of SPREAD with DEVIATION. Finally,Section 8 evaluates the efficiency of the presented propagators in terms offiltering on randomly generated instances.2 Background and notationsBasic constraint programming concepts largely inspired from Section 2 of [8] areintroduced.Let X be a finite-domain (discrete) variable. <strong>The</strong> domain of X is a set ofor<strong>de</strong>red values that can be assigned to X and is <strong>de</strong>noted by Dom(X). <strong>The</strong> minimum(resp. maximum) value of the domain is <strong>de</strong>noted by X min = min(Dom(X))(resp. X max = max(Dom(X)). Let X = {X 1 , X 2 , ..., X k } be a sequence of variables.A constraint C on X is <strong>de</strong>fined as a subset of the Cartesian product ofthe domains of the variables in X : C ⊆ Dom(X 1 ) × Dom(X 2 ) × ... × Dom(X k ).A tuple (v 1 , ..., v k ) ∈ C is called a solution to C. A value v ∈ Dom(X i ) for somei = 1, ..., k is inconsistent with respect to C if it does not belong to a tuple ofC, otherwise it is consistent. C is inconsistent if it does not contain a solution.Otherwise, C is called consistent.A constraint satisfaction problem, or a CSP , is <strong>de</strong>fined by a finite sequenceof variables X = {X 1 , X 2 , ..., X n }, together with a finite set of constraint C eachon a subset of X . <strong>The</strong> goal is to find an assignment X i := v with v ∈ Dom(X i )for i = 1, ..., n, such that all constraints are satisfied. This assignment is calleda solution to the CSP .<strong>The</strong> solution process of constraint programming interleaves constraint propagation,or propagation in short, and search. <strong>The</strong> search process essentially consistsof enumeration all possible variable-value combinations, until a solution isfound or it is proved that none exists. We say that this process constructs asearch tree. To reduce the exponential number of combinations, constraint propagationis applied to each no<strong>de</strong> of the search tree: Given the current domainsand a constraint C, the propagator for C removes domain values that do notbelong to a solution to C. This is repeated for all constraints until no more domainvalue can be removed. <strong>The</strong> removal of inconsistent domain values is calledfiltering.In or<strong>de</strong>r to be effective, filtering algorithms should be efficient, because theyare applied many times during the search process. <strong>The</strong>y should furthermoreremove as many inconsistent values as possible. If a filtering algorithm for aconstraint C removes all inconsistent values from the domains with respect toC, we say that it makes C domain-consistent. It is possible to achieve domainconsistencyin polynomial time for some constraints such as AllDiff but forother constraints such as SUM this would be too costly. In such cases a weaker3


notion of consistency called bounds-consistency (also called interval-consistency)appears to be highly cost-effective. A constraint C is bound consistent if thebounds of the domain of each variable implied in C belongs to at least onesolution of C. <strong>The</strong> i<strong>de</strong>a it to bound the domain of each variable by an intervaland make sure that the end-points of the intervals obey the domain-consistencyrequirement. If not, the upper and lower bounds of the intervals can be tighteneduntil bounds-consistency is achieved.Proposition 1 states that achieving domain-consistency for DEVIATION is notmore difficult than for arithmetic constraints in general.Proposition 1. Achieving domain-consistency for DEVIATION is N P-Complete.Proof. In the particular case where Dom(D) = [0, +∞], achieving domainconsistencyfor SUM constraint reduces to achieving domain-consistency for DE-VIATION. This is N P-Complete since the subset sum problem (see [3]) can bereduced to achieving domain-consistency for the SUM constraint. Domains of variables are consi<strong>de</strong>red as full and can be <strong>de</strong>scribed by the intervalDom(X) = [X min ..X max ].Definition 2 introduces some useful notations and can be easily un<strong>de</strong>rstoodwith the graphical illustration on Figure 1. A numerical example is also given inExample 1.mrdldX maxX max rdld=rd=0 rd=rd=0 X min rdld=ld=0X max ldldX min X minFig. 1. Illustration of the <strong>de</strong>finitions introduced in Definition 2 for three variables.Definition 2. For a variable X and a given value m, the upper bounds on theright and left <strong>de</strong>viation are respectively• rd(X, m) = max(0, X max − m) and• ld(X, m) = max(0, m − X min ).<strong>The</strong> sum of these values over X are respectively4


• RD(X , m) = ∑ X∈Xrd(X, m) and• LD(X , m) = ∑ X∈Xld(X, m).<strong>The</strong> same i<strong>de</strong>a holds for the lower bounds on the <strong>de</strong>viations:• rd(X, m) = max(0, X min − m).• ld(X, m) = max(0, m − X max ).• RD(X , m) = ∑ X∈Xrd(X, m).• LD(X , m) = ∑ X∈Xld(X, m).For a variable X i ∈ X we <strong>de</strong>fine:• LD i (X , m) = LD(X , m) − ld(X i , m) and• RD i (X , m) = RD(X , m) − rd(X i , m).To alleviate notations, (X , m) are sometimes omitted. For example LD(X , m)is simply written LD.Example 1. Let X = {X 1 , X 2 , X 3 , X 4 } be four variables with domains Dom(X 1 ) =[8, 10], Dom(X 2 ) = [4, 7], Dom(X 3 ) = [1, 5] and Dom(X 4 ) = [3, 4]. <strong>The</strong> followingtable exhibits the quantities introduced in Definition 2.i rd(X i , 5) ld(X i , 5) rd(X i , 5) ld(X i , 5)1 5 0 3 02 2 1 0 03 0 4 0 0∑4 0 2 0 1i7 7 3 1RD i (X , 5) LD i (X , 5) RD i (X , 5) LD i (X , 5)1 2 7 0 12 5 6 3 13 7 3 3 14 7 5 3 0<strong>The</strong> filtering for DEVIATION is based on the next theorem stating that thesum of <strong>de</strong>viations above and un<strong>de</strong>r the mean are equal.<strong>The</strong>orem 1. Let X = {X 1 , ..., X n }. <strong>The</strong> equality n.m = ∑ X∈XX holds if andonly if ∑ X>m (X − m) = ∑ Xm (X −m) + ∑ Xm (X − m) − ∑ Xm(X − m) ∈ [RD(X , m), RD(X , m)] and• ∑ X


1. RD(X , m) ≤ Dmax22. LD(X , m) ≤ Dmax23. RD(X , m) ≥ Dmin24. LD(X , m) ≥ Dmin25. [ LD(X , m), LD(X , m) ] ∩ [ RD(X , m), RD(X , m) ] ≠ φProof. 1. If RD(X , m) > Dmax2then ∑ DmaxX>m(X − m) >2(Property 1).Hence ∑ ni=1 |X i − m| > D max (by <strong>The</strong>orem 1).2., 3. and 4. similar to 1.5. Direct consequence of <strong>The</strong>orem 1 and Property 1. 3 Naive implementationThis section explains why a naive implementation of DEVIATION by <strong>de</strong>compositioninto more elementary constraints is not optimal in terms of filtering.As stated in Definition 1, DEVIATION(X , m, D) holds if and only if n.m =∑ ni=1 X i and D = ∑ ni=1 |X i −m|. This suggests a natural implementation of theconstraint by <strong>de</strong>composing it into two SUM constraints. Figure 2 illustrates thatthe filtering obtained with the <strong>de</strong>composition is not optimal.Dom X 2∣X 1−m∣∣X 2−m∣D maxD maxm , mX 1 X 2=2mDom X 1Fig. 2. Filtering of X 1 with <strong>de</strong>composition and with DEVIATION.Assume two variables X 1 , X 2 with unboun<strong>de</strong>d finite domains and the constraintDEVIATION({X 1 , X 2 }, m, D ∈ [0, D max ]).<strong>The</strong> diagonally sha<strong>de</strong>d square (see Figure 2) <strong>de</strong>limits the set of points such that|X 1 − m| + |X 2 − m| ≤ D max . <strong>The</strong> diagonal line is the set of points such thatX 1 + X 2 = 2.m. <strong>The</strong> unboun<strong>de</strong>d domains for X 1 and X 2 are bound-consistentfor the mean constraint. <strong>The</strong> vertically sha<strong>de</strong>d rectangle <strong>de</strong>fines the domain of6


X 1 after a bound-consistent filtering for |X 1 − m| + |X 2 − m| ≤ D max . <strong>The</strong>set of solutions for DEVIATION is the bold diagonal segment obtained by intersectingthe square surface and the diagonal line. It can be seen on the figurethat more filtering is possible. Bound consistent filtering on the bold diagonalsegment leads to a domain of X 1 <strong>de</strong>fined by the diagonally sha<strong>de</strong>d rectangle.In conclusion a bound consistent filtering for the <strong>de</strong>composition leads toDom(X 1 ) = Dom(X 2 ) = [m − D max , m + D max ] while a bound consistent filteringfor DEVIATION({X 1 , X 2 }, m, D ∈ [0, D max ]) leads to domains two timessmaller Dom(X 1 ) = Dom(X 2 ) = [m − Dmax2, m + Dmax2].4 Filtering of D<strong>The</strong> filtering of D to achieve bound consistency requires to solve two optimizationproblems: the minimization and maximization of the sum of <strong>de</strong>viations from agiven mean m.Definition 3. D and D <strong>de</strong>note the optimal values to problems:such that :n∑n∑D = min |X i − m| and D = max |X i − m|i=1n∑X i = n.mi=1Ximin≤ X i ≤ Ximax , 1 ≤ i ≤ nX i ∈ Q, 1 ≤ i ≤ n.Values D and D can be used to filter the domain of D:Dom(D) ←− Dom(D) ∩ [D, D].<strong>The</strong> remaining of this section mainly explains how D can be computed inlinear time with respect to the number of variables n = |X |. Unfortunatelyfinding D is an N P-complete problem and the best we can do is to <strong>de</strong>sign agood upper bound for it as explained at the end of this section.Definition 4 characterizes an optimal solution to the problem of finding D.Definition 4 (up and down centered assignment). Let X = {X 1 , ..., X n }.Let A : X → Dom(X) be an assignment of X ∈ X . <strong>The</strong> quantity s(A) <strong>de</strong>notesthe sum of assigned values: s(A) = ∑ X∈X A(X).An assignment A is said to be up-centered when:{= Xminif XA(X)min ≥ s(A)/n≤ s(A)/n otherwiseIn other words, each variable with minimum domain value larger than the meanof the assigned values takes its minimum domain value and the other variablestake values smaller than the mean of the assigned values.i=17


An assignment A is said to be down-centered when:{= Xmaxif XA(X)max ≤ s(A)/n≥ s(A)/n otherwiseIn other words, each variable with maximum domain value smaller than the meanof the assigned values takes its maximum domain value and the other variablestake values larger than the mean of the assigned values.Example 2. Consi<strong>de</strong>ring the variables and domains of Example 1, the followingassignment is up-centered with mean 17/4:A(X 1 ) = 8, A(X 2 ) = 4, A(X 3 ) = 2, A(X 4 ) = 3.<strong>The</strong>orem 3. An assignment is an optimal solution to the problem of finding Dif and only if it is a down-centered assignment or an up-centered assignment ofmean m.Proof. (if) Given an assignment A of mean m i.e. s(A) = n.m. <strong>The</strong> only wayto <strong>de</strong>crease the sum of <strong>de</strong>viations while conserving the mean m is to find a pairof variables X i , X j such that A(X i ) > m, A(X i ) > Xi min , A(X j ) < m, A(X j ) m and A(X i ) > Ximin (violation of up-centered) and one withA(X j ) < m and A(X j ) < Xj max (violation of down-centered). Let <strong>de</strong>fine δ =min ( A(X i ) − max(Ximin , m), min(Xjmax , m) − A(X j ) ) . <strong>The</strong> assignment A(X) isnot optimal since the sum of <strong>de</strong>viations can be <strong>de</strong>creased by 2δ by modifyingthe assignment on X i and X j : A ′ (X i ) = A(X i ) − δ and A ′ (X j ) = A(X j ) + δ. <strong>The</strong>orem 4. If DEVIATION is consistent thenD = 2. max(LD (X , m), RD(X , m)) .Proof. Assume LD ≥ RD, then it is possible to build a down-centered assignment∑A of mean m and which is optimal by <strong>The</strong>orem 3. For this assignment∑ A(X)m(X − m) =X


<strong>The</strong>orem 5. Computing D is N P-complete.Proof. It is possible to reduce the subset sum problem [3] to the problem ofcomputing D (see Definition 3). This problem is not more difficult than theparticular case where m = 0:such that :D = maxn∑|X i |i=1n∑X i = 0i=1Ximin≤ X i ≤ X maxi , 1 ≤ i ≤ n.Given a set of n positive values {b 1 , ..., b n−1 , T }, the subset sum problem consistsin finding if there exists a set of binary values {y 1 , ..., y n−1 }, y i ∈ {0, 1}, 1 ≤i < n such that ∑ n−1i=1 y i.b i = T . <strong>The</strong> reduction is the following:• X miniand Xmax i= − biP2 n−1i=1 bi2− T .= bi2for 1 ≤ i < n.• X n =P n−1Pi=1 n−1• <strong>The</strong>re is a solution to the subset sum problem if D ≥bi i=1∣2+ ∣bi2− T ∣.This constraint on the optimal value ensures that the optimal solution is suchthat X i ∈ {− bi2 , bi2}. <strong>The</strong> solution to the subset sum problem is then givenby y i = 1 if X i = bi2 and y i = 0 if X i = −bi2 . Unless P = N P, the problem of computing D is exponential (<strong>The</strong>orem 5).As explained in Section 2, in or<strong>de</strong>r to be effective, filtering algorithms should beas efficient as possible because they are applied many times during the searchprocess. This is why we prefer to find efficiently a good upper bound D ↑ for Dthan to find its exact value. An upper bound which can be computed in O(n) isD ↑ =n∑i=1max ( |X maxi<strong>The</strong> filtering on Dom(D) becomes:− m|, |X mini − m| ) .Dom(D) ←− Dom(D) ∩ [D, D ↑ ]5 Filtering on XTwo propagators could be consi<strong>de</strong>red to filter the domain of X :1. from D min and m to X and2. from D max and m to X .9


Achieving bound-consistency for the first propagator is N P-complete. In<strong>de</strong>ed,checking the consistency of one value requires to maximize the sum of<strong>de</strong>viations which is an N P-complete problem (<strong>The</strong>orem 5). <strong>The</strong> <strong>de</strong>compositionof DEVIATION presented in Section 3 can however be used to realize boundconsistencyon constraint ∑ X∈X |X − m| ≥ Dmin . In any case, this filteringis useless if one seeks a balanced solution on X . Hence, the remaining of thissection focuses on a linear time filtering algorithm for the second propagator.<strong>The</strong> filtering is based on the computation of the values X i and X i introducedin Definition 5.Definition 5. X i and X i are the optimal values to the following problems:X i = max(X i ) and X i = min(X i )n∑such that : X j = n.m (1)j=1n∑|X j − m| ≤ D max (2)j=1X minj≤ X j ≤ Xjmax , 1 ≤ j ≤ n, j ≠ iX j ∈ Q, 1 ≤ j ≤ n.<strong>The</strong> filtering rule on the domain of X i can be simply written:Dom(X i ) ←− Dom(X i ) ∩ [X i , X i ] (3)<strong>The</strong>orem 6. For a variable X i , assuming the constraint is consistent, the followingequalities hold:( )DmaxX i = min , LD i (X , m) − RD2i (X , m) + m.( )DmaxX i = − min , RD i (X , m) + LD2i (X , m) + m.Proof. Only X i is consi<strong>de</strong>red because the proof for X i is symmetrical with respectto m. Two cases can be consi<strong>de</strong>red:• LD i ≤ Dmax2: By <strong>The</strong>orem 1 the <strong>de</strong>viation above the mean and un<strong>de</strong>r themean must be equal. Hence the optimal solution is such that X i −m+RD i =LD i . <strong>Constraint</strong> (2) is not tight in this case.• LD i > Dmax2: By <strong>The</strong>orem 1 the constraint (1) means that the <strong>de</strong>viationabove the mean and un<strong>de</strong>r the mean must be equal. <strong>The</strong> conjunction ofconstraint (1) with constraint (2) means that the <strong>de</strong>viation above and un<strong>de</strong>rthe mean are equal and at most D max /2. Hence the optimal solution is suchthat X i − m + RD i = Dmax2. <strong>Constraint</strong> (2) is tight in this case.10


If both cases are consi<strong>de</strong>red together, equality X i − m + RD i = min( Dmax2, LD i )holds at the optimal solution. <strong>The</strong> filtering procedure on X applies rule (3) once on each X i ∈ X . This canbe achieved in linear time with respect to the number of variables.Example 4. Variables and domains consi<strong>de</strong>red are the same as in Example 1. <strong>The</strong>constraint consi<strong>de</strong>red is DEVIATION(X = {X 1 , X 2 , X 3 , X 4 }, m = 5, D ∈ [0, 7]).Values X i and X i are: X 1 = min(3.5, 7)−0+5 = 8.5, X 2 = min(3.5, 6)−3+5 =5.5, X 3 = min(3.5, 3) − 3 + 5 = 5, X 4 = min(3.5, 5) − 3 + 5 = 5.5, X 1 =− min(3.5, 2)+1+5 = 4, X 2 = − min(3.5, 5)+1+5 = 2.5, X 3 = − min(3.5, 7)+1 + 5 = 2.5 and X 4 = − min(3.5, 7) + 0 + 5 = 1.5. Hence filtering rule (3) leadsto filtered domains: Dom(X 1 ) = [8, 8], Dom(X 2 ) = [4, 5], Dom(X 3 ) = [3, 5] andDom(X 4 ) = [3, 4].6 Bound consistency for DEVIATION<strong>The</strong> total filtering is achieved in O(n) as follows.1. Filtering from D max and m to X : ∀X ∈ X , Dom(X) ←− Dom(X) ∩ [X, X].2. Filtering from X and m to D: Dom(D) ←− Dom(D) ∩ [D, D ↑ ].Even if it was possible to compute D efficiently, bound consistency is notnecessarily obtained. <strong>The</strong> reason is that values X, X (Definition 5) and D (Definition3) are computed making the assumption that interval domains are <strong>de</strong>finedon rational numbers Q rather than on integers Z. As the next example shows,this can lead to miss some possible filtering.Example 5. Assume a set of 10 variables X with domain [0, 1] and a mean ofm = 0.5. <strong>The</strong>orem 4 gives a value D = 0 because every domain overlaps m.In fact the only way to obtain an assignment respecting the mean constraintis to have five variables assigned to 0 and five to 1. For such an assignment,the minimal sum of <strong>de</strong>viations from the mean is 5 and not 0. Consequently,the constraint DEVIATION(X , m = 0.5, D ∈ [0, 3]) is inconsistent but such aninconsistency will not be <strong>de</strong>tected by our propagator.Example 5 shows that all inconsistencies are not <strong>de</strong>tected by the propagator.This occurs when the mean is not an integer but a rational number and whenthe domains of some variables inclu<strong>de</strong> the mean. When the mean is an integer,such a problem does not occur and the propagator is bound-consistent.7 Relation between SPREAD and DEVIATIONThis section shows that DEVIATION can be used as a relaxation of SPREAD. Thisrelaxation might be useful since the propagator of the former runs in O(n)against O(n 2 ) for the latter. Furthermore, DEVIATION is easier to implement.11


<strong>The</strong> relaxation is illustrated graphically and the parameters given to DEVIATIONto obtain the strongest relaxation as possible are expressed as a function ofSPREAD parameters.SPREAD(X , m, ∆ 2 ) holds if the m value is the average over X and the sumof square <strong>de</strong>viation to m is ∆ 2 . More formally SPREAD holds if ∑ x∈X X = n.mand ∑ x∈X (X − m)2 = ∆ 2 .From a geometrical point of view, ∑ x∈X (X − m)2 ≤ (∆ max ) 2 <strong>de</strong>fines anhyper-sphere centered on [m, ..., m] of radius ∆ max . <strong>The</strong> set of points satisfying∑x∈X |X − m| ≤ Dmax lies on a regular polytope centered in [m, ..., m] with 2 nfaces in an n-dimensional space 1 .Dom X 2X 1 X 2=2m maxD maxm , mDom X 1Fig. 3. Relation between SPREAD and DEVIATION for two variables.<strong>The</strong> i<strong>de</strong>a is to relax SPREAD with <strong>de</strong>viation by finding the smallest D max aspossible such that the hyper-sphere is inclu<strong>de</strong>d in the polytope. For two variablesX 1 and X 2 , Figure 3 shows that the circle can be subsumed by the tangent outersquare.For D max = √ 2∆ the outer-square is tangent with the circle (Pythagorerelation). For n variables the result is <strong>de</strong>scribed in the following theorem.<strong>The</strong>orem 7. SPREAD(X , m, [0, (∆ max ) 2 ]) ⊆ DEVIATION(X , m, [0, √ n.∆ max ]) and∄ (D max < √ n.∆) such that SPREAD(X , m, [0, (∆ max ) 2 ]) ⊆ DEVIATION(X , m, [0, D max ]).Proof. For simplicity we assume m = 0. Recall that, the set of points such that∑x∈X |X| ≤ Dmax <strong>de</strong>fine a regular polytope centered in the origin with 2 n facesin an n-dimensional space. To find D max such that the polyhedron is tangentwith the hyper-sphere of radius ∆, it is easier to work in the positive orthantsince others are symmetrical. In this orthant the problem is reduced to findingD max such that the hyper-plan X 1 + X 2 + ... + X n = D max is tangent with thehyper-sphere X 2 1 + X 2 2 + ... + X 2 n = (∆ max ) 2 . At the tangent point we have X 1 =1 For n = 2 it is a square and for n = 3 it is an octahedron.12


X 2 = ... = X n . Consequently at the tangent point X 1 = X 2 = ... = X n = ∆max √ nand hence D max = √ n n∆ max . Note that the equality SPREAD(X , m, [0, (∆ max ) 2 ]) = DEVIATION(X , m, [0, √ n.∆])is valid only when n = 2 (two variables). For three variables or more the strict inclusionholds. For instance, the tuple t = 〈X 1 = √ 32 ∆max , X 2 = − √ 32 ∆max , X 3 =0〉 ∈ DEVIATION(X , m = 0, [0, √ 3.∆ max ]) but t /∈ SPREAD(X , m = 0, [0, (∆ max ) 2 ]).( √3 ) 2 ( √3 ) 2In<strong>de</strong>ed,2 ∆max +2 ∆max + 0 2 = 3 2 (∆max ) 2 > (∆ max ) 2 .8 Experimental Resultsfail<strong>de</strong>v0 5000 10000 15000 20000Detected inconsistenciesDEVIATIONDecompositionperc[sel]0 5 10 15 20 25Percentage filtering on consistent problemsDEVIATIONDecomposition200 400 600 800 1000400 500 600 700 800 900 1000D maxD maxFig. 4. Experimental Results: DEVIATION v.s. <strong>de</strong>composition of Section 3.<strong>The</strong> goal of this experiment is to compare the filtering of the DEVIATION propagators<strong>de</strong>scribed in Section 4 and 5, with an implementation by <strong>de</strong>compositionas suggested in Section 3.20, 000 sets X = {X 1 , ..., X 50 } of random instances were generated. <strong>The</strong> domainof one variable X are all the integer values between the minimum andmaximum of a generated pair of two uniform random integer values between -50and 50. <strong>The</strong> mean constraint on each instance is m = 0.5. <strong>The</strong> maximum sumof <strong>de</strong>viations D max varies between 200 and 1000. This interval was found experimentallysuch that for D max = 200 (resp. 1000) all instances are inconsistent(resp. consistent).<strong>The</strong> number of inconsistent instances <strong>de</strong>tected by both approaches are givenon the left of Figure 4. Note that if an example is <strong>de</strong>tected as inconsistent by<strong>de</strong>composition, DEVIATION also <strong>de</strong>tects it. <strong>The</strong> average percentage of filtering(i.e. the number of filtered values divi<strong>de</strong>d by the number of initial values in thedomains) on consistent instances are plotted on the right of Figure 4.13


<strong>The</strong> number of inconsistent instances <strong>de</strong>tected is significantly larger withthe presented propagator than with an implementation by <strong>de</strong>composition. Forinstance, with D max = 500, DEVIATION <strong>de</strong>tects 9, 619 inconsistencies against3, 628 with the <strong>de</strong>composition. On the 10, 381 consistent instances, the pruningpercentage obtained with DEVIATION is 11.8% against 0.9% with <strong>de</strong>composition.As shown in Section 6, all inconsistencies are not <strong>de</strong>tected by our propagatorif the mean is not integer. Since m = 0.5, some inconsistent instances canbe un<strong>de</strong>tected. Figure 5 shows a plot of the percentage of inconsistencies <strong>de</strong>tectedby <strong>de</strong>composition and DEVIATION approaches. Almost all inconsistenciesare <strong>de</strong>tected by DEVIATION. <strong>The</strong> lowest percentage is 99.66% for D max = 400.Percentage of <strong>de</strong>tected inconsistencies0 20 40 60 80 100Percentage of <strong>de</strong>tected inconsistenciesDEVIATIONDecomposition200 400 600 800 1000D maxFig. 5. Percentage of <strong>de</strong>tected inconsistencies.Section 7 introduces an approximation of SPREAD with DEVIATION. <strong>The</strong> leftof Figure 6 shows the number of inconsistencies <strong>de</strong>tected by SPREAD (as implementedin [7]) compared with the number of inconsistencies found by theapproximation. Many inconsistencies remain un<strong>de</strong>tected but, as shown on theleft of Figure 6, the propagation using DEVIATION is two or<strong>de</strong>rs of magnitu<strong>de</strong>faster than with SPREAD on these 20.000 random instances.9 ConclusionThis work presents DEVIATION, a new global constraint to balance a set of variables.This constraint is closely related to the SPREAD constraint [5, 7]. WhileSPREAD constrains the L 2 norm to the mean, DEVIATION constrains the L 1 norm.<strong>The</strong> filtering algorithms we introduce run in linear time with respect to thenumber of variables. Experiments evaluate the efficiency in terms of filteringof our propagators. A relaxation of SPREAD with DEVIATION is also introduced.Such a relaxation offers less filtering but significantly reduces the computationtime.14


failspread5000 10000 15000 20000Detected inconsistenciesDEVIATIONSPREADtimespread1 10 100 1000 10000Total time (milli seconds)DEVIATIONSPREAD5000 10000 150005000 10000 15000(∆ max ) 2(∆ max ) 2Fig. 6. Experimental Results: SPREAD v.s. approximation with DEVIATION.Acknowledgment<strong>The</strong> authors wish to thank Julien Hendrickx and Raphaël Jungers for theirproof of <strong>The</strong>orem 5 and also Jean-Noël Monette and Grégoire Dooms for variousinteresting discussions.This research is supported by the Walloon Region, project Transmaze (516207).References1. Problem 30 of CSPLIB (www.csplib.org).2. C. Castro and S. Manzano. Variable and value or<strong>de</strong>ring when solving balancedaca<strong>de</strong>mic curriculum problem. Proc. of the ERCIM WG on constraints, 2001.3. M. R. Garey and David S. Johnson. Computer and Intractability: A Gui<strong>de</strong> to the<strong>The</strong>ory of NP-Completeness. W. H. Freeman, 1979.4. Brahim Hnich, Zeynep Kiziltan, and Toby Walsh. Mo<strong>de</strong>lling a balanced aca<strong>de</strong>miccurriculum problem. Proceedings of CP-AI-OR-2002, 2002.5. G. Pesant and J.C. Régin. Spread: A balancing constraint based on statistics.Lecture Notes in Computer Science, 3709:460–474, 2005.6. J.C. Régin, T. Petit, C. Bessiere, and J.-F. Puget. An original constraint basedapproach for solving over constrained problems. Sixth International Conference onPrinciples and Practice of <strong>Constraint</strong> Programming (CP 2000), 1894, 2000.7. P. Schaus, Y. Deville, P. Dupont, and J.C. Régin. Simplication and extension of thespread constraint. Third International Workshop on <strong>Constraint</strong> Propagation AndImplementation, 2006.8. W.J. van Hoeve, G. Pesant, L.M. Rousseau, and A. Sabharwal. Revisiting thesequence constraint. Twelfth International Conference on Principles and Practiceof <strong>Constraint</strong> Programming (CP 2006), 4204, 2006.15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!