this repo has no description
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 * This file is part of Gecode, the generic constraint
12 * development environment:
13 * http://www.gecode.org
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining
16 * a copy of this software and associated documentation files (the
17 * "Software"), to deal in the Software without restriction, including
18 * without limitation the rights to use, copy, modify, merge, publish,
19 * distribute, sublicense, and/or sell copies of the Software, and to
20 * permit persons to whom the Software is furnished to do so, subject to
21 * the following conditions:
22 *
23 * The above copyright notice and this permission notice shall be
24 * included in all copies or substantial portions of the Software.
25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 *
34 */
35
36namespace Gecode { namespace Int { namespace Cumulative {
37
38 /*
39 * Mandatory fixed task
40 */
41
42 forceinline
43 ManFixPTask::ManFixPTask(void) {}
44 forceinline
45 ManFixPTask::ManFixPTask(IntVar s, int p, int c)
46 : Unary::ManFixPTask(s,p), _c(c) {}
47 forceinline void
48 ManFixPTask::init(IntVar s, int p, int c) {
49 Unary::ManFixPTask::init(s,p); _c=c;
50 }
51 forceinline void
52 ManFixPTask::init(const ManFixPTask& t) {
53 Unary::ManFixPTask::init(t); _c=t._c;
54 }
55
56 forceinline int
57 ManFixPTask::c(void) const {
58 return _c;
59 }
60 forceinline long long int
61 ManFixPTask::e(void) const {
62 return static_cast<long long int>(pmin())*c();
63 }
64
65 forceinline void
66 ManFixPTask::update(Space& home, ManFixPTask& t) {
67 Unary::ManFixPTask::update(home,t); _c=t._c;
68 }
69
70 template<class Char, class Traits>
71 std::basic_ostream<Char,Traits>&
72 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t) {
73 std::basic_ostringstream<Char,Traits> s;
74 s.copyfmt(os); s.width(0);
75 s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct();
76 return os << s.str();
77 }
78
79 /*
80 * Mandatory fixed task with fixed processing, start or end time
81 */
82
83 forceinline
84 ManFixPSETask::ManFixPSETask(void) {}
85 forceinline
86 ManFixPSETask::ManFixPSETask(TaskType t, IntVar s, int p, int c)
87 : Unary::ManFixPSETask(t,s,p), _c(c) {}
88 forceinline void
89 ManFixPSETask::init(TaskType t, IntVar s, int p, int c) {
90 Unary::ManFixPSETask::init(t,s,p); _c=c;
91 }
92 forceinline void
93 ManFixPSETask::init(const ManFixPSETask& t0) {
94 Unary::ManFixPSETask::init(t0); _c=t0._c;
95 }
96
97 forceinline int
98 ManFixPSETask::c(void) const {
99 return _c;
100 }
101 forceinline long long int
102 ManFixPSETask::e(void) const {
103 return static_cast<long long int>(pmin())*c();
104 }
105
106 forceinline void
107 ManFixPSETask::update(Space& home, ManFixPSETask& t) {
108 Unary::ManFixPSETask::update(home,t); _c=t._c;
109 }
110
111 template<class Char, class Traits>
112 std::basic_ostream<Char,Traits>&
113 operator <<(std::basic_ostream<Char,Traits>& os,const ManFixPSETask& t) {
114 std::basic_ostringstream<Char,Traits> s;
115 s.copyfmt(os); s.width(0);
116 s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct();
117 return os << s.str();
118 }
119
120 /*
121 * Mandatory flexible task
122 */
123
124 forceinline
125 ManFlexTask::ManFlexTask(void) {}
126 forceinline
127 ManFlexTask::ManFlexTask(IntVar s, IntVar p, IntVar e, int c)
128 : Unary::ManFlexTask(s,p,e), _c(c) {}
129 forceinline void
130 ManFlexTask::init(IntVar s, IntVar p, IntVar e, int c) {
131 Unary::ManFlexTask::init(s,p,e); _c=c;
132 }
133 forceinline void
134 ManFlexTask::init(const ManFlexTask& t) {
135 Unary::ManFlexTask::init(t); _c=t._c;
136 }
137
138 forceinline int
139 ManFlexTask::c(void) const {
140 return _c;
141 }
142 forceinline long long int
143 ManFlexTask::e(void) const {
144 return static_cast<long long int>(pmin())*c();
145 }
146
147 forceinline void
148 ManFlexTask::update(Space& home, ManFlexTask& t) {
149 Unary::ManFlexTask::update(home,t); _c=t._c;
150 }
151
152 template<class Char, class Traits>
153 std::basic_ostream<Char,Traits>&
154 operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t) {
155 std::basic_ostringstream<Char,Traits> s;
156 s.copyfmt(os); s.width(0);
157 s << t.est() << ':' << t.lst() << ':' << t.pmin() << ':'
158 << t.pmax() << ':' << t.c() << ':' << t.ect() << ':' << t.lct();
159 return os << s.str();
160 }
161
162 /*
163 * Optional fixed task
164 */
165
166 forceinline
167 OptFixPTask::OptFixPTask(void) {}
168 forceinline
169 OptFixPTask::OptFixPTask(IntVar s, int p, int c, BoolVar m) {
170 ManFixPTask::init(s,p,c); _m=m;
171 }
172 forceinline void
173 OptFixPTask::init(IntVar s, int p, int c, BoolVar m) {
174 ManFixPTask::init(s,p,c); _m=m;
175 }
176 forceinline
177 OptFixPTask::operator Unary::OptFixPTask (void) {
178 return Unary::OptFixPTask(_s,_p,_m);
179 }
180
181 template<class Char, class Traits>
182 std::basic_ostream<Char,Traits>&
183 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t) {
184 std::basic_ostringstream<Char,Traits> s;
185 s.copyfmt(os); s.width(0);
186 s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct() << ':'
187 << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
188 return os << s.str();
189 }
190
191 /*
192 * Optional fixed task
193 */
194
195 forceinline
196 OptFixPSETask::OptFixPSETask(void) {}
197 forceinline
198 OptFixPSETask::OptFixPSETask(TaskType t,IntVar s,int p,int c,BoolVar m) {
199 ManFixPSETask::init(t,s,p,c); _m=m;
200 }
201 forceinline void
202 OptFixPSETask::init(TaskType t, IntVar s, int p, int c, BoolVar m) {
203 ManFixPSETask::init(t,s,p,c); _m=m;
204 }
205 forceinline
206 OptFixPSETask::operator Unary::OptFixPSETask (void) {
207 return Unary::OptFixPSETask(_t,_s,_p,_m);
208 }
209
210 template<class Char, class Traits>
211 std::basic_ostream<Char,Traits>&
212 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t) {
213 std::basic_ostringstream<Char,Traits> s;
214 s.copyfmt(os); s.width(0);
215 s << t.est() << ":[" << t.pmin() << ',' << t.c() << "]:" << t.lct() << ':'
216 << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
217 return os << s.str();
218 }
219
220 /*
221 * Optional flexible task
222 */
223
224 forceinline
225 OptFlexTask::OptFlexTask(void) {}
226 forceinline
227 OptFlexTask::OptFlexTask(IntVar s, IntVar p, IntVar e, int c, BoolVar m) {
228 ManFlexTask::init(s,p,e,c); _m=m;
229 }
230 forceinline void
231 OptFlexTask::init(IntVar s, IntVar p, IntVar e, int c, BoolVar m) {
232 ManFlexTask::init(s,p,e,c); _m=m;
233 }
234 forceinline
235 OptFlexTask::operator Unary::OptFlexTask (void) {
236 return Unary::OptFlexTask(_s,_p,_e,_m);
237 }
238
239 template<class Char, class Traits>
240 std::basic_ostream<Char,Traits>&
241 operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t) {
242 std::basic_ostringstream<Char,Traits> s;
243 s.copyfmt(os); s.width(0);
244 s << t.est() << ':' << t.lst() << ':' << t.pmin() << ':'
245 << t.pmax() << ':' << t.c() << ':' << t.ect() << ':' << t.lct()
246 << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
247 return os << s.str();
248 }
249
250}}}
251
252// STATISTICS: int-var