Generated on Sat Feb 12 2011 17:41:02 for Gecode by doxygen 1.7.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  *  Last modified:
00012  *     $Date: 2011-01-18 23:37:08 +0100 (Tue, 18 Jan 2011) $ by $Author: tack $
00013  *     $Revision: 11551 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  Permission is hereby granted, free of charge, to any person obtaining
00020  *  a copy of this software and associated documentation files (the
00021  *  "Software"), to deal in the Software without restriction, including
00022  *  without limitation the rights to use, copy, modify, merge, publish,
00023  *  distribute, sublicense, and/or sell copies of the Software, and to
00024  *  permit persons to whom the Software is furnished to do so, subject to
00025  *  the following conditions:
00026  *
00027  *  The above copyright notice and this permission notice shall be
00028  *  included in all copies or substantial portions of the Software.
00029  *
00030  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00031  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00032  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00033  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00034  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00035  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00036  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00037  *
00038  */
00039 
00040 namespace Gecode { namespace Scheduling { namespace Cumulative {
00041 
00042   /*
00043    * Mandatory fixed task
00044    */
00045 
00046   forceinline
00047   ManFixPTask::ManFixPTask(void) {}
00048   forceinline
00049   ManFixPTask::ManFixPTask(IntVar s, int p, int c) 
00050     : Unary::ManFixPTask(s,p), _c(c) {}
00051   forceinline void
00052   ManFixPTask::init(IntVar s, int p, int c) {
00053     Unary::ManFixPTask::init(s,p); _c=c;
00054   }
00055   forceinline void
00056   ManFixPTask::init(const ManFixPTask& t) {
00057     Unary::ManFixPTask::init(t); _c=t._c;
00058   }
00059 
00060   forceinline int
00061   ManFixPTask::c(void) const {
00062     return _c;
00063   }
00064   forceinline double
00065   ManFixPTask::e(void) const {
00066     return static_cast<double>(pmin())*c();
00067   }
00068 
00069   forceinline void
00070   ManFixPTask::update(Space& home, bool share, ManFixPTask& t) {
00071     Unary::ManFixPTask::update(home,share,t); _c=t._c;
00072   }
00073 
00074   template<class Char, class Traits>
00075   std::basic_ostream<Char,Traits>&
00076   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t) {
00077     std::basic_ostringstream<Char,Traits> s;
00078     s.copyfmt(os); s.width(0);
00079     s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct();
00080     return os << s.str();
00081   }
00082 
00083   /*
00084    * Mandatory fixed task with fixed processing, start or end time
00085    */
00086 
00087   forceinline
00088   ManFixPSETask::ManFixPSETask(void) {}
00089   forceinline
00090   ManFixPSETask::ManFixPSETask(TaskType t, IntVar s, int p, int c) 
00091     : Unary::ManFixPSETask(t,s,p), _c(c) {}
00092   forceinline void
00093   ManFixPSETask::init(TaskType t, IntVar s, int p, int c) {
00094     Unary::ManFixPSETask::init(t,s,p); _c=c;
00095   }
00096   forceinline void
00097   ManFixPSETask::init(const ManFixPSETask& t0) {
00098     Unary::ManFixPSETask::init(t0); _c=t0._c;
00099   }
00100 
00101   forceinline int
00102   ManFixPSETask::c(void) const {
00103     return _c;
00104   }
00105   forceinline double
00106   ManFixPSETask::e(void) const {
00107     return static_cast<double>(pmin())*c();
00108   }
00109 
00110   forceinline void
00111   ManFixPSETask::update(Space& home, bool share, ManFixPSETask& t) {
00112     Unary::ManFixPSETask::update(home,share,t); _c=t._c;
00113   }
00114 
00115   template<class Char, class Traits>
00116   std::basic_ostream<Char,Traits>&
00117   operator <<(std::basic_ostream<Char,Traits>& os,const ManFixPSETask& t) {
00118     std::basic_ostringstream<Char,Traits> s;
00119     s.copyfmt(os); s.width(0);
00120     s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct();
00121     return os << s.str();
00122   }
00123  
00124   /*
00125    * Mandatory flexible task
00126    */
00127 
00128   forceinline
00129   ManFlexTask::ManFlexTask(void) {}
00130   forceinline
00131   ManFlexTask::ManFlexTask(IntVar s, IntVar p, IntVar e, int c)
00132     : Unary::ManFlexTask(s,p,e), _c(c) {}
00133   forceinline void
00134   ManFlexTask::init(IntVar s, IntVar p, IntVar e, int c) {
00135     Unary::ManFlexTask::init(s,p,e); _c=c;
00136   }
00137   forceinline void
00138   ManFlexTask::init(const ManFlexTask& t) {
00139     Unary::ManFlexTask::init(t); _c=t._c;
00140   }
00141 
00142   forceinline int
00143   ManFlexTask::c(void) const {
00144     return _c;
00145   }
00146   forceinline double
00147   ManFlexTask::e(void) const {
00148     return static_cast<double>(pmin())*c();
00149   }
00150 
00151   forceinline void
00152   ManFlexTask::update(Space& home, bool share, ManFlexTask& t) {
00153     Unary::ManFlexTask::update(home,share,t); _c=t._c;
00154   }
00155 
00156   template<class Char, class Traits>
00157   std::basic_ostream<Char,Traits>&
00158   operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t) {
00159     std::basic_ostringstream<Char,Traits> s;
00160     s.copyfmt(os); s.width(0);
00161     s << t.est() << ':' << t.lst() << ':' << t.pmin() << ':'
00162       << t.pmax() << ':' << t.c() << ':' << t.ect() << ':' << t.lct();
00163     return os << s.str();
00164   }
00165 
00166   /*
00167    * Optional fixed task
00168    */
00169 
00170   forceinline
00171   OptFixPTask::OptFixPTask(void) {}
00172   forceinline
00173   OptFixPTask::OptFixPTask(IntVar s, int p, int c, BoolVar m) {
00174     ManFixPTask::init(s,p,c); _m=m;
00175   }
00176   forceinline void
00177   OptFixPTask::init(IntVar s, int p, int c, BoolVar m) {
00178     ManFixPTask::init(s,p,c); _m=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 
00206   template<class Char, class Traits>
00207   std::basic_ostream<Char,Traits>&
00208   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t) {
00209     std::basic_ostringstream<Char,Traits> s;
00210     s.copyfmt(os); s.width(0);
00211     s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct() << ':'
00212       << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00213     return os << s.str();
00214   }
00215 
00216   /*
00217    * Optional flexible task
00218    */
00219 
00220   forceinline
00221   OptFlexTask::OptFlexTask(void) {}
00222   forceinline
00223   OptFlexTask::OptFlexTask(IntVar s, IntVar p, IntVar e, int c, BoolVar m) {
00224     ManFlexTask::init(s,p,e,c); _m=m;
00225   }
00226   forceinline void
00227   OptFlexTask::init(IntVar s, IntVar p, IntVar e, int c, BoolVar m) {
00228     ManFlexTask::init(s,p,e,c); _m=m;
00229   }
00230 
00231   template<class Char, class Traits>
00232   std::basic_ostream<Char,Traits>&
00233   operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t) {
00234     std::basic_ostringstream<Char,Traits> s;
00235     s.copyfmt(os); s.width(0);
00236     s << t.est() << ':' << t.lst() << ':' << t.pmin() << ':'
00237       << t.pmax() << ':' << t.c() << ':' << t.ect() << ':' << t.lct()
00238       << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00239     return os << s.str();
00240   }
00241     
00242 }}}
00243 
00244 // STATISTICS: scheduling-var