Generated on Thu Mar 22 10:39:36 2012 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  *  Last modified:
00012  *     $Date: 2011-07-13 12:11:00 +0200 (Wed, 13 Jul 2011) $ by $Author: tack $
00013  *     $Revision: 12181 $
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 Int { 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   forceinline
00181   OptFixPTask::operator Unary::OptFixPTask (void) {
00182     return Unary::OptFixPTask(_s,_p,_m);
00183   }
00184 
00185   template<class Char, class Traits>
00186   std::basic_ostream<Char,Traits>&
00187   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t) {
00188     std::basic_ostringstream<Char,Traits> s;
00189     s.copyfmt(os); s.width(0);
00190     s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct() << ':'
00191       << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00192     return os << s.str();
00193   }
00194 
00195   /*
00196    * Optional fixed task
00197    */
00198 
00199   forceinline
00200   OptFixPSETask::OptFixPSETask(void) {}
00201   forceinline
00202   OptFixPSETask::OptFixPSETask(TaskType t,IntVar s,int p,int c,BoolVar m) {
00203     ManFixPSETask::init(t,s,p,c); _m=m;
00204   }
00205   forceinline void
00206   OptFixPSETask::init(TaskType t, IntVar s, int p, int c, BoolVar m) {
00207     ManFixPSETask::init(t,s,p,c); _m=m;
00208   }
00209   forceinline
00210   OptFixPSETask::operator Unary::OptFixPSETask (void) {
00211     return Unary::OptFixPSETask(_t,_s,_p,_m);
00212   }
00213 
00214   template<class Char, class Traits>
00215   std::basic_ostream<Char,Traits>&
00216   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t) {
00217     std::basic_ostringstream<Char,Traits> s;
00218     s.copyfmt(os); s.width(0);
00219     s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct() << ':'
00220       << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00221     return os << s.str();
00222   }
00223 
00224   /*
00225    * Optional flexible task
00226    */
00227 
00228   forceinline
00229   OptFlexTask::OptFlexTask(void) {}
00230   forceinline
00231   OptFlexTask::OptFlexTask(IntVar s, IntVar p, IntVar e, int c, BoolVar m) {
00232     ManFlexTask::init(s,p,e,c); _m=m;
00233   }
00234   forceinline void
00235   OptFlexTask::init(IntVar s, IntVar p, IntVar e, int c, BoolVar m) {
00236     ManFlexTask::init(s,p,e,c); _m=m;
00237   }
00238   forceinline
00239   OptFlexTask::operator Unary::OptFlexTask (void) {
00240     return Unary::OptFlexTask(_s,_p,_e,_m);
00241   }
00242 
00243   template<class Char, class Traits>
00244   std::basic_ostream<Char,Traits>&
00245   operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t) {
00246     std::basic_ostringstream<Char,Traits> s;
00247     s.copyfmt(os); s.width(0);
00248     s << t.est() << ':' << t.lst() << ':' << t.pmin() << ':'
00249       << t.pmax() << ':' << t.c() << ':' << t.ect() << ':' << t.lct()
00250       << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00251     return os << s.str();
00252   }
00253     
00254 }}}
00255 
00256 // STATISTICS: int-var