view-eq.hpp /usr/include/gecode/int/count.hh Gecode Gecode::Int Gecode::Int::Count /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> * *Copyright: *ChristianSchulte,2003 * *Lastmodified: *$Date:2011-09-2013:58:39+0200(Tue,20Sep2011)$by$Author:schulte$ *$Revision:12404$ * *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{namespaceCount{ template<classVX,classVY,classVZ,boolshr,booldom> forceinline EqView<VX,VY,VZ,shr,dom>::EqView(Homehome, ViewArray<VX>&x,VYy,VZz,intc) :ViewBase<VX,VY,VZ>(home,x,y,z,c){} template<classVX,classVY,classVZ,boolshr,booldom> ExecStatus EqView<VX,VY,VZ,shr,dom>::post(Homehome, ViewArray<VX>&x,VYy,VZz,intc){ GECODE_ME_CHECK(z.gq(home,-c)); GECODE_ME_CHECK(z.lq(home,x.size()-c)); if((vtd(y)!=VTD_VARVIEW)&&z.assigned()) returnEqInt<VX,VY>::post(home,x,y,z.val()+c); if(sharing(x,y,z)) (void)new(home)EqView<VX,VY,VZ,true,dom>(home,x,y,z,c); else (void)new(home)EqView<VX,VY,VZ,false,dom>(home,x,y,z,c); returnES_OK; } template<classVX,classVY,classVZ,boolshr,booldom> forceinline EqView<VX,VY,VZ,shr,dom>::EqView(Space&home,boolshare, EqView<VX,VY,VZ,shr,dom>&p) :ViewBase<VX,VY,VZ>(home,share,p){} template<classVX,classVY,classVZ,boolshr,booldom> Actor* EqView<VX,VY,VZ,shr,dom>::copy(Space&home,boolshare){ returnnew(home)EqView<VX,VY,VZ,shr,dom>(home,share,*this); } template<classVX,classVY,classVZ,boolshr,booldom> ExecStatus EqView<VX,VY,VZ,shr,dom>::propagate(Space&home,constModEventDelta&){ count(home); GECODE_ME_CHECK(z.gq(home,atleast())); GECODE_ME_CHECK(z.lq(home,atmost())); if(z.assigned()){ if(z.val()==atleast()){ GECODE_ES_CHECK(post_false(home,x,y)); returnhome.ES_SUBSUMED(*this); } if(z.val()==atmost()){ GECODE_ES_CHECK(post_true(home,x,y)); returnhome.ES_SUBSUMED(*this); } if(!dom||(vtd(y)!=VTD_VARVIEW)){ VYyc(y); GECODE_REWRITE(*this,(EqInt<VX,VY> ::post(home(*this),x,yc,z.val()+c))); } } if(dom&&(vtd(y)==VTD_VARVIEW)&&(z.min()>0)){ /* *Onlyifthepropagatorisatfixpointhere,continue *whenthingsareshared:thereasonisthatprune *requiresthattheviewsinxoverlapwithy! */ if(shr&&(VX::me(Propagator::modeventdelta())!=ME_INT_NONE)) returnES_NOFIX; GECODE_ES_CHECK(prune(home,x,y)); returnES_NOFIX; } returnshr?ES_NOFIX:ES_FIX; } }}} //STATISTICS:int-prop