dim.hpp /usr/include/gecode/int/no-overlap.hh Gecode Gecode::Int Gecode::Int::NoOverlap /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> * *Copyright: *ChristianSchulte,2011 * *Lastmodified: *$Date:2011-07-1318:55:08+0200(Wed,13Jul2011)$by$Author:schulte$ *$Revision:12194$ * *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{namespaceNoOverlap{ /* *Dimensionwithintegersize * */ forceinline FixDim::FixDim(void) :s(0){} forceinline FixDim::FixDim(IntViewc0,ints0) :c(c0),s(s0){} forceinlineint FixDim::ssc(void)const{ returnc.min(); } forceinlineint FixDim::lsc(void)const{ returnc.max(); } forceinlineint FixDim::sec(void)const{ returnc.min()+s; } forceinlineint FixDim::lec(void)const{ returnc.max()+s; } forceinlineExecStatus FixDim::ssc(Space&home,intn){ GECODE_ME_CHECK(c.gq(home,n)); returnES_OK; } forceinlineExecStatus FixDim::lec(Space&home,intn){ GECODE_ME_CHECK(c.lq(home,n-s)); returnES_OK; } forceinlineExecStatus FixDim::nooverlap(Space&home,intn,intm){ if(n<=m){ Iter::Ranges::Singletonr(n-s+1,m); GECODE_ME_CHECK(c.minus_r(home,r,false)); } returnES_OK; } forceinlineExecStatus FixDim::nooverlap(Space&home,FixDim&d){ if(d.sec()>lsc()){ //Propagatethatdmustbeafterthis GECODE_ES_CHECK(lec(home,d.lsc())); GECODE_ES_CHECK(d.ssc(home,sec())); }else{ nooverlap(home,d.lsc(),d.sec()-1); } returnES_OK; } forceinlinevoid FixDim::update(Space&home,boolshare,FixDim&d){ c.update(home,share,d.c); s=d.s; } forceinlinevoid FixDim::subscribe(Space&home,Propagator&p){ c.subscribe(home,p,PC_INT_DOM); } forceinlinevoid FixDim::cancel(Space&home,Propagator&p){ c.cancel(home,p,PC_INT_DOM); } /* *Dimensionwithintegerviewsize * */ forceinline FlexDim::FlexDim(void){} forceinline FlexDim::FlexDim(IntViewc00,IntViews0,IntViewc10) :c0(c00),s(s0),c1(c10){} forceinlineint FlexDim::ssc(void)const{ returnc0.min(); } forceinlineint FlexDim::lsc(void)const{ returnc0.max(); } forceinlineint FlexDim::sec(void)const{ returnc1.min(); } forceinlineint FlexDim::lec(void)const{ returnc1.max(); } forceinlineExecStatus FlexDim::ssc(Space&home,intn){ GECODE_ME_CHECK(c0.gq(home,n)); returnES_OK; } forceinlineExecStatus FlexDim::lec(Space&home,intn){ GECODE_ME_CHECK(c1.lq(home,n)); returnES_OK; } forceinlineExecStatus FlexDim::nooverlap(Space&home,intn,intm){ if(n<=m){ Iter::Ranges::Singletonr0(n-s.min()+1,m); GECODE_ME_CHECK(c0.minus_r(home,r0,false)); Iter::Ranges::Singletonr1(n+1,s.min()+m); GECODE_ME_CHECK(c1.minus_r(home,r1,false)); } returnES_OK; } forceinlineExecStatus FlexDim::nooverlap(Space&home,FlexDim&d){ if(d.sec()>lsc()){ //Propagatethatdmustbeafterthis GECODE_ES_CHECK(lec(home,d.lsc())); GECODE_ES_CHECK(d.ssc(home,sec())); }else{ nooverlap(home,d.lsc(),d.sec()-1); } returnES_OK; } forceinlinevoid FlexDim::update(Space&home,boolshare,FlexDim&d){ c0.update(home,share,d.c0); s.update(home,share,d.s); c1.update(home,share,d.c1); } forceinlinevoid FlexDim::subscribe(Space&home,Propagator&p){ c0.subscribe(home,p,PC_INT_DOM); s.subscribe(home,p,PC_INT_BND); c1.subscribe(home,p,PC_INT_DOM); } forceinlinevoid FlexDim::cancel(Space&home,Propagator&p){ c0.cancel(home,p,PC_INT_DOM); s.cancel(home,p,PC_INT_BND); c1.cancel(home,p,PC_INT_DOM); } }}} //STATISTICS:int-prop