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