Generated on Sat Jan 20 2018 22:21:14 for Gecode by doxygen 1.8.13
cumulative.cpp
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  *
6  * Copyright:
7  * Christian Schulte, 2009
8  *
9  * Last modified:
10  * $Date: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
11  * $Revision: 14967 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #include "test/int.hh"
39 
40 #include <gecode/minimodel.hh>
41 
42 namespace Test { namespace Int {
43 
45  namespace Cumulative {
46 
52  class ManFixPCumulative : public Test {
54  protected:
56  int c;
62  static int st(int c,
63  const Gecode::IntArgs& p, const Gecode::IntArgs& u) {
64  double e = 0;
65  for (int i=p.size(); i--; )
66  e += static_cast<double>(p[i])*u[i];
67  return e / std::max(1,std::abs(c));
68  }
70  int o;
71  public:
74  const Gecode::IntArgs& p0,
75  const Gecode::IntArgs& u0,
76  int o0,
78  : Test("Cumulative::Man::Fix::"+str(o0)+"::"+
79  str(c0)+"::"+str(p0)+"::"+str(u0)+"::"+str(ipl0),
80  (c0 >= 0) ? p0.size():p0.size()+1,0,st(c0,p0,u0),false,ipl0),
81  c(c0), p(p0), u(u0), o(o0) {
82  testsearch = false;
83  testfix = false;
84  contest = CTL_NONE;
85  }
87  virtual Assignment* assignment(void) const {
88  return new RandomAssignment(arity,dom,500);
89  }
91  virtual bool solution(const Assignment& x) const {
92  int cmax = (c >= 0) ? c : x[x.size()-1];
93  int n = (c >= 0) ? x.size() : x.size()-1;
94 
95  if (c < 0 && x[n] > -c)
96  return false;
97 
98  // Compute maximal time
99  int t = 0;
100  for (int i=0; i<n; i++)
101  t = std::max(t,x[i]+std::max(1,p[i]));
102  // Compute resource usage (including at start times)
103  int* used = new int[t];
104  for (int i=0; i<t; i++)
105  used[i] = 0;
106  for (int i=0; i<n; i++)
107  for (int t=0; t<p[i]; t++)
108  used[x[i]+t] += u[i];
109  // Check resource usage
110  for (int i=0; i<t; i++)
111  if (used[i] > cmax) {
112  delete [] used;
113  return false;
114  }
115  // Compute resource usage (only internal)
116  for (int i=0; i<t; i++)
117  used[i] = 0;
118  for (int i=0; i<n; i++) {
119  for (int t=1; t<p[i]; t++) {
120  used[x[i]+t] += u[i];
121  }
122  }
123  // Check resource usage at start times
124  for (int i=0; i<n; i++)
125  if (used[x[i]]+u[i] > cmax) {
126  delete [] used;
127  return false;
128  }
129  delete [] used;
130  return true;
131  }
133  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
134  int n = (c >= 0) ? x.size() : x.size()-1;
136  if (o==0) {
137  xx=x.slice(0,1,n);
138  } else {
139  xx=Gecode::IntVarArgs(n);
140  for (int i=n; i--;)
141  xx[i]=Gecode::expr(home,x[i]+o,Gecode::IPL_DOM);
142  }
143  if (c >= 0) {
144  Gecode::cumulative(home, c, xx, p, u, ipl);
145  } else {
146  Gecode::rel(home, x[n] <= -c);
147  Gecode::cumulative(home, x[n], xx, p, u, ipl);
148  }
149  }
150  };
151 
152 
154  class OptFixPCumulative : public Test {
155  protected:
157  int c;
163  int l;
165  int o;
167  static int st(int c,
168  const Gecode::IntArgs& p, const Gecode::IntArgs& u) {
169  double e = 0;
170  for (int i=p.size(); i--; )
171  e += static_cast<double>(p[i])*u[i];
172  return e / std::max(1,std::abs(c));
173  }
174  public:
177  const Gecode::IntArgs& p0,
178  const Gecode::IntArgs& u0,
179  int o0,
181  : Test("Cumulative::Opt::Fix::"+str(o0)+"::"+
182  str(c0)+"::"+str(p0)+"::"+str(u0)+"::"+str(ipl0),
183  (c0 >= 0) ? 2*p0.size() : 2*p0.size()+1,0,st(c0,p0,u0),
184  false,ipl0),
185  c(c0), p(p0), u(u0), l(st(c,p,u)/2), o(o0) {
186  testsearch = false;
187  testfix = false;
188  contest = CTL_NONE;
189  }
191  virtual Assignment* assignment(void) const {
192  return new RandomAssignment(arity,dom,500);
193  }
195  virtual bool solution(const Assignment& x) const {
196  int nn = (c >= 0) ? x.size() : x.size()-1;
197  int cmax = (c >= 0) ? c : x[nn];
198 
199  if (c < 0 && x[nn] > -c)
200  return false;
201 
202  int n = nn / 2;
203  // Compute maximal time
204  int t = 0;
205  for (int i=0; i<n; i++)
206  t = std::max(t,x[i]+std::max(1,p[i]));
207  // Compute resource usage (including at start times)
208  int* used = new int[t];
209  for (int i=0; i<t; i++)
210  used[i] = 0;
211  for (int i=0; i<n; i++)
212  if (x[n+i] > l)
213  for (int t=0; t<p[i]; t++)
214  used[x[i]+t] += u[i];
215  // Check resource usage
216  for (int i=0; i<t; i++) {
217  if (used[i] > cmax) {
218  delete [] used;
219  return false;
220  }
221  }
222  // Compute resource usage (only internal)
223  for (int i=0; i<t; i++)
224  used[i] = 0;
225  for (int i=0; i<n; i++)
226  if (x[n+i] > l) {
227  for (int t=1; t<p[i]; t++)
228  used[x[i]+t] += u[i];
229  }
230  // Check resource usage at start times
231  for (int i=0; i<n; i++)
232  if (x[n+i] > l)
233  if (used[x[i]]+u[i] > cmax) {
234  delete [] used;
235  return false;
236  }
237  delete [] used;
238  return true;
239  }
241  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
242  int nn=(c >= 0) ? x.size() : x.size()-1;
243  int n=nn / 2;
244  Gecode::IntVarArgs s(n);
245  Gecode::BoolVarArgs m(n);
246 
247  for (int i=0; i<n; i++) {
248  s[i]=(c >= 0) ? x[i] : Gecode::expr(home,x[i]+o,Gecode::IPL_DOM);
249  m[i]=Gecode::expr(home, x[n+i] > l);
250  }
251 
252  if (c >= 0) {
253  Gecode::cumulative(home, c, s, p, u, m, ipl);
254  } else {
255  Gecode::rel(home, x[nn] <= -c);
256  Gecode::cumulative(home, x[nn], s, p, u, m, ipl);
257  }
258  }
259  };
260 
262  class ManFlexCumulative : public Test {
263  protected:
265  int c;
267  int _minP;
269  int _maxP;
273  static int st(int c, int maxP, const Gecode::IntArgs& u) {
274  double e = 0;
275  for (int i=u.size(); i--; )
276  e += static_cast<double>(maxP)*u[i];
277  return e / std::max(1,std::abs(c));
278  }
280  int o;
281  public:
283  ManFlexCumulative(int c0, int minP, int maxP,
284  const Gecode::IntArgs& u0,
285  int o0,
287  : Test("Cumulative::Man::Flex::"+str(o0)+"::"+
288  str(c0)+"::"+str(minP)+"::"+str(maxP)+"::"+str(u0)+
289  "::"+str(ipl0),
290  (c0 >= 0) ? 2*u0.size() : 2*u0.size()+1,
291  0,std::max(maxP,st(c0,maxP,u0)),false,ipl0),
292  c(c0), _minP(minP), _maxP(maxP), u(u0), o(o0) {
293  testsearch = false;
294  testfix = false;
295  contest = CTL_NONE;
296  }
298  virtual Assignment* assignment(void) const {
299  return new RandomMixAssignment((c >= 0) ? arity/2 : arity/2+1,
300  dom,arity/2,
301  Gecode::IntSet(_minP,_maxP),500);
302  }
304  virtual bool solution(const Assignment& x) const {
305  int nn = (c >= 0) ? x.size() : x.size()-1;
306  int n = nn/2;
307  int cmax = (c >= 0) ? c : x[n];
308  int pstart = (c >= 0) ? n : n+1;
309 
310  if (c < 0 && cmax > -c)
311  return false;
312 
313  // Compute maximal time
314  int t = 0;
315  for (int i=0; i<n; i++) {
316  t = std::max(t,x[i]+std::max(1,x[pstart+i]));
317  }
318  // Compute resource usage (including at start times)
319  int* used = new int[t];
320  for (int i=0; i<t; i++)
321  used[i] = 0;
322  for (int i=0; i<n; i++)
323  for (int t=0; t<x[pstart+i]; t++)
324  used[x[i]+t] += u[i];
325  // Check resource usage
326  for (int i=0; i<t; i++)
327  if (used[i] > cmax) {
328  delete [] used;
329  return false;
330  }
331  // Compute resource usage (only internal)
332  for (int i=0; i<t; i++)
333  used[i] = 0;
334  for (int i=0; i<n; i++) {
335  for (int t=1; t<x[pstart+i]; t++)
336  used[x[i]+t] += u[i];
337  }
338  // Check resource usage at start times
339  for (int i=0; i<n; i++)
340  if (used[x[i]]+u[i] > cmax) {
341  delete [] used;
342  return false;
343  }
344  delete [] used;
345  return true;
346  }
348  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
349  int nn = (c >= 0) ? x.size() : x.size()-1;
350  int n = nn/2;
351  int pstart = (c >= 0) ? n : n+1;
352  Gecode::IntVarArgs s(n);
353  Gecode::IntVarArgs px(x.slice(pstart,1,n));
354  Gecode::IntVarArgs e(home,n,
357  for (int i=s.size(); i--;) {
358  s[i] = expr(home, o+x[i], Gecode::IPL_DOM);
359  rel(home, s[i]+px[i] == e[i]);
360  rel(home, _minP <= px[i]);
361  rel(home, _maxP >= px[i]);
362  }
363  if (c >= 0) {
364  Gecode::cumulative(home, c, s, px, e, u, ipl);
365  } else {
366  rel(home, x[n] <= -c);
367  Gecode::cumulative(home, x[n], s, px, e, u, ipl);
368  }
369  }
370  };
371 
373  class OptFlexCumulative : public Test {
374  protected:
376  int c;
378  int _minP;
380  int _maxP;
384  int l;
386  int o;
388  static int st(int c, int maxP, const Gecode::IntArgs& u) {
389  double e = 0;
390  for (int i=u.size(); i--; )
391  e += static_cast<double>(maxP)*u[i];
392  return e / std::max(1,std::abs(c));
393  }
394  public:
396  OptFlexCumulative(int c0, int minP, int maxP,
397  const Gecode::IntArgs& u0,
398  int o0,
400  : Test("Cumulative::Opt::Flex::"+str(o0)+"::"+
401  str(c0)+"::"+str(minP)+"::"+str(maxP)+"::"+str(u0)+
402  "::"+str(ipl0),
403  (c0 >= 0) ? 3*u0.size() : 3*u0.size()+1,
404  0,std::max(maxP,st(c0,maxP,u0)), false,ipl0),
405  c(c0), _minP(minP), _maxP(maxP), u(u0),
406  l(std::max(maxP,st(c0,maxP,u0))/2), o(o0) {
407  testsearch = false;
408  testfix = false;
409  contest = CTL_NONE;
410  }
412  virtual Assignment* assignment(void) const {
413  return new RandomMixAssignment((c >= 0) ? 2*(arity/3) : 2*(arity/3)+1,
414  dom,arity/3,
415  Gecode::IntSet(_minP,_maxP),500);
416  }
418  virtual bool solution(const Assignment& x) const {
419  int nn = (c >= 0) ? x.size() : x.size()-1;
420  int n = nn / 3;
421  int cmax = (c >= 0) ? c : x[2*n];
422  int pstart = (c >= 0) ? 2*n : 2*n+1;
423 
424  if (c < 0 && cmax > -c)
425  return false;
426 
427  // Compute maximal time
428  int t = 0;
429  for (int i=0; i<n; i++)
430  t = std::max(t,x[i]+std::max(1,x[pstart+i]));
431  // Compute resource usage (including at start times)
432  int* used = new int[t];
433  for (int i=0; i<t; i++)
434  used[i] = 0;
435  for (int i=0; i<n; i++)
436  if (x[n+i] > l)
437  for (int t=0; t<x[pstart+i]; t++)
438  used[x[i]+t] += u[i];
439  // Check resource usage
440  for (int i=0; i<t; i++)
441  if (used[i] > cmax) {
442  delete [] used;
443  return false;
444  }
445  // Compute resource usage (only internal)
446  for (int i=0; i<t; i++)
447  used[i] = 0;
448  for (int i=0; i<n; i++)
449  if (x[n+i] > l)
450  for (int t=1; t<x[pstart+i]; t++)
451  used[x[i]+t] += u[i];
452  // Check resource usage at start times
453  for (int i=0; i<n; i++)
454  if (x[n+i] > l && used[x[i]]+u[i] > cmax) {
455  delete [] used;
456  return false;
457  }
458  delete [] used;
459  return true;
460  }
462  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
463  int nn = (c >= 0) ? x.size() : x.size()-1;
464  int n=nn / 3;
465  int pstart= (c >= 0) ? 2*n : 2*n+1;
466 
467  Gecode::IntVarArgs s(n);
468  Gecode::IntVarArgs px(n);
469  Gecode::IntVarArgs e(home,n,
472  for (int i=n; i--;) {
473  s[i] = expr(home, o+x[i]);
474  px[i] = x[pstart+i];
475  rel(home, s[i]+px[i] == e[i]);
476  rel(home, _minP <= px[i]);
477  rel(home, _maxP >= px[i]);
478  }
479  Gecode::BoolVarArgs m(n);
480  for (int i=0; i<n; i++)
481  m[i]=Gecode::expr(home, (x[n+i] > l));
482  if (c >= 0) {
483  Gecode::cumulative(home, c, s, px, e, u, m, ipl);
484  } else {
485  Gecode::rel(home, x[2*n] <= -c);
486  Gecode::cumulative(home, x[2*n], s, px, e, u, m, ipl);
487  }
488  }
489  };
490 
492  class Create {
493  public:
495  Create(void) {
496  using namespace Gecode;
497  IntArgs p1(4, 1,1,1,1);
498  IntArgs p2(4, 2,2,2,2);
499  IntArgs p3(4, 4,3,3,5);
500  IntArgs p4(4, 4,0,3,5);
501  IntArgs p5(3, 1,1,1);
502 
503  IntArgs u1(4, 1,1,1,1);
504  IntArgs u2(4, 2,2,2,2);
505  IntArgs u3(4, 2,3,4,5);
506  IntArgs u4(4, 2,3,0,5);
507  IntArgs u5(3, 1,3,2);
508 
509  for (IntPropBasicAdvanced ipba; ipba(); ++ipba) {
510  // Regression test: check correct detection of disjunctive case
511  (void) new ManFixPCumulative(3,p5,u5,0,ipba.ipl());
512 
513  for (int c=-7; c<8; c++) {
514  int off = 0;
515  for (int coff=0; coff<2; coff++) {
516  (void) new ManFixPCumulative(c,p1,u1,off,ipba.ipl());
517  (void) new ManFixPCumulative(c,p1,u2,off,ipba.ipl());
518  (void) new ManFixPCumulative(c,p1,u3,off,ipba.ipl());
519  (void) new ManFixPCumulative(c,p1,u4,off,ipba.ipl());
520  (void) new ManFixPCumulative(c,p2,u1,off,ipba.ipl());
521  (void) new ManFixPCumulative(c,p2,u2,off,ipba.ipl());
522  (void) new ManFixPCumulative(c,p2,u3,off,ipba.ipl());
523  (void) new ManFixPCumulative(c,p2,u4,off,ipba.ipl());
524  (void) new ManFixPCumulative(c,p3,u1,off,ipba.ipl());
525  (void) new ManFixPCumulative(c,p3,u2,off,ipba.ipl());
526  (void) new ManFixPCumulative(c,p3,u3,off,ipba.ipl());
527  (void) new ManFixPCumulative(c,p3,u4,off,ipba.ipl());
528  (void) new ManFixPCumulative(c,p4,u1,off,ipba.ipl());
529  (void) new ManFixPCumulative(c,p4,u2,off,ipba.ipl());
530  (void) new ManFixPCumulative(c,p4,u3,off,ipba.ipl());
531  (void) new ManFixPCumulative(c,p4,u4,off,ipba.ipl());
532 
533  (void) new ManFlexCumulative(c,0,1,u1,off,ipba.ipl());
534  (void) new ManFlexCumulative(c,0,1,u2,off,ipba.ipl());
535  (void) new ManFlexCumulative(c,0,1,u3,off,ipba.ipl());
536  (void) new ManFlexCumulative(c,0,1,u4,off,ipba.ipl());
537  (void) new ManFlexCumulative(c,0,2,u1,off,ipba.ipl());
538  (void) new ManFlexCumulative(c,0,2,u2,off,ipba.ipl());
539  (void) new ManFlexCumulative(c,0,2,u3,off,ipba.ipl());
540  (void) new ManFlexCumulative(c,0,2,u4,off,ipba.ipl());
541  (void) new ManFlexCumulative(c,3,5,u1,off,ipba.ipl());
542  (void) new ManFlexCumulative(c,3,5,u2,off,ipba.ipl());
543  (void) new ManFlexCumulative(c,3,5,u3,off,ipba.ipl());
544  (void) new ManFlexCumulative(c,3,5,u4,off,ipba.ipl());
545 
546  (void) new OptFixPCumulative(c,p1,u1,off,ipba.ipl());
547  (void) new OptFixPCumulative(c,p1,u2,off,ipba.ipl());
548  (void) new OptFixPCumulative(c,p1,u3,off,ipba.ipl());
549  (void) new OptFixPCumulative(c,p1,u4,off,ipba.ipl());
550  (void) new OptFixPCumulative(c,p2,u1,off,ipba.ipl());
551  (void) new OptFixPCumulative(c,p2,u2,off,ipba.ipl());
552  (void) new OptFixPCumulative(c,p2,u3,off,ipba.ipl());
553  (void) new OptFixPCumulative(c,p2,u4,off,ipba.ipl());
554  (void) new OptFixPCumulative(c,p3,u1,off,ipba.ipl());
555  (void) new OptFixPCumulative(c,p3,u2,off,ipba.ipl());
556  (void) new OptFixPCumulative(c,p3,u3,off,ipba.ipl());
557  (void) new OptFixPCumulative(c,p3,u4,off,ipba.ipl());
558  (void) new OptFixPCumulative(c,p4,u1,off,ipba.ipl());
559  (void) new OptFixPCumulative(c,p4,u2,off,ipba.ipl());
560  (void) new OptFixPCumulative(c,p4,u3,off,ipba.ipl());
561  (void) new OptFixPCumulative(c,p4,u4,off,ipba.ipl());
562 
563  (void) new OptFlexCumulative(c,0,1,u1,off,ipba.ipl());
564  (void) new OptFlexCumulative(c,0,1,u2,off,ipba.ipl());
565  (void) new OptFlexCumulative(c,0,1,u3,off,ipba.ipl());
566  (void) new OptFlexCumulative(c,0,1,u4,off,ipba.ipl());
567  (void) new OptFlexCumulative(c,0,2,u1,off,ipba.ipl());
568  (void) new OptFlexCumulative(c,0,2,u2,off,ipba.ipl());
569  (void) new OptFlexCumulative(c,0,2,u3,off,ipba.ipl());
570  (void) new OptFlexCumulative(c,0,2,u4,off,ipba.ipl());
571  (void) new OptFlexCumulative(c,3,5,u1,off,ipba.ipl());
572  (void) new OptFlexCumulative(c,3,5,u2,off,ipba.ipl());
573  (void) new OptFlexCumulative(c,3,5,u3,off,ipba.ipl());
574  (void) new OptFlexCumulative(c,3,5,u4,off,ipba.ipl());
575 
577  }
578  }
579  }
580  }
581  };
582 
585 
586  }
587 }}
588 
589 // STATISTICS: test-int
static int st(int c, const Gecode::IntArgs &p, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
Definition: cumulative.cpp:167
NodeType t
Type of node.
Definition: bool-expr.cpp:234
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
Definition: int.hpp:212
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: cumulative.cpp:348
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1669
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:985
const FloatNum max
Largest allowed float value.
Definition: float.hh:848
int size(void) const
Return number of variables.
Definition: int.hpp:50
static int st(int c, int maxP, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
Definition: cumulative.cpp:388
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:45
Gecode::IntArgs u
The resource usage.
Definition: cumulative.cpp:271
Gecode::IntArgs u
The resource usage.
Definition: cumulative.cpp:161
int _minP
Minimum processing time.
Definition: cumulative.cpp:378
int _minP
Minimum processing time.
Definition: cumulative.cpp:267
Gecode::IntSet dom
Domain of variables.
Definition: int.hh:232
Integer variable array.
Definition: int.hh:744
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: cumulative.cpp:462
ConTestLevel contest
Whether to test for certain consistency.
Definition: int.hh:240
const int max
Largest allowed integer value.
Definition: int.hh:116
Computation spaces.
Definition: core.hpp:1748
virtual Assignment * assignment(void) const
Create and register initial assignment.
Definition: cumulative.cpp:412
Generate random selection of assignments.
Definition: int.hh:100
const int min
Smallest allowed integer value.
Definition: int.hh:118
Iterator for basic and advanced integer propagation levels.
Definition: int.hh:352
static int st(int c, const Gecode::IntArgs &p, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
Definition: cumulative.cpp:62
int _maxP
Maximum processing time.
Definition: cumulative.cpp:269
int l
Limit for optional tasks.
Definition: cumulative.cpp:163
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
virtual Assignment * assignment(void) const
Create and register initial assignment.
Definition: cumulative.cpp:87
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Definition: cumulative.cpp:91
No consistency-test.
Definition: int.hh:144
Generate random selection of assignments.
Definition: int.hh:120
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: cumulative.cpp:241
ManFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
Definition: cumulative.cpp:73
unsigned int size(I &i)
Size of all ranges of range iterator i.
int _maxP
Maximum processing time.
Definition: cumulative.cpp:380
Integer sets.
Definition: int.hh:174
Help class to create and register tests.
Definition: cumulative.cpp:492
ArrayTraits< VarArgArray< Var > >::ArgsType slice(int start, int inc=1, int n=-1)
Definition: array.hpp:1005
Test for cumulative constraint with optional tasks.
Definition: cumulative.cpp:154
Gecode::IntPropLevel ipl
Propagation level.
Definition: int.hh:238
Passing integer variables.
Definition: int.hh:639
Passing integer arguments.
Definition: int.hh:610
Passing Boolean variables.
Definition: int.hh:693
BoolVar expr(Home home, const BoolExpr &e, IntPropLevel ipl)
Post Boolean expression and return its value.
Definition: bool-expr.cpp:632
bool testfix
Whether to perform fixpoint test.
Definition: int.hh:244
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: cumulative.cpp:133
General test support.
Definition: afc.cpp:43
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:955
Gecode::IntArgs u
The resource usage.
Definition: cumulative.cpp:60
Test for cumulative constraint with mandatory tasks.
Definition: cumulative.cpp:53
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
bool testsearch
Whether to perform search test.
Definition: int.hh:242
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Definition: cumulative.cpp:304
Base class for assignments
Definition: int.hh:63
static int st(int c, int maxP, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
Definition: cumulative.cpp:273
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
Gecode::IntArgs p
The processing times.
Definition: cumulative.cpp:58
Domain propagation Preferences: prefer speed or memory.
Definition: int.hh:960
virtual Assignment * assignment(void) const
Create and register initial assignment.
Definition: cumulative.cpp:298
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Definition: cumulative.cpp:195
Test for cumulative constraint with optional flexible tasks.
Definition: cumulative.cpp:373
Gecode toplevel namespace
Gecode::IntArgs u
The resource usage.
Definition: cumulative.cpp:382
Create(void)
Perform creation and registration.
Definition: cumulative.cpp:495
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Definition: cumulative.cpp:418
int arity
Number of variables.
Definition: int.hh:230
void cumulative(Home home, int c, const TaskTypeArgs &t, const IntVarArgs &s, const IntArgs &p, const IntArgs &u, IntPropLevel ipl)
Post propagators for scheduling tasks on cumulative resources.
Definition: cumulative.cpp:357
virtual Assignment * assignment(void) const
Create and register initial assignment.
Definition: cumulative.cpp:191
Test for cumulative constraint with flexible mandatory tasks.
Definition: cumulative.cpp:262
OptFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
Definition: cumulative.cpp:176
OptFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
Definition: cumulative.cpp:396
ManFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
Definition: cumulative.cpp:283
int l
Limit for optional tasks.
Definition: cumulative.cpp:384
Gecode::IntArgs p
The processing times.
Definition: cumulative.cpp:159