Perfect Derived Propagators

When implementing a propagator for a constraint, one must decide about variants: When implementing min, should one also implement max? Should one implement linear equations both with and without coefficients? Constraint variants are ubiquitous: imple…

Authors: Christian Schulte, Guido Tack

P erfect Deriv ed Propagators Christian Sch ulte 1 and Guido T ack 2 1 ICT, KTH - R o yal I nstitute of T ec h n ology , Sw eden, cs chulte@kth.se 2 PS Lab, Saarland U niversi ty , Saarbr¨ uck en, Germa ny , tack @ps.uni-sb.de Abstract. When impleme nting a propagator fo r a constrain t, one must decide ab out v arian ts: When implementi ng min, should one also imple- ment max? Should one imp lement l inear equations b oth with and with- out co efficients? Constraint vari ants are ubiquitous: implemen ting them requires considerable (if n ot p rohibitive) effo rt and decreases maintain- abilit y , b u t will deliv er better performance. This pap er sho ws how to use v ariable v iews, previously introduced for an implemen tation architecture, to derive p erfe ct propagator v arian ts. A mod el for views and derived propagators is introduced. Derived propaga- tors are prov ed to b e ind eed p erfect in that they inherit essen tial proper- ties such as correctness and domain and b ounds consistency . T ec hniques for systematically deriving propagators suc h as transformatio n, gener- alization, sp ecializatio n , and c hanneling are developed for several v ari- able domains. W e ev aluate the massiv e impact of derived propagators. Without derived propagators, Geco de would require 140 000 rather than 40 000 lines of co de for propagators. 1 In tro duction When implemen ting a propa g ator for a constra int , one typically needs to decide whether to also implemen t some of its v ariant s. F or example, when implemen ting a propag ator for max n i =1 x i = y , should o ne also implemen t min n i =1 x i = y ? When implemen ting the linear equation P n i =1 a i x i = c for integer v a riables x i and int eg e rs a i and c , should one also implement P n i =1 x i = c for be tter perfor ma nce? When implementing the reified linear equa tion ( P n i =1 x i = c ) ⇔ b , should one also implement its almost identical a lgebraic v aria nt ( P n i =1 x i 6 = c ) ⇔ b ? Implemen ting inflates co de and do cumentation. Not implementing increas es space and runt ime: by using more gener a l propa gators or by decomp os ing into several other constra in ts. W or se, given the p otential co de explosio n, one may b e able to only implement some v ariants (sa y , minim um and maximum). Other v ari- ants imp orta n t for p erformance (say , minimu m and maximum for tw o v ariables) may be infea s ible due to exces sive prog ramming and maintenance effort. Here, we follow a third approach: we derive propag ators fr o m already e x ist- ing propag ators using v a riable views. In [1 2], we introduced an implementation architecture for v ar iable vie ws to reuse g eneric pr opagator s without p erfor mance pena lt y . This a rchitecture has b een implemented in Geco de [5 ], and is in fact essential for the system, as it saves approximately 10 0 000 lines of co de. Due to the massive use of views in Geco de , it is vital to develop a mo del tha t a llows us to prov e that derived propa gators hav e the des ir ed pro per ties. In this pap er, we argue that pr opagato r s that are derived using v ariable views are indeed p erfe ct : they are not only per fect for perfor mance, w e prov e that they inherit all essential prop erties such as c o rrectness and completeness from their original propaga tor. Last but not lea st, we sho w common techniques for der iv ing propagator s with views and d emo nstrate their wide a pplicability . In Geco de, every propaga to r implemen tatio n is reused 3 . 6 times on av erag e. Without vie ws, Gecode would feature 140 0 00 ra ther than 4 0 000 lines of propa gator implementation to b e written, tested, and ma in tained. V ariable views . Consider a b ounds consisten t pro pagator for max( x, y ) = z . Assume tha t x ( x ) r e turns the maximum (minimum ) of the finite domain v ar iable x , wherea s x ← n ( x ← n ) a djusts the maximum (minim um) v alue of x to min( x, n ) (max( x, n )), only taking v ariable b ounds in to accoun t. The propaga tor is implement ed by p erforming the following op erations on its v ariables: x ← z y ← z z ← max( x, y ) z ← max( x, y ) Given three more pr opagato r s for x ′ = − x , y ′ = − y , and z ′ = − z , we co uld propaga te the constr aint min( x ′ , y ′ ) = z ′ . In contrast to this de c omp osition , we prop ose to us e generic propag a tors that p erfor m o per ations on views ra ther than v ariables. Views provide the same interface (set of op erations) as v ariables while enabling additional tr a nsformations. F or example, an operatio n on a min us view x ′ on a v ariable x behaves as if executed on − x : x ′ is defined as − x and x ′ ← n is defined as x ← − n . With views, the implementation of the maximum propaga tor can b e reuse d: w e derive a pr opagator for the minimum co nstraint by insta n tiating the maximum pro pa gator with minus views for its v aria bles. The feasibility of v ariable views rests o n to day’s pr ogramming languag es’ suppo rt for generic (or poly morphic) constructions (for example, templates in C ++ ) a nd tha t the simple tr ansformations provided b y views are o ptimized awa y . Con tribution s . This pap er contributes an implementation indepe nden t mo del for vie ws and derived pr opagato r s, techniques for deriving propagator s, and a n ev aluation that shows that views are widely applicable, drastica lly reduce pro- gramming effo r t, and ar e mor e efficient than decomp osition. More specifically , the key con tributio n is the identification of pro per ties of views that ar e essential for deriving p erfe ct propagato rs. T o this end, the pa- per establishes a formal mode l that defines a view a s a function and a derived propaga tor as functional comp osition of views (mapping v alues to v a lues) with a propaga tor (mapping v ariable domains to v a riable domains). This mo del yields all the desired r esults: der ived pr opagator s are indeed pr opagator s; derived prop- agator s faithfully implement the in tended constra in ts; domain consis tency carr ies ov er to der ived propaga tors; different forms of b ounds consistency ov er integer v ariables car ry ov er provided that the view s satisfy additio na l pro per ties. 2 After es tablishing the fundamental r esults, w e address further pr op erties o f derived pro pagator s such as idempo tence, subsumption, and events. Finally , we clarify the connectio n b etw een der ived pro pagators and path consistency when regar ding views as binar y constraints. W e introduce techniques for deriving propag ators that use view s for sp ecial- ization and generaliza tion of propaga tors, c hanneling b etw een v aria ble domains, and genera l doma in- spe cific transforma tions. W e show how to a pply these tech- niques for differen t v ar iable domains us ing v a rious views. W e provide a break- down o f how succe ssful the use of derived propag ators has b een for Geco de. Ov erview. The next section int r o duces the basic notions we will use. Sect. 3 presents views and der ived propag ators and prov es fundamental pr op erties like correctnes s a nd co mpleteness. The following three sections develop techniques for deriving propa gators: transformatio n, g eneralization, spe c ia lization, and chan- neling. Sect. 7 presents extensio ns of the mo del, and Sect. 8 discusses its limita- tions. Sect. 9 provides empirica l evidence that views are useful in practice. 2 Preliminaries This section sets the sta ge for the pap er with definitions of the basic co ncepts. V ariables and constrain ts. W e assume a finite set of v ar iables V ar = { x 1 , . . . , x n } and a finite set of v alues V al . Constraints ar e characterized b y assignments a ∈ Asn that map v ariables to v alues: Asn = V ar → V al . A constraint c ∈ Con is a rela tion over the v ariables, represented as the set o f all assignments that satisfy the co nstraint, Con = 2 Asn . W e base constraints on full a ssignments, defined for a ll v ar ia bles in V ar . How ever, for t ypica l c o n- straints, only a subset v ars( c ) of the v a riables is signific ant ; the constraint is the full relation for all x / ∈ v ars( c ). W e write a constraint in extensio n ( c = { ( x 7→ 0 , y 7→ 1 ) , ( x 7→ 1 , y 7→ 2) } ) or intensionally ( c ≡ x < y ). Domains. Constraints are implemented b y pr o pagator s over do mains, which are constructed as follows. A domain d ∈ Dom maps each v ar iable to a finite s et of p o ssible v alues, the variable domain d ( x ) ⊆ V al . A domain d c an be identified with a se t o f as signments d ∈ 2 Asn . W e can therefore trea t do mains as constr aints. In particular, for any assignment a , { a } is a domain a s well as a constraint. W e simply write domai n fo r domains and v ariable do mains when there is no risk of confusion. A domain d 1 is str onger than a domain d 2 (written d 1 ⊆ d 2 ), iff for all v ariables x , d 1 ( x ) ⊆ d 2 ( x ). By dom( c ) w e refer to the strongest doma in including all v alid assignments of a c o nstraint, defined as min { d ∈ Dom | c ⊆ d } = { a | ∀ x ∃ b ∈ c. a ( x ) = b ( x ) } . The minimum exists as doma ins are clo sed under int er section, and the definition is non-trivia l b ecause not every constr a int ca n be captured by a doma in. Now, for a constraint c and a domain d , dom( c ∩ d ) refers to r emoving all v alues from d not supp or ted by the cons tr aint c . 3 Propagators. Pr opagator s serve her e as implemen tatio ns of constraints. They are sometimes also referred to as constraint nar rowing op er a tors or filter func- tions. A propaga tor is a function p ∈ Dom → Dom that is co ntracting ( p ( d ) ⊆ d ) and mono tone ( d ′ ⊆ d ⇒ p ( d ′ ) ⊆ p ( d )). Idemp otence is not required. Propag ators are contracting, they o nly remov e v a lues from v ar iable domains. F or an assignment a , a pro pa gator p hence has only tw o o ptions: accept it ( p ( { a } ) = { a } ), or re ject it ( p ( { a } ) = ∅ ). Monotonicity gua r antees that if some domain d contains an ass ignment a ∈ d that p accepts, then p will not remov e a from d : a ∈ p ( d ). The propaga tor there fo re behaves lik e a characteristic function for the s e t o f accepted as signments. This set is the asso ciate d c onstr aint of p . W e say that a pr opagato r p implements its asso cia t e d c onstr aint c p = { a ∈ Asn | p ( { a } ) = { a }} . Monoto nicit y implies that for any domain d , we have dom( c p ∩ d ) ⊆ p ( d ): no solution of c p is ever remov ed by p . W e say that p is sound for any c ⊆ c p and we akly c omplete for any c ′ ⊇ c p (meaning that it a c c epts all a ssignments in c and rejects all assignments not in c ′ ). F o r any constraint c , we can find at least one pro pagator p suc h that c = c p . Typically , there a re se veral pr opagator s, differing by pr op agatio n str ength (see Sect. 3). Our definitions of so undness and differe nt notions of co mpleteness for prop- agator s a re based on and equiv alent to Benhamou’s [2 ] and Maher’s [9]. W e sp ecify wha t is computed by cons tr aint propa gation and not how . Approaches for p er fo rming co nstraint pro pa gation can b e found in [2, 1, 11]. 3 Views and Deriv ed Propagators W e now in tro duce our central conce pts, views and derived propaga tors. A view on a v a riable x is an injective function ϕ x ∈ V al → V al ′ , mapping v alues from V al to v alues from a p ossibly different set V al ′ . W e lift a fa m- ily of views ϕ x (one for eac h x ∈ V ar ) p oint-wise to ass ignments as follows: ϕ Asn ( a )( x ) = ϕ x ( a ( x )). Finally , given a family of views lifted to assignments, we define a v iew ϕ ∈ Con → Con o n constraints as ϕ ( c ) = { ϕ Asn ( a ) | a ∈ c } . The inv erse of that view is defined as ϕ − ( c ) = { a ∈ Asn | ϕ Asn ( a ) ∈ c } . In the implemen tatio n, a view on x presents the same interface as x , but applies transfor mations when a propagato r adjusts o r accesse s the domain of x through the view. In our mode l, ϕ per forms the transfor mations for accessing, and ϕ − for adjusting the v ariable domains . Views can now b e comp osed with a propaga tor: a derive d pr op agator is defined as b ϕ ( p )( d ) = ϕ − ( p ( ϕ ( d ))), o r, using function comp osition, a s b ϕ ( p ) = ϕ − ◦ p ◦ ϕ . Example. Given a pr opagator p for the constraint c ≡ ( x = y ), we wan t to derive a pr opagato r for c ′ ≡ ( x = 2 y ) using a view ϕ such that ϕ − ( c ) = c ′ . It is usually eas ier to think ab out the o ther direction: ϕ ( c ′ ) ⊆ c . Intuitiv ely , the function ϕ leav es x as it is and s cales y b y 2, while ϕ − do es the inv erse transformatio n. W e thus define ϕ x ( v ) = v a nd ϕ y ( v ) = 2 v . W e have a subset relation b ecause some tuples of c may b e ruled out by ϕ . F or instance, with ϕ defined as above, there is no a ssignment a such that ϕ Asn ( a )( y ) = 3 , but the assignment ( x 7→ 3 , y 7→ 3) is in c . 4 This example also makes clear why the set V al ′ is allow ed to differ from V al . In this par ticula r case, V al ′ has to contain all multiples of 2 o f e le men ts in V al . The derived propag ator is b ϕ ( p ) = ϕ − ◦ p ◦ ϕ . W e say that b ϕ ( p ) “uses a sca le view o n” y , meaning tha t ϕ y is the function defined a s ϕ y ( v ) = 2 v . Similarly , using a n ide ntit y view on x amounts to ϕ x being the identit y function on V al . Given the assig nment a = ( x 7→ 2 , y 7→ 1), we first apply ϕ Asn and get ϕ Asn ( a ) = ( x 7→ 2 , y 7→ 2 ). This is accepted by p and re tur ned unchanged, so ϕ − transforms it back to a . Another a s signment, a ′ = ( x 7→ 1 , y 7→ 2), is transformed to ϕ Asn ( a ′ ) = ( x 7→ 1 , y 7→ 4), rejected ( p ( { ϕ Asn ( a ′ ) } ) = ∅ ), and the empty domain is mapp ed to the empt y domain by ϕ − . The propa gator b ϕ ( p ) implemen ts ϕ − ( c ).  Views and der ived propa g ators satisfy a num ber of essential pro p er ties: 1. A derived pro pagator b ϕ ( p ) is in fact a propa gator. 2. The a sso ciated constr aint of b ϕ ( p ) is ϕ − ( c p ). 3. A view ϕ preserves contraction of a propagator p : If p ( ϕ ( d )) ⊂ ϕ ( d ), then b ϕ ( p )( d ) ⊂ d . This pro p er ty makes sure that if the pro pagator makes an inference, then this inference will actually be reflected in a domain change. In the following, we will pr ov e these prop erties. F or the pr o o fs, we employ some direct consequences of the definitio ns of v iews and der ived propag a tors: (1) ϕ and ϕ − are monoto ne by construc tio n; (2) ϕ − ◦ ϕ = id (the identit y function); (3) | ϕ ( { a } ) | = 1 , ϕ ( ∅ ) = ∅ ; (4) for any view ϕ and do ma in d , we have ϕ ( d ) ∈ Dom and ϕ − ( d ) ∈ Dom (as views ar e defined p oint-wise). Theorem 1. A der ived propagator is a propagator : for all propaga to rs p and views ϕ , b ϕ ( p ) is a monotone and co n tra cting function in Dom → Dom .  Pro of. The derived propag ator is well-defined be c ause b oth ϕ ( d ) and ϕ − ( d ) are domains (see (4) a b ove). Monotonicity is obvious, as c ompo sitions of monoto ne functions are monotone. F or contraction, w e hav e p ( ϕ ( d )) ⊆ ϕ ( d ) a s p is con- tracting. B y mo no tonicity of ϕ − , we know that ϕ − ( p ( ϕ ( d ))) ⊆ ϕ − ( ϕ ( d )). As ϕ − ◦ ϕ = id, we hav e ϕ − ( p ( ϕ ( d ))) ⊆ d , which prov es that b ϕ ( p ) is contracting. In summary , for any propaga tor p , b ϕ ( p ) = ϕ − ◦ p ◦ ϕ is a propaga tor. Theorem 2. If p implemen ts c p , then b ϕ ( p ) implements ϕ − ( c p ).  Pro of. As p implements c p , w e know p ( { a } ) = c p ∩ { a } for all as signments a . With | ϕ ( { a } ) | = 1, we ha ve p ( ϕ ( { a } )) = c p ∩ ϕ ( { a } ). F ur thermore, we know that c p ∩ ϕ ( { a } ) is either ∅ or ϕ ( { a } ). Case ∅ : W e hav e ϕ − ( p ( ϕ ( { a } ))) = ∅ = { a } ∩ ϕ − ( c p ). Case ϕ ( { a } ): As ϕ − ◦ ϕ = id, w e hav e ϕ − ( p ( ϕ ( { a } ))) = { a } . F urthermore : c p ∩ ϕ ( { a } ) = ϕ ( { a } ) ⇒ ∃ b ∈ c p . b = ϕ ( a ) ⇒ a ∈ { a ′ ∈ Asn | ϕ ( a ′ ) ∈ c p } ⇒ a ∈ ϕ − ( c p ) T ogether, this shows that ϕ − ◦ p ◦ ϕ ( { a } ) = { a } ∩ ϕ − ( c p ). 5 Theorem 3. Views preserve contraction: for any domain d , if p ( ϕ ( d )) ⊆ ϕ ( d ), then b ϕ ( p )( d ) ⊂ d .  Pro of. Recall the definition of ϕ − ( c ) as { a ∈ As n | ϕ Asn ( a ) ∈ c } . It clearly follows that | ϕ − ( c ) | ≤ | c | . Similarly , we know that | ϕ ( c ) | = | c | . F rom p ( ϕ ( d )) ⊂ ϕ ( d ), we know that | p ( ϕ ( d )) | < | ϕ ( d ) | . T oge ther, this yields | b ϕ ( p )( d ) | < | ϕ ( d ) | = | d | . W e hav e alrea dy seen in Theorem 1 that b ϕ ( p )( d ) ⊆ d , so w e can conclude that b ϕ ( p )( d ) ⊂ d . Completenes s. W eak completeness, as introduced ab ov e, is the minim um re- quired for a constraint solver to be complete. A weakly complete pr opagator doe s not hav e to pr une v ariable doma ins, it only has to check if an assigned domain is a solution of the co nstraint. The success o f constraint propa gation ho wev er crucially dep ends on s trong pro pagators that prune v ariable domains. The stro ngest p oss ible inference that a single propagato r can do establishes domain c onsistency (also known as gener alize d ar c c onsistency ): a domain d is do ma in consistent for a cons tr aint c , iff for a ll v ariables x i and a ll v alues v i ∈ d ( x i ), there exist v alues v j ∈ d ( x j ) for all other v ariables x j such that the assignment ( x 1 7→ v 1 , . . . , x i 7→ v i , . . . , x n 7→ v n ) is a solution of c . A pr opagator is domain c omplete (or simply complete) for a constra in t c if it establishes doma in consistency . More for ma lly , a propag ator p is co mplete for a constraint c iff for a ll domains d , we hav e p ( d ) ⊆ dom( c ∩ d ). A co mplete propaga tor th us removes all assignments from d that are inco nsistent with c . W e will now prove that propaga tors derived from co mplete pro pagator s are also complete. In Sect. 5, we will ex tend this result to w eaker notions of com- pleteness, such as bo unds( Z ) and b ounds( R ) completenes s. F or this pro o f, we ne e d tw o auxiliary definitions . A constra in t c is a ϕ c on- str aint iff for all a ∈ c , ther e is a b ∈ Asn such that a = ϕ Asn ( b ). A view ϕ is dom inje ctive iff ϕ − (dom( c )) = dom( ϕ − ( c )) for all ϕ co nstraints c . F or the completeness pr o of, we need a lemma that states tha t a ny view is dom injective. Pro of. By definition of ϕ − and dom( · ), w e have ϕ − (dom( c )) = { a ∈ Asn | ∀ x. ∃ b ∈ c.ϕ Asn ( a )( x ) = b ( x ) } . As c is a ϕ constraint, w e can find suc h a b that is in the r ange of ϕ Asn , if and only if there is also a b ′ ∈ ϕ − ( c ) s uch that ϕ Asn ( b ′ ) = b . Ther efore, w e g et { a ∈ Asn | ∀ x. ∃ b ′ ∈ ϕ − ( c ) .a ( x ) = b ′ ( x ) } = dom( ϕ − ( c )). F urthermore , we need a le mma that states tha t views co mm ute with set int er section: F or any view ϕ , the eq uation ϕ − ( c 1 ∩ c 2 ) = ϕ − ( c 1 ) ∩ ϕ − ( c 2 ) holds. Pro of. By definition of ϕ − , we hav e ϕ − ( c 1 ∩ c 2 ) = { a ∈ A s n | ϕ Asn ( a ) ∈ c 1 ∧ ϕ Asn ( a ) ∈ c 2 } . As ϕ Asn is a function, this is equal to { a ∈ Asn | ϕ Asn ( a ) ∈ c 1 } ∩ { a ∈ Asn | ϕ Asn ( a ) ∈ c 2 } = ϕ − ( c 1 ) ∩ ϕ − ( c 2 ). Theorem 4. If p is complete for c , then b ϕ ( p ) is complete for ϕ − ( c ).  6 Pro of. By mono to nicit y of ϕ and completeness of p , w e k now tha t ϕ − ◦ p ◦ ϕ ( d ) ⊆ ϕ − (dom( c ∩ ϕ ( d ))). W e now use the fact that ϕ − is dom injective and commutes with s et intersection: ϕ − (dom( c ∩ ϕ ( d ))) = dom( ϕ − ( c ∩ ϕ ( d ))) = dom( ϕ − ( c ) ∩ ϕ − ( ϕ ( d ))) = dom( ϕ − ( c ) ∩ d ) 4 Bo olean V ariables: T ra nsformation This sectio n discusses views a nd derived pr o pagator s for Bo o lean v ar iables where V al = { 0 , 1 } . Not surprisingly , the only view a part from identit y for Bo olean v ariables captures negation. Tha t is, us ing a ne gation view on x defines ϕ x ( v ) = 1 − v for x ∈ V ar and v ∈ V al . Negation views are more widely a pplica ble than one would initially b elieve. They demonstrate how views ca n b e used systematically to obtain implementa- tions o f co nstraint v ariants by tr ansformation . Bo olean connectives. The immediate a pplication of negation views is to derive propaga tors for all Bo o lean connectives from just thre e propag ators: A nega tion view for x in x = y yields a propa gator for ¬ x = y . F ro m disjunction x ∨ y = z one can derive conjunction x ∧ y = z with negatio n views on x , y , z , and implication x → y = z with a neg ation view o n x . F r om equiv alence x ↔ y = z one can derive exclusive o r x ⊕ y = z with a neg ation view on z . As Bo o lean constra int s are widespread in mo dels, it pays off to optimize fre- quently o ccurring cases. One impo r tant propag a tor is disjunction W n i =1 x i = y for arbitr a rily ma n y v aria bles; again conjunction can b e de r ived with nega tion views o n the x i and on y . Another important propag ator is for the constraint W n i =1 x i = 1, stating that the dis junction must b e true. A propagato r for this constraint is essential as the constra in t o ccur s frequently and as it can b e im- plement ed efficie ntly using watc hed literals , see for example [6]. With views and derived pr opagator s all implementation w or k is readily reused for conjunction. This shows a g eneral adv antage of views: effort put into optimizing a sing le propaga tor directly pays off for all other pro pagators derived from it. Bo olean cardinalit y . Like the constra in t W n i =1 x i = 1, the Bo o le a n cardinality constraint P n i =1 x i ≥ c o ccurs freq uen tly and ca n be implemented efficien tly using watc hed liter a ls (r equiring c + 1 watc hed literals, Bo ole a n disjunction cor- resp onds to the ca se where c = 1 ). But also a propagator for P n i =1 x i ≤ c can be de r ived us ing nega tion views with the following trans formation: P n i =1 x i ≤ c ⇐ ⇒ − P n i =1 x i ≥ − c ⇐ ⇒ n − P n i =1 x i ≥ n − c ⇐ ⇒ P n i =1 1 − x i ≥ n − c ⇐ ⇒ P n i =1 ¬ x i ≥ n − c 7 Reification. Ma ny reified constra in ts (such as ( P n i =1 x i = c ) ⇔ b ) a ls o exist in a nega ted version (such a s ( P n i =1 x i 6 = c ) ⇔ b ). Deriv ing the negated version is trivial b y using a negation view on the Bo olean con trol v a riable b . T his co n tra sts nicely with the effort without views: either the en tire co de m ust be duplica ted or the pa rts that perfor m chec king whether the co nstraint or its nega tion is entailed m ust b e factor ized out and combined differently for the tw o v ariants. 5 In teger V ariables: Generalization, Bounds Consistency , Sp ecialization Common vie w s for finite domain in teger v ariables ca ptur e linear transformations of the int eg e r v alues. In [12 ], the following vie w s are in tro duced for a v a riable x and v alues v : a minus view on x is defined as ϕ x ( v ) = − v , a n offset view for o ∈ Z on x is defined a s ϕ x ( v ) = v + o , and a sc ale view for a ∈ Z o n x is defined as ϕ x ( v ) = a · v . Propag ators for integer v ariable s offer a gre ater deg ree of fr e e dom c o ncern- ing their lev el of completeness. While Boo lean pr o pagator s most often will be domain co mplete, b ounds completeness is impor tant for in teger propagator s . Be- fore w e discuss transforma tion and g eneralizatio n tec hniques for deriving integer propaga tors, we s tudy how b ounds completeness is affected by views. Bounds consistency and b ounds compl eteness. Ther e are several different notions of b ounds consistency in the liter ature (see [4 ] for an ov erv ie w). F or our purp oses, we disting uis h b ounds( D ), b ounds ( Z ), and b ounds( R ) cons is tency: – A domain d is b ounds( D ) c onsistent for a cons tr aint c , iff for a ll v ariables x i there exist v j ∈ d ( x j ) for all other v ariables x j such that { x 1 7→ v 1 , . . . , x i 7→ min( d ( x i )) , . . . , x n 7→ v n } ∈ c and analo gously for x i 7→ max( d ( x i )). – A domain d is bounds( Z ) c onsistent for a co ns traint c , iff for all v ariables x i , there exist integers v j with min( d ( x j )) ≤ v j ≤ max( d ( x j )) for all other v ariables x j such that { x 1 7→ v 1 , . . . , x i 7→ min( d ( x i )) , . . . , x n 7→ v n } ∈ c and analogo usly for x i 7→ max( d ( x i )). – A domain d is b ounds( R ) c onsistent for a constr aint c , iff for all v aria bles x i , ther e exist real num b ers v j ∈ R with min( d ( x j )) ≤ v j ≤ ma x( d ( x j )) for all other v ariables x j such that { x 1 7→ v 1 , . . . , x i 7→ min( d ( x i )) , . . . , x n 7→ v n } ∈ c R and analog ously for x i 7→ max( d ( x i )), where c R is c relax e d to R (for constra ints like arithmetics where r elaxation ma kes s ense). A propagato r p is b ounds( X ) complete for its asso ciated constraint c p , iff p ( d ) is b ounds( X ) consistent for c p for every domain d that is a fix- po in t o f p . W e use an eq uiv alent definition ba sed on the s tr ongest c on- vex domain that contains a constraint, conv( c ) = min { d ∈ Dom | c ⊆ d and d convex } . A con vex domain maps each v ariable to an interv a l, so that conv( c )( x ) = { min a ∈ c ( a ( x )) , . . . , max a ∈ c ( a ( x )) } . Note that conv( c ) is weak er than the strongest do main that contains c : co n v( c ) ⊇ dom( c ) for all constraints c . In the same wa y as Benhamou [2] a nd Maher [9], we define 8 – p is b ounds( D ) complete for c iff p ( d ) ⊆ con v ( c ∩ d ). – p is b ounds( Z ) complete for c iff p ( d ) ⊆ con v ( c ∩ conv( d )) . – p is bo unds( R ) complete for c iff p ( d ) ⊆ conv( c R ∩ conv R ( d )), where con v R ( d ) is the conv ex hull of d in R , and c R is c r elaxed to R . Bounds com pleteness o f deriv ed propagators. Theorem 4 s ta tes that prop- agator s derived from domain complete propagator s are domain complete. A sim- ilar theorem holds for bounds completeness, if v iews commute with conv( · ) in the following wa ys: A v ie w ϕ is int erval inje ctive iff ϕ − (conv( c )) = conv( ϕ − ( c )) for all ϕ con- straints c . It is interval bije ctive iff it is interv a l injective and ϕ (conv( d )) = conv( ϕ ( d )) for all do mains d . Proving b ounds completeness of derived propaga tors is now similar to proving domain co mpleteness. W e o nly formulate b ounds( Z ) co mpleteness. Theorem 5. If p is bounds( Z ) complete for c and ϕ is in terv al bijective, then b ϕ ( p ) is b ounds( Z ) complete for ϕ ( c ).  Pro of. By monotonicity of ϕ and b ounds( Z ) completeness of p , we know that ϕ − ◦ p ◦ ϕ ( d ) ⊆ ϕ − (conv( c ∩ conv( ϕ ( d ))) ). W e now use the fact that b oth ϕ a nd ϕ − commute with conv and intersection: ϕ (conv( c ∩ conv( ϕ − 1 ( d )))) = ϕ (con v ( c ∩ ϕ − 1 (conv( d )) )) = conv( ϕ ( c ∩ ϕ − 1 (conv( d )) )) = conv( ϕ ( c ) ∩ ϕ ( ϕ − 1 (conv( d )))) = conv( ϕ ( c ) ∩ conv( d ) ) The pro o f for bounds( D ) is ana lo gous, but w e o nly require in terv al injectivity for the view. With an interv al injective view, o ne can also derive b ounds( R ) com- plete propaga tors from b ounds( R ) o r b ounds( Z ) co mplete propa gators. T a ble 1 summarizes how completeness dep ends on vie w bijectivity . T able 1. Completeness of derived propagators pr op agat or view interval bij e ctive i nterval inje ctive arbitr ary domain domain domain domain b ounds( D ) b ounds( D ) b ounds( D ) w eakly b ounds( Z ) b ounds( Z ) b ounds( R ) weakly b ounds( R ) b ounds( R ) b ounds( R ) weakly The views fo r integer v ariables pre sent ed a t the beginning of this s e ction hav e the following prop erties: minus and offset v iews a re interv al bijective, wher eas a scale view for a ∈ Z on x is alwa ys interv a l injective and only int er v al bijective if a = 1 or a = − 1 (in w hich ca s es it coincides with the identit y view or a min us view, resp ectively). An imp ortant conse q uence is that a b ounds( Z ) c omplete propaga tor for the co ns traint P i x i = c , when instantiated with sc a le views for the x i , results in a b ounds( R ) complete pr o pagator for P i a i x i = c . 9 T ransformation. Like the negation v iew for Boo lean v aria bles, minus v iews for int eg e r v ariables help to derive propa gators following simple transformations: for example, min( x, y ) = z ca n b e derived from ma x( x, y ) = z b y using min us views for x , y , and z . T ransfor mations through minus vie ws ca n improv e p erformanc e in subtle wa ys. Consider a bounds ( Z ) consis tent propagato r for multiplication x × y = z . Pro pagation dep ends on whether zero is still included in the domains of x , y , or z . T esting for inclusion of z e ro each time the propagator is executed is not v ery efficient . Instead, one would lik e to rewr ite the propaga tor to special v ariants wher e x , y , and z a re either strictly p ositive or neg ative. Thes e v ariants can propagate more efficiently , in particula r b ecause propa gation can ea sily be implemen ted to b e ide mp otent (see Sec tion 7). Implementing three differen t propaga tors (all v ariables strictly p ositive, x or y stric tly p ositive, only z strictly po sitive) se e ms excess ive. Her e, a single propag ator a s suming that all views are po sitive is sufficien t, the others can b e der ived using minus views . Generalization. Offset and scale views are useful fo r generalizing propag ators. Generalization has tw o key adv a n tag es: simplicit y and efficiency . A more sp e- cialized propag a tor is often s impler to implemen t than a g eneralized version. The p ossibility to use the spe cialized version when the full p ow er of the g eneral version is not r e quired may save spac e and time during execution. The pro pagator for a linear equality c o nstraint P n i =1 x i = c is efficient for the common cas e that the linear equa tion has only unit co efficie nts. The more g e neral case P n i =1 a i x i = c can b e derived b y using scale views for a i on x i (This of course also holds tr ue for linear inequality and disequality rather than equality). Similarly , a propag ator for a lldifferent ( x i ) can b e gener alized to alldifferent( c i + x i ) by using offset v iews for c i ∈ Z on x i . Likewise, a propa gator for the element constraint h c 1 , . . . , c n i [ x ] = y can b e ge ne r alized to h c 1 , . . . , c n i [ x + o ] = y with an offset view, where o ∈ Z provides a useful offset for the index v ariable x . It is imp orta n t to recall that propag ators ar e derived: in Ge c o de, the ab ov e generaliza tions a re a pplied to domain as well as bo unds complete propag ators. Sp ecialization. W e employ c onstant views to sp ecia lize propaga tors. A co n- stant view b ehav es like a fixed v ariable. In practice, sp ecializa tion ha s tw o ad- v an tage s: F ewer v aria bles are needed, which mea ns less s pace consumption. And sp ecialized propag ators ca n be compiled to mo re efficient co de, if co nstants are known at compile time. Examples fo r sp ecializatio n ar e a propaga tor for binar y linear inequality x + y ≤ c deriv ed fro m a propagator for x + y + z ≤ c by using a co ns tant 0 for z ; a Bo olea n propag a tor for x ∧ y ↔ 1 from x ∧ y ↔ z and consta nt 1 for z ; a pr o pagator for the e le men t constraint h c 1 , . . . , c n i [ y ] = z d er ived from a propaga tor for h x 1 , . . . , x n i [ y ] = z ; a reified pr opagator for ( x = c ) ↔ b from ( x = y ) ↔ b and a co nstant c for y ; a propag ator for counting |{ i | x i = y }| = c from a pro pagator for |{ i | x i = y }| = z ; a nd many mo re. W e have to extend our mo del to suppo rt constant views. Pr opagato r s may now b e defined with r esp ect to a sup erset o f the v aria bles, V ar ′ ⊇ V ar . A 10 constant view for the v alue k on a v a riable z ∈ V ar ′ \ V ar translates betw een the t wo sets of v ariables as follows: ϕ − ( c ) = { a | V ar | a ∈ c } ϕ ( c ) = { a [ k /z ] | a ∈ c } Here, a [ k /z ] means a ugmentin g the assig nmen t a so tha t it maps z to k , and a | V ar is the functional res triction o f a to the set V ar . It is impo rtant to see that this definition preserves failure: if a propag ator returns a failed domain d that maps z to the empty set, then ϕ − ( d ) is the empty s et, to o . Indexicals. Views that p e rform arithmetic tra nsformations a re related to in- dexicals [3, 13]. An index ical is a propaga tor that pr unes a single v ariable and is defined in terms of rang e expressio ns. A view is simila r to an indexical with a single input v ariable. How ever, views are not use d to build pr opagator s directly , but to derive new propaga tors from existing ones. Allowing the full expressivity of indexicals for views would imply g iv ing up our completeness results. Another related concept are arithmetic expressio ns , which can b e us e d for mo deling in man y sys tems (suc h a s ILOG Solver [10]). In co nt r a st to views, these expressions are not used for propagation directly and, lik e indexicals, yield no completeness guarantees. 6 Set V ariables: Channeling Set constra in ts deal with v ariables whose domains are sets of finite se ts . This powerset lattice is a Boo lean alg ebra, so typical constraints are constructed from the Bo olea n primitives disjunction (union), conjunction (intersection), and nega- tion (complement), and the r elations equality and implicatio n (subs e t). T ransformation and Spe cialization. As for Bo olean and integer v ariables , views on set v ariables enable tra nsformation and sp ecializatio n. Using c omple- ment views (analo gous to Bo o lean negation) on x, y , z with a propag a tor for x ∩ y = z yie lds a propa gator for x ∪ y = z . A complement view on y gives us x \ y = z . Constant vie w s like the empty set or the univ er s e enable specia lization; for example, x ∩ y = z implements set disjoint ness if z is the constant e mpty set. Channeling views. A channeling view c hanges the t yp e of the v alues tha t a v ariable can take. O ur mo del alrea dy a c commo dates for this as a view ϕ x maps elements b et ween different sets V al and V al ′ . An impor tant channeling v iew is a singleton view on an integer v ariable x , defined as ϕ x ( v ) = { v } . It pres e nts an int eg er v aria ble as a singleton se t v ariable. Many useful co nstraints inv olve b oth integer and set v ariables, and some of them can b e expre s sed with singleto n views . The simplest co nstraint is x ∈ y , where x is an integer v ariable and y a set v ariable. Singleton views let us implement it a s { x } ⊆ y , and just as easily give us the negated a nd r e ifie d v ariants. O b vio usly , this extends to { x } ⋄ y for all o ther set relations ⋄ . 11 Singleton views can also b e us e d to der ive pure in teger constraints from s e t propaga tors. F or example, the constra int sa me([ x 1 , . . . , x n ] , [ y 1 , . . . , y m ]) s tates that the tw o sequences of integer v ariables ta ke the s ame v alues. With singleton views, S n i =1 { x i } = S m j =1 { y j } implements this co nstraint. Channeling b et ween domain implementations. Most systems a pproxi- mate finite set domains a s conv ex sets defined b y a low er and an upper bound [7]. How ever, Hawkins et al. [8] introduced a complete representation for the do- mains o f finite set v ariables using ROBDDs. Channeling views c a n tra nslate betw een int er v al- a nd ROBDD-based implemen tations . W e can derive a propa - gator on ROBDD-based v ariables from a set-interv a l pro pagator , a nd thu s reuse set-interv al propa gators for which no e fficie nt ROBDD representation exis ts. 7 Extended Prop erties of Derived Propagators This section dis c usses how views can b e comp osed, how derived pr opagator s behave with resp ect to idempo tence and subsumption, a nd how even ts can be used to schedule derived propag a tors. Finally , w e discuss the relation betw een views a nd path consis tency . Comp osi ng views. A derived pro pagator p ermits further deriv ation: b ϕ ( b ϕ ′ ( p )) for tw o v ie w s ϕ, ϕ ′ is p erfectly acceptable, pr op e rties like correctness and com- pleteness car ry o ver. F or instance, we can derive a propaga tor for x − y = c from a pr opagator for x + y = 0 by combining an offset view and a minus view o n y . Idemp otent propagators. A propagator is idempo ten t iff p ( p ( d )) = p ( d ) for all domains d . Some sys tems requir e all pro pagator s to be idemp otent, other s apply optimizations if the idemp otence of a pr o pagator is known [1 1]. If a propa- gator is derived from an idemp otent pro pagator , the result is idemp otent aga in: Theorem 6. If p ( p ( d )) = p ( d ) for a pro pagator p and a domain d , then, for any view ϕ , b ϕ ( p )( b ϕ ( p )( d )) = b ϕ ( p )( d ).  Pro of. F unction comp osition is ass o c iative, so we can write b ϕ ( p )( b ϕ ( p )( d )) as ϕ − ◦ p ◦ ( ϕ ◦ ϕ − ) ◦ p ◦ ϕ ( d ). W e know that ϕ ◦ ϕ − = id for all domains that contain only a ssignments on whic h ϕ − is fully defined, meaning that | ϕ − ( d ) | = | d | . As we first apply ϕ , this is the case here, so w e can remov e ϕ ◦ ϕ − , leaving ϕ − ◦ p ◦ p ◦ ϕ ( d ). As p is idemp otent, this is equiv alent to ϕ − ◦ p ◦ ϕ ( d ) = b ϕ ( p )( d ). Subsumption. A propaga tor is s ubsumed for a doma in d iff for all str o nger domains d ′ ⊆ d , p ( d ′ ) = d ′ . Subsumed pr opagator s do not contribute any prop- agation in the r e maining subtree of the sea rch, and can therefor e b e remo ved. Deciding subsumption is coNP-complete in general, but for most propagators an approximation can b e decided easily . This can b e used to optimize propa gation. Theorem 7. p is subs umed by ϕ ( d ) iff b ϕ ( p ) is s ubsumed by d .  12 Pro of. The definition o f ϕ gives us that ∀ d ′ ⊆ d. ϕ − ( p ( ϕ ( d ′ ))) = d ′ is equiv- alent with ∀ d ′ ⊆ d. ϕ − ( p ( ϕ ( d ′ ))) = ϕ − ( ϕ ( d ′ ). As ϕ − is a function, and bec ause it is c o nt r a ction-preser ving (see Theor em 3), this is equiv alen t with ∀ d ′ ⊆ d. p ( ϕ ( d ′ )) = ϕ ( d ′ ). Because all ϕ ( d ′ ) are subsets of ϕ ( d ), we can rewrite this to ∀ d ′′ ⊆ ϕ ( d ) . p ( d ′′ ) = d ′′ , concluding the pr o of. Ev ents. Many systems control propagator inv o cation using events (for a de- tailed discussion, see [11]). An even t desc rib es how a domain c hanged. Typi- cal events for finite domain in teger v ar iables are: the v ariable x b ecomes fixed (fix( x )); the lower bo und of v ariable x changes (lb c ( x )); the upper bound of v ari- able x ch a nges (ub c( x )); the domain o f v a riable x c hang es (dmc( x ) ). In some systems, lbc( x ) and ubc( x ) are co llapsed into one even t, b c ( x ) = lb c( x ) ∨ ub c ( x ). Even ts ar e monotone: if even ts( d, d ′′ ) is the set of even ts o ccurring when the domain changes from d to d ′′ (with d ′′ ⊆ d ), then we hav e even ts( d, d ′′ ) = even ts( d, d ′ ) ∪ event s( d ′ , d ′′ ) for a n y d ′′ ⊆ d ′ ⊆ d . Propaga tors are a s so ciated with event sets : A propag ator p depends on an even t set es ( p ) iff 1. for all d if p ( d ) 6 = p ( p ( d )), then even ts( d, p ( d )) ∩ es ( p ) 6 = ∅ 2. for all d, d ′ where p ( d ) = d , d ′ ⊆ d , p ( d ′ ) 6 = d ′ , then e vents ( d, d ′ ) ∩ es ( p ) 6 = ∅ If a pro pa gator p depends on es ( p ), what ev ent set doe s b ϕ ( p ) depend on? W e can co nstruct a safe appr oximation of es ( b ϕ ( p )): If fix( x ) ∈ es ( p ), put fix( x ) ∈ es ( b ϕ ( p )). F or any other ev ent e ∈ es ( p ), put dmc( x ) ∈ es ( b ϕ ( p )). This is correct bec ause ϕ x is injective. If ϕ x is monoto ne with respe ct to the or der on V al x , a < b ⇒ ϕ x ( a ) < ϕ x ( b ), we can also use b ounds even ts. If ϕ x is anti-monotone with r esp ect to that or der, we hav e to switch lb c with ub c. Arc and path consis tency . Instead of regarding a view ϕ as tra nsforming a constraint c , we ca n reg a rd ϕ as additional constr aints, implemen ting the decom- po sition. Assuming V ar = { x 1 , . . . , x n } , w e use additional v ariables x ′ 1 , . . . , x ′ n . Instead of c , we hav e c ′ = c [ x 1 /x ′ 1 , . . . , x n /x ′ n ], which enforces the same rela tion as c , but on x ′ 1 . . . x ′ n . Finally , we have n view c onstra ints c ϕ,i , e a ch equiv alent to the rela tion ϕ i ( x i ) = x ′ i . The solutions of the deco mpo sition mo del, restricted to the x 1 . . . x n , are exactly the solutions of the or iginal view-ba sed mo del. Example. Assume the equality constraint c ≡ ( x = y ). In order to propag a te c ′ ≡ ( x = y + 1 ), we could use a domain complete propaga to r p for c and a view ϕ with ϕ x ( v ) = v , ϕ y ( v ) = v + 1. The a lternative mo del would b e defined with additional v a riables x ′ and y ′ , a view constraint c ϕ,x for x ′ = x , a view constraint c ϕ,y for y ′ − 1 = y , and c [ x/x ′ , y /y ′ ], yielding x ′ = y ′ .  Every view constr aint c ϕ,i shares exac tly one v ariable with c and no v ariable with any other c ϕ,i . Thus, the constr a int graph is Berge- acyclic, and we c a n r each a fixpo in t by first propaga ting all the c ϕ,i , then pro pagating c [ x 1 /x ′ 1 , . . . , x n /x ′ n ], and then ag a in propagating the c ϕ,i . This is exac tly what ϕ − ◦ p ◦ ϕ do es. In this sense, vie w s ca n be seen as a way for sp ecifying a p erfe ct or der of pr op aga t ion , which is usua lly not p oss ible in constr a int progr amming systems. If b ϕ ( p ) is domain complete for ϕ − ( c ), then it achieves p ath c onsistency for c [ x 1 /x ′ 1 , . . . , x n /x ′ n ] and all the c ϕ,i in the dec ompo sition mo del. 13 8 Limitations Although vie ws are widely applicable, they ar e no silver bullet. This section explores s ome limitations of the presented architecture. Bey ond injective views . Views as defined in this paper a re required to b e injectiv e. This excludes some interesting views, such as a view for the abso lute v alue o f a v ariable , or a view of a v ariable modulo some consta n t. None of the basic pro ofs mak es use of injectivit y , so non-injective views ca n b e used to derive (bo unds) co mplete, c orrect pr o pagator s. How ever, even t ha ndling changes w he n v iews ar e not injective: – A domain change even t on a v ariable do es not necessar ily translate to a domain change even t on the view. F or instance, given a do main d with d ( x ) = {− 1 , 0 , 1 } , removing the v alue − 1 from x is a domain change event on x , but not on a bs( x ). – A domain c hang e even t on a v aria ble may result in a v alue even t o n the view. F o r instance, removing 0 instead of − 1 in the ab ov e example results in d ( x ) = {− 1 , 1 } , but in abs( x ) there is only a single v alue left. These effects may lea d to unnece s sary pro pagtor inv o cations, o r even to in- correct b ehavior if a propaga tor relies on the accuracy of the rep or ted even t. As propaga tors in Geco de may assume that even ts are crisp in this sense , we decided not to a llow non-injective v iews. Multi-v ariable views. S o me multi-v a riable views that see m interesting for practical applications do not prese r ve co n tra ction, for instance a view o n the sum or pro duct of t wo v ariables. The re ason is that r emoving a v alue through the view would hav e to result in removing a tuple o f v alues from the a ctual domain. As domains can only repr esent ca r tesian pro ducts, this is no t p ossible in general. F or views that do not preserve contraction, Theorem 7 does not hold. That means that a propa gator p canno t e a sily detect subsumption any longer , as it would hav e to detect it for b ϕ ( p ) instead of just for itse lf, p . In Geco de, propaga tors re p or t whether they ar e subsumed, so that they a re not co ns idered for propagation ag ain. This optimization is vital for p erformance, so we only allow contraction-preserv ing v iews. F or contraction-preser v ing views o n mult iple v ariables, all our theo r ems still hold. Some us eful vie ws we could identify ar e – A set view of Bo olea n v ariables [ b 1 , . . . , b n ], b ehaving like { i | b i = 1 } . – An integer vie w of Bo olean v ariables [ b 1 , . . . , b n ], where b i is 1 iff the integer has v alue i . – The inv er s e views of the t wo views ab ov e. These vie ws are of limited use, and the de c o mpo sition appr oach will probably work just as well in these cases . 14 T able 2. Ap plicabilit y of views: number of generic v s. derived propagators V ariable typ e Generic pr op agators Derive d pr op agators R atio Integer 69 230 3.34 Boolean 23 72 3.13 Set 24 114 4.75 Over al l 116 416 3.59 Propagator inv arian ts. Propagator s typically rely on certa in inv aria n ts of a v ariable domain implementation. If idempotence or completenes s of a propa gator depe nd on these inv ariants, channeling views lead to problems, as the actual v ariable implementation b ehind the view may not resp ect the same inv aria n ts. F or exa mple, a propagato r for interv al-based finite set v ariables can assume that adjusting the low er b ound of a v ariable do es not affect its uppe r bo und. If this propa gator is instantiated with a channeling view for an ROBDD-based set v ariable, this inv ar iant is vio lated: if, fo r instance, the current domain is {{ 1 , 2 } , { 3 }} , and you add 1 to the low er b ound, the 3 is remov ed from the upper b ound (in addition to 2 b eing added to the low er b ound). A propag ator that relies on the inv ariant may lose idempo tence. 9 Exp erimen ts Our exp eriments in [1 2 ] show ed that der iving propaga tors using view s incurs no runtime ov erhead. Here, we present empirical evidence for tw o mor e facts: views are highly applicable in rea l-world c onstraint prog ramming systems, and they are clearly s uper ior to a decomp osition- based appro a ch. Applicability . The Geco de C ++ library [5 ] makes heavy us e o f views. T able 2 shows the num b er of generic propaga tors implemen ted in Geco de, and the num- ber of derived instances. On av era ge, every generic pro pa gator results in 3.5 9 propaga tor instances. P ropaga tors in Geco de account for mor e than 40 0 00 lines of code and do cumentation. As a r ough e s timate, g eneric propa gators with views sav e ar ound 100 000 lines of co de and do cument a tion to b e written, tested, a nd maintained. O n the other hand, the views are implement ed in less than 8 000 lines of co de, y ielding a 125 0% return on inv estment. Views vs. decom p ositio n. In or der to relate derived pro pagator s to arc a nd path cons istency , Sect. 7 deco mpo s ed a der ived propa gator b ϕ ( p ) into additional v ariables and propa gators for the individua l ϕ x and p . Of course, one has to a sk why we advertise v ariable views instead of alwa ys using decomp osition. T able 3 shows the runtime and s pace requirements of several b enchmarks implemen ted in Geco de. The num b ers w er e obtained on a Intel Pentium IV at 2.8 GHz r unning Linux and Geco de 2.1.1. The fig ures illustr ate that derived pro pagator s clearly outp e rform the dec o mpo sition, b oth in runtime and space. 15 T able 3. Ru ntime and space comparison: derived propagators vs. decomp osition Benchmark derive d de c omp ose d time (ms) sp ac e (kB) r elative tim e (%) r elative sp ac e (%) Alpha 91.25 83.22 405.62 167.32 Eq-20 1.37 70.03 613.61 219.95 Queens 100 24.72 2 110.00 705.10 103.03 Golf 8-4-9 310.40 10 502.00 211.47 231.64 Steiner trip les 9 135.7 2 957.03 108.38 100.03 10 Conclusion and F uture W or k The pap er ha s developed v ariable views as a technique to derive perfect prop- agator v ariants. Suc h v aria nt s ar e ubiquitous, and the pap er has shown ho w to systema tically derive propa gators using techniques such as transformation, generaliza tion, sp ecialization, and channeling. W e ha ve presented a model of view s that allow ed us to prove that derived propaga tors a re indeed p erfect: they inherit corr e ctness and domain complete- ness from their origina l propagator , a nd preser ve b ounds completeness g iven additional prop erties of vie w s . As witnessed by the empirical ev aluation, deriving propa gators sav es h ug e amounts of code to b e written and maintained in practice, a nd is clearly superior to decomp osing co nstraints into a dditional v aria bles and simple propaga tors. F or future work, it will b e interesting to inv estigate how views can b e gener - alized, e ven if that means that derived propag ators are not pe r fect any mo re. Ac kno wledg emen ts. W e thank Mik a e l Lagerkvis t and Gert Smolk a for fruitful discussions ab out v iews and helpful comments on a draft of this pap er. References 1. K. Apt. Pri nciples of Constr aint Pr o gr am m ing . Cambridge Un ive rsity Press, 2003. 2. F. Benhamou. Heterogeneous Constrain t Solving. In Pr o c e e di ngs of the fif th Inter- national Confer enc e on Algebr aic and L o gic Pr o gr amming (ALP’96) , volume 1139 of LNCS , p ages 62–76. Springer, 1996. 3. M. Carlsson, G. Ottosson, and B. Carlson. An op en-en ded finite domain constraint solv er. In H. Glaser, P . H. Hartel, and H. K u chen, editors, Pr o gr amming L anguages: Implementations, L o gics, and Pr o gr ams, 9th International Symp osium, PLILP’ 97 , vol u me 1292 of LNCS , pages 191–206, S outhampton, U K, 1997. Springer. 4. C. W. Choi, W. Harvey , J. H. M. Lee, and P . J. Stu c key . Finite d omain b ounds consistency revisited. In A. Sattar and B.-H. K an g, editors, AI 2006: A dvanc es i n Ar tificial Intel ligenc e , volume 4304 of LNCS , pages 49–58. Springer, 2006. 5. Gecode: Generic constrai nt develo pment environment, 2008. Av ailable as an open- source library from www.gecode.org . 6. I. P . Gen t, C. Jefferso n, and I. Miguel. W atc hed literals fo r constrain t propagation in Minion. In F. Benhamou, editor, Twelfth International Confer enc e on Pri nci ples 16 and Pr actic e of Constr aint Pr o gr amming , v olume 4204 of LNCS , pages 182–197, Nantes, F rance, 2006. Sp rin ger. 7. C. Gervet. Interv al propagation to reason ab out sets: Definition and implementa- tion of a p ractical language. Constr aints , 1(3):191–244 , 1997. 8. P . Hawkins, V. Lagoon, and P . Stuck ey . Solving set constraint satisfaction problems using ROBDDs. J. Art if . I ntel l. R es. (JAIR ) , 24:109–1 56, 2005. 9. M. J. Maher. Propagation completeness of reactive constraints. In ICLP ’02: Pr o c e e dings of the 18th International Conf er enc e on L o gic Pr o gr amming , volume 2401 of LNCS , pages 148–162 , London, UK, 2002. Sp ringer. 10. J.-F. Pu get and M. Leconte. Beyond th e glass b ox: Constraints as ob jects. In J. Llo y d , ed itor, Pr o c e e dings of the International Symp osium on L o gic Pr o gr am- ming , p ages 513–527 , Portland, OR, U SA, D ec. 1995. The MIT Press. 11. C. Sch ulte and P . J. Stuckey . Efficien t constraint propagation engines. T r ansactions on Pr o gr amming L anguages and Systems , 2008. T o app ear. 12. C. Sc hulte and G. T ack. V iews and iterators for generic constraint implementa tions. In Re c ent A dvanc es in Constr ai nts (2005) , volume 3978 of LNAI , pages 118–132. Springer, 2006. 13. P . V an H entenryc k, V. Sarasw at, and Y. Dev ille. Design, implemen tation, and ev aluation of the constraint language cc(FD). The Journal of L o gic Pr o gr amming , 37(1–3):13 9–164, Oct. 1998. 17

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment