ter-dom.hpp /usr/include/gecode/int/distinct.hh Gecode Gecode::Int Gecode::Int::Distinct GECODE_INT_HALL_ONE x0 x1 x2 if (x0.assigned()) { \ GECODE_ME_CHECK(x1.nq(home,x0.val())); \ GECODE_ME_CHECK(x2.nq(home,x0.val())); \ if (x1.assigned()) { \ GECODE_ME_CHECK(x2.nq(home,x1.val())); \ return home.ES_SUBSUMED(*this); \ } \ if (x2.assigned()) { \ GECODE_ME_CHECK(x1.nq(home,x2.val())); \ return home.ES_SUBSUMED(*this); \ } \ return ES_FIX; \ } Check whether x0 forms a Hall set of cardinality one. GECODE_INT_HALL_TWO x0 x1 x2 if ((x0.size() == 2) && (x1.size() == 2) && \ (x0.min() == x1.min()) && (x0.max() == x1.max())) { \ GECODE_ME_CHECK(x2.nq(home,x0.min())); \ GECODE_ME_CHECK(x2.nq(home,x0.max())); \ return ES_FIX; \ } Check whether x0 and x1 form a Hall set of cardinality two. /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> * *Copyright: *ChristianSchulte,2003 * *Lastmodified: *$Date:2010-03-0317:32:21+0100(Wed,03Mar2010)$by$Author:schulte$ *$Revision:10364$ * *ThisfileispartofGecode,thegenericconstraint *developmentenvironment: *http://www.gecode.org * *Permissionisherebygranted,freeofcharge,toanypersonobtaining *acopyofthissoftwareandassociateddocumentationfiles(the *"Software"),todealintheSoftwarewithoutrestriction,including *withoutlimitationtherightstouse,copy,modify,merge,publish, *distribute,sublicense,and/orsellcopiesoftheSoftware,andto *permitpersonstowhomtheSoftwareisfurnishedtodoso,subjectto *thefollowingconditions: * *Theabovecopyrightnoticeandthispermissionnoticeshallbe *includedinallcopiesorsubstantialportionsoftheSoftware. * *THESOFTWAREISPROVIDED"ASIS",WITHOUTWARRANTYOFANYKIND, *EXPRESSORIMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOF *MERCHANTABILITY,FITNESSFORAPARTICULARPURPOSEAND *NONINFRINGEMENT.INNOEVENTSHALLTHEAUTHORSORCOPYRIGHTHOLDERSBE *LIABLEFORANYCLAIM,DAMAGESOROTHERLIABILITY,WHETHERINANACTION *OFCONTRACT,TORTOROTHERWISE,ARISINGFROM,OUTOFORINCONNECTION *WITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHESOFTWARE. * */ namespaceGecode{namespaceInt{namespaceDistinct{ /* *Ternarydomainconsistentdistinct * */ template<classView> forceinline TerDom<View>::TerDom(Homehome,Viewx0,Viewx1,Viewx2) :TernaryPropagator<View,PC_INT_DOM>(home,x0,x1,x2){} template<classView> ExecStatus TerDom<View>::post(Homehome,Viewx0,Viewx1,Viewx2){ (void)new(home)TerDom<View>(home,x0,x1,x2); returnES_OK; } template<classView> forceinline TerDom<View>::TerDom(Space&home,boolshare,TerDom<View>&p) :TernaryPropagator<View,PC_INT_DOM>(home,share,p){} template<classView> Actor* TerDom<View>::copy(Space&home,boolshare){ returnnew(home)TerDom<View>(home,share,*this); } #defineGECODE_INT_HALL_ONE(x0,x1,x2)\ if(x0.assigned()){\ GECODE_ME_CHECK(x1.nq(home,x0.val()));\ GECODE_ME_CHECK(x2.nq(home,x0.val()));\ if(x1.assigned()){\ GECODE_ME_CHECK(x2.nq(home,x1.val()));\ returnhome.ES_SUBSUMED(*this);\ }\ if(x2.assigned()){\ GECODE_ME_CHECK(x1.nq(home,x2.val()));\ returnhome.ES_SUBSUMED(*this);\ }\ returnES_FIX;\ } #defineGECODE_INT_HALL_TWO(x0,x1,x2)\ if((x0.size()==2)&&(x1.size()==2)&&\ (x0.min()==x1.min())&&(x0.max()==x1.max())){\ GECODE_ME_CHECK(x2.nq(home,x0.min()));\ GECODE_ME_CHECK(x2.nq(home,x0.max()));\ returnES_FIX;\ } template<classView> ExecStatus TerDom<View>::propagate(Space&home,constModEventDelta&){ GECODE_INT_HALL_ONE(x0,x1,x2); GECODE_INT_HALL_ONE(x1,x0,x2); GECODE_INT_HALL_ONE(x2,x0,x1); GECODE_INT_HALL_TWO(x0,x1,x2); GECODE_INT_HALL_TWO(x0,x2,x1); GECODE_INT_HALL_TWO(x1,x2,x0); returnES_FIX; } #undefGECODE_INT_HALL_ONE #undefGECODE_INT_HALL_TWO }}} //STATISTICS:int-prop