overload.hpp /usr/include/gecode/int/unary.hh Gecode Gecode::Int Gecode::Int::Unary /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> * *Copyright: *ChristianSchulte,2009 * *Lastmodified: *$Date:2012-09-0717:31:22+0200(Fri,07Sep2012)$by$Author:schulte$ *$Revision:13068$ * *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{namespaceUnary{ //Overloadcheckingformandatorytasks template<classManTask> ExecStatus overload(Space&home,TaskArray<ManTask>&t){ TaskViewArray<typename TaskTraits<ManTask>::TaskViewFwd>f(t); sort<typenameTaskTraits<ManTask>::TaskViewFwd,STO_LCT,true>(f); Regionr(home); OmegaTree<typename TaskTraits<ManTask>::TaskViewFwd>o(r,f); for(inti=0;i<f.size();i++){ o.insert(i); if(o.ect()>f[i].lct()) returnES_FAILED; } returnES_OK; } //Overloadcheckingforoptionaltasks template<classOptTask> ExecStatus overload(Space&home,Propagator&p,TaskArray<OptTask>&t){ TaskViewArray<typename TaskTraits<OptTask>::TaskViewFwd>f(t); sort<typenameTaskTraits<OptTask>::TaskViewFwd,STO_LCT,true>(f); Regionr(home); OmegaLambdaTree<typename TaskTraits<OptTask>::TaskViewFwd>ol(r,f,false); boolto_purge=false; for(inti=0;i<f.size();i++){ if(f[i].optional()){ ol.linsert(i); }elseif(f[i].mandatory()){ ol.oinsert(i); if(ol.ect()>f[i].lct()) returnES_FAILED; } while(!ol.lempty()&&(ol.lect()>f[i].lct())){ intj=ol.responsible(); GECODE_ME_CHECK(f[j].excluded(home)); ol.lremove(j); to_purge=true; } } if(to_purge) GECODE_ES_CHECK((purge<OptTask,Int::PC_INT_BND>(home,p,t))); returnES_OK; } }}} //STATISTICS:int-prop