Generated on Thu Apr 11 13:59:06 2019 for Gecode by doxygen 1.6.3

task.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Guido Tack <tack@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Christian Schulte, 2009
00009  *     Guido Tack, 2010
00010  *
00011  *  This file is part of Gecode, the generic constraint
00012  *  development environment:
00013  *     http://www.gecode.org
00014  *
00015  *  Permission is hereby granted, free of charge, to any person obtaining
00016  *  a copy of this software and associated documentation files (the
00017  *  "Software"), to deal in the Software without restriction, including
00018  *  without limitation the rights to use, copy, modify, merge, publish,
00019  *  distribute, sublicense, and/or sell copies of the Software, and to
00020  *  permit persons to whom the Software is furnished to do so, subject to
00021  *  the following conditions:
00022  *
00023  *  The above copyright notice and this permission notice shall be
00024  *  included in all copies or substantial portions of the Software.
00025  *
00026  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00027  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00028  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00029  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00030  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00031  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00032  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00033  *
00034  */
00035 
00036 namespace Gecode { namespace Int { namespace Cumulative {
00037 
00038   /*
00039    * Mandatory fixed task
00040    */
00041 
00042   forceinline
00043   ManFixPTask::ManFixPTask(void) {}
00044   forceinline
00045   ManFixPTask::ManFixPTask(IntVar s, int p, int c)
00046     : Unary::ManFixPTask(s,p), _c(c) {}
00047   forceinline void
00048   ManFixPTask::init(IntVar s, int p, int c) {
00049     Unary::ManFixPTask::init(s,p); _c=c;
00050   }
00051   forceinline void
00052   ManFixPTask::init(const ManFixPTask& t) {
00053     Unary::ManFixPTask::init(t); _c=t._c;
00054   }
00055 
00056   forceinline int
00057   ManFixPTask::c(void) const {
00058     return _c;
00059   }
00060   forceinline long long int
00061   ManFixPTask::e(void) const {
00062     return static_cast<long long int>(pmin())*c();
00063   }
00064 
00065   forceinline void
00066   ManFixPTask::update(Space& home, ManFixPTask& t) {
00067     Unary::ManFixPTask::update(home,t); _c=t._c;
00068   }
00069 
00070   template<class Char, class Traits>
00071   std::basic_ostream<Char,Traits>&
00072   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t) {
00073     std::basic_ostringstream<Char,Traits> s;
00074     s.copyfmt(os); s.width(0);
00075     s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct();
00076     return os << s.str();
00077   }
00078 
00079   /*
00080    * Mandatory fixed task with fixed processing, start or end time
00081    */
00082 
00083   forceinline
00084   ManFixPSETask::ManFixPSETask(void) {}
00085   forceinline
00086   ManFixPSETask::ManFixPSETask(TaskType t, IntVar s, int p, int c)
00087     : Unary::ManFixPSETask(t,s,p), _c(c) {}
00088   forceinline void
00089   ManFixPSETask::init(TaskType t, IntVar s, int p, int c) {
00090     Unary::ManFixPSETask::init(t,s,p); _c=c;
00091   }
00092   forceinline void
00093   ManFixPSETask::init(const ManFixPSETask& t0) {
00094     Unary::ManFixPSETask::init(t0); _c=t0._c;
00095   }
00096 
00097   forceinline int
00098   ManFixPSETask::c(void) const {
00099     return _c;
00100   }
00101   forceinline long long int
00102   ManFixPSETask::e(void) const {
00103     return static_cast<long long int>(pmin())*c();
00104   }
00105 
00106   forceinline void
00107   ManFixPSETask::update(Space& home, ManFixPSETask& t) {
00108     Unary::ManFixPSETask::update(home,t); _c=t._c;
00109   }
00110 
00111   template<class Char, class Traits>
00112   std::basic_ostream<Char,Traits>&
00113   operator <<(std::basic_ostream<Char,Traits>& os,const ManFixPSETask& t) {
00114     std::basic_ostringstream<Char,Traits> s;
00115     s.copyfmt(os); s.width(0);
00116     s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct();
00117     return os << s.str();
00118   }
00119 
00120   /*
00121    * Mandatory flexible task
00122    */
00123 
00124   forceinline
00125   ManFlexTask::ManFlexTask(void) {}
00126   forceinline
00127   ManFlexTask::ManFlexTask(IntVar s, IntVar p, IntVar e, int c)
00128     : Unary::ManFlexTask(s,p,e), _c(c) {}
00129   forceinline void
00130   ManFlexTask::init(IntVar s, IntVar p, IntVar e, int c) {
00131     Unary::ManFlexTask::init(s,p,e); _c=c;
00132   }
00133   forceinline void
00134   ManFlexTask::init(const ManFlexTask& t) {
00135     Unary::ManFlexTask::init(t); _c=t._c;
00136   }
00137 
00138   forceinline int
00139   ManFlexTask::c(void) const {
00140     return _c;
00141   }
00142   forceinline long long int
00143   ManFlexTask::e(void) const {
00144     return static_cast<long long int>(pmin())*c();
00145   }
00146 
00147   forceinline void
00148   ManFlexTask::update(Space& home, ManFlexTask& t) {
00149     Unary::ManFlexTask::update(home,t); _c=t._c;
00150   }
00151 
00152   template<class Char, class Traits>
00153   std::basic_ostream<Char,Traits>&
00154   operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t) {
00155     std::basic_ostringstream<Char,Traits> s;
00156     s.copyfmt(os); s.width(0);
00157     s << t.est() << ':' << t.lst() << ':' << t.pmin() << ':'
00158       << t.pmax() << ':' << t.c() << ':' << t.ect() << ':' << t.lct();
00159     return os << s.str();
00160   }
00161 
00162   /*
00163    * Optional fixed task
00164    */
00165 
00166   forceinline
00167   OptFixPTask::OptFixPTask(void) {}
00168   forceinline
00169   OptFixPTask::OptFixPTask(IntVar s, int p, int c, BoolVar m) {
00170     ManFixPTask::init(s,p,c); _m=m;
00171   }
00172   forceinline void
00173   OptFixPTask::init(IntVar s, int p, int c, BoolVar m) {
00174     ManFixPTask::init(s,p,c); _m=m;
00175   }
00176   forceinline
00177   OptFixPTask::operator Unary::OptFixPTask (void) {
00178     return Unary::OptFixPTask(_s,_p,_m);
00179   }
00180 
00181   template<class Char, class Traits>
00182   std::basic_ostream<Char,Traits>&
00183   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t) {
00184     std::basic_ostringstream<Char,Traits> s;
00185     s.copyfmt(os); s.width(0);
00186     s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct() << ':'
00187       << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00188     return os << s.str();
00189   }
00190 
00191   /*
00192    * Optional fixed task
00193    */
00194 
00195   forceinline
00196   OptFixPSETask::OptFixPSETask(void) {}
00197   forceinline
00198   OptFixPSETask::OptFixPSETask(TaskType t,IntVar s,int p,int c,BoolVar m) {
00199     ManFixPSETask::init(t,s,p,c); _m=m;
00200   }
00201   forceinline void
00202   OptFixPSETask::init(TaskType t, IntVar s, int p, int c, BoolVar m) {
00203     ManFixPSETask::init(t,s,p,c); _m=m;
00204   }
00205   forceinline
00206   OptFixPSETask::operator Unary::OptFixPSETask (void) {
00207     return Unary::OptFixPSETask(_t,_s,_p,_m);
00208   }
00209 
00210   template<class Char, class Traits>
00211   std::basic_ostream<Char,Traits>&
00212   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t) {
00213     std::basic_ostringstream<Char,Traits> s;
00214     s.copyfmt(os); s.width(0);
00215     s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct() << ':'
00216       << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00217     return os << s.str();
00218   }
00219 
00220   /*
00221    * Optional flexible task
00222    */
00223 
00224   forceinline
00225   OptFlexTask::OptFlexTask(void) {}
00226   forceinline
00227   OptFlexTask::OptFlexTask(IntVar s, IntVar p, IntVar e, int c, BoolVar m) {
00228     ManFlexTask::init(s,p,e,c); _m=m;
00229   }
00230   forceinline void
00231   OptFlexTask::init(IntVar s, IntVar p, IntVar e, int c, BoolVar m) {
00232     ManFlexTask::init(s,p,e,c); _m=m;
00233   }
00234   forceinline
00235   OptFlexTask::operator Unary::OptFlexTask (void) {
00236     return Unary::OptFlexTask(_s,_p,_e,_m);
00237   }
00238 
00239   template<class Char, class Traits>
00240   std::basic_ostream<Char,Traits>&
00241   operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t) {
00242     std::basic_ostringstream<Char,Traits> s;
00243     s.copyfmt(os); s.width(0);
00244     s << t.est() << ':' << t.lst() << ':' << t.pmin() << ':'
00245       << t.pmax() << ':' << t.c() << ':' << t.ect() << ':' << t.lct()
00246       << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00247     return os << s.str();
00248   }
00249 
00250 }}}
00251 
00252 // STATISTICS: int-var