task.hpp /usr/include/gecode/int/cumulative.hh Gecode Gecode::Int Gecode::Int::Cumulative /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> *GuidoTack<tack@gecode.org> * *Copyright: *ChristianSchulte,2009 *GuidoTack,2010 * *Lastmodified: *$Date:2013-03-1106:26:07+0100(Mon,11Mar2013)$by$Author:tack$ *$Revision:13487$ * *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{namespaceCumulative{ /* *Mandatoryfixedtask */ forceinline ManFixPTask::ManFixPTask(void){} forceinline ManFixPTask::ManFixPTask(IntVars,intp,intc) :Unary::ManFixPTask(s,p),_c(c){} forceinlinevoid ManFixPTask::init(IntVars,intp,intc){ Unary::ManFixPTask::init(s,p);_c=c; } forceinlinevoid ManFixPTask::init(constManFixPTask&t){ Unary::ManFixPTask::init(t);_c=t._c; } forceinlineint ManFixPTask::c(void)const{ return_c; } forceinlinelonglongint ManFixPTask::e(void)const{ returnstatic_cast<longlongint>(pmin())*c(); } forceinlinevoid ManFixPTask::update(Space&home,boolshare,ManFixPTask&t){ Unary::ManFixPTask::update(home,share,t);_c=t._c; } template<classChar,classTraits> std::basic_ostream<Char,Traits>& operator<<(std::basic_ostream<Char,Traits>&os,constManFixPTask&t){ std::basic_ostringstream<Char,Traits>s; s.copyfmt(os);s.width(0); s<<t.est()<<":["<<t.pmin()<<','<<t.c()<<"]:"<<t.lct(); returnos<<s.str(); } /* *Mandatoryfixedtaskwithfixedprocessing,startorendtime */ forceinline ManFixPSETask::ManFixPSETask(void){} forceinline ManFixPSETask::ManFixPSETask(TaskTypet,IntVars,intp,intc) :Unary::ManFixPSETask(t,s,p),_c(c){} forceinlinevoid ManFixPSETask::init(TaskTypet,IntVars,intp,intc){ Unary::ManFixPSETask::init(t,s,p);_c=c; } forceinlinevoid ManFixPSETask::init(constManFixPSETask&t0){ Unary::ManFixPSETask::init(t0);_c=t0._c; } forceinlineint ManFixPSETask::c(void)const{ return_c; } forceinlinelonglongint ManFixPSETask::e(void)const{ returnstatic_cast<longlongint>(pmin())*c(); } forceinlinevoid ManFixPSETask::update(Space&home,boolshare,ManFixPSETask&t){ Unary::ManFixPSETask::update(home,share,t);_c=t._c; } template<classChar,classTraits> std::basic_ostream<Char,Traits>& operator<<(std::basic_ostream<Char,Traits>&os,constManFixPSETask&t){ std::basic_ostringstream<Char,Traits>s; s.copyfmt(os);s.width(0); s<<t.est()<<":["<<t.pmin()<<','<<t.c()<<"]:"<<t.lct(); returnos<<s.str(); } /* *Mandatoryflexibletask */ forceinline ManFlexTask::ManFlexTask(void){} forceinline ManFlexTask::ManFlexTask(IntVars,IntVarp,IntVare,intc) :Unary::ManFlexTask(s,p,e),_c(c){} forceinlinevoid ManFlexTask::init(IntVars,IntVarp,IntVare,intc){ Unary::ManFlexTask::init(s,p,e);_c=c; } forceinlinevoid ManFlexTask::init(constManFlexTask&t){ Unary::ManFlexTask::init(t);_c=t._c; } forceinlineint ManFlexTask::c(void)const{ return_c; } forceinlinelonglongint ManFlexTask::e(void)const{ returnstatic_cast<longlongint>(pmin())*c(); } forceinlinevoid ManFlexTask::update(Space&home,boolshare,ManFlexTask&t){ Unary::ManFlexTask::update(home,share,t);_c=t._c; } template<classChar,classTraits> std::basic_ostream<Char,Traits>& operator<<(std::basic_ostream<Char,Traits>&os,constManFlexTask&t){ std::basic_ostringstream<Char,Traits>s; s.copyfmt(os);s.width(0); s<<t.est()<<':'<<t.lst()<<':'<<t.pmin()<<':' <<t.pmax()<<':'<<t.c()<<':'<<t.ect()<<':'<<t.lct(); returnos<<s.str(); } /* *Optionalfixedtask */ forceinline OptFixPTask::OptFixPTask(void){} forceinline OptFixPTask::OptFixPTask(IntVars,intp,intc,BoolVarm){ ManFixPTask::init(s,p,c);_m=m; } forceinlinevoid OptFixPTask::init(IntVars,intp,intc,BoolVarm){ ManFixPTask::init(s,p,c);_m=m; } forceinline OptFixPTask::operatorUnary::OptFixPTask(void){ returnUnary::OptFixPTask(_s,_p,_m); } template<classChar,classTraits> std::basic_ostream<Char,Traits>& operator<<(std::basic_ostream<Char,Traits>&os,constOptFixPTask&t){ std::basic_ostringstream<Char,Traits>s; s.copyfmt(os);s.width(0); s<<t.est()<<":["<<t.pmin()<<','<<t.c()<<"]:"<<t.lct()<<':' <<(t.mandatory()?'1':(t.optional()?'?':'0')); returnos<<s.str(); } /* *Optionalfixedtask */ forceinline OptFixPSETask::OptFixPSETask(void){} forceinline OptFixPSETask::OptFixPSETask(TaskTypet,IntVars,intp,intc,BoolVarm){ ManFixPSETask::init(t,s,p,c);_m=m; } forceinlinevoid OptFixPSETask::init(TaskTypet,IntVars,intp,intc,BoolVarm){ ManFixPSETask::init(t,s,p,c);_m=m; } forceinline OptFixPSETask::operatorUnary::OptFixPSETask(void){ returnUnary::OptFixPSETask(_t,_s,_p,_m); } template<classChar,classTraits> std::basic_ostream<Char,Traits>& operator<<(std::basic_ostream<Char,Traits>&os,constOptFixPSETask&t){ std::basic_ostringstream<Char,Traits>s; s.copyfmt(os);s.width(0); s<<t.est()<<":["<<t.pmin()<<','<<t.c()<<"]:"<<t.lct()<<':' <<(t.mandatory()?'1':(t.optional()?'?':'0')); returnos<<s.str(); } /* *Optionalflexibletask */ forceinline OptFlexTask::OptFlexTask(void){} forceinline OptFlexTask::OptFlexTask(IntVars,IntVarp,IntVare,intc,BoolVarm){ ManFlexTask::init(s,p,e,c);_m=m; } forceinlinevoid OptFlexTask::init(IntVars,IntVarp,IntVare,intc,BoolVarm){ ManFlexTask::init(s,p,e,c);_m=m; } forceinline OptFlexTask::operatorUnary::OptFlexTask(void){ returnUnary::OptFlexTask(_s,_p,_e,_m); } template<classChar,classTraits> std::basic_ostream<Char,Traits>& operator<<(std::basic_ostream<Char,Traits>&os,constOptFlexTask&t){ std::basic_ostringstream<Char,Traits>s; s.copyfmt(os);s.width(0); s<<t.est()<<':'<<t.lst()<<':'<<t.pmin()<<':' <<t.pmax()<<':'<<t.c()<<':'<<t.ect()<<':'<<t.lct() <<(t.mandatory()?'1':(t.optional()?'?':'0')); returnos<<s.str(); } }}} //STATISTICS:int-var