Filtering Algorithms for the Multiset Ordering Constraint

Constraint programming (CP) has been used with great success to tackle a wide variety of constraint satisfaction problems which are computationally intractable in general. Global constraints are one of the important factors behind the success of CP. …

Authors: ** Alan M. Frisch (University of York, UK) Brahim Hnich (Izmir University of Economics, Turkey) Zeynep Kiziltan (University of Bologna

Filtering Algorith ms for the Multiset Ordering Con strain t Alan M. F risc h Departmen t of Computer Science, Univ ersit y of Y ork, UK. frisch@cs.y ork.ac.uk Brahim Hnic h F acult y of Computer Science, Izmir Univ ersit y of Economics, T urk ey . brahim.hnic h@ieu.edu.tr Zeynep Kiziltan Departmen t of Computer Science , Unive rsit y of Bologna , Italy . zeynep@cs.u nibo.it Ian Miguel Sc ho ol of Computer Science, Univ ersit y of St Andrews, UK. ianm@dcs.st -and.ac.uk T ob y W alsh NICT A and Sc ho ol of Computer Science and Engineering, Univ ersit y of New South W ales, Aus tralia. toby.walsh@ nicta.com.au Octob er 23, 2018 Abstract Constraint progra mming (CP) has bee n used with g reat success to tackle a wide v a r iety of constraint satisfaction pro blems which ar e computationally intractable in gener al. Global constraints are one of the imp or tant fa ctors b ehind the succes s of CP . In this pa pe r , we study a new global constraint, the m ultiset ordering co nstraint, whic h is s hown to b e useful in symmetry breaking and searching for leximin optimal solutions in CP . W e prop os e efficient and effective filtering algo rithms for pr opaga ting this global cons traint. W e show that the algorithms maintain g eneralised arc-consis tency and we discuss po s sible extensions. W e als o consider alternative propagation methods based on existing co nstraints in CP to olkits. Our exp erimental results o n a n umber of b enchmark pro blems demonstr ate that propagating the m ultiset ordering constraint via a dedicated algorithm can b e very b eneficia l. 1 In tro duction Constrain t satisfaction p roblems (CSPs) p la y an imp ortan t role in v arious fields of computer science [Tsa93] and are ubiquitous in many real-life application areas suc h as pr o duction plan- ning, staff scheduling, resource allo cation, circuit design, option trading, and DNA sequencing. In general, solving CSPs is NP-hard and so is computationally in tractable [Mac77a]. Constr aint pr o gr amming (CP) provides a platform for solving CSPs [MS98][Apt03] and has p ro ven s u ccess- ful in man y real-life app lications [W al96][Ros00][RvBW06] despite this in tractabilit y . One of the jew els of CP is th e notion of global (or non-b in ary) constraints. They encapsulate patterns that o ccur frequently in constraint mo dels. Moreo ver, they con tain sp ecialised fi ltering algorithms for p ow erful constrain t inference. Dedicated filtering algorithms for global constraints are vital for efficient and effectiv e constrain t solving. A num b er of suc h algorithms ha v e b een d evelo p ed (see [BCR05] for examples). 1 In this p ap er, we s tu dy a new global constrain t, the m ultiset ord er in g constrain t, whic h ensures that the v alues tak en b y tw o v ectors of v ariables, when viewe d as multiset s, are ord ered. This constraint has ap p lications in breaking ro w and column symmetry as wel l as in searching for leximin optimal solutions. W e prop ose t w o different filtering algorithms f or the multiset ordering (global) constrain t. Whilst they b oth mainta in generalised arc-consisten y , they differ in their complexit y . The first algorithm MsetLeq runs in time that is in the n u m b er of v ariables ( n ) and in the num b er of distinct v alues ( d ) and is suitable when n is muc h b igger than d . Instead, the second algorithm is m ore suitable wh en we h av e large d omains and r u ns in time O ( nl og ( n )) indep endent of d . W e prop ose f urther algorithms b y considering some extensions to MsetLeq . In particular, w e show ho w we can id en tify ent ailmen t and obtain a filtering algo rithm for the strict m ultiset ord ering constrain t. These algorithms are prov en to m ain tain generalised arc-consistency . W e consid er alternativ e approac hes to p ropagating the multiset orderin g constrain t b y u sing existing constrain ts in CP to olkits. W e ev aluate our algorithms in con trast to th e alternativ e approac h es on a v ariet y of represen tativ e pr oblems in the con text of sy m metry breaking. The results demonstrate that our fi ltering algorithms are sup erior to the alternativ e app roac hes either in term s of pru ning capabilities or in terms of computational times or b oth. W e stress that the con trib ution of this pap er is the study of the filtering algorithms f or th e multiset orderin g constrain t. S y m metry breaking is merely used to compare the efficiency of these propagators. A more in d epth comparison of s y m metry breaking metho d s a w aits a separate stu dy . Such a stud y w ould b e in teresting in its own righ t as multise t ordering constraints are one of the few metho d s for br eaking symmetry whic h are n ot sp ecial cases of lexicographical ordering constrain ts [CLGR96]. Nev ertheless, we pr o vid e exp erimental evidence to supp ort th e need of m ultiset ordering consraint s in the con text of symmetry breaking. The rest of the p ap er is organised as follo ws. After w e giv e the necessary form al bac kground in the next section, w e present in Section 3 the utilit y of the m u ltiset orderin g constrain t. In Section 4, w e p r esen t our fi r st filtering algorithm, pr o ve that it m ain tains generalised arc- consistency , and d iscuss its complexit y . Our second algorithm is int ro du ced in Section 5. In Section 6, w e extend our fir st algorithm to obtain an algorithm for the strict multiset ordering constrain t and to detect en tailment . Alternative propagation m etho ds are discussed in Section 7. W e demonstrate in Section 8 that d ecomp osing a c hain of multiset ordering constrain ts in to m ultiset ordering constrain ts b etw een adjacen t or all pairs of v ectors hind ers constrain t propagation. Compu tational results are p resen ted in Section 9. Finally , w e conclud e and outline our plans for f uture work in Section 10. 2 F ormal Bac kground 2.1 Constrain t Satisfaction Problems And Constrain t Pro gr amming A finite-domain c onstr aint satisfaction pr oblem (CSP) consists of: (i) a fi n ite set of v ariables X ; (ii) for eac h v ariable X ∈ X , a fi nite set D ( X ) of v alues (its d omain); (iii) and a fin ite set C of constraints on the v ariables, where eac h constrain t c ( X i , . . . , X j ) ∈ C is defined o ver the v ariables X i , . . . , X j b y a sub set of D ( X i ) × · · · × D ( X j ) giving the set of allo w ed com binations of v alues. That is, c is an n -ary relation. A v ariable assignment or instantiation is an assignmen t to a v ariable X of one of the v alues from D ( X ). Whilst a p artial assignment A to X is an assignm ent to some b ut not all X ∈ X , a total assignment 1 A to X is an assignmen t to ev er y X ∈ X . W e use the notation A [ S ] to denote the pro jection of A on to the set of v ariables S . A (partial) assignmen t A to the set of v ariables T ⊆ X is c onsistent iff for all constr aints c ( X i , . . . , X j ) ∈ C such that { X i , . . . , X j } ⊆ T , we ha ve A [ { X i , . . . , X j } ] ∈ c ( X i , . . . , X j ). A solution to the CS P is a consistent assignmen t to X . 1 Throughout, we wil l sa y assignment when we mean total assignment to the problem va riables. 2 A CS P is said to b e satisfiable if it has a solution; otherwise it is un satisfiable. Typically , we are in terested in fin ding one or all solutions, or an optimal solution giv en some ob jectiv e function. In the p resence of an ob jectiv e function, a CSP is a c onstr aint optimisation pr oblem . Constrain t Programming (CP) has b een used with great success to solve CSPs. R ecent y ears ha ve witnessed the dev elopmen t of sev eral CP systems [RvBW06]. T o solv e a p roblem u sing CP , we need first to f ormulate it as a CSP by declaring the v ariables, their d omains, as well as the constrain ts on the v ariables. Th is part of the pr oblem solving is called mo del ling . In the follo wing, we fi rst introdu ce our notations and then briefly o ve rview mo d elling and solving in C P . Sin ce we compare our algorithms against the alternativ e approac h es in the con text of symmetry breaking, w e also briefly r eview matrix mo delling and index symmetry . 2.2 Notation Throughout, w e assume fin ite integ er d omains, whic h are totally ordered . The domain of a v ariable X is d enoted b y D ( X ), and the minim um and the maxim u m elemen ts in this domain b y min ( X ) and max ( X ). W e use vars ( c ) to denote the set of v ariables constrained b y constrain t c . If a v ariable X h as a singleton domain { v } w e sa y that v is assigned to X an d den otes this b y X ← v , or simply sa y that X is assigned. If t wo v ariables X and X ′ are assigned the same v alue, then we wr ite X . = X ′ , otherwise we wr ite ¬ ( X . = X ′ ). A one-dimensional matrix, or v ector, is an ordered list of elemen ts. W e denote a v ector of n v ariables as ~ X = h X 0 , . . . , X n − 1 i and a v ector of n int egers as ~ x = h x 0 , . . . , x n − 1 i . In either case, a sub -v ector fr om ind ex a to index b inclusiv e is denoted b y the su bscript a → b , suc h as: ~ x a → b . Unless otherwise stated, the indexing of v ectors is f rom left to right , with 0 b eing the most s ignifi can t ind ex, and the v ariables of a ve ctor ~ X are assumed to b e disjoin t and not rep eated. The vect or ~ X X i ← d is the vec tor ~ X with some X i b eing assigned to d . T he fu nctions floor ( ~ X ) and ceiling ( ~ X ) assign all th e v ariables of ~ X their min im u m an d maximum v alues, resp ectiv ely . A vec tor ~ x in the domain of ~ X is designated by ~ x ∈ ~ X . W e write { ~ x | C ∧ ~ x ∈ ~ X } to denote the set of v ectors in the domain of ~ X wh ich satisfy condition C . A vec tor of v ariables is disp la yed b y a v ector of the domains of th e corresp ondin g v ariables. F or instance, ~ X = h{ 1 , 3 , 4 } , { 1 , 2 , 3 , 4 , 5 } , { 1 , 2 }}i denotes the v ector of thr ee v ariables wh ose domains are { 1 , 3 , 4 } , { 1 , 2 , 3 , 4 , 5 } , and { 1 , 2 } , r esp ectiv ely . A set is an unordered list of elemen ts in wh ic h r ep etition is not allo w ed. W e denote a set of n elemen ts as X = { x 0 , . . . , x n − 1 } . A m ultiset is an unordered list of elemen ts in which rep etition is allo wed. W e den ote a multiset of n elemen ts as x = { { x 0 , . . . , x n − 1 } } . W e wr ite max ( x ) or max { { x 0 , . . . , x n − 1 } } for the maxim um elemen t of a multiset x . By ignoring the ord er of elemen ts in a v ector, w e can view a v ector as a multiset. F or example, the v ector h 0 , 1 , 0 i can b e view ed as the multiset { { 1 , 0 , 0 } } . W e will abuse n otation and write { { ~ x } } or { {h x 0 , . . . , x n − 1 i} } for the m ultiset view of the vecto r ~ x = h x 0 , . . . , x n − 1 i . An o ccurrence v ector occ ( ~ x ) asso ciated with ~ x is ind exed in decreasing order of significance from the maximum max { { ~ x } } to the min im u m min { { ~ x } } v alue from the v alues in { { ~ x } } . The i th elemen t of occ ( ~ x ) is the num b er of o ccurrences of max { { ~ x } } − i in { { ~ x } } . When comparing t w o o ccurrence v ectors, w e assum e they s tart and end with the o ccur rence of the same v alue, ad d ing leading/trailing zero es as n ecessary . Finally , sor t ( ~ x ) is the ve ctor obtained b y sorting the v alues in ~ x in non-increasing order. 2.3 Searc h, Lo cal Consistency and Propagation Solutions to C SPs are often foun d b y se ar ching systematically the space of partial assignmen ts. A common s earch strategy is b acktr acking se ar ch . W e tra v erse th e searc h space in a d epth- first man n er and at eac h step extend a partial assignment b y assigning a v alue to one m ore v ariable. I f th e extended assignmen t is consistent then one more v ariable is instan tiated and so on. Otherw ise, the v ariable is re-instan tiated with another v alue. If none of the v alues in the 3 domain of the v ariable is consisten t w ith the curr en t partial assignment then one of the previous v ariable assignmen ts is reconsidered. Bac ktrac king searc h ma y b e seen as a se ar c h tr e e trav ersal. Each no de defines a partial assignmen t and eac h branc h defines a v ariable assignment. A p artial assignment is extended b y br anc h ing from the corresp onding n o de to one of its su btrees b y assigning a v alue j to the next v ariable X i from the curr en t D ( X i ). Up on bac ktracking, j is remov ed from D ( X i ). This pro cess is often called lab el ling . T he ord er of the v ariables an d v alues c h osen for consideration can hav e a p rofound effect on th e size of the searc h tree [HE80]. The order can b e d etermined b efore search starts, in which case the lab elling heur istic is static . If the next v ariable and/or v alue are determined during searc h then th e lab elling heuristic is dynamic . The size of the s earc h tree of a CSP is in the w orst case equal to the pro d uct of the domain sizes of all v ariables. It is th us to o exp ensiv e in general to enumerate all p ossible assignment s using a naive b ac ktracki ng algorithm. Consequen tly , man y C P solution m etho ds are based on infer enc e which redu ces the problem to an equiv alen t (i.e. with the same solution set) b u t smaller problem. Since complete inf er en ce is to o compu tationally exp ensiv e to b e used in p ractice, inference metho ds are often incomplete and enforce lo c al c onsistencies . A lo cal consistency is a prop ert y of a CSP d efined o ver “lo cal” p arts of the CSP , in other words d efined o ver subsets of the v ariables and constraints of the CSP . The main idea is to remo ve from the domains of the v ariables the v alues that w ill not tak e part of any solution. Such v alues are said to b e inc onsistent . Inconsistent v alues can b e detected by using a n umber of consistency prop erties. A common consistency prop erty prop osed in [Mac77b] is generalised arc-consistency . A constrain t c is gener alise d ar c-c onsistent (or GA C ), wr itten GA C( c ), if and only if for eve ry X ∈ vars ( c ) and ev ery v ∈ D ( X ), there is at least one assignment to vars ( c ) that assigns v to X and satisfies c . V alues for v ariables other than X p articipating in su c h assignmen ts are known as the supp ort for the assignment of v to X . Generalised arc-consistency is established on a constrain t c by remo vin g elements from the domains of v ariables in v ars ( c ) until the GAC prop ert y holds. F or binary constraints, GA C is equiv alen t to ar c-c onsistency (A C, see [Mac 77a ]). Another useful lo cal consistency is b ound c onsistency th at treats the domains of th e v ariables as in terv als. F or in teger v ariables, the v alues hav e a natural total order, therefore the domain can b e represented b y an in terv al whose low er b ound is the minimum v alue and the up p er b ound is the maximum v alue in the d omain. A constrain t C is b ound c onsistent ( BC ) iff for ev ery v ariable, for its minim um (maxim u m) there exists a v alue for ev ery other v ariable b et we en its minim um and maxim u m that satisfies C [vHSD98]. W e will compare lo cal consistency prop er ties app lied to (sets of ) logically equiv alen t con- strain ts, c 1 and c 2 . As in [DB97], we say that a lo cal consistency prop erty Φ on c 1 is as strong as Ψ on c 2 iff, giv en an y domains, if Φ h olds on c 1 then Ψ holds on c 2 ; we sa y that Φ on c 1 is strictly stronger than Ψ on c 2 iff Φ on c 1 is as str ong as Ψ on c 2 but not vice versa. In a constrain t pr ogram, searc hin g for solutions is in terlea ve d with lo cal consistency as fol- lo ws. Local consistency is first enforced b efore searc h starts to p repro cess th e problem and prun e su bsequent searc h . I t is then mainta ined dynamically at eac h n o de of th e search tree with resp ect to th e curr en t v ariable assignmen t. In this wa y , the domains of the uninstanti ated v ariables shr ink and the searc h tree gets sm aller. Whilst the pro cess of main taining local consis- tency o ver a CSP is kno wn as pr op agation , the pro cess of remo ving inconsistent v alues f r om the domains is kno w n as pruning or filtering . F or effectiv e constr aint solving, it is imp ortant that propagation remo ves efficient ly as man y inconsisten t v alues as p ossible. Note that GA C is an imp ortant consistency prop erty as it is the strongest filtering that b e done by reasoning on only a single constrain t at a time. Man y global constrain ts in CP to olkits therefore encapsulate their o wn filtering algorith m whic h t ypically ac hiev es GA C at a lo w cost b y exploting the semantic s of the constraint. As an example, R´ egin in [R ´ eg94 ] giv es a filtering algorithm f or the al l- differ ent constrain t which main tains GA C in time O ( n 2 . 5 ) where n is the num b er of v ariables. The seman tics of a constrain t can h elp not only find s upp orts and inconsisten t v alues quickly 4 Matrices: S lots ր 3 2 6 6 5 5 T i,j,k 1 1 2 3 4 4 ↓ 4 5 4 5 6 6 P er iods 2 3 3 2 1 1 ↓ 6 6 5 4 3 3 5 4 1 1 2 2 → E week s → → W eeks → G i,j 3 2 12 18 23 ↓ 10 17 16 11 6 P er iods 30 24 5 4 9 Constraints: (1) ∀ i ∈ E wee k s . al l-differ ent ( T i ) (2) al l-differ ent ( G ) (3) ∀ j ∈ P e r iods . g cc ( h T 0 ,j, 0 , T 0 ,j, 1 , . . . , T n − 1 ,j, 0 , T n − 1 ,j, 1 i , h 1 , 2 , . . . , n i , h 2 , . . . , 2 i ) (4) ∀ i ∈ W eek s . ∀ j ∈ P er iods . h T i,j, 0 , T i,j, 1 , G i,j i ∈ {h h, a, ( h − 1) ∗ n + a i| h, a, h < a ∈ { 1 , . . . , n }} (5) ∀ i ∈ E wee k s . ∀ j ∈ P eriods . T i,j, 0 < T i,j, 1 Figure 1: The matrix mo del of the sp ort scheduling p roblem in [vHMPR99]. but also detect en tailmen t and d isen tailmen t without ha vin g to do filtering. A constraint c is entaile d if all assignments of v alues to v ars ( c ) satisfy c . Similarly , a constrain t c is disentaile d when all assignmen ts of v alues to vars ( c ) violate c . If a constraint in a CSP is detected to b e en tailed, it do es not ha v e to propagated in the f uture, and if it is detected to b e d isen tailed th en it is p ro ven th at the cu r ren t CSP h as no solution and we can bac ktrac k. 2.4 Mo delling CP to olkits provi de constru cts f or declaring the v ariables, their domains, as well as the con- strain ts b et w een th ese v ariables of a CS P . They often cont ain a libr ary of predefined constraints with a particular semant ics that can b e app lied to sets of v ariables with v arying arities and d o- mains. F or instance, al l-differ ent ([ X 1 , .., X 3 ]) w ith D ( X 1 ) = D ( X 2 ) = { 1 , 2 } , D ( X 3 ) = { 1 , 2 , 3 } is an instance of al l- diffe r ent ([ X 1 , . . . , X n ]) d efined on th ree v ariables with the sp ecified do- mains. It has the s emantics that the v ariables inv olv ed tak e differen t v alues [R ´ eg94]. The al l-differ ent ([ X 1 , . . . , X n ]) constrain t can b e applied to an y num b er of v ariables with any do- mains. Suc h constraints are often referred as glob al c onstr aints . Beldicean u has catalog ued h undr eds of global constraints, most of whic h are defined o v er finite d omain v ariables [BCR05]. They p ermit the u ser to mod el a p roblem easily by compactly sp ecifying common patterns that o ccur in many constrain t mo dels. Th ey also provide solving adv ant ages w hic h we shall explain later. Since constrain ts p ro v id e a ric h language, a n um b er of alternativ e m o dels will often exist, some of whic h will b e more effectiv e than others. How ev er, one of the most common and effectiv e mo delling patterns in constraint programming is a matrix mo del . A matrix mo del is th e form ulation of a CSP with one or more matrices of decision v ariables (of one or more d imensions) [FFH + 02b]. Matrix mo dels are a natural wa y to rep resen t prob lems that inv olv e fi nding a function or a relation. W e sh all illustr ate matrix m o dels and th e p o w er of global constrain ts in mo delling through the sp ort sc heduling problem . This problem inv olv es sc heduling games b et w een n teams ov er n − 1 we eks [vHMPR99]. Eac h w eek is divided into n/ 2 p erio ds, and eac h p erio d is divided into t wo s lots. Th e team in th e firs t slot pla ys at home, w hile the team in the second slot p la ys a wa y . T he goal is to find a sc hedule suc h that: (i) ev ery team pla ys exactly once a w eek; (ii) eve ry team plays against ev ery other team; (iii) ev ery team p la ys at 5 most t w ice in the same p erio d o ver the tourn amen t. V an Hen tenryck et al. prop ose a mo del for this problem in [vHMPR99], where th ey extend the problem with a “dumm y” final w eek to mak e the problem more un iform. The mo d el consists of t w o matrices: a 3-d matrix T of P eriods × E week s × S lots and a 2-d matrix G of P er iods × W eeks , where P eriods is the set of n/ 2 p erio ds, E w eek s is the set of n extended w eeks, W eeks is the s et of n − 1 we eks, and S l ots is the set of 2 slots. In T , weeks are extended to include the du mm y week, and eac h elemen t tak es a v alue fr om { 1 , . . . , n } expressing th at a team plays in a particular w eek in a p articular p erio d, in the h ome or a wa y slot. F or the sak e of simplicit y , we w ill treat this matrix as 2-d where the ro ws represen t the p erio ds and the columns repr esen t the extended w eeks, and eac h en try of the matrix is a pair of v ariables. The elements of G take s v alues from { 1 , . . . , n 2 } , and eac h elemen t denotes a particular unique com bination of home and aw a y teams. More p recisely , a game pla yed b et ween a home team h and an a wa y team a is un iquely iden tified by ( h − 1) ∗ n + a . (see Figure 1 ). Consider the columns of T which denote the (extended) w eeks. The first s et of constrain ts p ost al l- differ ent (global) constrain ts on th e columns of T to enforce that eac h column is a p ermutatio n of 1 . . . n . The second constraint is an al l-diffe r ent (global) constrain t on G that enforces that all games m ust b e different. Consider th e rows of T w hic h rep r esen t the p erio d s . The th ird set of constraints p ost the global cardinalit y constraints ( gc c ) on the ro ws to ensure that eac h of 1 . . . n o ccur exactly t wice in ev ery r ow. The fourth set of constraint s are called channel ling c onstr aints and are often used wh en m u ltiple matrices are used to mo d el the problem and they hav e to b e linked together. In our case, the channelling constrain ts links a v ariable represent ing a game ( G i,j ) with a v ariable represent ing the team p la ying home team ( T i,j, 0 ) and the corresp ond ing v ariable representing the a wa y team ( T i,j, 1 ) suc h th at G i,j = ( T i,j, 0 − 1) ∗ n + T i,j, 1 . Th e final set of constraints will b e discussed after giving an o verview of symmetry in CP . 2.5 Symmetry A symmetry is an intrinsic prop ert y of an ob ject whic h is preserved under certain classes of transformations. F or instance, rotating a chess b oard 90 ◦ giv es us a b oard w h ic h is indistin- guishable from th e original one. A CSP can ha v e symmetries in the v ariables or domains or b oth wh ic h preserve satisfiabilit y . In the p resence of symmetry , an y (p artial) assignment can b e transformed in to a set of symmetrically equiv alen t assignments without affecting whether or not the original assignmen t satisfies the constraints. Symmetry in constrain t programs incr eases the size of the searc h s p ace. It is therefore imp ortant to pru n e symmetric states so as to impr o ve the search efficiency . Th is pr o cess is referred to as symmetry b r e aking . One of the easiest and most efficien t wa ys of symmetry breaking is adding symmetry br e aking c onstr aints [Pug93, CL GR96]. These constraints imp ose an ordering on the sym metric ob jects. Among the set of symmetric assignmen ts, only those that satisfy the ord ering constraints are c hosen for consideration durin g the p ro cess of search. F or instance, in the matrix mo del of Figure 1, any solution can b e mapp ed to a symmetric solution b y sw apping an y tw o teams ( T i,j, 0 and T i,j, 1 ). These solutions are essentia lly the same. W e can add the set of constrain ts (5) in ord er to break such sym metry b et w een the tw o teams and sp eed up search by av oiding visiting sym m etric b ranc hes. A common p attern of sym m etry in matrix mo dels is that the ro ws and/or column s of a 2-d matrix rep resen t ind istinguishable ob jects. Consequently the ro ws and/or columns of an assign- men t can b e swapped without affecting whether or not the assignment is a solution [FFH + 02a]. These are calle d r ow or c olumn symmetry ; the general term is index symmetry . F or instance, in the matrix mo del of Figure 1, the (extended) w eeks o v er w hic h the tournament is held, as w ell the p erio ds of a w eek are in distinguishable. Th e rows and the columns of T and G are therefore symmetric. Note that we treat T as a 2-d matrix wh ere the ro ws represent the p erio d s and columns represent the (extended ) w eeks, and eac h en tr y of th e matrix is a pair of v ariables. If ev ery bijection on the v alues of an index is an index symmetry , then we sa y that th e ind ex 6 has total symmetry . If the firs t (resp. second) in dex of a 2-d matrix has total s ymmetry , we say that the matrix has total c olumn symmetry (resp. total r ow symmetry ). In many matrix mo d els only a sub s et of the ro ws or columns are in terc hangeable. If the first (resp. second) index of a 2-d matrix h as partial s y m metry , w e say th at the matrix has p artial c olumn symmetry (resp . p artial r ow symmetry ) 2 . There is one fi nal case to consider: an in dex ma y h a ve partial ind ex symmetry on multiple s ubsets of its v alues. F or example, a CSP ma y ha v e a 2-d matrix for whic h ro ws 1, 2 and 3 are interc hangeable and ro ws 5, 6 and 7 are in terc h angeable. This can o ccur on any or all of the indices. An n × m matrix with total ro w and column symmetry has n ! m ! sy m metries, a num b er whic h increases sup er-exp onentia lly . An effectiv e wa y to deal w ith this class of symmetry is to use lexicographic ordering constraints. Definition 1 A strict lexi c o gr aphic or dering ~ x < lex ~ y b etwe e n two ve c tors of inte gers ~ x = h x 0 , x 1 , . . . , x n − 1 i and ~ y = h y 0 , y 1 , . . . , y n − 1 i holds iff ∃ k 0 ≤ k < n suc h that x i = y i for al l 0 ≤ i < k and x k < y k . The ordering can b e weak ened to includ e equalit y . Definition 2 Two ve ctors of inte gers ~ x = h x 0 , x 1 , . . . , x n − 1 i and ~ y = h y 0 , y 1 , . . . , y n − 1 i ar e lexic o gr aphic al ly or der e d ~ x ≤ lex ~ y iff ~ x < lex ~ y or ~ x = ~ y . Giv en t wo v ectors of v ariables ~ X = h X 0 , X 1 , . . . , X n − 1 i and ~ Y = h Y 0 , Y 1 , . . . , Y n − 1 i , w e write a lexicographic ord ering constrain t as ~ X ≤ lex ~ Y and a strict lexicog raphic ordering constrain t as ~ X < lex ~ Y . These constrain ts are s atisfied by an assignment if the v ectors ~ x and ~ y assigned to ~ X and ~ Y are ordered according to Definitions 2 and 1, r esp ectiv ely . T o d eal with column (resp. row) symmetry , we can constrain the columns (resp. ro ws) to b e non-decreasing as the v alue of the index in creases. One w a y to ac hiev e this is by imp osing a lexicographic order in g constrain t b etw een adjacen t columns (resp. ro w s). These constraints are c onsistent wh ic h means that they lea v e at least one assignmen t among the set of symm etric assignmen ts. W e can deal with ro w and column symmetry in a similar wa y by imp osing a lexicographic orderin g constraint b et w een adj acen t ro ws and columns sim u ltaneously . Also such constrain ts are consisten t. Even though these constr aints ma y not eliminate all symmetry , they ha ve b een sh o wn to b e effectiv e at removing man y symm etries from the searc h spaces of m any problems. If a matrix has only partial column (resp. p artial ro w) symm etry then the symmetry can b e b r ok en b y constraining the interc hangeable columns (resp. rows) to b e in lexicographically non-decreasing order. This can b e ac hiev ed in a manner similar to that describ ed ab o ve. Th e metho d also extends to m atrices th at ha v e partial or total column symmetry together with partial or total ro w sym metry . Fi nally , if the columns and/or ro ws of a matrix hav e multiple partial symmetries than eac h can b e brok en in th e manner ju st d escrib ed [FFH + 02a]. 3 The Mu ltiset Ordering Constrain t and Its Applications Multiset ordering is a total ord ering on multisets. Definition 3 Strict multiset or dering x < m y b e twe en two multisets of inte gers x and y holds iff: x = { {} } ∧ y 6 = { {} } ∨ max ( x ) < max ( y ) ∨ ( max ( x ) = max ( y ) ∧ x − { { max ( x ) } } < m y − { { max ( y ) } } ) 2 Throughout, we will say r ow symmetry (resp. c olumn symmetry ) when we mean total r ow symmetry (resp. total c olumn symmetry ) to the problem vari ables. 7 That is, either x is empty and y is not, or the largest v alue in x is less than the largest v alue in y , or the largest v alues are the same and, if we eliminate one o ccurrence of the largest v alue from b oth x and y , the resulting tw o multi sets are ordered. W e can w eak en the ordering to include m ultiset equalit y . Definition 4 Two multisets of i nte g e rs x and y ar e multiset or der e d x ≤ m y iff x < m y or x = y . Ev en though this ordering is d efined on multiset s, it ma y also b e usefu l to ord er v ectors b y ignoring the p ositions but r ather concen trating on th e v alues tak en by the v ariables. W e can do this by tr eating a v ector as a multiset. Giv en t w o v ectors of v ariables ~ X = h X 0 , X 1 , . . . , X n − 1 i and ~ Y = h Y 0 , Y 1 , . . . , Y n − 1 i , we write a multiset ordering constrain t as ~ X ≤ m ~ Y and a s tr ict m ultiset ordering constrain t as ~ X < m ~ Y . Th ese constraints ensure that the v ectors ~ x and ~ y assigned to ~ X and ~ Y , w hen view ed as multisets, are m ultiset ord er ed according to Definitions 4 and 3, resp ectiv ely . 3.1 Breaking Index Symmetry One imp ortan t app lication of the multiset ord ering constrain t is in b reaking index symmetry [FHK + 03]. If X is an n by m matrix of decision v ariables, then w e can break its column symm etry b y imp osing th e constrain ts h X i, 0 , . . . , X i,m i ≤ m h X i +1 , 0 , . . . , X i +1 ,m i for i ∈ [0 , n − 2], or for short ~ C 0 ≤ m ~ C 1 . . . ≤ m ~ C n − 1 where ~ C i corresp onds to the v ector of v ariables h X i, 0 , . . . , X i,m i whic h b elong to the i th column of th e matrix. Similarly w e can break its ro w symmetry by imp osing the constrain ts h X 0 ,j , . . . , X n,j i ≤ m h X 0 ,j +1 , . . . , X n,j +1 i for j ∈ [0 , m − 2], or for short ~ R 0 ≤ m ~ R 1 . . . ≤ m ~ R m − 1 in which ~ R j corresp onds to the v ariables h X 0 ,j , . . . , X n,j i of the j th ro w . Suc h constrain ts are consisten t symmetry breaking constrain ts. Note that when we h av e partial column (resp. ro w ) symmetry , th en th e symm etry can b e brok en b y imp osing multiset ordering constrain ts on the sy m metric columns (resp. ro w s ) only . Whilst m ultiset ord ering is a total ordering on multisets, it is not a total ord ering on v ectors. In fact, it is a p reordering as it is n ot an tisymm etric. Hence, eac h symm etry class may ha ve more than one elemen t wh er e the rows (resp. columns) are multiset ordered. Th is do es n ot ho wev er m ak e lexicographic ordering constrain ts pr eferable o v er multiset ordering constrain ts in breaking ro w (resp. column) symmetry . The reason is that they are incomparable as they remo ve differen t symmetric assignmen ts in an equiv alence class [FHK + 03]. One of the nice features of u sing multiset ordering for breaking index symmetry is that b y constraining one d imension of the matrix, sa y the rows, to b e multiset ordered, w e do not distinguish the columns. W e can still freely p ermute th e columns, as m u ltiset ordering the ro w s ignores p ositions and is inv ariant to column p ermutat ion. W e can therefore consistent ly p ost m ultiset orderin g constrain ts on the ro w s together with either multiset ordering or lexicog raphic ordering constraints on the columns when we hav e b oth ro w and column s y m metry . Neither approac h may eliminate all symmetries, ho wev er they are all p oten tially interesting. Since lexicographic ordering and m u ltiset ord ering co nstraints are incomparable, imp osing one ordering in one dimension and the other ord er in g in the other d imension of a matrix is also incomparable to imp osing the same ordering on b oth dimensions of the matrix [FHK + 03]. Stu dying th e effectiv eness of all these different metho ds in reducing index sym metry is outside the scop e of this p ap er as w e only fo cus on the design of efficien t and effectiv e filtering algorithms for the m ultiset ord er in g constrain ts. Nev ertheless, exp erimental r esults in Section 9 show that exploiting b oth m u ltiset ordering an d lexicographic ord er in g constraints can b e very effectiv e in breaking in dex s ymmetry . A multiset ordering constrain t can also b e helpfu l for imp lemen ting other constrain ts u seful to break in dex symmetry . One suc h constraint is al lp erm [FJM03]. Exp eriment al r esults in [FJM03] show that th e decomp osition of al lp erm usin g a multiset ordering constrain t can b e as effectiv e and efficien t as the s p ecialised algorithm p rop osed. 8 3.2 Searc hing for Leximin Optimal Solutions Another in teresting app lication of the multi set orderin g constrain t arises in the con text of searc h- ing f or leximin optimal solutions. Such solutions can b e u s eful in fuzzy CSPs. A fuzzy constrain t asso ciates a degree of satisfaction to an assignment tuple for the v ariables it constrains. T o com- bine d egrees of satisfaction, we can use a com bination op erator lik e the minim um function. Unfortunately , the minim um function m ay cause a dr owning effe ct w hen one p o orly satisfied constrain t ‘dr o wn s’ many h ighly satisfied constrain ts. On e solution is to collect a v ector of de- grees of satisfactio n, sort these v alues in ascending ord er and compare them lexicog raphically . This leximin com bination op erator id en tifies the assignmen t th at violates th e few est constrain ts [F ar94 ]. T his ind uces an ordering identic al to the multiset ordering except th at the low er ele- men ts of the satisfaction scale are the more significant . It is simple to m o dify a multiset ordering constrain t to consider th e v alues in a rev erse order. T o solv e suc h leximin fu zzy CS Ps, we can then us e bran ch and b ound, adding a multiset orderin g constrain t w hen we find a solution to ensure that future solutions are greater in the leximin orderin g. Leximin optimal solutions can b e u seful also in other domains. F or instance, as sho wn in [BL07], they can b e exploited as a fairness and pareto optimalit y criterion wh en solving multi- ob jectiv e p r oblems in CP . Exp erimental results in [BL07] sh o w that u sing a m ultiset ordering constrain t in a bran ch and b ound searc h can b e comp etitiv e with the alternativ e app r oac hes to finding leximin optimal solutions. 4 A Filtering Algorithm for Multiset Ordering Constrain t In this section, we present our first filtering algorithm whic h either detects that ~ X ≤ m ~ Y is disen tailed or p runes in consisten t v alues so as to achiev e GAC on ~ X ≤ m ~ Y . After sk etc hing the main features of the algorithm on a run ning examp le in Section 4.1, we first present the theoretical results that the algorithm exploits in Section 4.2 and th en giv e the details of the algorithm in Section 4.3. T h roughout, w e assume that the v ariables of the v ectors ~ X and ~ Y are disjoin t. 4.1 A W orked E xample The k ey idea b ehind the algorithm is to bu ild a pair of o ccurrence v ectors asso ciated with floor ( ~ X ) and ceili ng ( ~ Y ). The algorithm go es through every v ariable of ~ X and ~ Y c hec k- ing for supp ort for v alues in the domains. It su ffi ces to hav e occ ( floor ( ~ X X i ← max ( X i ) )) ≤ lex occ ( ceiling ( ~ Y )) to ensure that all v alues of D ( X i ) are consisten t. Similarly , w e only n eed occ ( floor ( ~ X )) ≤ lex occ ( ceiling ( ~ Y Y j ← min ( Y j ) )) to hold for the v alues of D ( Y j ) to b e consis- ten t. W e can av oid the rep eated construction and tra v ersal of these vec tors b y building, once and for all, the v ectors occ ( floor ( ~ X )) and occ ( ceiling ( ~ Y )) , and defin ing some p oint ers and flags on them. F or instance, assume w e ha v e occ ( floor ( ~ X )) ≤ lex occ ( ceiling ( ~ Y )) . The v ector occ ( floor ( ~ X X i ← max ( X i ) )) can b e obtained from occ ( floor ( ~ X )) by decreasing th e num b er of o ccurrences of min ( X i ) by 1, and increasing the num b er of o ccurr ences of max ( X i ) by 1. The p ointe rs an d fl ags tell us wh ether this distur b s the lexicographic orderin g, and if so they help us to find quic kly the largest max ( X i ) wh ic h do es not. Consider the m u ltiset ordering constrain t ~ X ≤ m ~ Y where: ~ X = h{ 5 } , { 4 , 5 } , { 3 , 4 , 5 } , { 2 , 4 } , { 1 } , { 1 }i ~ Y = h{ 4 , 5 } , { 4 } , { 1 , 2 , 3 , 4 } , { 2 , 3 } , { 1 } , { 0 }i W e h a ve floo r ( ~ X ) = h 5 , 4 , 3 , 2 , 1 , 1 i and ceiling ( ~ Y ) = h 5 , 4 , 4 , 3 , 1 , 0 i . W e construct our o ccur - rence v ectors ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceilin g ( ~ Y )) , ind exed f rom m ax ( { { ceiling ( ~ X ) } }∪ 9 { { ceiling ( ~ Y ) } } ) = 5 to min ( { { floor ( ~ X ) } } ∪ { { floo r ( ~ Y ) } } ) = 0: 5 4 3 2 1 0 ~ ox = h 1 , 1 , 1 , 1 , 2 , 0 i ~ oy = h 1 , 2 , 1 , 0 , 1 , 1 i Recall that ox i and oy i denote the num b er of o ccurr ences of the v alue i in { { fl oor ( ~ X ) } } and { { ceiling ( ~ Y ) } } , resp ectiv ely . F or example, oy 4 = 2 as 4 o ccur s t w ice in { { ceilin g ( ~ Y ) } } . Next, w e define our p oint ers and flags on ~ ox and ~ oy . The p oin ter α p oin ts to the most s ignifi can t index ab o v e wh ich the v alues are pairwise equal and at α w e h a ve ox α < oy α . This means that w e will fail to find supp ort if an y of the X i is assigned a n ew v alue greater than α , but we will alw ays fi nd supp ort for v alues less than α . I f ~ ox = ~ oy then w e set α = −∞ . Otherwise, we fail imm ediately b ecause no v alue for an y v ariable can h a ve su pp ort. W e define β as the most significan t ind ex b elo w α such that ox β > oy β . Th is means that we m ight fail to find su pp ort if an y of the Y j is assigned a new v alue less than or equal to β , but we will alw a ys find supp ort for v alues larger than β . If s uc h an index do es not exist then we set β = −∞ . Finally , th e flag γ is tr ue iff β = α − 1 or ~ ox α +1 → β − 1 = ~ oy α +1 → β − 1 , and σ is tr ue iff the subv ectors b elo w β are ordered lexicographically the wrong w a y . I n our example, α = 4, β = 2, γ = tr ue , and σ = tr ue : 5 4 3 2 1 0 ~ ox = h 1 , 1 , 1 , 1 , 2 , 0 i ~ oy = h 1 , 2 , 1 , 0 , 1 , 1 i α ↑ γ = tr ue β ↑ σ = tr ue W e now go th rough eac h X i and find the largest v alue in its domain whic h is supp orted. If X i has a singleton domain then w e skip it b ecause we ha v e ~ ox ≤ lex ~ oy , meaning that its only v alue has sup p ort. Cons id er X 1 . As min ( X 1 ) = α , c han ging ~ ox to occ ( floor ( ~ X X 1 ← max ( X 1 ) )) increases the n umber of o ccurr ences of an in dex ab o v e α by 1. This upsets ~ ox ≤ lex ~ oy . W e therefore prun e all v alues in D ( X 1 ) larger than α . No w consider X 2 . W e ha v e max ( X 2 ) > α and min ( X 2 ) < α . As with X 1 , any v alue of X 2 larger than α upsets the lexicographic orderin g, but an y v alue less than α guarantees the lexicographic ordering. Th e question is whether α has an y sup p ort? Changing ~ ox to occ ( floor ( ~ X X 2 ← α )) decreases the num b er of o ccurrences of 3 in ~ ox b y 1, and increases th e n um b er of o ccurrences of α by 1. No w we ha ve ox α = oy α but decreasing an ent ry in ~ ox b etw een α and β guarante es lexicographic orderin g. W e therefore prun e fr om D ( X 2 ) only the v alues greater than α . No w consider X 3 . W e ha ve max ( X 3 ) = α and min ( X 3 ) < α . Any v alue less than α has sup p ort b ut do es α hav e an y sup p ort? Ch anging ~ ox to occ ( floor ( ~ X X 3 ← α )) decreases the num b er of o ccurrences of beta in ~ ox by 1, and increases the num b er of o ccurrences of α by 1. No w we ha ve ox α = oy α and ox β = oy β . S ince γ and σ are tr ue , the o ccurrence v ectors are lexicographically ordered the wrong w ay . W e therefore pru ne α from D ( X 3 ). W e skip X 4 and X 5 . Similarly , w e go thr ough eac h Y j and find the smallest v alue in its domain whic h is supp orted. If Y j has a s in gleton d omain then w e skip it b ecause w e ha v e ~ ox ≤ lex ~ oy , meaning that its only v alue has supp ort. Consider Y 0 . As max ( Y 0 ) > α , c hanging ~ oy to occ ( ceiling ( ~ Y Y 0 ← min ( Y 0 ) )) decreases th e n umber of o ccurr ences of an index ab o v e α by 1. This upsets ~ ox ≤ lex ~ oy . W e therefore p r une all v alues in D ( Y 0 ) less than or equal to α . No w consider Y 2 . W e h a ve max ( Y 2 ) = α an d min ( Y 2 ) ≤ β . Any v alue larger th an β guaran tees lexicographic orderin g. The question is whether the v alues less than or equ al to β hav e any sup p ort? Changing ~ oy to occ ( ceiling ( ~ Y Y 2 ← min ( Y 2 ) )) decreases the num b er of o ccurrences of α by 1, giving us ox α = oy α . If min ( Y 2 ) = β then we hav e ox β = oy β . This distu r bs ~ ox ≤ lex ~ oy b ecause γ and σ are b oth tr ue . If min ( Y 2 ) < β then again w e disturb ~ ox ≤ lex ~ oy b ecause γ is tr ue and the vec tors are n ot lexicographicall y ordered as of β . So, we pru n e from D ( Y 2 ) the v alues less than or equal to β . No w consid er Y 3 . As max ( Y 3 ) < α , changing ~ oy to occ ( ceiling ( ~ Y Y 3 ← min ( Y 3 ) )) do es not c h an ge that ~ ox ≤ lex ~ oy . Hence, min ( Y 3 ) is su pp orted. W e skip Y 4 and Y 5 . 10 W e ha v e no w the follo win g generalised arc-consisten t vect ors: ~ X = h{ 5 } , { 4 } , { 3 , 4 } , { 2 } , { 1 } , { 1 } i ~ Y = h{ 5 } , { 4 } , { 3 , 4 } , { 2 , 3 } , { 1 } , { 0 }i 4.2 Theoretical Bac kgr ound The algorithm exploits four theoretical results. Th e firs t redu ces GA C to consistency on the upp er b ound s of ~ X and on the low er b ounds of ~ Y . Th e second and the third show in tur n when ~ X ≤ m ~ Y is disen tailed an d what conditions ensure GA C on ~ X ≤ m ~ Y . And the fourth establishes that tw o ground vect ors are m ultiset ordered iff the asso ciated o ccurrence vect ors are lexicographicall y ordered. Theorem 1 GAC( ~ X ≤ m ~ Y ) i ff for al l 0 ≤ i < n , max ( X i ) and min ( Y i ) ar e c onsistent. Pro of: GA C implies that ev ery v alue is consisten t. T o sh ow the reve rse, su pp ose for all 0 ≤ i < n , max ( X i ) and min ( Y i ) are su pp orted, but th e constrain t is not GA C. Th en there is an inconsistent v alue. If this v alue is in some D ( X i ) then an y v alue greater than this v alue, in particular max ( X i ), is inconsistent . S im ilarly , if the inconsistent v alue is in some D ( Y i ) then an y v alue less than this v alue, in p articular min ( Y i ), is inconsisten t. I n an y case, the b oun ds are not consistent. Q E D. A constrain t is said to b e disentaile d when the constraint is f als e . The n ext t wo theorems sho w when ~ X ≤ m ~ Y is disentaile d and wh at conditions ensu re GAC on ~ X ≤ m ~ Y . Theorem 2 ~ X ≤ m ~ Y is disentaile d iff { { floor ( ~ X ) } } > m { { ceil ing ( ~ Y ) } } . Pro of: ( ⇒ ) S ince ~ X ≤ m ~ Y is disentaile d, any combination of assignmen ts, including ~ X ← floor ( ~ X ) and ~ Y ← ceiling ( ~ Y ), does not satisfy ~ X ≤ m ~ Y . Hence, { { floor ( ~ X ) } } > m { { ceiling ( ~ Y ) } } . ( ⇐ ) Any ~ x ∈ ~ X is greater than an y ~ y ∈ ~ Y und er th e multiset ordering. Hence, ~ X ≤ m ~ Y is disen tailed. QED. Theorem 3 GAC( ~ X ≤ m ~ Y ) i ff for al l i in [0 , n ) : { { floo r ( ~ X X i ← max ( X i ) ) } } ≤ m { { ceil ing ( ~ Y ) } } (1) { { floo r ( ~ X ) } } ≤ m { { ceil ing ( ~ Y Y i ← min ( Y i ) ) } } (2) Pro of: ( ⇒ ) As the constraint is GA C, all v alues h av e supp ort. In p articular, X i ← max ( X i ) has a supp ort ~ x 1 ∈ { ~ x | x i = max ( X i ) ∧ ~ x ∈ ~ X } and ~ y 1 ∈ ~ Y where { { ~ x 1 } } ≤ m { { ~ y 1 } } . An y ~ x 2 ∈ { ~ x | x i = max ( X i ) ∧ ~ x ∈ ~ X } less than o r equal to ~ x 1 , and an y ~ y 2 ∈ ~ Y greater th an or equal to ~ y 1 , under m ultiset ordering, supp ort X i ← max ( X i ). In particular, min { ~ x | x i = max ( X i ) ∧ ~ x ∈ ~ X } and max { ~ y | ~ y ∈ ~ Y } supp ort X i ← max ( X i ). W e get min { ~ x | x i = max ( X i ) ∧ ~ x ∈ ~ X } if all the other v ariables in ~ X tak e their minim ums, and we get max { ~ y | ~ y ∈ ~ Y } if all the v ariables in ~ Y tak e their maximums. Hence, { { flo or ( ~ X X i ← max ( X i ) ) } } ≤ m { { ceiling ( ~ Y ) } } . A dual argum en t h olds for the v ariables of ~ Y . As the constrain t is GAC, Y i ← m in ( Y i ) has a supp ort ~ x 1 ∈ ~ X and ~ y 1 ∈ { ~ y | y i = min ( Y i ) ∧ ~ y ∈ ~ Y } where { { ~ x 1 } } ≤ m { { ~ y 1 } } . Any ~ x 2 ∈ ~ X less than or equal to ~ x 1 , and any ~ y 2 ∈ { ~ y | y i = min ( Y i ) ∧ ~ y ∈ ~ Y } greater than or equal to ~ y 1 , in p articular m in { ~ x | ~ x ∈ ~ X } and max { ~ y | y i = min ( Y i ) ∧ ~ y ∈ ~ Y } supp ort Y i ← min ( Y i ). W e get min { ~ x | ~ x ∈ ~ X } if all th e v ariables in ~ X take their minimums, and w e get max { ~ y | y i = m in ( Y i ) ∧ ~ y ∈ ~ Y } if all the other v ariables in ~ Y take their maxim u ms. Hence, { { flo or ( ~ X ) } } ≤ m { { ceiling ( ~ Y Y i ← min ( Y i ) ) } } . ( ⇐ ) Equ ation (1) ensures that for all 0 ≤ i < n , max ( X i ) is supp orted, and Equation (2) ensures that for all 0 ≤ i < n , min ( Y i ) is supp orted. By Theorem 1, the constraint is GA C. QED. 11 In Theorems 2 and 3, w e n eed to chec k whether t w o ground vecto rs are multiset ord er ed . The follo wing theorem sh o ws that we can do this by lexicographically comparing the o ccurrence v ectors asso ciated with these v ectors. Theorem 4 { { ~ x } } ≤ m { { ~ y } } iff occ ( ~ x ) ≤ lex occ ( ~ y ) . Pro of: ( ⇒ ) Su pp ose { { ~ x } } = { { ~ y } } . Th en the o ccurr ence vecto rs asso ciated with ~ x and ~ y are the same. S upp ose { { ~ x } } < m { { ~ y } } . If max { { ~ x } } < m ax { { ~ y } } then the leftmost ind ex of ~ ox = occ ( ~ x ) and ~ oy = occ ( ~ y ) is max { { ~ y } } , and we h a ve ox max { { ~ y } } = 0 and oy max { { ~ y } } > 0. This giv es ~ ox < lex ~ oy . If max { { ~ x } } = max { { ~ y } } = a then w e eliminate one o ccurrence of a from eac h m ultiset and compare the resulting m ultisets. ( ⇐ ) Supp ose occ ( ~ x ) = occ ( ~ y ). Then { { ~ x } } and { { ~ y } } con tain the same elemen ts with equal o ccurrences. Supp ose occ ( ~ x ) < lex occ ( ~ y ). Th en a v alue a o ccurs more in { { ~ y } } than in { { ~ x } } , and the o ccurrence of an y v alue b > a is th e same in b oth m ultisets. By deleting all the o ccurrences of a from { { ~ x } } and the same num b er of o ccurren ces of a fr om { { ~ y } } , as we ll as any b > a f r om b oth m ultisets, w e get max { { ~ x } } < max { { ~ y } } . QED. Theorems 2 and 3 together with Th eorem 4 yield to the follo w ing prop ositions: Prop osition 1 ~ X ≤ m ~ Y is disentaile d iff occ ( floor ( ~ X )) > lex occ ( ceiling ( ~ Y )) . Prop osition 2 GAC( ~ X ≤ m ~ Y ) iff for al l i in [0 , n ) : occ ( floor ( ~ X X i ← max ( X i ) )) ≤ lex occ ( ceiling ( ~ Y )) (3) occ ( floor ( ~ X )) ≤ lex occ ( ceiling ( ~ Y Y i ← min ( Y i ) )) (4) A naiv e wa y to enf orce GAC on ~ X ≤ m ~ Y is going thr ough ev ery v ariable in the v ectors, constructing the appropr iate o ccurrence v ectors, and c h ec king if th eir b ounds satisfy 3 and 4. If they d o, then the b oun d is consisten t. Otherwise, we try the n earest b ou n d u n til w e obtain a consistent b oun d. W e can, ho wev er, do b etter than this b y building only the v ectors occ ( floor ( ~ X )) and occ ( ceili ng ( ~ Y )) , and then definin g some p oint ers and Bo olean flags on them. T his sa ve s us from the rep eated construction and tra ve rsal of the appropriate occur rence v ectors. Another adv an tage is that we can fi nd consisten t b ound s without h a vin g to explore the v alues in the domains. W e start by definin g our p oin ters and flags. W e w rite ~ ox for occ ( floo r ( ~ X )), and ~ oy for occ ( ceiling ( ~ Y )). W e assume ~ ox and ~ oy are indexed from u to l , and ~ ox ≤ lex ~ oy . 3 Definition 5 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wher e ~ ox ≤ lex ~ oy , the p ointer α is set ei ther to the index in [ u, l ] such that: ox α < oy α ∧ ∀ i u ≥ i > α . ox i = oy i or (if this is not the c ase) to −∞ . Informally , α p oint s to the m ost s ignifican t ind ex in [ u, l ] such that ox α < oy α and all the v ariables ab o v e it are pairwise equal. If, ho w ev er, ~ ox = ~ oy th en α p oint s to −∞ . Definition 6 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wher e ~ ox ≤ lex ~ oy , the p ointer β is set either to the index in ( α, l ] such that: ox β > oy β ∧ ∀ i α > i > β . ox i ≤ oy i or (if α ≤ l or for al l α > i ≥ l we have ox i ≤ oy i ) to −∞ . 3 In the context of o ccurrence vector indexing, u..l and [ u, l ] imply u ≥ l . The exact meaning of the these abused notations will b e clear from the context. 12 Informally , β p oints to the most signifi cant index in ( α, l ] suc h th at ~ ox β → l > lex ~ oy β → l . If, suc h an ind ex do es n ot exist, th en β p oin ts to −∞ . Note that we hav e P i ox i = P i oy i = n , as ~ ox and ~ oy are b oth asso ciated with v ectors of length n . Hence, α cannot b e l , and we alwa ys ha v e ~ ox α − 1 → l > lex ~ oy α − 1 → l when α 6 = −∞ . Definition 7 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wher e ~ ox ≤ lex ~ oy , the flag γ is tr ue i ff : β 6 = −∞ ∧ ( β = α − 1 ∨ ∀ i α > i > β . ox i = oy i ) Informally , γ is tr ue if β 6 = −∞ , an d either β is jut next to α or the s ubv ectors b etw een α and β are equal. Otherwise, γ is f al se . Definition 8 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wher e ~ ox ≤ lex ~ oy , the flag σ is tr ue iff: β > l ∧ ~ ox β − 1 → l > lex ~ oy β − 1 → l Informally , σ is tr ue if β > l and the subv ectors b elo w β are lexicographically ordered the wrong w a y . If, ho we v er, β ≤ l , or the subv ectors b elo w β are lexico graphically ordered, th en σ is f al se . Using α , β , γ , and σ , w e can fi nd the tigh t upp er b ound for eac h D ( X i ), as w ell as the tigh t low er b ound for eac h D ( Y i ) without ha ving to tra verse the occurr ence v ectors. In the next three theorems, we are concerned w ith X i . When lo oking for a supp ort for a v alue v ∈ D ( X i ), w e obtain occ ( floor ( ~ X X i ← v )) b y increasing ox v b y 1, and decreasing ox min ( X i ) b y 1. Since ~ ox ≤ lex ~ oy , min ( X i ) is consistent. W e ther efore s eek su pp ort for v alues greater than min ( X i ). Theorem 5 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wh er e ~ ox ≤ lex ~ oy , if max ( X i ) ≥ α and min ( X i ) < α then for al l v ∈ D ( X i ) : 1. if v > α then v is inc onsistent; 2. if v < α then v is c onsistent; 3. if v = α then v is inc onsistent iff: ( ox α + 1 = oy α ∧ min ( X i ) = β ∧ γ ∧ ox β > oy β + 1) ∨ ( ox α + 1 = oy α ∧ min ( X i ) = β ∧ γ ∧ ox β = oy β + 1 ∧ σ ) ∨ ( ox α + 1 = oy α ∧ min ( X i ) < β ∧ γ ) Pro of: If min ( X i ) < α then α 6 = −∞ and ~ ox < lex ~ oy . Let v b e a v alue in D ( X i ) greater than α . Increasing ox v b y 1 give s ~ ox > lex ~ oy . By Pr op osition 2, v is inconsisten t. No w let v b e less than α . Increasing ox v b y 1 do es n ot c h ange ~ ox < lex ~ oy . By Prop osition 2, v is consisten t. Is α a tigh t up p er b ound ? I f any of the conditions in item 3 is tr ue then we obtain ~ ox > lex ~ oy b y increasing ox α b y 1 and decreasing ox min ( X i ) b y 1. By P rop osition 2, v = α is inconsisten t and therefore the largest v alue wh ic h is less than α is the tight upp er b oun d . W e no w n eed to sho w th at the conditions of item 3 are exh austiv e. If v = α is inconsistent then, b y Prop osition 2, w e ob tain ~ ox > lex ~ oy after in creasing ox α b y 1 and decreasing ox min ( X i ) b y 1. Th is can happ en only if ox α + 1 = oy α b ecause otherwise we still hav e ox α < oy α . No w, it is imp ortant where we decrease an o ccurrence. I f it is ab o ve β (but b elo w α as min ( X i ) < α ) then w e still ha ve ~ ox < lex ~ oy b ecause for all α > i > max { l − 1 , β } , we ha ve ox i ≤ oy i . If it is on or b elo w β (when β 6 = −∞ ) and γ is f als e , then w e still hav e ~ ox < lex ~ oy b ecause γ is f als e when β < α − 1 and ~ ox α − 1 → β +1 < lex ~ ox α − 1 → β +1 . Ther efore, it is necessary to h a ve ox α +1 + 1 = oy α ∧ min ( X i ) ≤ β ∧ γ for α to b e inconsisten t. Two cases arise h ere. In the fir st, w e hav e ox α +1 + 1 = oy α ∧ min ( X i ) = β ∧ γ . Decreasing ox β b y 1 can giv e 13 ~ ox > lex ~ oy in t w o w a y s : either we still hav e ox β > oy β , or we n o w ha v e ox β = oy β but the v ectors b elo w β are ord ered lexicographically the w rong w a y . Note that decreasing ox β b y 1 cannot giv e ox β < oy β . Th er efore, the fi rst case r esults in t w o conditions f or α to b e inconsisten t: ox α +1 + 1 = oy α ∧ min ( X i ) = β ∧ γ ∧ ox β > oy β + 1 or ox α +1 + 1 = oy α ∧ min ( X i ) = β ∧ γ ∧ ox β = oy β + 1 ∧ σ . No w consider the second case, wh ere w e ha ve ox α +1 + 1 = oy α ∧ min ( X i ) < β ∧ γ . Decreasing ox min ( X i ) b y 1 giv es ~ ox > lex ~ oy . Hence, if v = α is inconsisten t then w e ha v e either of the three conditions. QED. Theorem 6 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wh er e ~ ox ≤ lex ~ oy , if max ( X i ) < α then max ( X i ) is the tight upp er b ound. Pro of: If max ( X i ) < α then we ha ve α 6 = −∞ and ~ ox < lex ~ oy . In cr easing ox max ( X i ) b y 1 do es not c h ange th is. By Pr op osition 2, max ( X i ) is consistent. Q ED. Theorem 7 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wh er e ~ ox ≤ lex ~ oy , if min ( X i ) ≥ α then min ( X i ) is the tight upp er b ound. Pro of: Any v > min ( X i ) in D ( X i ) is greate r than α . Increasing ox v b y 1 giv es ~ ox > lex ~ oy . By Prop osition 2, an y v > min ( X i ) in D ( X i ) is in consisten t. QED. In the next four theorems, w e are concerned with Y i . When looking for a supp ort for a v alue v ∈ D ( Y i ), we obtain occ ( ceiling ( ~ Y Y i ← v )) b y increasing oy v b y 1, and decreasing oy max ( Y i ) b y 1. Since ~ ox ≤ lex ~ oy , max ( Y i ) is consisten t. W e therefore seek supp ort f or v alues less than max ( Y i ). Theorem 8 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wh er e ~ ox ≤ lex ~ oy , if max ( Y i ) = α and min ( Y i ) ≤ β then for al l v ∈ D ( Y i ) 1. if v > β then v i s c onsistent; 2. if v < β then v i s inc onsistent iff ox α + 1 = oy α ∧ γ 3. if v = β then v i s inc onsistent iff: ( ox α + 1 = oy α ∧ γ ∧ ox β > oy β + 1) ∨ ( ox α + 1 = oy α ∧ γ ∧ ox β = oy β + 1 ∧ σ ) Pro of: If max ( Y i ) = α an d min ( Y i ) ≤ β then α 6 = −∞ , β 6 = − ∞ , and ~ ox < lex ~ oy . Let v b e a v alue in D ( Y i ) greater than β . I ncreasing oy v b y 1 and decreasing oy α b y 1 do es not c h an ge ~ ox < lex ~ oy . Th is is b ecause for all α > i > β , we h av e ox i ≤ oy i . Ev en if no w ~ ox α → v +1 = ~ oy α → v +1 , at v we ha v e ox v < oy v . By Prop osition 2, v is consistent. No w let v b e less than β . If th e condition in item 2 is tr ue th en we obtain ~ ox > lex ~ oy by decreasing oy α b y 1 and in creasing oy v b y 1. By Pr op osition 2, v is inconsistent . W e no w n eed to s h o w that th is condition is exhaustive . If v is inconsisten t th en by Prop osition 2, we ob tain ~ ox > lex ~ oy after decreasing oy α b y 1 and increasing oy v b y 1. This is in fact the same as obtaining ~ ox > lex ~ oy after increasing ox α b y 1 and decreasing ox v b y 1. W e hav e already captured this case in the last condition of item 3 in Theorem 5. Hence, it is necessary to hav e ox α + 1 = oy α ∧ γ for v to b e inconsistent . What ab out β then ? If an y of the conditions in item 3 is t r ue then w e obtain ~ ox > lex ~ oy by d ecreasing oy α b y 1 and increasing oy β b y 1. By Prop osition 2, v = β is inconsisten t. In this case, the v alues less than β are also inconsisten t. Therefore, th e smallest v alue whic h is greater than β is the tigh t lo wer b ound . W e no w need to sh ow that the conditions of item 3 are exhaustiv e. If v = β is inconsisten t then by Prop osition 2, we obtain ~ ox > lex ~ oy after d ecreasing oy α b y 1 and increasing oy β b y 1. This is th e same as obtaining ~ ox > lex ~ oy after increasing ox α b y 1 and decreasing ox β b y 1. W e hav e captur ed this case in the fi rst t wo conditions of item 3 in Theorem 5. Hence, if v = β is inconsisten t th en we hav e either ox α +1 + 1 = oy α ∧ γ ∧ ox β > oy β + 1 or ox α +1 + 1 = oy α ∧ γ ∧ ox β = oy β + 1 ∧ σ . QE D. 14 Algorithm 1: I nitialis e Data : h X 0 , X 1 , . . . , X n − 1 i , h Y 0 , Y 1 , . . . , Y n − 1 i Result : occ ( floor ( ~ X )) and occ ( ceiling ( ~ Y )) are initialis ed, GA C( ~ X ≤ m ~ Y ) 1 l := m in ( { { floor ( ~ X ) } } ∪ { { fl oor ( ~ Y ) } } ); 2 u := max ( { { ceiling ( ~ X ) } } ∪ { { ce iling ( ~ Y ) } } ); 3 ~ ox := occ ( floor ( ~ X ) ); 4 ~ oy := occ ( cei ling ( ~ Y )); 5 MsetLeq ; Theorem 9 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wh er e ~ ox ≤ lex ~ oy , if max ( Y i ) = α and min ( Y i ) > β then min ( Y i ) is the tight lower b ound. Pro of: If max ( Y i ) = α then α 6 = −∞ and ~ ox < lex ~ oy . In cr easing oy min ( Y i ) b y 1 and decreasing oy α b y 1 do es n ot change ~ ox < lex ~ oy . This is b ecause for all α > i > max { l − 1 , β } , we ha ve ox i ≤ oy i . Ev en if n o w ~ ox α → min ( Y i )+1 = ~ oy α → min ( Y i )+1 , at m in ( Y i ) w e ha ve ox min ( Y i ) < oy min ( Y i ) . By Prop osition 2, min ( Y i ) is consistent. Q ED. Theorem 10 Give n ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wher e ~ ox ≤ lex ~ oy , if max ( Y i ) < α then min ( Y i ) is the tight lower b ound. Pro of: If max ( Y i ) < α then we ha v e α 6 = −∞ and ~ ox < lex ~ oy . Decreasing oy max ( Y i ) b y 1 do es not c h ange th is. By Pr op osition 2, min ( Y i ) is consistent. Q ED. Theorem 11 Give n ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wher e ~ ox ≤ lex ~ oy , if max ( Y i ) > α then max ( Y i ) is the tight lower b ound. Pro of: Decreasing oy max ( Y i ) b y 1 giv es ~ ox > lex ~ oy . By Prop osition 2, an y v < m ax ( Y i ) in D ( Y i ) is in consisten t. QED. 4.3 Algorithm Details and Theoretical Prop erties In this subsection, w e first explain Mset Leq as wel l as p ro ve that it is correct and complete. W e then discuss its time complexit y . The algorithm is b ased on Theorems 5-11. The p oin ters and flags are recomputed ev ery time the algorithm is called, as mainta ining them incremental ly in an easy w ay is not obvio us. F ortunately , incremen tal main tenance of the o ccurr ence vecto rs is tr ivial. When the minim um v alue in some D ( X i ) c hanges, w e up date ~ ox by incrementing the entry corresp onding to new min ( X i ) by 1, and d ecremen ting the entry corresp onding to old min ( X i ) by 1. S imilarly , when the maxim u m v alue in some D ( Y i ) c hanges, we u p d ate ~ oy by incrementing th e en try corresp ondin g to new max ( Y i ) by 1, and decremen ting the entry corresp onding to old max ( Y i ) b y 1. When the constrain t is first p osted, we need to initialise th e o ccurrence ve ctors, and call the filtering algorithm Mse tLeq to establish the generalised arc-consisten t state with the initial v alues of the o ccurrence vect ors. In Algorithm 1 , we sh o w the steps of this initialisation. Theorem 12 I nitialis e initialises ~ ox and ~ oy c orr e ctly. Then i t either establishes failur e if ~ X ≤ m ~ Y is disentaile d, or prunes al l i nc onsistent values fr om ~ X and ~ Y to ensur e GAC( ~ X ≤ m ~ Y ). Pro of: Initialise first computes the most and the least significant indices of the o ccur rence v ectors as u and l (lines 1 and 2). An o ccurrence v ector occ ( ~ x ) asso ciated with ~ x is indexed in decreasing order of significance from max { { ~ x } } to min { { ~ x } } . Ou r o ccurr ence v ectors are associated with floor ( ~ X ) and ceili ng ( ~ Y ) bu t they are also used for c h ec king sup p ort f or max ( X i ) and 15 Algorithm 2: M setLeq Data : h X 0 , X 1 , . . . , X n − 1 i , h Y 0 , Y 1 , . . . , Y n − 1 i Result : GAC( ~ X ≤ m ~ Y ) A1 SetPointersAndFl ags ; B1 foreach i ∈ [0 , n ) do B2 if min ( X i ) 6 = max ( X i ) then B3 if min ( X i ) ≥ α then setMax( X i , min ( X i ) ) ; B4 if max ( X i ) ≥ α ∧ min ( X i ) < α then B5 setMax( X i , α ) ; B6 if ox α + 1 = oy α ∧ m in ( X i ) = β ∧ γ then B7 if ox β = oy β + 1 then B8 if σ then setMax( X i , α − 1 ) ; else B9 setMax( X i , α − 1 ) ; end end B10 if ox α + 1 = oy α ∧ m in ( X i ) < β ∧ γ then B11 setMax( X i , α − 1 ) ; end end end end C1 foreach i ∈ [0 , n ) do C2 if min ( Y i ) 6 = max ( Y i ) then C3 if max ( Y i ) > α then setMin( Y i , max ( Y i ) ) ; C4 if max ( Y i ) = α ∧ min ( Y i ) ≤ β then C5 if ox α + 1 = oy α ∧ γ then C6 s etMin( Y i , β ) ; C7 if ox β = oy β + 1 then C8 if σ then setMin( Y i , β + 1 ) ; else C9 setMin( Y i , β + 1 ) ; end end end end end min ( Y i ) for all 0 ≤ i < n . W e th erefore n eed to make sure th at there are corresp ond ing en tries. Also, to b e able to compare tw o o ccurrence v ectors, th ey need to start and end with the o ccur rence of the same v alue. Therefore, u is max ( { { ceilin g ( ~ X ) } } ∪ { { ceiling ( ~ Y ) } } ) and l is min ( { { flo or ( ~ X ) } } ∪ { { floo r ( ~ Y ) } } ). Using these in dices, a pair of vecto rs ~ ox and ~ oy of length u − l + 1 are constructed and eac h en try in these vec tors are set to 0. Then, ox min ( X i ) and oy max ( Y i ) are in cremen ted by 1 for all 0 ≤ i < n . No w , for all u ≥ v ≥ l , ox v is the num b er of o ccurrences of v in { { floor ( ~ X ) } } . Similarly , for all u ≥ v ≥ l , oy v is th e num b er of o ccurrences of v in { { ceiling ( ~ Y ) } } . This giv es u s ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceil ing ( ~ Y )) (lines 3 and 4). Finally , in line 5, Initiali se calls the filtering algorithm Ms etLeq which either establishes failure if ~ X ≤ m ~ Y is disen tailed, or prun es all inconsisten t v alues from ~ X and ~ Y to ensure GA C( ~ X ≤ m ~ Y ). QED. Note that when ~ X ≤ m ~ Y is GA C, ev ery v alue in D ( X i ) is supp orted by h min ( X 0 ) , . . . , min ( X i − 1 ) , min ( X i +1 ) , . . . , min ( X n − 1 ) i , and h max ( Y 0 ) , . . . , max ( Y n − 1 ) i . S imilarly , every v alue in D ( Y i ) is supp orted b y h min ( X 0 ) , . . . , min ( X n − 1 ) i and h max ( Y 0 ) , . . . , max ( Y i − 1 ) , max ( Y i +1 ) , . . . , max ( Y n − 1 ) i . So, MsetLeq is also called b y the eve nt handler whenev er min ( X i ) or max ( Y i ) of some i in [0 , n ) c h an ges. In Algorithm 2, w e sho w the steps of MsetL eq . Since ~ ox and ~ oy are main tained increment ally , the algorithm fir st sets the p ointers and flags in line A1 via SetP ointersAn dFlags usin g the 16 Pro cedure SetP ointersA ndFlags 1 i := u ; 2 whil e i ≥ l ∧ ox i = oy i do i := i − 1; 3 if i ≥ l ∧ ox i > oy i then fail; 4 els e if i = l − 1 then α := −∞ ; 5 els e α := i ; 6 if α ≤ l then β := −∞ ; 7 els e if α > l then 8 j := α − 1, temp := tr ue ; 9 while j ≥ l ∧ ox j ≤ oy j do 10 if ox j < oy j then temp := f alse ; 11 j := j − 1; end 12 if j = l − 1 then β := −∞ ; 13 else β := j ; end 14 γ := f a lse , σ := f alse ; 15 i f β 6 = −∞ ∧ temp then γ := true ; 16 i f β > l then 17 k := β − 1; 18 while k ≥ l ∧ ox k = oy k do k := k − 1; 19 if k ≥ l ∧ ox k > oy k then σ := tr ue ; end current state of these vec tors. Theorem 13 S etPointe rsAndFla gs either sets α , β , γ , and σ as p er their definitions, or establishes failur e as ~ X ≤ m ~ Y is disentaile d. Pro of: Line 2 of SetP ointersAn dFlags tra v er s es ~ ox and ~ oy , starting at index u , u n til either it reac hes the end of the vect ors (b ecause ~ ox = ~ oy ), or it finds an ind ex i wh ere ox i 6 = oy i . In the first case, α is set to −∞ (line 4) as p er Definition 5. In the second case, α is s et to i only if ox i < oy i (line 5). This is correct by Definition 5 and means that ~ ox < lex ~ oy . If, ho wev er, ox i > oy i then w e hav e ~ ox > lex ~ oy . By Prop osition 1, ~ X ≤ m ~ Y is disent ailed and thus SetPoint ersAndFl ags terminates with failure (line 3). This also triggers the fi ltering algorithm to f ail. If α ≤ l then β is set to −∞ (line 6) as p er Definition 6. Oth er w ise, the ve ctors are tr av ersed in lines 9-11, starting at in dex α − 1, u n til either the end of the v ectors are reac hed (b ecause ~ ox α − 1 → l ≤ lex ~ oy α − 1 → l ), or an in dex j where ox j > oy j is f ou n d. In the first case, β is set to −∞ (line 12), and in the second case, β is set j (line 13) as p er Defin ition 6. During this tra versal, the Bo olean flag temp is set to tr ue iff ~ ox α − 1 → max { l,β +1 } = ~ oy α − 1 → max { l,β +1 } . In lines 14 and 15, γ is s et to tr ue iff β 6 = −∞ , and either β = α − 1 or temp is tr ue (b ecause ~ ox α − 1 → β +1 = ~ oy α − 1 → β +1 ). This is corr ect by Defin ition 7. In line 14, σ is initialised to f alse . If β ≤ l then σ remains f als e (line 16) as p er Definition 8. Otherw ise, the vect ors are tra versed in lin e 18, starting at index β − 1, un til either the end of the v ectors are r eac hed (b ecause ~ ox β − 1 → l = ~ oy β − 1 → l ), or an in d ex k where ox k 6 = oy k is found. In the first case, σ remains f als e as p er Definition 8. In the second case, σ is set to tr ue only if ox k > oy k (line 19). This is correct by Definition 8 and means that ~ ox β − 1 → l > lex ~ oy β − 1 → l . If , ho wev er, ox k < oy k then σ remains f als e as p er Definition 8. QE D. W e n o w analyse the rest of MsetL eq , where the tigh t upp er b ound for X i and the tight lo wer b ound for Y i , for all 0 ≤ i < n , are sough t. Theorem 14 M setLeq e ither establishes failur e if ~ X ≤ m ~ Y is disentaile d, or prunes al l inc on- sistent values f r om ~ X and ~ Y to ensur e GAC( ~ X ≤ m ~ Y ). Pro of: 17 If ~ X ≤ m ~ Y is not d isentaile d then we ha v e ~ ox ≤ lex ~ oy b y Prop osition 1. T his means that min ( X i ) and max ( Y i ) for all 0 ≤ i < n are consisten t b y Prop osition 2. The algorithm therefore seeks the tigh t upp er b oun d for X i only if max ( X i ) > min ( X i ) (lines B2-11 ), and similarly th e tigh t lo wer b ound for Y i only if min ( Y i ) < max ( Y i ) (lines C 2-9 ). F or eac h D ( X i ): (1) If min ( X i ) ≥ α th en all v alues greater than min ( X i ) are prun ed, giving min ( X i ) as th e tigh t upp er b ound (line B3 ). T his is correct b y Th eorem 7. (2) I f max ( X i ) ≥ α ∧ min ( X i ) < α th en: • all v alues greater than α are prun ed (line B5 ); • α is pr uned if ox α + 1 = oy α ∧ min ( X i ) = β ∧ γ ∧ ox β > oy β + 1 (line B9 ), or ox α + 1 = oy α ∧ min ( X i ) = β ∧ γ ∧ ox β = oy β + 1 ∧ σ (line B8 ), or ox α + 1 = oy α ∧ min ( X i ) < β ∧ γ (line B11 ). All the v alues less than α remain in the domain. By Theorem 5, all the inconsistent v alues are remo ved. (3) If, ho w ev er, max ( X i ) < α then max ( X i ) is th e tight upp er b ound by T heorem 6, and th us no p runin g is n ecessary . F or eac h D ( Y i ): (1) If max ( Y i ) > α then all v alues less than max ( Y i ) are pru n ed, giving max ( Y i ) as the tigh t lo wer b ound (line C3 ). This is correct b y T heorem 11. (2) I f max ( Y i ) = α ∧ m in ( Y i ) ≤ β th en: • all v alues less than β are pru ned if ox α + 1 = oy α ∧ γ (line C6 ); • β is pruned if ox α + 1 = oy α ∧ γ ∧ ox β > oy β + 1 (line C9 ) or ox α + 1 = oy α ∧ γ ∧ ox β = oy β + 1 ∧ σ (line C8 ). All the v alues greater than β remain in the d omain. By Th eorem 8, all the inconsistent v alues are remo v ed. (3) If, how ev er, max ( Y i ) = α ∧ min ( Y i ) > β or max ( Y i ) < α then min ( Y i ) is the tigh t lo wer b ound b y Theorems 9 and 10, and thus no pru ning is needed. MsetLeq is a correct and complete filtering algorithm, as it either establishes failure if ~ X ≤ m ~ Y is disentail ed, or prun es all inconsistent v alues f rom ~ X and ~ Y to ensu re GA C( ~ X ≤ m ~ Y ). QED. When w e p rune a v alue, we d o not need to c hec k r ecursiv ely that p revious supp ort remains. The algorithm tighte ns max ( X i ) and min ( Y i ) without touching min ( X i ) and max ( Y i ), for all 0 ≤ i < n , which provide sup p ort for the v alues in the v ectors. The exception is if a d omain wip e out o ccurs. As the constrain t is not disentaile d, w e hav e ~ ox ≤ lex ~ oy . This means min ( X i ) and max ( Y i ) for all 0 ≤ i < n are su p p orted. Hence, th e pr unings of the algorithm cannot cause an y domain w ip e-out. The algorithm w orks also when the v ectors are of different length as w e bu ild an d reason ab out the o ccurrence v ectors as opp osed to th e original vect ors. Also, w e do not assum e that the original v ectors are of the same length when we set the p ointe r β . The algorithm corrects a mistak e that app ears in [FHK + 03]. W e h a ve noticed that in [FHK + 03] w e d o not alw a ys pr une the v alues greater than α when we hav e max ( X i ) ≥ α an d min ( X i ) < α . As sho wn ab o ve, th is algorithm is correct and complete. T o impro v e the time complexit y , w e assu m e that domains are transf orm ed so that their union is a con tin uous interv al. Supp ose, for in stance, that w e ha v e v ariables with domains { 1 , 5 } , { 1 , 100 } and { 5 , 100 } . T his transformation normalises the domains to { 1 , 2 } , { 1 , 3 } and { 2 , 3 } . This This tec hniqu e is widely used (see for instance [KT05]) and d o es not c h an ge the w orst-case complexit y of our propagator. It giv es us a tigh ter upp er b ound on the complexit y of our propagator in terms of the n umber of distinct v alues as compared to the difference b et w een the largest and s m allest v alues. Theorem 15 I nitialis e runs in time O ( n + d ) , wher e d is the numb er of distinct values. 18 Pro of: Ini tialise first constr u cts ~ ox and ~ oy of length d where eac h en try is zero, and then incremen ts ox min ( X i ) and oy max ( Y i ) b y 1 for all 0 ≤ i < n . Hence, the complexit y of initialisation is O ( n + d ). QED. Theorem 16 M setLeq runs in time O ( nb + d ) , wher e b is the c ost of adjusting the b ounds of a variable, and d is the numb er of diffe r ent values. Pro of: MsetLeq do es not constru ct ~ ox and ~ oy , but r ather us es their most up-to-date states. MsetLeq first sets the p oin ters and flags which are defined on ~ ox and ~ oy . In the w orst case b oth v ectors are tra v ersed once fr om the b eginnin g unti l the end, wh ic h giv es an O ( d ) complexit y . Next, the algorithm go es through ev ery v ariable in the original vec tors ~ X and ~ Y to c hec k for supp ort. Deciding the tigh t b ound for eac h v ariable is a constan t time op eration, but the cost of adj u sting the b oun d is b . Since we hav e O ( n ) v ariables, the complexit y of the algorithm is O ( nb + d ). QED. If d ≪ n then the algorithm ru ns in time O ( nb ). Since a multiset is a set with p ossible rep etitions, we exp ect that the num b er of d istinct v alues in a m ultiset is often less than the cardinalit y of th e m ultiset, giving us a linear time fi ltering algorithm. 5 Multiset Ordering with Large Domains MsetLeq is a linear time algorithm in the n giv en that d ≪ n . If instead w e ha v e n ≪ d then the complexit y of the algorithm is O ( d ), d omin ated by the cost of the construction of the o ccurrence v ectors and the initialisation of the p oin ters and flags. T his can h app en, for instance, when th e v ectors b eing m ultiset ordered are v ariables in the occur rence r ep resen tation of a m ultiset [KW02]. Is there then an alternativ e w a y of propagating the multiset ordering constrain t whose complexit y is in dep end en t of the domains? 5.1 Remedy In case d is a large n u mb er, it could b e costl y to construct the o ccurren ce v ectors. W e can instead sort floor ( ~ X ) and ceilin g ( ~ Y ), and compute α , β , γ , σ , and the num b er of o ccurrences of α and β in { { flo or ( ~ X ) } } and { { cei ling ( ~ Y ) } } as if we had the occurren ce v ectors by scanning these sorted vec tors. This information is all we need to find sup p ort for the b ound s of the v ariables. Let u s illustr ate th is on an example. T o simplify presentat ion, w e assum e th at the vec tors are of the same length. Consider ~ X ≤ m ~ Y wh ere ~ sx = sor t ( fl oor ( ~ X )) and ~ sy = sor t ( ceiling ( ~ Y )) are as follo ws: ~ sx = h 5 , 4 , 3 , 2 , 2 , 2 , 2 , 1 i ~ sy = h 5 , 4 , 4 , 4 , 3 , 1 , 1 , 1 i W e tr a verse ~ sx and ~ sy until we find an ind ex i su c h that sx i < sy i , and for all 0 ≤ t < i we ha ve sx t = sy t . In our example, i is 2: ↓ i ~ sx = h 5 , 4 , 3 , 2 , 2 , 2 , 2 , 1 i ~ sy = h 5 , 4 , 4 , 4 , 3 , 1 , 1 , 1 i This means that the num b er occurr ences of any v alue greater than sy i are equal in { { floor ( ~ X ) } } and in { { ceilin g ( ~ Y ) } } , but there are m ore o ccurr ence of sy i in { { ceilin g ( ~ Y ) } } than in { { floor ( ~ X ) } } . That is, ox 5 = oy 5 and ox 4 < oy 4 . By Definition 5, α is equal to 4. W e no w mo v e only along ~ sy u n til we fin d an index j suc h that sy j 6 = sy j − 1 , so th at w e reason ab out the num b er of o ccurrences of the sm aller v alues. In ou r example, j is 4: ↓ i ~ sx = h 5 , 4 , 3 , 2 , 2 , 2 , 2 , 1 i ~ sy = h 5 , 4 , 4 , 4 , 3 , 1 , 1 , 1 i ↑ j 19 Algorithm 4: I nitialis e Data : h X 0 , X 1 , . . . , X n − 1 i , h Y 0 , Y 1 , . . . , Y n − 1 i Result : sor t ( floor ( ~ X ) ) and sor t ( ceiling ( ~ Y ) ) are initialised, GAC( ~ X ≤ m ~ Y ) 1 ~ sx := sort ( floor ( ~ X )); 2 ~ sy := s or t ( ceiling ( ~ Y ) ); 3 MsetLeq ; W e here initialise γ to tr ue , and start tr av ersing ~ s x and ~ sy simultaneously . W e ha v e s x i = sy j = 3. This adds 1 to ox 3 and oy 3 , k eeping γ = tr ue . W e mo ve one index ahead in b oth v ectors by incremen ting i to 3 and j to 5: ↓ i ~ sx = h 5 , 4 , 3 , 2 , 2 , 2 , 2 , 1 i ~ sy = h 5 , 4 , 4 , 4 , 3 , 1 , 1 , 1 i ↑ j W e n o w ha v e sx i > sy j , whic h suggests that sx i o ccurs at least once in { { flo or ( ~ X ) } } bu t do es not o ccur in { { ceiling ( ~ Y ) } } . That is, ox 2 > 0 and oy 2 = 0. By Definition 6, β p oints to 2. This do es not c hange that γ is tr ue . W e no w mo ve only along ~ sx by incremen ting i until w e find sx i 6 = sx i − 1 , so that we reason ab out the num b er of o ccurren ces of the smaller v alues: ↓ i ~ sx = h 5 , 4 , 3 , 2 , 2 , 2 , 2 , 1 i ~ sy = h 5 , 4 , 4 , 4 , 3 , 1 , 1 , 1 i ↑ j With the new v alue of i , we hav e sx i = sy i = 1. T his increases b oth ox 1 and oy 1 b y one. Reac hin g the end of only ~ s x hints the follo wing: either 1 o ccurs more than once in { { ceiling ( ~ Y ) } } , or it o ccurs once b ut there are v alues in { { ceiling ( ~ Y ) } } less than 1 and they do n ot o ccur in { { floor ( ~ X ) } } . By Definition 8 , γ is f al se . Finally , w e need to kno w th e num b er of occurr ences of α and β in { { floor ( ~ X ) } } and { { ceiling ( ~ Y ) } } . Since we already kn o w wh at α an d β are, another scan of ~ sx and ~ s y giv es us the needed information: for all 0 ≤ i < n , w e incremen t ox α (resp. ox β ) by 1 if sx i = α (resp . sx i = β ), and also oy α (resp. oy β ) by 1 if sy i = α (resp. sy i = β ). 5.2 An Alternativ e Filtering Algorit hm As witn essed in th e pr evious section, it suffices to sort floor ( ~ X ) and ceiling ( ~ Y ), and scan the sorted vec tors to compute α , β , γ , σ , ox α , oy α , ox β , and oy β . W e can then directly reuse lines B1-11 and C 1-9 of Mset Leq to obtain a n ew filtering algorithm. As a result, we need to c hange only Ini tialise and SetPoi ntersAnd Flags . In Algorithm 4, we sho w the n ew Initiali se . Instead of constr u cting a pair of o ccurrence v ectors asso ciated with floor ( ~ X ) and ceiling ( ~ Y ), w e no w sort f loor ( ~ X ) and ceiling ( ~ Y ) and then call MsetLeq . Similar to the original algorithm, w e r ecompu te the p oin ters and flags ev ery time we call the filtering algorithm. Main taining the sorted vec tors incremen tally is trivial. When the minimum v alue in some D ( X i ) changes, w e u p d ate ~ s x by inserting the new min ( X i ) int o, and removing the old min ( X i ) fr om ~ s x . Similarly , when the maximum v alue in some D ( Y i ) changes, we up d ate ~ sy by inserting the new max ( Y i ) in to, and removing th e old max ( Y i ) from ~ s y . Since these v ectors need to remain sorted after the up date, suc h mo difications require b in ary searc h . The cost of incremental it y th u s increases from O (1) to O ( l og ( n )) compared to the original filtering algorithm. 20 Pro cedure SetP ointersA ndFlags 1 i := 0; 2 whil e i < n ∧ sx i = sy i do i := i + 1; 3 if i < n ∧ sx i > sy i then fail; 4 els e if i = n then α := −∞ , β := −∞ , γ := f alse , σ := f alse , return ; 5 els e α := s y i ; 6 γ := t r ue ; 7 j := i + 1; 8 whil e j < n ∧ sy j = sy j − 1 do j := j + 1; 9 if j = n then β := sx i ; 10 e lse if j < n then 11 while i < n ∧ j < n do 12 if sx i > sy j then β := sx i , break ; 13 if sx i < sy j then γ := f alse , j := j + 1; 14 if sx i = sy j then i := i + 1, j := j + 1; end 15 if j = n then β := sx i ; end 16 k := i + 1; 17 whi le k < n ∧ sx k = sx k − 1 do k := k + 1; 18 i f k = n then σ := f al se ; 19 e lse if k < n then 20 while k < n ∧ j < n do 21 if sx k > sy j then σ := true , break ; 22 if sx k < sy j then σ := f al se , break ; 23 if sx k = sy j then k := k + 1, j := j + 1; end 24 if k = n then σ := f als e ; 25 else if j = n then σ := tr ue ; end end 26 i := 0, ox α = 0, oy α = 0, ox β = 0, oy β = 0; 27 foreach i ∈ [0 , n ) do 28 if sx i = α then ox α := ox α + 1; 29 if sx i = β then ox β := ox β + 1; 30 if sy i = α then oy α := oy α + 1; 31 if sy i = β then oy β := oy β + 1; end Giv en the most up -to-date ~ sx and ~ sy , ho w d o w e set our p oin ters and flags? I n line 2 of our new SetPointers AndFlags , w e tra verse ~ sx and ~ sy , starting at index 0, un til either we reac h the end of the v ectors (b ecause the v ectors are equal), or we fin d an index i w here sx i 6 = sy i . In the first case, we firs t set α and β to −∞ , and γ and σ to f alse , and th en return (line 4). In the second case, if s x i > s y i then d isen tailmen t is detected and SetPointer sAndFlag s terminates with failure (line 3). The reason of the return and failure is due to the follo win g theoretical result. Theorem 17 occ ( ~ x ) ≤ lex occ ( ~ y ) iff sor t ( ~ x ) ≤ lex sor t ( ~ y ) . Pro of: ( ⇒ ) I f occ ( ~ x ) < lex occ ( ~ y ) then a v alue a o ccurs more in { { ~ y } } than in { { ~ x } } , and th e o ccurrence of an y v alue b > a is the same in b oth m u ltisets. By deleting all th e o ccurr en ces of a from { { ~ x } } and the same num b er of o ccurren ces of a fr om { { ~ y } } , as we ll as any b > a f r om b oth multisets, we get max { { ~ x } } < max { { ~ y } } . Since the leftmost v alues in sor t ( ~ x ) and sor t ( ~ y ) are max { { ~ x } } and max { { ~ y } } resp ectiv ely , w e h a ve sor t ( ~ x ) < lex sor t ( ~ y ). If occ ( ~ x ) = occ ( ~ y ) then w e ha ve { { ~ x } } = { { ~ y } } . By sorting the element s in ~ x and ~ y , we obtain the same v ectors. Hence, sor t ( ~ x ) = sor t ( ~ y ). ( ⇐ ) Su pp ose ~ ox = occ ( ~ x ), ~ oy = occ ( ~ y ), ~ sx = sor t ( ~ x ), ~ sy = sor t ( ~ y ), and we ha v e ~ sx = ~ sy . 21 Then { { ~ x } } and { { ~ y } } con tain the same elemen ts with equal o ccurrences. Hence, ~ ox = ~ oy . Sup p ose ~ sx < lex ~ sy . If s x 0 < sy 0 then the leftmost index of ~ ox and ~ oy is sy 0 , and we ha ve ox sy 0 = 0 and oy sy 0 > 0. This giv es ~ ox < lex ~ oy . If s x 0 = sy 0 = a then we eliminate one o ccurr en ce of a fr om { { ~ x } } and { { ~ y } } , and compare the resulting multisets. QED. Hence, when ev er w e hav e ~ sx ≥ lex ~ sy , w e pro ceed as if w e had occ ( floor ( ~ X )) ≥ lex occ ( ceiling ( ~ Y )) . But then wh at do we do if we hav e ~ s x < lex ~ sy ? In line 5, w e ha v e sx i < sy i and s x t = sy t for all 0 ≤ t < i . This means that the num b er o ccurrences of any v alue greater than sy i are equal in { { floor ( ~ X ) } } and in { { cei ling ( ~ Y ) } } , but th ere are m ore o ccurren ce of sy i in { { ceili ng ( ~ Y ) } } than in { { flo or ( ~ X ) } } . Therefore, w e here s et α to s y i . After initialising γ to tr ue in line 6, we s tart seeking a v alue for β . F or the sak e of simplicit y , w e here assu me our original vecto rs are of same length. Hence, β cannot b e −∞ as α is not −∞ . In line 8, w e trav erse ~ sy , starting at index i + 1, until either we reac h the end of the v ector (b ecause all the remaining v alues in { { ceiling ( ~ Y ) } } are sy i ), or w e fin d an in dex j su c h that s y j 6 = s y j − 1 . I n th e fir st case, w e set β to sx i (line 9) b ecause sx i o ccurs at least once in { { floor ( ~ X ) } } but do es not o ccur in { { ceili ng ( ~ Y ) } } . Since no v alue b et ween α and β o ccur more in { { ceili ng ( ~ Y ) } } than in { { flo or ( ~ X ) } } , γ remains tr ue . In the second case, sy j giv es us the next largest v alue in { { ceilin g ( ~ Y ) } } . In lines 11-14 , w e tra verse ~ sx starting from i , and ~ sy starting f rom j . I f s x i > s y j then w e set β to sx i (line 12) b ecause sx i o ccurs more in { { floor ( ~ X ) } } than in { { ceili ng ( ~ Y ) } } . Havi ng foun d the v alue of β , we here exit the wh ile lo op using break . If sx i < sy j then sy j o ccurs more in { { ceili ng ( ~ Y ) } } than in { { floor ( ~ X ) } } . Since w e are still lo oking for a v alue for β , we set γ to f al s e (line 13). W e then mo v e to the n ext index in ~ sy to fi nd the n ext largest v alue in { { ce iling ( ~ Y ) } } . If sx i = s y j then we mo v e to the n ext index b oth in ~ sx and ~ sy to find the next largest v alues in { { flo or ( ~ X ) } } and { { ceiling ( ~ Y ) } } (line 14). As j is at least one in d ex ahead of i , j can reac h to n b efore i do es dur ing this tra v ersal. In suc h a case, we set β to sx i (line 15) du e to the same reasoning as in line 12. The pro cess of fin ding the v alue of σ (lines 16-25) is v ery similar to that of β . In line 17, we tra verse ~ sx , starting at index i + 1, until either w e reac h the end of the vect or (b ecause all the remaining v alues in { { floor ( ~ X ) } } are β ), or we fin d an index k su c h that s x k 6 = s x k − 1 . In the first case, w e set σ to f alse (line 18) b ecause either sy j o ccurs at least once in { { ceiling ( ~ Y ) } } but do es not o ccur in { { floor ( ~ X ) } } (due to line 12), or there are no v alues less than β b oth in { { floor ( ~ X ) } } and in { { ceilin g ( ~ Y ) } } (du e to line 15). In the second case, s x k giv es us the next largest v alue in { { floor ( ~ X ) } } . In lines 20-23, we tra verse ~ s x starting fr om k , and ~ sy starting from j . The reasoning n o w is v ery similar to that of the tra v ersal for β . In stead of s etting a v alue for β , we set σ to tr ue , and instead of setting γ to f als e , we set σ to f al se , for the same reasons. If k reac hes n b efore j , then we set σ to f al se (line 24) due to the same reason as in line 22. If k and j r eac h n toge ther, then again w e set σ to f al se , b ecause w e ha ve the same n u m b er of o ccur rences of any v alue less than β in { { floor ( ~ X ) } } and in { { ceili ng ( ~ Y ) } } . If, ho wev er, j reac hes n b efore k , then w e set σ to tr ue (line 25) due to th e same reason as in line 21. Finally , we go through eac h of sx i and sy i in lines 26-31, and find ho w many times α and β o ccur in { { fl oor ( ~ X ) } } and in { { cei ling ( ~ Y ) } } , by counting h o w many times α and β o ccur in ~ sx and in ~ s y , resp ective ly . The complexit y of this new algorithm is in d ep endent of the domains and is O ( n l og ( n )), as the cost of sorting domin ates. 6 Extensions In this section, we answer t w o imp ortan t questions. First, ho w can we enforce strict multiset ordering? Second, ho w can w e d etect en tailment? 22 6.1 Strict Multiset Ordering Constrain t W e can easily get a filtering algo rithm for strict m ultiset ordering constrain t by s lightly modifyin g MsetLeq . This new algorithm, called MsetLe ss , either detects the d isen tailmen t of ~ X < m ~ Y , or pru nes in consisten t v alues to p erform GA C on ~ X < m ~ Y . Before s ho w ing ho w we mo d ify MsetLeq , w e fi r st stud y ~ X < m ~ Y fr om a theoretical p oin t of view. It is not difficult to mo dify Theorems 2, 3 an d 4 so as to exclude the equalit y and obtain th e f ollo wing prop ositions: Prop osition 3 ~ X < m ~ Y is disentaile d iff occ ( floor ( ~ X )) ≥ lex occ ( ceiling ( ~ Y )) . Prop osition 4 GAC( ~ X < m ~ Y ) iff for al l i in [0 , n ) : occ ( floor ( ~ X X i ← max ( X i ) )) < lex occ ( ceiling ( ~ Y )) occ ( floor ( ~ X )) < lex occ ( ceiling ( ~ Y Y i ← min ( Y i ) )) W e can exploit the similarit y b et wee n Prop osition 2 and 4, and find the tigh t consistent b ounds b y making u se of the o ccurrence v ectors ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) , th e p ointe rs, and the fl ags. In Th eorems 5 to 11, we hav e ~ ox ≤ lex ~ oy . W e d ecide wh ether a v alue v in some domain D is consistent or not b y first increasing ox v / oy v b y 1, and then d ecreasing min ( D )/ max ( D ) b y 1. The v alue is consisten t for ~ X ≤ m ~ Y iff th e c han ge giv es ~ ox ≤ lex ~ oy . In Theorems 7 and 11, c hanging the o ccurrences giv es ~ ox > lex ~ oy . This means that v is inconsistent not only for ~ X ≤ m ~ Y but also for ~ X < m ~ Y . In Theorems 6, 9, and 10, ho w ev er , w e initially ha ve ~ ox < lex ~ oy and c hanging the o ccurren ces do es not disturb the s trict lexicographic ordering. This suggests v is consisten t also for ~ X < m ~ Y . In Theorems 5 and 8, w e initially hav e ~ ox < lex ~ oy , and after the c hange we obtain either of ~ ox > lex ~ oy , ~ ox = ~ oy , and ~ ox < lex ~ oy . In the first case v is inconsisten t, w h ereas in the third case v is consisten t, for b oth constraints. In the s econd case, ho w ev er, v is consistent for ~ X ≤ m ~ Y but not f or ~ X < m ~ Y . This case arises if w e get ~ ox u → β = ~ oy u → β b y the change to the o ccur rence v ectors, and we ha v e either β > l and ~ ox β − 1 → l = ~ oy β − 1 → l , or β = l . W e therefore need to record whether there are an y subv ectors b elow β , and if th is is the case w e need to kno w whether they are equal. This can easily b e done by extendin g the definition of σ whic h already tells us whether w e ha v e β > l and ~ ox β − 1 → l > lex ~ oy β − 1 → l . Definition 9 Given ~ ox = occ ( floor ( ~ X )) and ~ oy = occ ( ceiling ( ~ Y )) indexe d as u..l wher e ~ ox < lex ~ oy , the flag σ is tr ue iff: ( β > l ∧ ~ ox β − 1 → l ≥ lex ~ oy β − 1 → l ) ∨ β = l Theorems 5 and 8 no w declare a v alue inconsistent if w e get ~ ox u → β = ~ oy u → β when the o ccurr ence v ectors c h ange, and we h av e either β > l and ~ ox β − 1 → l = ~ oy β − 1 → l , or β = l . Ho w do we no w mo dify M setLeq to obtain the filtering algorithm MsetLe ss ? Theorems 6, 7, 9, 10, and 11 are v alid also for ~ X < m ~ Y . Moreo ver, Th eorems 5 and 8 can easily b e adapted for ~ X < m ~ Y by changing the d efinition of σ . Hence, the pr uning part of the algorithm need not to b e m o dified, pro vided that σ is set correctly . Also, by Prop osition 3, w e need to fail u nder the new disen tailmen t condition. T hese suggest w e only need to revise SetP ointersAn dFlags , so that w e fail when ev er w e ha v e ~ ox ≥ lex ~ oy , and set σ to tr ue also when we ha v e β = l , or β > l and ~ ox β − 1 → l = ~ ox β − 1 → l . This corrects a mistak e in [FHK + 03] whic h claims that failing whenev er we ha v e ~ ox ≥ lex ~ oy and setting β to l − 1 as opp osed to −∞ are enough to ac hiev e strict m ultiset ordering. 6.2 En tailmen t MsetLeq is a correct and complete filtering algorithm. Ho w ev er, it do es not detect en tailment . Ev en though detecti ng en tailment do es not c hange the seman tics of the algo rithm, it can lead to 23 Algorithm 6: I nitialis e Data : h X 0 , X 1 , . . . , X n − 1 i , h Y 0 , Y 1 , . . . , Y n − 1 i Result : occ ( floor ( ~ X )), occ ( ceiling ( ~ Y )), occ ( ceiling ( ~ X )), occ ( floor ( ~ Y )), and entailed are ini- tialised, GAC( ~ X ≤ m ~ Y ) 0 entail ed := f alse ; . . . 5 ~ ex := occ ( ceil ing ( ~ X ) ); 6 ~ ey := occ ( floor ( ~ Y )); 7 MsetLeq ; significan t sa vings from an op erational p oin t of view. W e thus in tro duce another Bo olean fl ag, called entail ed , whic h in dicates w hether ~ X ≤ m ~ Y is enta iled. More form ally: Definition 10 Give n ~ X and ~ Y , the flag en tailed is set to tr ue iff ~ X ≤ m ~ Y is tr ue . The multiset orderin g constraint is en tailed whenev er the largest v alue that ~ X can tak e is less than or equal to the smallest v alue that ~ Y ca n take un der the ordering in concern. Theorem 18 ~ X ≤ m ~ Y is entaile d iff { { cei ling ( ~ X ) } } ≤ m { { floo r ( ~ Y ) } } . Pro of: ( ⇒ ) Since ~ X ≤ m ~ Y is en tailed, any com bination of assignments, in cluding ~ X ← ceiling ( ~ X ) and ~ Y ← floor ( ~ Y ), satisfies ~ X ≤ m ~ Y . Hence, { { ceiling ( ~ X ) } } ≤ m { { floor ( ~ Y ) } } . ( ⇐ ) An y ~ x ∈ ~ X is less than or equal to an y ~ y ∈ ~ Y und er m u ltiset ordering. Hence, ~ X ≤ m ~ Y is entail ed. QED. By Th eorems 4 and 18, w e can detect enta ilmen t by lexicographicall y comparing the o ccur- rence v ectors asso ciated with ceiling ( ~ X ) and f loor ( ~ Y ). Prop osition 5 ~ X ≤ m ~ Y is entaile d iff occ ( ceiling ( ~ X )) ≤ lex occ ( floor ( ~ Y )) . When MsetL eq is executed, w e ha ve three p ossible s cenarios in terms of entai lmen t: (1) ~ X ≤ m ~ Y has already b een en tailed in the past due to the pr evious m o difications to the v ariables; (2) ~ X ≤ m ~ Y w as not ent ailed b efore, bu t after the recen t mo difications w hic h inv ok ed the algorithm, ~ X ≤ m ~ Y is now entai led; (3) ~ X ≤ m ~ Y has n ot b een enta iled, bu t after the pru n ings of the algo rithm, ~ X ≤ m ~ Y is no w en tailed. In all cases, we can safely return fr om the algorithm. W e need to, h o wev er, record entailme nt in our flag entail ed in the second and the third cases, b efore returning. T o deal with en tailmen t, we n eed to mo d ify b oth Init ialise and Ms etLeq . In Algorithm 6, we show ho w w e revise Algorithm 1 . W e add line 0 to initialise the fl ag entail ed to f als e . W e r eplace line 5 of Algorithm 1 w ith lines 5-7. Before calling MsetL eq , we no w initialise our new o ccurrence v ectors occ ( ceiling ( ~ X )) and occ ( floo r ( ~ Y )) in a similar wa y to that of occ ( floor ( ~ X )) and occ ( ceiling ( ~ Y )) : we create a p air of vec tors ~ ex and ~ ey of length u − l + 1 where eac h ex i and ey i are first set to 0. Then, f or eac h v alue v in { { cei ling ( ~ X ) } } , w e increment ex v b y 1. Similarly , for eac h v in { { floor ( ~ Y ) } } , we in cr ement ey v b y 1. These vec tors are then used in Ms etLeq to detect en tailmen t. It is p ossible to maintain ~ ex and ~ ey increment ally . When the maxim um v alue in some D ( X i ) changes, w e up d ate ~ ex by incremen ting the entry corresp ondin g to new max ( X i ) by 1, and decrementing the en try corresp ond ing to old max ( X i ) b y 1. Likewise, when the m inim um v alue in some D ( Y i ) c hanges, w e up d ate ~ ey by incrementing the en try corresp ond in g to new min ( Y i ) by 1, and d ecremen ting the entry corresp onding to old min ( Y i ) b y 1. In Algorithm 7, w e sho w h o w w e mo dify the filtering algorithm giv en in Algorithm 2 to deal with the three p ossible scenarios describ ed ab o v e. W e add line A0 where w e return if the constrain t has already b een enta iled in the past. Moreo ver, just b efore setting our p ointe rs and flags, we c heck w h ether the recen t mo difications that triggered th e algorithm resulted in 24 Algorithm 7: M setLeq Data : h X 0 , X 1 , . . . , X n − 1 i , h Y 0 , Y 1 , . . . , Y n − 1 i Result : GAC( ~ X ≤ m ~ Y ) A0 if entailed then return; ⇒ if ~ ex ≤ lex ~ ey then entail e d := tr ue , return; A1 SetPointersAndFl ags ; B1 foreach i ∈ [0 , n ) do B2 if min ( X i ) 6 = max ( X i ) then B3 if min ( X i ) ≥ α then ⇒ ex max ( X i ) := ex max ( X i ) − 1, setMax( X i , min ( X i ) ) ; ⇒ ex max ( X i ) := ex max ( X i ) + 1; end B4 if max ( X i ) ≥ α ∧ min ( X i ) < α then B5 ⇒ ex max ( X i ) := ex max ( X i ) − 1, setMax( X i , α ) ; . . . ⇒ ex max ( X i ) := ex max ( X i ) + 1; end end end ⇒ if ~ ex ≤ lex ~ ey then entail e d := tr ue , return; C1 foreach i ∈ [0 , n ) do C2 if min ( Y i ) 6 = max ( Y i ) then C3 if max ( Y i ) > α then ⇒ ey min ( Y i ) := ey min ( Y i ) − 1, setMin( Y i , ma x ( Y i ) ) , ey min ( Y i ) := ey min ( Y i ) + 1; end C4 if max ( Y i ) = α ∧ min ( Y i ) ≤ β then C5 if ox α + 1 = oy α ∧ γ then C6 ⇒ ey min ( Y i ) := ey min ( Y i ) − 1, setMin( Y i , β ) ; . . . ⇒ ey min ( Y i ) := ey min ( Y i ) + 1 end end end end ⇒ if ~ ex ≤ lex ~ ey then entail e d := tr ue , return; en tailmen t. If this is the case, w e fir st set entail ed to tr ue an d then return f r om the algorithm. F urthermore, w e c hec k en tailmen t after the algorithm go es through its v ariables. Lines B1-B11 visit the v ariables of ~ X and pru n e in consistent v alues from the u pp er b ounds, affecting ~ ex . Ev en if we h a ve ~ ex > lex ~ ey w hen the algorithm is called, we might get ~ ex ≤ lex ~ ey j ust b efore the algorithm pro ceeds to th e v ariables of ~ Y . In suc h case, we return f r om the algorithm after setting entail ed to tr ue . As an example, assume we hav e ~ X ≤ m ~ Y , and M setLeq is called with ~ X = h{ 1 , 2 } , { 1 , 2 , 4 }i and ~ Y = h{ 2 , 3 } , { 2 , 3 }i . As 4 in D ( X 1 ) lac k s sup p ort, it is p runed. No w w e ha ve ~ ex = ~ ey . Alternative ly , the constrain t might b e en tailed after the algorithm visits the v ariables of ~ Y and p runes inconsisten t v alues fr om the lo we r b ound s, affecting ~ ey . In this case, w e return from the algorithm b y s etting entail ed to tr ue . As an example, assume we also ha v e 0 in D ( Y 1 ) in the previous example. The constraint is en tailed only after th e v ariables of ~ Y are visited and 0 is r emo ved. Finally , b efore/after the algorithm mo d ifies max ( X i ) or min ( Y i ) of some i in [0 , n ), we k eep our o ccur rence v ectors ~ ex and ~ ey up-to-date b y decrementi ng/incremen ting the n ecessary en tries. 25 7 Alternativ e Approac hes There are several alternativ e w a ys k n o w n f or p osting and propagating m u ltiset ordering con- strain ts. W e can, for instance, p ost arithmetic inequalit y constraint s, or d ecomp ose m ultiset ordering constrain ts into other constrain ts. In this section, w e explore these app roac hes and ar- gue wh y it is preferable to propagate multiset ordering constraints using our filtering algorithms. 7.1 Arithmetic Constrain t W e can ac hieve m ultiset ordering b et w een tw o ve ctors by assigning a we igh t to eac h v alue, summing the weig hts along eac h v ector, and then insisting the sums to b e non-decreasing. Sin ce the ord ering is determined according to the maximum v alue in the v ectors, the w eigh t sh ould increase with the v alue. A suitable weig ht ing sc heme w as prop osed in [KS02], where eac h v alue v gets assigned the w eigh t n v , wh ere n is the length of th e v ectors. ~ X ≤ m ~ Y on vec tors of length n can then b e enforced v ia the follo w ing arithmetic in equalit y constraint: n X 0 + . . . + n X n − 1 ≤ n Y 0 + . . . + n Y n − 1 Therefore, a vec tor con taining one elemen t with v alue v and n − 1 0s is greater than a v ector whose n elemen ts are only v − 1. Th is is in fact similar to the transformation of a leximin fuzzy CSP into an equiv alen t MAX CSP [SFV95 ]. Strict m ultiset ordering constraint ~ X < m ~ Y is enforced by disallo wing equ ality: n X 0 + . . . + n X n − 1 < n Y 0 + . . . + n Y n − 1 BC on suc h arithmetic constr aints do es the same pru ning as GAC on the original m ultiset ordering constraints. Ho wev er, s uc h arithm etic constrain ts are f easible only for small n and u , where u is the maxim um v alue in the domains of the v ariables. As n and u get large, n X i or n Y i will b e a very large n umb er and therefore it might b e imp ossible to im p lemen t the multise t ordering constrain t. Consequently , it can b e pr eferab le to p ost and propagate the multi set ordering constrain ts using ou r global constr aints. Theorem 19 GAC( ~ X ≤ m ~ Y ) and GAC( ~ X < m ~ Y ) ar e e quivalent to BC on the c orr esp onding arithmetic c onstr aints. Pro of: W e just consider GA C ( ~ X ≤ m ~ Y ) as the p ro of for GA C( ~ X < m ~ Y ) is en tirely analogous. As ~ X ≤ m ~ Y and the corresp ond ing arithmetic constrain t are logica lly equiv alen t, BC( ~ X ≤ m ~ Y ) and BC on the arithmetic constrain t are equiv alen t. By Theorem 1, BC( ~ X ≤ m ~ Y ) is equiv alen t to GAC( ~ X ≤ m ~ Y ). QED. 7.2 Decomp osition Global ordering constraints can often b e b uilt out of the logica l connectiv es ( ∧ , ∨ , → , ↔ , and ¬ ) and existing (global) constraints. W e can thus comp ose other constraint s b et ween ~ X and ~ Y so as to ob tain the multiset ord er in g constrain t b et w een ~ X and ~ Y . W e r efer to suc h a logica l constrain t as a d ecomp osition of the multiset ordering constrain t. The m ultiset view of t w o ve ctors of int egers ~ x and ~ y are m u ltiset ordered { { ~ x } } ≤ m { { ~ y } } iff occ ( ~ x ) ≤ lex occ ( ~ y ) by Theorem 4. On e wa y of decomp osing the multiset ordering constrain t ~ X ≤ m ~ Y is th u s insisting that the o ccur rence v ectors asso ciated with the v ectors assigned to ~ X and ~ Y are lexicographicall y ordered. Suc h o ccurr en ce v ectors can b e constructed via an extended global cardinalit y constraint ( g cc ). Giv en a vec tor of v ariables ~ X and a ve ctor of v alues ~ d , th e constrain t g cc ( ~ X , ~ d, ~ O X ) en s ures that O X i is the n umber of v ariables in ~ X assigned to d i . T o ensure multiset ordering, we can enforce lexicographic ord ering constraint on a pair of o ccurren ce 26 v ectors constru cted via g cc where ~ d is the vect or of v alues that the v ariables can b e assigned to, arranged in d escending ord er, without an y rep etition: g cc ( ~ X , ~ d, ~ O X ) ∧ g cc ( ~ Y , ~ d, ~ O Y ) ∧ ~ O X ≤ lex ~ O Y In order to d ecomp ose the strict m u ltiset ordering constrain t ~ X < m ~ Y , we need to enforce s tr ict lexicographic ordering constrain t on the o ccurrence v ectors: g cc ( ~ X , ~ d, ~ O X ) ∧ g cc ( ~ Y , ~ d, ~ O Y ) ∧ ~ O X < lex ~ O Y W e call this wa y of decomp osing a m u ltiset ord ering constraint as g cc decomp osition. The g cc constraint is a v ailable in, for instance, ILOG Solv er 5.3 [ILO02], SI CStus Pr olog 3.10.1 [SIC04], and the F aCiLe constr aint solv er 1.0 [F aC01]. These solv ers pr op agate th e g cc constrain t usin g the algorithm prop osed in [R ´ eg96]. Among the v arious fi ltering algorithms of g cc , which m ain tain either GA C [R ´ eg96][QvBL + 03] or BC [Q vBL + 03][KT05], only th e algo- rithms in [KT05] p rune v alues from ~ O X and ~ O Y . Ev en thou gh the algorithm in tegrated in ILOG Solv er 5.3 may also prun e the o ccurr en ce v ectors, this may n ot alwa ys b e the case. F or instance, when w e ha v e g cc ( h{ 1 } , { 1 , 2 } , { 1 , 2 } , { 2 } , { 3 , 4 } , { 3 , 4 }i , h 4 , 3 , 2 , 1 i , h{ 1 } , { 1 } , { 1 , 2 } , { 1 , 2 , 3 }i , ILOG Solve r 5.3 lea ves ~ O X unchange d ev en thou gh 1 in D ( O X 3 ) is n ot consisten t. This sho w s that there is curr en tly very limited sup p ort in the constrain t to olkits to propagate the multiset ordering constrain t u sing the g cc decomp osition. Also, as the follo win g theorems demonstrate, the g cc d ecomp osition of a multiset ordering constraint hind ers constraint pr opa- gation. Theorem 20 GAC( ~ X ≤ m ~ Y ) is strictly str onger than GAC(gc c( ~ X , ~ d, ~ O X )), GAC(gc c( ~ Y , ~ d, ~ O Y )), and GAC( ~ O X ≤ lex ~ O Y ), wher e ~ d is the v e ctor of values that the variables c an take, arr ange d in desc ending or der, without any r ep etition. Pro of: Since ~ X ≤ m ~ Y is GA C, eve ry v alue has a sup p ort ~ x and ~ y wh ere occ ( ~ x ) ≤ lex occ ( ~ y ), in whic h case all th e three constrain ts p osted in the decomp osition are satisfied. Hence, ev ery constrain t imp osed is GA C, and GA C( ~ X ≤ m ~ Y ) is as strong as its decomp osition. T o show strictness, consider ~ X = h{ 0 , 3 } , { 2 }i and ~ Y = h{ 2 , 3 } , { 1 }i . T h e m ultiset orderin g constraint ~ X ≤ m ~ Y is not GA C as 3 in D ( X 0 ) has no supp ort. By enforcing GAC( gcc ( ~ X , h 3 , 2 , 1 , 0 i , ~ O X )) and GA C( g cc ( ~ Y , h 3 , 2 , 1 , 0 i , ~ O Y )) w e obtain th e follo wing o ccurrence v ectors: ~ O X = h{ 0 , 1 } , { 1 } , { 0 } , { 0 , 1 }i ~ O Y = h{ 0 , 1 } , { 0 , 1 } , { 1 } , { 0 }i Since we h av e GAC( ~ O X ≤ lex ~ O Y ), ~ X and ~ Y remain u nc hanged. Q ED. Theorem 21 GAC( ~ X < m ~ Y ) is strictly str onger than GAC(gc c( ~ X , ~ d, ~ O X )), GAC(gc c( ~ Y , ~ d, ~ O Y )), and GAC( ~ O X < lex ~ O Y ), wher e ~ d is the v e ctor of values that the variables c an take, arr ange d in desc ending or der, without any r ep etition. Pro of: Th e example in Theorem 20 sho ws the strictness. QED. In Theorem 17, w e ha v e established that occ ( ~ x ) ≤ lex occ ( ~ y ) iff sor t ( ~ x ) ≤ lex sor t ( ~ y ). Putting Theorems 4 and 17 together, the multiset view of tw o v ectors of integ ers ~ x and ~ y are multiset ordered { { ~ x } } ≤ m { { ~ y } } iff sor t ( ~ x ) ≤ lex sor t ( ~ y ). Th is suggests another w a y of decomp osing a m ultiset ordering constraint ~ X ≤ m ~ Y : w e ins ist that the sorted ve rsions of the v ectors assigned to ~ X and ~ Y are lexicographically ordered . F or this p urp ose, w e can use the constr aint s or ted whic h is a v ailable in, for instance, ECLiPSe constraint solv er 5.6 [ECL03], S ICStus Pr olog 3.10.1 [SIC04], and the F aCiLe constrain t solv er 1.0 [F aC01]. Giv en a v ector of v ariables ~ X , sor ted ( ~ X , ~ S X ) ensures that ~ S X is of length n and is a sorted p ermutatio n of ~ X . T o ensu re 27 m ultiset ordering, we can enf orce lexicographic ordering constrain t on a pair of ve ctors wh ic h are constrained to b e the s orted versions of th e original vect ors in d escending order: sor ted ( ~ X , ~ S X ) ∧ s or ted ( ~ Y , ~ S Y ) ∧ ~ S X ≤ lex ~ S Y A strict m ultiset ordering constrain t ~ X < m ~ Y is then ac hiev ed by enforcing strict lexicog raphic ordering constrain t on the sorted vecto rs: sor ted ( ~ X , ~ S X ) ∧ s or ted ( ~ Y , ~ S Y ) ∧ ~ S X < lex ~ S Y W e call this wa y of decomp osing a m u ltiset ord ering constraint as the s or t d ecomp osition. The sor ted constrain t has previously b een s tu died and s ome BC filtering algorithms ha v e b een pr op osed [BC97 ][BC00][MT00]. Unfortun ately , we lose in the amount of constraint prop- agatio n also by the sor t decomp osition of a multiset ordering constrain t. Theorem 22 GAC( ~ X ≤ m ~ Y ) is strictly str onger than GAC(sorte d( ~ X , ~ S X )), GAC(s orte d ( ~ Y , ~ S Y )), and GAC( ~ S X ≤ lex ~ S Y ). Pro of: Sin ce ~ X ≤ m ~ Y is GAC, ev ery v alue h as a su pp ort ~ x and ~ y where sor t ( ~ x ) ≤ lex sor t ( ~ y ), in whic h case all th e three constrain ts p osted in the decomp osition are satisfied. Hence, ev ery constrain t imp osed is GA C, and GA C( ~ X ≤ m ~ Y ) is as strong as its decomp osition. T o show strictness, consider ~ X = h{ 0 , 3 } , { 2 }i and ~ Y = h{ 2 , 3 } , { 1 }i . T h e m ultiset orderin g constraint ~ X ≤ m ~ Y is not GAC as 3 in D ( X 0 ) has no supp ort. By enforcing GAC( sorted ( ~ X , ~ S X )) and GA C( sor ted ( ~ Y , ~ S Y )) we obtain the follo wing v ectors: ~ S X = h{ 2 , 3 } , { 0 , 2 }i ~ S Y = h{ 2 , 3 } , { 1 }i Since we h av e GAC( ~ S X ≤ lex ~ S Y ), ~ X and ~ Y remain u nc hanged. Q ED. Theorem 23 GAC( ~ X < m ~ Y ) is strictly str onger than GAC(sorte d( ~ X , ~ S X )), GAC(s orte d ( ~ Y , ~ S Y )), and GAC( ~ S X < lex ~ S Y ). Pro of: Th e example in Theorem 22 sho ws strictness. QED. Ho w do the t w o decomp ositions compare? Assu ming that GA C is enforced on ev ery n -ary constrain t of a d ecomp osition, the sor t decomp osition is sup er ior to the g cc decomp osition. Theorem 24 The sor t de c omp osition of ~ X ≤ m ~ Y is strictly str onger than the gcc de c omp osition of ~ X ≤ m ~ Y . Pro of: Assume that a v alue is pru ned from ~ X due to the g cc decomp osition. Then, th ere is an index α su c h that ¬ ( O X α . = O Y α ) and for all i > α w e ha ve O X i . = O Y i . Moreo v er, we ha ve min ( O X i ) = max ( O Y i ) and max ( O X i ) > max ( O Y i ). T h e r eason is that, only in this case, GA C( ~ O X ≤ lex ~ O Y ) will not only pr une v alues from O X α but also from ~ X . In an y other case, we will either get no prun in g at O X α , or the p r uning at O X α will reduce the num b er of o ccurrences of α in ~ X without deleting any of α from ~ X . No w consider the v ectors ~ S X and ~ S Y . W e name th e index of ~ S X and ~ S Y , where α first app ears in the domains of ~ S X and ~ S Y , as i . Since the num b er of o ccurren ces of an y v alue greater than α is already determined and is the same in b oth ~ X and ~ Y , the subv ectors of ~ S X and ~ S Y ab o v e i are groun d and equal. F or all i ≤ j < i + min ( OX i ), we ha ve S X j . = S Y j ← α . Since max ( O X i ) > max ( O Y i ), at p osition k = i + min ( O X i ) w e will ha v e α in D ( S X k ) bu t not in D ( S Y k ) whose v alues are less than α . T o ha v e ~ S X ≤ lex ~ S Y , α in D ( S X k ) is eliminated. This pr opagates to th e prun in g of α from the remaining v ariables of ~ S X , as well as f rom domains of the uninstant iated v ariables of ~ X . 28 Hence, an y v alue remov ed from ~ X du e to the g cc decomp osition is remov ed from ~ X also by the sor t decomp osition. Th e pro of can easily b e rev erted for v alues b eing remo v ed from ~ Y . T o show that the sor t decomp osition dominates the g cc decomp osition, consider ~ X = h{ 1 , 2 }i and ~ Y = h{ 0 , 1 , 2 }i where 0 in D ( Y 0 ) is inconsisten t and therefore ~ X ≤ m ~ Y is not GA C. W e ha ve ~ S X = h{ 1 , 2 }i and ~ S Y = h{ 0 , 1 , 2 }i b y GA C( sor ted ( ~ X , ~ S X )) and GA C( sor ted ( ~ Y , ~ S Y )), and ~ O X = h{ 0 , 1 } , { 0 , 1 } , { 0 }i and ~ O Y = h{ 0 , 1 } , { 0 , 1 } , { 0 , 1 }i by GA C( g cc ( ~ X , h 2 , 1 , 0 i , ~ O X )) and GA C( g cc ( ~ Y , h 2 , 1 , 0 i , ~ O Y )). T o ac hieve GA C ( ~ S X ≤ lex ~ S Y ), 0 in D ( S Y 0 ) is p runed . This leads to the prun in g of 0 also from D ( Y 0 ) so as to establish GA C( sor ted ( ~ Y , ~ S Y )). On the other hand, w e h a ve GA C( ~ O X ≤ lex ~ O Y ), in which case no v alue is p runed fr om any v ariable. QED. Theorem 25 The sor t de c omp osition of ~ X < m ~ Y is strictly str onger than the gcc de c omp osition of ~ X < m ~ Y . Pro of: Th e example in Theorem 24 sho ws strictness. QED. Ev en though th e sor t decomp osition of ~ X ≤ m ~ Y is stronger than the g cc decomp osition of ~ X ≤ m ~ Y , GAC on ~ X ≤ m ~ Y can lead to more pru ning than any of the t w o decomp ositions. A similar argument holds also for ~ X < m ~ Y . Hence, it can b e preferable to p ost and p ropagate m ultiset ordering constrain ts via our global constraint s. 8 Multiple V ectors W e often hav e m ultiple m ultiset ord er in g constraints. F or example, we p ost multiset ordering constrain ts on the rows or columns of a matrix of decision v ariables b ecause w e wan t to br eak ro w or column symm etry . W e can treat suc h a problem as a single global orderin g constrain t o ver the whole matrix. Alternativ ely , we can decomp ose it int o multise t orderin g constrain ts b etw een adjacen t or all p airs of ve ctors. In this s ection, we demonstrate that such decomp ositions hin der constrain t propagation. The follo wing theorems h old for n v ectors of m constrained v ariables. Theorem 26 GAC( ~ X i ≤ m ~ X j ) for al l 0 ≤ i < j ≤ n − 1 is strictly str onger than GAC( ~ X i ≤ m ~ X i +1 ) for al l 0 ≤ i < n − 1 . Pro of: GA C( ~ X i ≤ m ~ X j ) for all 0 ≤ i < j ≤ n − 1 is as strong as GA C( ~ X i ≤ m ~ X i +1 ) for all 0 ≤ i < n − 1, b ecause the former implies the latter. T o sho w strictness, consider the follo wing 3 v ectors: ~ X 0 = h{ 0 , 3 } , { 2 }i ~ X 1 = h{ 0 , 1 , 2 , 3 } , { 0 , 1 , 2 , 3 }i ~ X 2 = h{ 2 , 3 } , { 1 }i W e ha v e GA C( ~ X i ≤ m ~ X i +1 ) for all 0 ≤ i < 2. Th e assignmen t X 0 , 0 ← 3 forces ~ X 0 to b e h 3 , 2 i , and we hav e ce iling ( ~ X 2 ) = h 3 , 1 i . Sin ce { { 3 , 2 } } > m { { 3 , 1 } } , GA C( ~ X 0 ≤ m ~ X 2 ) do es not h old. QED. Theorem 27 GAC( ~ X i < m ~ X j ) for al l 0 ≤ i < j ≤ n − 1 is strictly str onger than GAC( ~ X i < m ~ X i +1 ) for al l 0 ≤ i < n − 1 . Pro of: Th e example in Theorem 26 sho ws strictness. QED. Theorem 28 GAC( ∀ ij 0 ≤ i < j ≤ n − 1 . ~ X i ≤ m ~ X j ) is strictly str onger than GA C( ~ X i ≤ m ~ X j ) for al l 0 ≤ i < j ≤ n − 1 . 29 Pro of: GA C ( ∀ ij 0 ≤ i < j ≤ n − 1 . ~ X i ≤ m ~ X j ) is as strong as GA C( ~ X i ≤ m ~ X j ) for all 0 ≤ i < j ≤ n − 1, b ecause the former imp lies the latter. T o sh o w strictness, consider the follo wing 3 v ectors: ~ X 0 = h{ 0 , 3 } , { 1 }i ~ X 1 = h{ 0 , 2 } , { 0 , 1 , 2 , 3 }i ~ X 2 = h{ 0 , 1 } , { 0 , 1 , 2 , 3 }i W e h a ve GA C( ~ X i ≤ m ~ X j ) for all 0 ≤ i < j ≤ 2. T he assignment X 0 , 0 ← 3 is supp orted b y X 0 ← h 3 , 1 i , X 1 ← h 2 , 3 i , and X 2 ← h 1 , 3 i . In this case, ~ X 1 ≤ m ~ X 2 is f al se . T h erefore, GA C( ∀ ij 0 ≤ i < j ≤ 2 . ~ X i ≤ m ~ X j ) do es not hold. QED. Theorem 29 GAC( ∀ ij 0 ≤ i < j ≤ n − 1 . ~ X i < m ~ X j ) is strictly str onger than GA C( ~ X i < m ~ X j ) for al l 0 ≤ i < j ≤ n − 1 . Pro of: GA C ( ∀ ij 0 ≤ i < j ≤ n − 1 . ~ X i < m ~ X j ) is as strong as GA C( ~ X i < m ~ X j ) for all 0 ≤ i < j ≤ n − 1, b ecause the former imp lies the latter. T o sh o w strictness, consider the follo wing 3 v ectors: ~ X 0 = h{ 0 , 3 } , { 1 }i ~ X 1 = h{ 1 , 3 } , { 0 , 1 , 3 }i ~ X 2 = h{ 0 , 2 } , { 0 , 1 , 2 , 3 }i W e h a ve GA C( ~ X i < m ~ X j ) for all 0 ≤ i < j ≤ 2. T he assignment X 0 , 0 ← 3 is supp orted b y X 0 ← h 3 , 1 i , X 1 ← h 3 , 3 i , and X 2 ← h 2 , 3 i . In this case, ~ X 1 < m ~ X 2 is f al se . T h erefore, GA C( ∀ ij 0 ≤ i < j ≤ 2 . ~ X i < m ~ X j ) do es not hold. QED. 9 Exp erimen ts W e imp lemen ted our global constraints ≤ m and < m in C + + using I L OG Solv er 5.3 [ILO 02]. Due th e absence of the sor ted constraint in Solv er 5.3, the m ultiset ordering constrain t is decom- p osed via the g cc decomp osition u sing the IloDistribute constraint. Th is constraint is the g cc constrain t but it d o es not alw ays prune completely the o ccur rence v ectors as describ ed b efore. In the exp eriments, we hav e a matrix of decision v ariables where the ro w s and/or columns are (partially) symmetric. T o br eak th e symmetry , we p ost m ultiset ordering constrain ts on the adjacen t symmetric rows or columns, and address several qu estions in the con text of lo oking for one solution or the optimal solution. First, d o es our filtering algorithm(s) do more inference in practice than its decomp osition? Similarly , is the algorithm more efficien t in p ractice than its decomp osition? Second, is it feasible to p ost the arithmetic constrain t? How do es our algorithm compare to BC on th e arithmetic constrain t? Ev en though studying the effectiv eness of the m ultiset ordering constrain ts in breaking symmetry is out of the scop e of this pap er, w e pro v id e exp erimenta l evidence of their v alue in symmetry breaking. W e r ep ort exp eriment s on three problem domains: the progressiv e part y prob lem, the rac k configuration pr oblem, and the sp ort scheduling problem. The decisions made when mo d elling and solving a problem are tuned by our in itial exp erimen tation. T he r esults are sho wn in tables where a “-” means n o result is obtained in 1 hour (3600 secs). Th e b est result of eac h entry in a table is t yp eset in b old. If p osing an ord ering constrain t on th e r o w s (resp . columns) is d one via a tec hnique called T ech then we write T ech R (resp. T ech C). The ordering constrain ts are enforced j ust b et ween the adj acen t rows and/or columns as we ha v e found it not worth wh ile to p ost them b et w een all pairs. Finally , th e hardw are used for the exp erimen ts is a 1Ghz p en tium I I I pro cessor with 256Mb RAM runn in g Windo ws XP . 30 Matrices: → P eriods → H i,j 0 1 2 ↓ 2 1 0 G ue sts 0 2 1 ↓ 1 0 2 H osts 0 0 1 C i,j,k ր 0 1 0 0 1 0 0 0 0 ↓ 0 0 1 1 1 G ue sts 1 0 0 0 ↓ 0 1 0 → P eriods → Constraints: (1) ∀ j 1 , j 2 , j 1 < j 2 ∈ G ues ts . P i ∈P eriod s ( H i,j 1 = H i,j 2 ) ≤ 1 (2) ∀ j ∈ G ues ts . al l-differ e nt ( h H 0 ,j , H 1 ,j , . . . , H p − 1 ,j i ) (3) ∀ i ∈ P eriods . ∀ k ∈ H os ts . P j ∈G uests g c j ∗ C i,j,k ≤ c k − h c k (4) ∀ i ∈ P eriods . ∀ j ∈ G uests . P k ∈H o sts C i,j,k = 1 (5) ∀ i ∈ P eriods . ∀ j ∈ G uests . ∀ k ∈ H osts . H i,j = k ↔ C i,j,k = 1 Figure 2: The matrix mo del of the p rogressiv e part y problem in [SBHW96]. 9.1 Progressiv e P art y Problem The progressiv e part y problem arises in the cont ext of organising the so cial programme for a ya c h ting rally (prob013 in CS PLib). W e consider a v ariant of the p roblem p rop osed in [SBHW96]. T here is a set H os ts of h ost b oats and a set G ues ts of guest b oats. Eac h host b oat i is charact erised by a tup le h hc i , c i i , wh ere and hc i is its crew size and c i is its capacit y; and eac h guest b oat is d escrib ed by g c i giving its crew size. Th e problem is to assign hosts to guests o ver p time p erio ds suc h that: • a guest crew n ev er visits the same h ost twice; • no t w o guest crews meet more than once; • the spare capacit y of eac h host b oat, after accommodating its o wn crew, is not exceeded. A matrix m o del of this p roblem is give n in [SBHW96]. It has a 2-d matrix H to represent the assignmen t of hosts to guests in time p erio ds (see Figure 2). The matrix H is indexed b y the set P er iods of time p erio d s and G uests , taking v alues from H osts . The first constrain t enforces that t wo guests can meet at most once by in tro ducing a new set of 0/1 v ariables: ∀ i ∈ P eriods . ∀ j 1 , j 2 , j 1 < j 2 ∈ G uests . M i,j 1 ,j 2 = 1 ↔ H i,j 1 = H i,j 2 The sum of these new v ariables are then constrained to b e at most 1. The al l- diffe r ent constrain ts on the ro ws of this matrix ensu re that no guest revisits a host. Additionally , a 3-d 0/1 matrix C of P eriods × G uests × H osts is u sed. A v ariable C i,j,k in th is new matrix is 1 iff the host b oat k is visited b y guest j in p erio d i . Eve n though C replicates the inf ormation held in the 2-d matrix, it allo ws capacit y constraints to b e stated concisely . Th e sum constraints on C ensure that a guest is assigned to exactly one host on a time p erio d. Finally , channelling constrain ts are used to link th e v ariables of H and C . The time p erio d s as well as the guests with equal crew size are indistinguishable. Hence, this mo del of the problem has partial ro w sy m metry b et w een the in d istinguishable guests of H , and column symm etry . In the follo wing we fir st sho w that m ultiset ord ering constraint s are useful in b reaking index sym metry . 31 Problem Model 5 Time Periods 6 Time Pe riod s F ails Choice Time F ails Choice Time p oints (secs.) p oints (secs.) No symmetry breaking 180,73 8 180,860 75.9 - - - < lex RC 2,720 2,842 2.7 - - - ≤ m RC - - - - - - ≤ m R ≥ m C 9,207 9,329 8.0 - - - ≤ m R < lex C 10,853 10,977 8.6 - - - ≤ m R > lex C 2,289 2,405 2.6 - - - < lex R ≤ m C 2,016 2, 137 2. 0 - - - < lex R ≥ m C - - - - - - T able 1: Progressiv e part y problem with ro w-wise lab elling of H . Problem Model 5 Time Periods 6 Time Pe riod s F ails Choice Time F ails Choice Time p oints (secs.) points (secs.) No symmetry breaking 20,546 20,676 9.0 20,722 20,871 12.3 < lex RC 20,546 20,676 9.0 20,722 20,871 12.4 ≤ m RC - - - - - - ≤ m R ≥ m C - - - - - - ≤ m R < lex C - - - - - - ≤ m R > lex C - - - - - - < lex R ≤ m C 7,038 7,168 3.4 7,053 7,202 4.6 < lex R ≥ m C - - - - - - T able 2: Progressiv e party problem with column-wise lab elling of H . T o break the ro w and column s ymmetries, we can utilise b oth lexicog raphic ordering and m ultiset ordering constraints, as well as combine lexicographic ordering constraints in one di- mension of the m atrix with multi set ordering constrain ts in the other. Due to the pr oblem constrain ts, no pair of rows/c olumns can ha ve equal assignmen ts, b ut they can b e equal when view ed as multisets. T his gives us the mo d els < lex R C , ≤ m R C , ≤ m R ≥ m C, ≤ m R < lex C, ≤ m R > lex C, < lex R ≤ m C, and < lex R ≥ m C. As the matrix H has partial row symm etry , the ordering constrain ts on the rows are p osted on only the symmetric rows. The ordering constrain ts on the columns are, ho wev er, p osted on all the columns . In our exp erimen ts, we compare the mo dels describ ed ab ov e in con trast to the initial mo del of the prob lem in whic h no symmetry breaking ordering constrain ts are imp osed. W e consider the original instance of the progressiv e part y pr oblem describ ed in [SBHW96], with 5 and 6 time p erio ds . As in [SBHW96], we giv e pr iorit y to the largest crews, so the guest b oats are ordered in descending order of their size. Also, w hen assigning a host to a guest, we try a v alue first whic h is most lik ely to succeed. W e therefore order the host b oats in descending order of th eir spare capacit y . W e adopt tw o static v ariable orderings, and instan tiate H either along its ro w s from top to b ottom, or along its columns from left to right . The results of the exp erimen ts are shown in T ables 1 and 2 . With ro w -w ise lab elling of H , we cannot solv e the problem with 6 time p erio ds w ith or without the symmetry breaking ordering constraints. As for the other instance, w hilst man y of the mo d els we ha v e considered giv e significantly smaller searc h trees and shorter run-times, ≤ m R C and < lex R ≥ m C cannot return an answer within an hour time limit. The smallest searc h tree and also the shortest solving time is obtained by < lex R ≤ m C, in which case th e reduction in the searc h effort is notew orthy compared to the mo del in which no ordering constrains are imp osed. This supp orts our conjecture that lexicographic ordering constrain ts in one d imension of a m atrix com bined 32 Instance Host Boats T otal Host T otal Guest %Capacit y # Spare Capacity Size 1 2 -12, 14, 16 102 92 .90 2 3 -14, 16 100 90 .90 3 3 -12, 14, 15, 16 1 01 91 .90 4 3 -12, 14, 16, 25 1 01 92 .91 5 3 -12, 14, 16, 23 99 90 .91 6 3 -12, 15, 16, 25 1 00 91 .91 7 1 , 3-12, 14, 16 100 92 .92 8 3 -12, 16, 25, 26 1 00 92 .92 9 3 -12, 14, 16, 30 98 90 .92 T able 3: Instance s p ecification for the p rogressiv e part y problem. MsetLeq R Arithmetic g cc R Instance Constrain t R # F ails Choice Time Time F ails Choice Time p oints (secs.) (secs.) points (secs.) 1 10,839 10,963 8.3 16 20,367 20,491 11.6 2 56,209 56,327 46.8 123.7 57,949 58,067 48.6 3 27,461 27,575 17.1 39.1 42,741 42,855 20.5 4 420,774 420,888 280.5 621.7 586, 902 587,016 298.1 5 - - - - - - - 6 5,052 5,170 3.8 7.3 8,002 8,123 4.3 7 86,432 86,547 65.5 135.2 128,08 0 128,195 75.7 8 - - - - - - - 9 - - - - - - - T able 4: Progressive part y prob lem: M setLeq vs g cc decomp osition and the arithmetic constraint with ro w -w ise lab elling. with m ultiset ord ering constrain ts in the other can break more sy m metry than lexicographic ordering or multiset ord ering constrain ts on b oth d imensions. Next, we sho w that our filtering algorithm is the b est w a y to pr opagate multiset ordering constrain ts. T o simplify the pr esen tation, we address only the r o w symmetry . Given a set of indistinguishable guests { g i , g i +1 , . . . , g j } , w e insist that the r o w s corresp onding to s u c h guests are m ultiset ordered: ~ R i ≤ m ~ R i +1 . . . ≤ m ~ R j . W e imp ose suc h constraints b y either using our filtering algorithm MsetLeq , or th e g cc decomp osition, or the arithmetic constrain t. W e no w consider seve ral instances of the pr oblem using the problem data giv en in CS PLib. W e randomly select the host b oats in suc h a wa y that the total spare capacit y of the host b oats is sufficien t to accommo d ate all th e guests. T able 3 sh o ws the data. T he last column of T able 3 giv es the p ercenta ge of the total capacit y used, wh ich is a measure of constrainedness [W al99 ]. W e instant iate H ro w -wise follo wing the same proto col describ ed previously . The results of the exp eriments are shown in T able 4. Not e that all the pr oblem in stances are solve d for 5 time p erio ds. Th e results sho w that MsetLe q main tains a significant adv anta ge o ver the g cc decomp osition and the arithmetic constrain t. Th e solutions to the instances, whic h can b e solve d within an hour limit, are foun d quic ker and compared to th e g cc decomp osition with m u c h less failures. Note that MsetLeq and the arithmetic constraint metho ds create the same searc h tree. 9.2 Rac k Configuration Pr oblem The rac k configuration problem consists of plugging a set of electronic cards into rac ks with electronic conn ectors (prob031 in CSPLib). E ac h card is a certain card t yp e. A card t yp e i in the set C ty pes is c haracterised by a tu ple h cp i , d i i , where cp i is the p o wer it requires, and d i is 33 Matrices: − → R acks − → R i 0 0 1 2 2 → C typ es → C i,j 0 0 0 0 ↓ 0 0 0 0 R ack s 0 1 2 0 ↓ 0 3 0 1 10 0 0 0 Constraints: (1) ∀ j ∈ R ack s . P i ∈C ty pes C i,j ≤ c R j (2) ∀ j ∈ R ack s . P i ∈C ty pes C i,j ∗ cp i ≤ r p R j (3) ∀ i ∈ C ty pes . P j ∈R ack s C i,j = d i Ob jective: minimiz e P i ∈R ack s s R i Figure 3: The matrix mo del of the r ac k configur ation problem in [IL O02]. the demand, whic h designates ho w man y cards of that t yp e ha v e to b e plugged. In ord er to plug a card into a rac k, th e rac k needs to b e assigned a rac k mo d el. Eac h rac k mo del i in the set R ack M odels is c haracterised b y a tuple h r p i , c i , s i i , where r p i is the maximal p o wer it can supp ly , c i is its n u m b er of connectors, and s i is its pr ice. Eac h card plugged in to a rac k u ses a connector. The problem is to d ecide ho w man y among the set R ack s of av ailable racks are needed, and whic h mo del the rac ks are in order to p lug all th e cards such that: • the n umber of card s plugged in to a rac k d o es n ot exceed its num b er of connectors; • the total p o we r of the cards plugged in to a rac k d o es not exceed its p o w er; • all the cards are p lugged into s ome r ac k; • the total price of th e rac ks is min imised. A matrix mo del of this p roblem is giv en in [ILO02] and shown in Figure 3. The idea is to assign a rac k mo del to ev ery a v ailable r ack. Since s ome of the rac ks migh t not b e needed in an optimal solution, a “dummy” rack mo del is in tro duced (i.e., a r ac k is assigned the d ummy rac k mo del when the rack is not needed). F u rthermore, for every a v ailable r ac k, the n umber of cards of a particular card t yp e plugged into the rack h as to b e determined. The assignment of rac k mo d els to rac ks is represent ed b y a 1-d matrix R , in d exed by R ack s , taking v alues from R ack M odel s which includ es the dum m y rac k mo del. In order to represent the n umber of cards of a particular card type plugged in to a p articular rack, a 2-d matrix C of C ty pes × R ack s is in tro duced. A v ariable in this matrix take s v alues from { 0 , . . . , m axC onn } w here maxC onn is the maxim um n umber of card s that can b e plugged into any rac k. The d u mmy r ac k mo del is defined as a rac k mod el where the maximal p o wer it can supply , its n umber of connectors, and its price are all set to 0. The constrain ts enf orce that the connector and the p o we r capacit y of eac h rac k is not exceeded and every card t yp e meets its demand. The ob jectiv e is then to minimise th e total cost of the r ac ks. The 2-d matrix C h as partial ro w sym m etry , b ecause rac ks of the same rac k mo del are indis- tinguishable and therefore their card assignments can b e in terc h anged. T o break this symmetry , w e p ost multiset ordering constraints on the ro ws conditionally . Giv en tw o rac ks i and j , we 34 Rack Mo del Po wer Connectors Price 1 150 8 15 0 2 200 16 200 Card T yp e P o wer 1 20 2 40 3 50 4 75 T able 5: Rac k mo del and card t yp e sp ecificatio ns in the rac k configur ation problem [ILO02]. Instance Demand # T yp e 1 Type 2 T y p e 3 T yp e 4 1 10 4 2 2 2 10 4 2 4 3 10 6 2 2 4 10 4 4 2 5 10 6 4 2 6 10 4 2 4 T able 6: Demand sp ecificatio n for the cards in the rac k configuration problem. Inst. M setLeq R Arithmetic Constraint R # F ails Choice Time Time p oints (secs.) (secs.) 1 3,052 3,063 0.2 2.8 2 15, 650 15,657 0.6 15. 6 3 3,990 3,999 0.2 2.6 4 8,864 8,872 0.4 7.1 5 40, 851 40,858 1.5 41. 3 6 42, 013 42,026 1.6 35. 2 T able 7: Rac k configuration problem: Mset Leq vs the arithmetic constrain t. enforce that the rows corresp ond in g to suc h r ac ks are m u ltiset ord ered if th e rac k s are assigned the same r ack m o del. T hat is: R i = R j → h C 0 ,i , . . . , C n − 1 ,i i ≤ m h C 0 ,j , . . . , C n − 1 ,j i where n is the n umber of card t yp es. W e imp ose su c h constrain ts b y either using our filtering algorithm MsetL eq or the arithmetic constraint . Unfortunately , w e are unable to compare MsetLeq against th e g cc decomp osition in this problem, as Solver 5.3 do es not allo w us to p ost IloDistribute constrain t conditionally . W e consider several instances of the rac k configuration pr oblem, which are describ ed in T ables 5 and 6. In the exp eriments, w e use the rac k mo del and card type sp ecifications giv en in [ILO02], bu t w e v ary the d emand of the card t yp es r andomly . As in [ILO02], we search f or the optimal solution by exploring the rac ks in turn. F or eac h rack, we fir st in stan tiate its mo del and then determine h o w man y card s fr om eac h card type are plugged into the rac k. The results of th e exp eriments are sho w n in T able 7. Mset Leq is clearly muc h more efficien t than th e arithmetic constraint on eve ry instance considered. Note that the tw o metho ds create the same search tree. 35 n Model F ails Choice p oints Time (sec.) 5 M setLess C 1 10 0. 8 Arithmetic Constrain t C 1 10 0.9 g cc C 2 1 1 1.2 7 M setLess C 69 87 0.8 Arithmetic Constrain t C 69 87 1.3 g cc C 74 92 1.3 9 M setLess C 760,973 761,003 121.3 Arithmetic Constrain t C 760,973 761,003 2500 g cc C 2,616,1 48 2,616,176 656.4 T able 8: Sp ort s cheduling problem: MsetLess v s g cc decomp osition and the arithmetic con- strain t with column-wise lab elling. F or one column, w e first lab el the first s lots; for the other, w e first lab el the second s lots. 9.3 Sp ort Sc heduling Problem This problem w as in tro duced in S ection 2. Figure 1 sho ws a matrix mo del. The (extended) w eeks o v er w hic h the tournament is h eld, as well the p erio d s of a w eek are ind istinguishable. The rows and the columns of T and G are therefore symmetric. Note th at we treat T as a 2-d matrix wh ere the ro w s represent th e p erio ds and columns represent the (extended) wee ks, and eac h en try of th e matrix is a p air of v alues. The global cardinalit y constraints p osted on the ro w s of T ensure th at eac h of 1 . . . n o ccur exactly t w ice in ev ery r o w. In any solution to the problem, th e ro w s w h en view ed as multise ts are therefore equal. The al l-differ ent constraints p osted on the column s state that eac h column is a p erm utation of 1 . . . n . Thus, the columns are also equal when view ed as multisets. Th erefore, w e cannot utilise multiset ord er in g constraints to b reak r o w and/or column symm etry of this mo d el of the problem. Sc heduling a tournament b etw een n teams means arranging n ( n − 1) / 2 games. The mo del describ ed in Figure 1 assumes n is an ev en num b er. If n is an o dd num b er instead, th en we can still schedule n ( n − 1) / 2 games provided that the games are p la yed o v er n w eeks and eac h w eek is divided into ( n − 1) / 2 p erio ds. The problem now requir es that eac h team plays at m ost once a wee k, and ev ery team p la ys exactly t wice in the same p erio d ov er the tournament. This v er s ion of the problem can b e mo delled using the original mo d el in Figure 1, as the al l-differ ent constrain ts on the ro w s and the cardinalit y constrain ts on the columns en f orce th e new problem constrain ts. W e can now p ost m ultiset ord er in g constr aints on the columns of T to break column sym - metry . S in ce the games are all d ifferen t, n o pair of column s can b e equ al, wh en viewe d as m ultisets. Hence, w e insist that the columns corresp onding to the n w eeks are strict m u ltiset ordered: ~ C 0 < m ~ C 1 . . . < m ~ C n − 1 . W e enforce su c h constrain ts by either using our fi ltering algorithm M setLess , or the g cc decomp osition, or the arithm etic constraint . Since the m ultiset ordering constrain ts are p osted on the columns, we instantiat e T column-b y-column. F or one column, w e firs t lab el the first slots; for the other, w e fi rst lab el the second slots. The results are sho wn in T able 8. W e obser ve that Mset Less is sup erior to the g cc decomp osition. As the problem gets more difficult, M setLess do es m ore p runin g and s olv es th e p roblem q u ic ker. The resu lts moreo ve r indicate a su bstan tial gain in efficiency by u sing MsetLe ss in p reference to the arithmetic con- strain t. Eve n though the same searc h tree is created b y the t wo, constr u cting and p ropagating the arithm etic constraints is m uch more costly than ru nning Mset Less to solve the m ultiset ordering constrain ts. 36 10 Conclusions W e h a ve dev elop ed filtering algorithms for the m ultiset ordering (global) constraint ~ X ≤ m ~ Y defined on a pair of vec tors of v ariables. It ensures that the v alues tak en by the v ectors ~ X and ~ Y , when view ed as m ultisets, are ordered . This global constraint is u s eful for breaking row and column symmetries of a matrix mo del and w hen searc hing for leximin solutions in fuzzy constrain ts. The filtering algorithms either prov e that ~ X ≤ m ~ Y is disentaile d, or ensure GAC on ~ X ≤ m ~ Y . The first algorithm MsetLeq is u seful when d ≪ n and run s in O ( n ) wh ere n is the length of the ve ctors and d is the num b er of distinct v alues. Th is is often the case as the n umber of distinct v alues in a multiset is t ypically less than its cardinalit y to p ermit rep etition. W e further prop osed another v arian t of the algorithm suitable wh en d ≫ n . This identi fies supp ort by lexicographicall y ord er in g suitable sorted v ectors. The complexit y is then ind ep endent of the n umber of distinct v alues an d is O ( n log ( n )), as the cost of sorting dominates. W e also ha v e sho wn that Mse tLeq can easily b e mo dified for ~ X < m ~ Y b y changing the defin ition of one of the flags. Moreo v er, the ease of main taining the o ccurrence ve ctors incremen tally helps detect en tailmen t in a s imple and d ual mann er to d etecting d isen tailmen t. Our exp erimen ts on the the progressive part y problem, the rac k configur ation problem, and and the sp ort s c h ed uling p roblem sup p ort the u sefulness of m u ltiset ordering constrain ts in the con text of s y m metry breaking and supp ort our theoretical stud ies: ev en if it is feasible to p ost the arithmetic constraint, it is m u c h more efficien t to pr opagate the m ultiset ord ering constrain t using our fi ltering algorithm; fur thermore, decomp osing the multiset constrain t carries p enalt y either in the amount or th e cost of constrain t p r opagation. In our fu ture w ork, we p lan to inv estigate wh ether the in cr emental cost for propagation can b e made less than linear time. Moreo v er, w e p lan to u nderstand wh ether it is w orthwhile to a propate a c hain of multiset ord ering constrain ts and if that is th e case devise an efficient fi ltering algorithm. Ac kno wledgemen ts The authors would lik e to thank the anonymous review ers for their useful commen ts on the present ation and C hris Jefferson for fruitful discus s ions on the work describ ed in the article. B. Hnic h is sup p orted by Scien tifi c an d T ec hnological Researc h C ouncil of T ur k ey (TUBIT AK) under Grant No: SOBAG- 108K027. I. Miguel is supp orted by a UK Ro yal Academ y of E ngi- neering/EPSR C Researc h F ello wsh ip. References [Apt03] K. R. Ap t. Principles of Constr aint Pr o gr amming . C ambridge Unive rsit y Press, 2003. [BC97] N. Bleuzen-Guernalec and A. Colmerauer. Narrowing a blo ck of sortings in quadratic time. In G. S molk a, editor, Pr o c e e dings of the 3r d International Confer- enc e on Principles and P r actic e of Constr aint Pr o gr amming (CP-97) , v olume 1330 of L e ctur e Notes in Computer Scienc e , pages 2–16. Sp ringer, 1997. [BC00] N. Bleuzen-Guernalec and A. Colmerauer. Optimal narro w ing of a b lo c k of sortings in op timal time. Constr aints , 5(1-2):85 –118, 2000. [BCR05] N. Beldicean u, M. Carlsson, and J-X. Ramp on. Global constrain ts catalog. T ec hni- cal Rep ort T 2005/08, Swedish Institute of Computer S cience (SI CS), 2005. Av ail- able at h ttp://ww w.emn.fr/ x- info/sdemasse/gccat/ . 37 [BL07] S . Bouv eret and M. Lema ˆ ıtre. New constraint programming approac hes for the computation of leximin-optimal solutions in constraint net w orks. In P r o c e e dings of the 20th International Joint Confer enc e on Art ificial Intel ligenc e (IJCAI- 07) , pages 62–67 , 2007. [CLGR96] J. C ra w ford, G. Lu ks, M. Ginsb erg, and A. Ro y . Symmetry breaking pr edicates for searc h problems. In Pr o c e e dings of the 5th International Confer enc e on Know le dge R epr esentation and R e asoning, (KR ’96) , pages 148–1 59, 1996. [DB97] R. Debruyne and C. Bessi ` ere. Some practicable fi ltering tec hniques for the con- strain t satisfaction pr oblem. In M. E . P ollac k, editor, P r o c e e dings of the 15th In- ternational Joint Confer enc e on Artificial Intel lige nc e (IJCA I- 97) , p ages 412–417 . Morgan K aufmann, 1997. [ECL03] P . Brisset and H. El Sakko ut and T . F r ¨ uh wir th and C. Gerv et and W. Harvey and M. Meier and S. No v ello and T. L e Pr o vost and J. Schimpf and K. Shen and M. G. W allace. ECLiP Se Constr aint Libr ary Manual R ele ase 5.6 , 2003. Av ailable at http://w ww.icpar c.ic.ac.uk/e clipse/doc/doc/libman/libman.html . [F aC01] N. Barnier and P . Brisset. F aCiL e: A F u nctional Constr aint Libr ary R ele ase 1.0 , 2001. Av ailable at http://w ww.reche rche.enac.fr/opti/facile/doc/ . [F ar94] H. F argier. Pr obl` emes de satisfaction de c onstr aintes flexibles: applic ation ` a l’or donna nc ement de pr o duction . Ph D thesis, Univ ersit y of P aul Sabatier, T olouse, 1994. [FFH + 02a] P . Flener, A. F r isc h , B. Hnic h , Z. Kiziltan, I. Miguel, J. Pea rson, and T. W alsh. Breaking row and column symmetry in matrix mo dels. In P . v an Hen tenr yc k, editor, Pr o c e e dings of the 8th International Confer enc e on Principles and Pr actic e of Constr aint pr o gr amming (CP- 02) , v olume 2470 of L e ctur e Notes in Computer Scienc e , pages 462–476. S pringer, 2002. [FFH + 02b] P . Flener, A.M. F risch, B. Hnic h, Z. Kiziltan, I. Miguel, and T. W alsh. Matrix mo delling: Exploiting common p atterns in constrain t programming. In A.M. F risch, editor, P r o c e e dings of the International Workshop on R eformulating Constr aint Satisfaction Pr oblems , pages 27–41 , 2002. [FHK + 03] A. M. F risc h, B. Hnich, Z. K iziltan, I. Miguel, and T. W alsh. Mu ltiset ord ering constrain ts. In G. Gottlob and T. W alsh, editors, P r o c e e dings of the 18th Inter- national Joint Confer enc e on Artificial Intel ligenc e (IJCAI-03) , pages 221–226. Morgan K aufmann, 2003. [FJM03] A.M. F r isc h , C. Jefferson, and I. Miguel. Constraint s for breaking more row and column symmetries. In F. Rossi, editor, Pr o c e e dings of the 9th International Con- fer enc e on Principles and Pr actic e of Constr aint Pr o gr amming (CP-03) , v olume 2833 of L e ctur e Notes i n Computer Scienc e , p ages 318–332. Spr inger, 2003. [FP02] P . Flener and J. Pearson, editors. Notes of the 2nd Inte rna- tional W orkshop on Symmetry in Constrain t Satisfaction Prob lems (SymCon-02), CP-02 Po st-conference W orksh op, 2002. Av ailable at http://w ww.it.uu .se/research /group/astra/SymCon02/ . [HE80] R.M. Haralic k and G.L. Elliot. Increasing tree searc h efficiency for constraint sat- isfaction problems. Artificial Intel ligenc e , 14:263– 313, 1980. [ILO02] ILOG S .A. ILO G Solver 5.3 R efer enc e and User Manual , 2002. 38 [KS02] Z. Kiziltan and B. M. Sm ith . Symm etry breaking constraints for matrix mo dels. In [FP02], 2002. [KT05] I. Katriel and S. Th iel. C omplete b ound consistency for the global cardinalit y constrain t. Constr aints , 10(3):19 1–217, 2005. [KW02] Z. Kiziltan and T. W alsh. Constr aint programming with m ultisets. In [FP02], 2002 . [Mac77 a] A.K. Mac kworth. Consistency in net works of relations. Artificial Intel lige nc e , 8(1):9 9–118, 1977. [Mac77 b] A.K. Mac kworth. On reading sketc h m aps. In P r o c e e dings of the 5th International Joint Confer enc e on Artificial Intel ligenc e (IJCAI-77) , p ages 598–606. William Kaufmann, 1977. [MS98] K. Marriott and P .J . Stuck ey . Pr o gr amming with c onstr aints . T he MIT Press, 1998. [MT00] K. Mehlhorn and S. Th iel. F aster algorithms for b oun d -consistency of the sort- edness and the alldifferen t constrain t. In R. Dec hter, editor, Pr o c e e dings of the Sixth International Confer enc e on Principles and Pr actic e of Constr aint Pr o gr am- ming (CP-00) , v olume 1894 of L e ctur e Notes in Computer Scienc e , pages 306–319. Springer, 2000. [Pug93] J .F. Puget. On th e satisfiabilit y of symmetrical constrained satisfaction pr oblems. In H. J. Komorowski and Z . W. Ras, editors, Pr o c e e dings of the 7th International Symp osium on M etho dolo gies for Intel ligent Systems (ISMIS-93) , v olume 689 of L e ctur e Notes in Computer Scienc e , p ages 350–361. S pringer, 1993. [QvBL + 03] C.-G. Quimp er, P . v an Beek, A. Lop ez-Ortiz, A. Golynski, and S. B. Sadjad. An efficien t b ounds consistency algorithm for th e global cardinalit y constraint. In F. Rossi, editor, P r o c e e dings of the 9th International Confer enc e on P rinciples and Pr actic e of Constr aint Pr o gr amming (CP-03) , vo lume 2833 of L e ctu r e Notes i n Computer Scienc e , p ages 600–614. S pringer, 2003. [R ´ eg94] J.C. R´ egin. A filtering algorithm for constrain ts of difference in CS Ps. In Pr o c e e d- ings of the 12th National Confer enc e on Artificial Intel ligenc e (AA AI-94) , pages 362–3 67. AAAI Press, 1994. [R ´ eg96] J.C. R´ egin. Generalized arc consistency for global cardinalit y constrain ts. In Pr o- c e e dings of the 13th National Confer enc e on Artificial Intel ligenc e and the 8th In- novative Applic ations of Artificial Intel ligenc e Confer enc e (AAAI/IAAI- 96) , pages 209–2 15. AAAI Press/The MIT Press, 1996. [Ros00] F. Rossi. Constraint (logic) pr ogramming: a survey on researc h and applications. In K. R. Ap t, A. C. Kak as, E. Monfroy , and F. Rossi, editors, New T r ends in Con- str aints , vo lume 1865 of L e ctur e Notes in Computer Scienc e , p ages 40– 74. Springer, 2000. [RvBW06] F. Rossi, P . v an Beek, and T. W alsh, editors. H andb o ok of c onstr aint pr o gr amming . Elsevier, 2006. [SBHW96] B.M. Sm ith, S .C. Brailsford, P .M. Hub bard, and H.P . Williams. Th e progressiv e part y pr oblem: inte ger linear programming and constrain t programming compared. Constr aints , 1:119–13 8, 1996. 39 [SFV95] T. S chiex, H. F argier, and G. V erfaille. V alued constraint satisfaction problems: hard and easy problems. In C. S . Mellish, editor, Pr o c e e dings of the 14th Inter- national Joint Confer enc e on Artificial Intel ligenc e (IJCAI-95) , pages 631–637. Morgan K aufmann, 1995. [SIC04] Sw ed ish Ins titue of Computer Science. SICStus Pr olo g User’s Manual, R ele ase 3.12.0 , No vem b er 2004. Av ailable at http://w ww.sics. se/sicstus/d ocs/latest/pdf/sicstus.pdf . [Tsa93] E.P .K. T s ang. F oundations of Constr aint Satisfaction . Academic Press, 1993. [vHMPR99] P . v an Hentenryc k, L. Mic hel, L. P erron, and J.C. R´ egin. Con s train t pr ogramming in OPL. In G. Nadath u r, editor, Pr o c e e dings of the International Confer enc e on the Principles and Pr actic e of De c lar ative Pr o gr amming (P PDP-99) , vo lume 1702 of L e ctur e Notes in Computer Scienc e , pages 98–116. Sp ringer, 1999. [vHSD98] P . v an Hentenryc k, V. A. Saraswa t, and Y. Deville. De sign, imp lemen tation and ev aluation of the constrain t language cc(FD ). Journal of L o gic Pr o gr amming , 37(1- 3):139 –164, 1998. [W al96] M. G. W allace. Practical app lications of constrain t p rogramming. Constr aints , 1(1-2) :139–16 8, 1996. [W al99] J. P . W alser. Inte ger Optimization by L o c al Se ar ch – A Domain-Indep endent Ap- pr o ach , vo lume 1637 of L e ctur e N otes in Artificial Intel ligenc e . Sp r inger, 1999. 40

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment