Generated on Tue Mar 5 2013 22:37:18 for Gecode by doxygen 1.8.3.1
task.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  * Guido Tack <tack@gecode.org>
6  *
7  * Copyright:
8  * Christian Schulte, 2009
9  * Guido Tack, 2010
10  *
11  * Last modified:
12  * $Date: 2011-07-13 20:11:00 +1000 (Wed, 13 Jul 2011) $ by $Author: tack $
13  * $Revision: 12181 $
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 namespace Gecode { namespace Int { namespace Cumulative {
41 
42  /*
43  * Mandatory fixed task
44  */
45 
50  : Unary::ManFixPTask(s,p), _c(c) {}
51  forceinline void
52  ManFixPTask::init(IntVar s, int p, int c) {
54  }
55  forceinline void
58  }
59 
60  forceinline int
61  ManFixPTask::c(void) const {
62  return _c;
63  }
64  forceinline double
65  ManFixPTask::e(void) const {
66  return static_cast<double>(pmin())*c();
67  }
68 
69  forceinline void
70  ManFixPTask::update(Space& home, bool share, ManFixPTask& t) {
71  Unary::ManFixPTask::update(home,share,t); _c=t._c;
72  }
73 
74  template<class Char, class Traits>
75  std::basic_ostream<Char,Traits>&
76  operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t) {
77  std::basic_ostringstream<Char,Traits> s;
78  s.copyfmt(os); s.width(0);
79  s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct();
80  return os << s.str();
81  }
82 
83  /*
84  * Mandatory fixed task with fixed processing, start or end time
85  */
86 
91  : Unary::ManFixPSETask(t,s,p), _c(c) {}
92  forceinline void
93  ManFixPSETask::init(TaskType t, IntVar s, int p, int c) {
95  }
96  forceinline void
99  }
100 
101  forceinline int
102  ManFixPSETask::c(void) const {
103  return _c;
104  }
105  forceinline double
106  ManFixPSETask::e(void) const {
107  return static_cast<double>(pmin())*c();
108  }
109 
110  forceinline void
111  ManFixPSETask::update(Space& home, bool share, ManFixPSETask& t) {
112  Unary::ManFixPSETask::update(home,share,t); _c=t._c;
113  }
114 
115  template<class Char, class Traits>
116  std::basic_ostream<Char,Traits>&
117  operator <<(std::basic_ostream<Char,Traits>& os,const ManFixPSETask& t) {
118  std::basic_ostringstream<Char,Traits> s;
119  s.copyfmt(os); s.width(0);
120  s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct();
121  return os << s.str();
122  }
123 
124  /*
125  * Mandatory flexible task
126  */
127 
132  : Unary::ManFlexTask(s,p,e), _c(c) {}
133  forceinline void
135  Unary::ManFlexTask::init(s,p,e); _c=c;
136  }
137  forceinline void
140  }
141 
142  forceinline int
143  ManFlexTask::c(void) const {
144  return _c;
145  }
146  forceinline double
147  ManFlexTask::e(void) const {
148  return static_cast<double>(pmin())*c();
149  }
150 
151  forceinline void
152  ManFlexTask::update(Space& home, bool share, ManFlexTask& t) {
153  Unary::ManFlexTask::update(home,share,t); _c=t._c;
154  }
155 
156  template<class Char, class Traits>
157  std::basic_ostream<Char,Traits>&
158  operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t) {
159  std::basic_ostringstream<Char,Traits> s;
160  s.copyfmt(os); s.width(0);
161  s << t.est() << ':' << t.lst() << ':' << t.pmin() << ':'
162  << t.pmax() << ':' << t.c() << ':' << t.ect() << ':' << t.lct();
163  return os << s.str();
164  }
165 
166  /*
167  * Optional fixed task
168  */
169 
174  ManFixPTask::init(s,p,c); _m=m;
175  }
176  forceinline void
177  OptFixPTask::init(IntVar s, int p, int c, BoolVar m) {
178  ManFixPTask::init(s,p,c); _m=m;
179  }
181  OptFixPTask::operator Unary::OptFixPTask (void) {
182  return Unary::OptFixPTask(_s,_p,_m);
183  }
184 
185  template<class Char, class Traits>
186  std::basic_ostream<Char,Traits>&
187  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t) {
188  std::basic_ostringstream<Char,Traits> s;
189  s.copyfmt(os); s.width(0);
190  s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct() << ':'
191  << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
192  return os << s.str();
193  }
194 
195  /*
196  * Optional fixed task
197  */
198 
203  ManFixPSETask::init(t,s,p,c); _m=m;
204  }
205  forceinline void
207  ManFixPSETask::init(t,s,p,c); _m=m;
208  }
210  OptFixPSETask::operator Unary::OptFixPSETask (void) {
211  return Unary::OptFixPSETask(_t,_s,_p,_m);
212  }
213 
214  template<class Char, class Traits>
215  std::basic_ostream<Char,Traits>&
216  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t) {
217  std::basic_ostringstream<Char,Traits> s;
218  s.copyfmt(os); s.width(0);
219  s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct() << ':'
220  << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
221  return os << s.str();
222  }
223 
224  /*
225  * Optional flexible task
226  */
227 
232  ManFlexTask::init(s,p,e,c); _m=m;
233  }
234  forceinline void
236  ManFlexTask::init(s,p,e,c); _m=m;
237  }
239  OptFlexTask::operator Unary::OptFlexTask (void) {
240  return Unary::OptFlexTask(_s,_p,_e,_m);
241  }
242 
243  template<class Char, class Traits>
244  std::basic_ostream<Char,Traits>&
245  operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t) {
246  std::basic_ostringstream<Char,Traits> s;
247  s.copyfmt(os); s.width(0);
248  s << t.est() << ':' << t.lst() << ':' << t.pmin() << ':'
249  << t.pmax() << ':' << t.c() << ':' << t.ect() << ':' << t.lct()
250  << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
251  return os << s.str();
252  }
253 
254 }}}
255 
256 // STATISTICS: int-var