Generated on for Gecode by doxygen 1.17.0
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.dev>
5 *
6 * Copyright:
7 * Christian Schulte, 2009
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.dev
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#include "test/int.hh"
35
36#include <gecode/minimodel.hh>
37
38#include <memory>
39
40namespace Test { namespace Int {
41
43 namespace Cumulative {
44
50
51 class ManFixPCumulative : public Test {
52 protected:
54 int c;
60 static int st(int c,
61 const Gecode::IntArgs& p, const Gecode::IntArgs& u) {
62 double e = 0;
63 for (int i=p.size(); i--; )
64 e += static_cast<double>(p[i])*u[i];
65 return e / std::max(1,std::abs(c));
66 }
67
68 int o;
69 public:
72 const Gecode::IntArgs& p0,
73 const Gecode::IntArgs& u0,
74 int o0,
76 : Test((o0 == 0) && (c0 == 4)
77 ? TestTags::check()
79 "Cumulative::Man::Fix::"+str(o0)+"::"+
80 str(c0)+"::"+str(p0)+"::"+str(u0)+"::"+str(ipl0),
81 (c0 >= 0) ? p0.size():p0.size()+1,0,st(c0,p0,u0),false,ipl0),
82 c(c0), p(p0), u(u0), o(o0) {
83 testsearch = false;
84 testfix = false;
86 }
87
88 virtual Assignment* assignment(void) const {
89 return new RandomAssignment(arity, dom, 500, _rand);
90 }
91
92 virtual bool solution(const Assignment& x) const {
93 int cmax = (c >= 0) ? c : x[x.size()-1];
94 int n = (c >= 0) ? x.size() : x.size()-1;
95
96 if (c < 0 && x[n] > -c)
97 return false;
98
99 // Compute maximal time
100 int t = 0;
101 for (int i=0; i<n; i++)
102 t = std::max(t,x[i]+std::max(1,p[i]));
103 // Compute resource usage (including at start times)
104 int* used = new int[t];
105 for (int i=0; i<t; i++)
106 used[i] = 0;
107 for (int i=0; i<n; i++)
108 for (int t=0; t<p[i]; t++)
109 used[x[i]+t] += u[i];
110 // Check resource usage
111 for (int i=0; i<t; i++)
112 if (used[i] > cmax) {
113 delete [] used;
114 return false;
115 }
116 // Compute resource usage (only internal)
117 for (int i=0; i<t; i++)
118 used[i] = 0;
119 for (int i=0; i<n; i++) {
120 for (int t=1; t<p[i]; t++) {
121 used[x[i]+t] += u[i];
122 }
123 }
124 // Check resource usage at start times
125 for (int i=0; i<n; i++)
126 if (used[x[i]]+u[i] > cmax) {
127 delete [] used;
128 return false;
129 }
130 delete [] used;
131 return true;
132 }
133
134 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
135 int n = (c >= 0) ? x.size() : x.size()-1;
137 if (o==0) {
138 xx=x.slice(0,1,n);
139 } else {
140 xx=Gecode::IntVarArgs(n);
141 for (int i=n; i--;)
142 xx[i]=Gecode::expr(home,x[i]+o,Gecode::IPL_DOM);
143 }
144 if (c >= 0) {
145 Gecode::cumulative(home, c, xx, p, u, ipl);
146 } else {
147 Gecode::rel(home, x[n] <= -c);
148 Gecode::cumulative(home, x[n], xx, p, u, ipl);
149 }
150 }
151 };
152
153
155 class OptFixPCumulative : public Test {
156 protected:
158 int c;
164 int l;
166 int o;
168 static int st(int c,
169 const Gecode::IntArgs& p, const Gecode::IntArgs& u) {
170 double e = 0;
171 for (int i=p.size(); i--; )
172 e += static_cast<double>(p[i])*u[i];
173 return e / std::max(1,std::abs(c));
174 }
175 public:
178 const Gecode::IntArgs& p0,
179 const Gecode::IntArgs& u0,
180 int o0,
182 : Test((o0 == Gecode::Int::Limits::min) && (c0 == -1)
184 "Cumulative::Opt::Fix::"+str(o0)+"::"+
185 str(c0)+"::"+str(p0)+"::"+str(u0)+"::"+str(ipl0),
186 (c0 >= 0) ? 2*p0.size() : 2*p0.size()+1,0,st(c0,p0,u0),
187 false,ipl0),
188 c(c0), p(p0), u(u0), l(st(c,p,u)/2), o(o0) {
189 testsearch = false;
190 testfix = false;
192 }
193
194 virtual Assignment* assignment(void) const {
195 return new RandomAssignment(arity, dom, 500, _rand);
196 }
197
198 virtual bool solution(const Assignment& x) const {
199 int nn = (c >= 0) ? x.size() : x.size()-1;
200 int cmax = (c >= 0) ? c : x[nn];
201
202 if (c < 0 && x[nn] > -c)
203 return false;
204
205 int n = nn / 2;
206 // Compute maximal time
207 int t = 0;
208 for (int i=0; i<n; i++)
209 t = std::max(t,x[i]+std::max(1,p[i]));
210 // Compute resource usage (including at start times)
211 int* used = new int[t];
212 for (int i=0; i<t; i++)
213 used[i] = 0;
214 for (int i=0; i<n; i++)
215 if (x[n+i] > l)
216 for (int t=0; t<p[i]; t++)
217 used[x[i]+t] += u[i];
218 // Check resource usage
219 for (int i=0; i<t; i++) {
220 if (used[i] > cmax) {
221 delete [] used;
222 return false;
223 }
224 }
225 // Compute resource usage (only internal)
226 for (int i=0; i<t; i++)
227 used[i] = 0;
228 for (int i=0; i<n; i++)
229 if (x[n+i] > l) {
230 for (int t=1; t<p[i]; t++)
231 used[x[i]+t] += u[i];
232 }
233 // Check resource usage at start times
234 for (int i=0; i<n; i++)
235 if (x[n+i] > l)
236 if (used[x[i]]+u[i] > cmax) {
237 delete [] used;
238 return false;
239 }
240 delete [] used;
241 return true;
242 }
243
244 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
245 int nn=(c >= 0) ? x.size() : x.size()-1;
246 int n=nn / 2;
249
250 for (int i=0; i<n; i++) {
251 s[i]=(c >= 0) ? x[i] : Gecode::expr(home,x[i]+o,Gecode::IPL_DOM);
252 m[i]=Gecode::expr(home, x[n+i] > l);
253 }
254
255 if (c >= 0) {
256 Gecode::cumulative(home, c, s, p, u, m, ipl);
257 } else {
258 Gecode::rel(home, x[nn] <= -c);
259 Gecode::cumulative(home, x[nn], s, p, u, m, ipl);
260 }
261 }
262 };
263
265 class ManFlexCumulative : public Test {
266 protected:
268 int c;
270 int _minP;
272 int _maxP;
276 static int st(int c, int maxP, const Gecode::IntArgs& u) {
277 double e = 0;
278 for (int i=u.size(); i--; )
279 e += static_cast<double>(maxP)*u[i];
280 return e / std::max(1,std::abs(c));
281 }
282
283 int o;
284 public:
286 ManFlexCumulative(int c0, int minP, int maxP,
287 const Gecode::IntArgs& u0,
288 int o0,
290 : Test(TestTags::sweep(),"Cumulative::Man::Flex::"+str(o0)+"::"+
291 str(c0)+"::"+str(minP)+"::"+str(maxP)+"::"+str(u0)+
292 "::"+str(ipl0),
293 (c0 >= 0) ? 2*u0.size() : 2*u0.size()+1,
294 0,std::max(maxP,st(c0,maxP,u0)),false,ipl0),
295 c(c0), _minP(minP), _maxP(maxP), u(u0), o(o0) {
296 testsearch = false;
297 testfix = false;
299 }
300
301 virtual Assignment* assignment(void) const {
302 return new RandomMixAssignment((c >= 0) ? arity / 2 : arity / 2 + 1,
303 dom, arity / 2,
305 }
306
307 virtual bool solution(const Assignment& x) const {
308 int nn = (c >= 0) ? x.size() : x.size()-1;
309 int n = nn/2;
310 int cmax = (c >= 0) ? c : x[n];
311 int pstart = (c >= 0) ? n : n+1;
312
313 if (c < 0 && cmax > -c)
314 return false;
315
316 // Compute maximal time
317 int t = 0;
318 for (int i=0; i<n; i++) {
319 t = std::max(t,x[i]+std::max(1,x[pstart+i]));
320 }
321 // Compute resource usage (including at start times)
322 int* used = new int[t];
323 for (int i=0; i<t; i++)
324 used[i] = 0;
325 for (int i=0; i<n; i++)
326 for (int t=0; t<x[pstart+i]; t++)
327 used[x[i]+t] += u[i];
328 // Check resource usage
329 for (int i=0; i<t; i++)
330 if (used[i] > cmax) {
331 delete [] used;
332 return false;
333 }
334 // Compute resource usage (only internal)
335 for (int i=0; i<t; i++)
336 used[i] = 0;
337 for (int i=0; i<n; i++) {
338 for (int t=1; t<x[pstart+i]; t++)
339 used[x[i]+t] += u[i];
340 }
341 // Check resource usage at start times
342 for (int i=0; i<n; i++)
343 if (used[x[i]]+u[i] > cmax) {
344 delete [] used;
345 return false;
346 }
347 delete [] used;
348 return true;
349 }
350
351 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
352 int nn = (c >= 0) ? x.size() : x.size()-1;
353 int n = nn/2;
354 int pstart = (c >= 0) ? n : n+1;
356 Gecode::IntVarArgs px(x.slice(pstart,1,n));
357 Gecode::IntVarArgs e(home,n,
360 for (int i=s.size(); i--;) {
361 s[i] = expr(home, o+x[i], Gecode::IPL_DOM);
362 rel(home, s[i]+px[i] == e[i]);
363 rel(home, _minP <= px[i]);
364 rel(home, _maxP >= px[i]);
365 }
366 if (c >= 0) {
367 Gecode::cumulative(home, c, s, px, e, u, ipl);
368 } else {
369 rel(home, x[n] <= -c);
370 Gecode::cumulative(home, x[n], s, px, e, u, ipl);
371 }
372 }
373 };
374
376 class OptFlexCumulative : public Test {
377 protected:
379 int c;
381 int _minP;
383 int _maxP;
387 int l;
389 int o;
391 static int st(int c, int maxP, const Gecode::IntArgs& u) {
392 double e = 0;
393 for (int i=u.size(); i--; )
394 e += static_cast<double>(maxP)*u[i];
395 return e / std::max(1,std::abs(c));
396 }
397 public:
399 OptFlexCumulative(int c0, int minP, int maxP,
400 const Gecode::IntArgs& u0,
401 int o0,
403 : Test((o0 == Gecode::Int::Limits::min) && (c0 == 4) &&
404 (minP == 0) && (maxP == 2)
406 "Cumulative::Opt::Flex::"+str(o0)+"::"+
407 str(c0)+"::"+str(minP)+"::"+str(maxP)+"::"+str(u0)+
408 "::"+str(ipl0),
409 (c0 >= 0) ? 3*u0.size() : 3*u0.size()+1,
410 0,std::max(maxP,st(c0,maxP,u0)), false,ipl0),
411 c(c0), _minP(minP), _maxP(maxP), u(u0),
412 l(std::max(maxP,st(c0,maxP,u0))/2), o(o0) {
413 testsearch = false;
414 testfix = false;
416 }
417
418 virtual Assignment* assignment(void) const {
419 return new RandomMixAssignment((c >= 0) ? 2 * (arity / 3) : 2 * (arity / 3) + 1,
420 dom, arity / 3,
422 }
423
424 virtual bool solution(const Assignment& x) const {
425 int nn = (c >= 0) ? x.size() : x.size()-1;
426 int n = nn / 3;
427 int cmax = (c >= 0) ? c : x[2*n];
428 int pstart = (c >= 0) ? 2*n : 2*n+1;
429
430 if (c < 0 && cmax > -c)
431 return false;
432
433 // Compute maximal time
434 int t = 0;
435 for (int i=0; i<n; i++)
436 t = std::max(t,x[i]+std::max(1,x[pstart+i]));
437 // Compute resource usage (including at start times)
438 int* used = new int[t];
439 for (int i=0; i<t; i++)
440 used[i] = 0;
441 for (int i=0; i<n; i++)
442 if (x[n+i] > l)
443 for (int t=0; t<x[pstart+i]; t++)
444 used[x[i]+t] += u[i];
445 // Check resource usage
446 for (int i=0; i<t; i++)
447 if (used[i] > cmax) {
448 delete [] used;
449 return false;
450 }
451 // Compute resource usage (only internal)
452 for (int i=0; i<t; i++)
453 used[i] = 0;
454 for (int i=0; i<n; i++)
455 if (x[n+i] > l)
456 for (int t=1; t<x[pstart+i]; t++)
457 used[x[i]+t] += u[i];
458 // Check resource usage at start times
459 for (int i=0; i<n; i++)
460 if (x[n+i] > l && used[x[i]]+u[i] > cmax) {
461 delete [] used;
462 return false;
463 }
464 delete [] used;
465 return true;
466 }
467
468 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
469 int nn = (c >= 0) ? x.size() : x.size()-1;
470 int n=nn / 3;
471 int pstart= (c >= 0) ? 2*n : 2*n+1;
472
474 Gecode::IntVarArgs px(n);
475 Gecode::IntVarArgs e(home,n,
478 for (int i=n; i--;) {
479 s[i] = expr(home, o+x[i]);
480 px[i] = x[pstart+i];
481 rel(home, s[i]+px[i] == e[i]);
482 rel(home, _minP <= px[i]);
483 rel(home, _maxP >= px[i]);
484 }
486 for (int i=0; i<n; i++)
487 m[i]=Gecode::expr(home, (x[n+i] > l));
488 if (c >= 0) {
489 Gecode::cumulative(home, c, s, px, e, u, m, ipl);
490 } else {
491 Gecode::rel(home, x[2*n] <= -c);
492 Gecode::cumulative(home, x[2*n], s, px, e, u, m, ipl);
493 }
494 }
495 };
496
498 class ManFixECumulative : public Test {
499 public:
501 : Test("Cumulative::Man::FixE",4,
502 Gecode::IntSet({0,9,19,29,39}),false,Gecode::IPL_ADVANCED) {
503 testfix = false;
505 }
506 virtual bool solution(const Assignment& x) const {
507 for (int i=0; i<4; i++)
508 if (x[i] >= 10*(i+1))
509 return false;
510 for (int t=0; t<40; t++) {
511 int used = 0;
512 for (int i=0; i<4; i++)
513 if ((x[i] <= t) && (t < 10*(i+1)))
514 used += 2;
515 if (used > 4)
516 return false;
517 }
518 return true;
519 }
520 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
521 Gecode::IntArgs ends({10,20,30,40});
522 Gecode::TaskTypeArgs types(4);
523 for (int i=0; i<4; i++) {
524 Gecode::dom(home,x[i],0,ends[i]-1);
525 types[i] = Gecode::TT_FIXE;
526 }
527 Gecode::cumulative(home,4,types,x,ends,
528 Gecode::IntArgs({2,2,2,2}),ipl);
529 }
530 };
532
534 // Complete assignments cannot distinguish basic from advanced propagation.
536 private:
537 class Fixture : public Gecode::Space {
538 public:
539 Gecode::IntVarArray starts;
540 Fixture(Gecode::IntPropLevel level)
541 : starts(*this,5,0,6) {
542 starts[0] = Gecode::IntVar(*this,1,4);
543 starts[1] = Gecode::IntVar(*this,0,6);
544 starts[2] = Gecode::IntVar(*this,2,6);
545 starts[3] = Gecode::IntVar(*this,0,0);
546 starts[4] = Gecode::IntVar(*this,0,1);
547 Gecode::cumulative(*this,3,starts,
548 Gecode::IntArgs({3,1,1,2,4}),
549 Gecode::IntArgs({3,3,1,2,1}),level);
550 }
551 Fixture(Fixture& fixture) : Gecode::Space(fixture) {
552 starts.update(*this,fixture.starts);
553 }
554 virtual Gecode::Space* copy(void) {
555 return new Fixture(*this);
556 }
557 };
558
559 class VariableCapacityFixture : public Gecode::Space {
560 public:
561 Gecode::IntVarArray starts;
563 VariableCapacityFixture(void)
564 : starts(*this,5,0,6), capacity(*this,3,4) {
565 starts[0] = Gecode::IntVar(*this,1,4);
566 starts[1] = Gecode::IntVar(*this,0,6);
567 starts[2] = Gecode::IntVar(*this,2,6);
568 starts[3] = Gecode::IntVar(*this,0,0);
569 starts[4] = Gecode::IntVar(*this,0,1);
570 Gecode::cumulative(*this,capacity,starts,
571 Gecode::IntArgs({3,1,1,2,4}),
573 }
574 VariableCapacityFixture(VariableCapacityFixture& fixture)
575 : Gecode::Space(fixture) {
576 starts.update(*this,fixture.starts);
577 capacity.update(*this,fixture.capacity);
578 }
579 virtual Gecode::Space* copy(void) {
580 return new VariableCapacityFixture(*this);
581 }
582 };
583
584 static bool variable_capacity_rechecks(void) {
585 VariableCapacityFixture root;
586 if (root.status() == Gecode::SS_FAILED)
587 return false;
588 std::unique_ptr<VariableCapacityFixture> clone(
589 static_cast<VariableCapacityFixture*>(root.clone()));
590 Gecode::rel(*clone,clone->capacity,Gecode::IRT_EQ,3);
591 return clone->status() == Gecode::SS_FAILED;
592 }
593
594 static bool optional_subset(void) {
595 class OptionalSubsetFixture : public Gecode::Space {
596 public:
597 OptionalSubsetFixture(Gecode::IntPropLevel level) {
598 const int n = 69;
599 Gecode::IntVarArgs starts(n);
600 Gecode::BoolVarArgs mandatory(n);
601 Gecode::IntArgs processing(n);
602 Gecode::IntArgs demand(n);
603 for (int i=0; i<n; i++) {
604 starts[i] = Gecode::IntVar(*this,2*i,2*i);
605 mandatory[i] = Gecode::BoolVar(*this,i < 5 ? 1 : 0,1);
606 processing[i] = 1;
607 demand[i] = 2+(i & 1);
608 }
609 const int earliest[] = {1,0,2,0,0};
610 const int latest[] = {4,6,6,0,1};
611 const int durations[] = {3,1,1,2,4};
612 const int demands[] = {3,3,1,2,1};
613 for (int i=0; i<5; i++) {
614 starts[i] = Gecode::IntVar(*this,earliest[i],latest[i]);
615 processing[i] = durations[i];
616 demand[i] = demands[i];
617 }
618 Gecode::cumulative(*this,3,starts,processing,demand,mandatory,
619 level);
620 }
621 OptionalSubsetFixture(OptionalSubsetFixture& fixture)
622 : Gecode::Space(fixture) {}
623 virtual Gecode::Space* copy(void) {
624 return new OptionalSubsetFixture(*this);
625 }
626 };
627
628 OptionalSubsetFixture basic(Gecode::IPL_BASIC);
629 OptionalSubsetFixture advanced(Gecode::IPL_ADVANCED);
630 return (basic.status() != Gecode::SS_FAILED) &&
631 (advanced.status() == Gecode::SS_FAILED);
632 }
633
634 public:
636 : Test::Base("Cumulative::KnapsackAugmentedOverload") {}
637
638 virtual bool run(void) {
639 Fixture basic(Gecode::IPL_BASIC);
640 Fixture advanced(Gecode::IPL_ADVANCED);
641 return (basic.status() != Gecode::SS_FAILED) &&
642 (advanced.status() == Gecode::SS_FAILED) &&
643 variable_capacity_rechecks() && optional_subset();
644 }
645 };
646
648
650 class Create {
651 public:
653 Create(void) {
654 using namespace Gecode;
655 IntArgs p1({1,1,1,1});
656 IntArgs p2({2,2,2,2});
657 IntArgs p3({4,3,3,5});
658 IntArgs p4({4,0,3,5});
659 IntArgs p5({1,1,1});
660
661 IntArgs u1({1,1,1,1});
662 IntArgs u2({2,2,2,2});
663 IntArgs u3({2,3,4,5});
664 IntArgs u4({2,3,0,5});
665 IntArgs u5({1,3,2});
666
667 for (IntPropBasicAdvanced ipba; ipba(); ++ipba) {
668 // Regression test: check correct detection of disjunctive case
669 (void) new ManFixPCumulative(3,p5,u5,0,ipba.ipl());
670
671 for (int c=-7; c<8; c++) {
672 int off = 0;
673 for (int coff=0; coff<2; coff++) {
674 (void) new ManFixPCumulative(c,p1,u1,off,ipba.ipl());
675 (void) new ManFixPCumulative(c,p1,u2,off,ipba.ipl());
676 (void) new ManFixPCumulative(c,p1,u3,off,ipba.ipl());
677 (void) new ManFixPCumulative(c,p1,u4,off,ipba.ipl());
678 (void) new ManFixPCumulative(c,p2,u1,off,ipba.ipl());
679 (void) new ManFixPCumulative(c,p2,u2,off,ipba.ipl());
680 (void) new ManFixPCumulative(c,p2,u3,off,ipba.ipl());
681 (void) new ManFixPCumulative(c,p2,u4,off,ipba.ipl());
682 (void) new ManFixPCumulative(c,p3,u1,off,ipba.ipl());
683 (void) new ManFixPCumulative(c,p3,u2,off,ipba.ipl());
684 (void) new ManFixPCumulative(c,p3,u3,off,ipba.ipl());
685 (void) new ManFixPCumulative(c,p3,u4,off,ipba.ipl());
686 (void) new ManFixPCumulative(c,p4,u1,off,ipba.ipl());
687 (void) new ManFixPCumulative(c,p4,u2,off,ipba.ipl());
688 (void) new ManFixPCumulative(c,p4,u3,off,ipba.ipl());
689 (void) new ManFixPCumulative(c,p4,u4,off,ipba.ipl());
690
691 (void) new ManFlexCumulative(c,0,1,u1,off,ipba.ipl());
692 (void) new ManFlexCumulative(c,0,1,u2,off,ipba.ipl());
693 (void) new ManFlexCumulative(c,0,1,u3,off,ipba.ipl());
694 (void) new ManFlexCumulative(c,0,1,u4,off,ipba.ipl());
695 (void) new ManFlexCumulative(c,0,2,u1,off,ipba.ipl());
696 (void) new ManFlexCumulative(c,0,2,u2,off,ipba.ipl());
697 (void) new ManFlexCumulative(c,0,2,u3,off,ipba.ipl());
698 (void) new ManFlexCumulative(c,0,2,u4,off,ipba.ipl());
699 (void) new ManFlexCumulative(c,3,5,u1,off,ipba.ipl());
700 (void) new ManFlexCumulative(c,3,5,u2,off,ipba.ipl());
701 (void) new ManFlexCumulative(c,3,5,u3,off,ipba.ipl());
702 (void) new ManFlexCumulative(c,3,5,u4,off,ipba.ipl());
703
704 (void) new OptFixPCumulative(c,p1,u1,off,ipba.ipl());
705 (void) new OptFixPCumulative(c,p1,u2,off,ipba.ipl());
706 (void) new OptFixPCumulative(c,p1,u3,off,ipba.ipl());
707 (void) new OptFixPCumulative(c,p1,u4,off,ipba.ipl());
708 (void) new OptFixPCumulative(c,p2,u1,off,ipba.ipl());
709 (void) new OptFixPCumulative(c,p2,u2,off,ipba.ipl());
710 (void) new OptFixPCumulative(c,p2,u3,off,ipba.ipl());
711 (void) new OptFixPCumulative(c,p2,u4,off,ipba.ipl());
712 (void) new OptFixPCumulative(c,p3,u1,off,ipba.ipl());
713 (void) new OptFixPCumulative(c,p3,u2,off,ipba.ipl());
714 (void) new OptFixPCumulative(c,p3,u3,off,ipba.ipl());
715 (void) new OptFixPCumulative(c,p3,u4,off,ipba.ipl());
716 (void) new OptFixPCumulative(c,p4,u1,off,ipba.ipl());
717 (void) new OptFixPCumulative(c,p4,u2,off,ipba.ipl());
718 (void) new OptFixPCumulative(c,p4,u3,off,ipba.ipl());
719 (void) new OptFixPCumulative(c,p4,u4,off,ipba.ipl());
720
721 (void) new OptFlexCumulative(c,0,1,u1,off,ipba.ipl());
722 (void) new OptFlexCumulative(c,0,1,u2,off,ipba.ipl());
723 (void) new OptFlexCumulative(c,0,1,u3,off,ipba.ipl());
724 (void) new OptFlexCumulative(c,0,1,u4,off,ipba.ipl());
725 (void) new OptFlexCumulative(c,0,2,u1,off,ipba.ipl());
726 (void) new OptFlexCumulative(c,0,2,u2,off,ipba.ipl());
727 (void) new OptFlexCumulative(c,0,2,u3,off,ipba.ipl());
728 (void) new OptFlexCumulative(c,0,2,u4,off,ipba.ipl());
729 (void) new OptFlexCumulative(c,3,5,u1,off,ipba.ipl());
730 (void) new OptFlexCumulative(c,3,5,u2,off,ipba.ipl());
731 (void) new OptFlexCumulative(c,3,5,u3,off,ipba.ipl());
732 (void) new OptFlexCumulative(c,3,5,u4,off,ipba.ipl());
733
735 }
736 }
737 }
738 }
739 };
740
743
744 }
745}}
746
747// STATISTICS: test-int
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1606
Passing Boolean variables.
Definition int.hh:739
Boolean integer variables.
Definition int.hh:534
Passing integer arguments.
Definition int.hh:653
Integer sets.
Definition int.hh:179
Passing integer variables.
Definition int.hh:681
Integer variable array.
Definition int.hh:792
Integer variables.
Definition int.hh:390
Computation spaces.
Definition core.hpp:1787
ArrayTraits< VarArgArray< Var > >::ArgsType slice(int start, int inc=1, int n=-1)
Definition array.hpp:965
int size(void) const
Return size of array (number of elements).
Definition array.hpp:945
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
Definition array.hpp:1032
Gecode::Support::RandomGenerator _rand
Random number generator.
Definition test.hh:238
Base(std::string s)
Create and register a standard test with name s.
Definition test.cpp:125
Base class for assignments
Definition int.hh:73
int size(void) const
Return number of variables.
Definition int.hpp:46
Help class to create and register tests.
Create(void)
Perform creation and registration.
Check overload detection before search, including capacity wakeups.
Fixed-end tasks must accept exactly the capacity-feasible schedules.
virtual bool solution(const Assignment &x) const
Check for solution.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint.
Test for cumulative constraint with mandatory tasks.
virtual Assignment * assignment(void) const
Create and register initial assignment.
ManFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
Gecode::IntArgs u
The resource usage.
Gecode::IntArgs p
The processing times.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
static int st(int c, const Gecode::IntArgs &p, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Test for cumulative constraint with flexible mandatory tasks.
virtual Assignment * assignment(void) const
Create and register initial assignment.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Gecode::IntArgs u
The resource usage.
static int st(int c, int maxP, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
int _maxP
Maximum processing time.
ManFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
int _minP
Minimum processing time.
Test for cumulative constraint with optional tasks.
int l
Limit for optional tasks.
Gecode::IntArgs p
The processing times.
Gecode::IntArgs u
The resource usage.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual Assignment * assignment(void) const
Create and register initial assignment.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
static int st(int c, const Gecode::IntArgs &p, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
OptFixPCumulative(int c0, const Gecode::IntArgs &p0, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
Test for cumulative constraint with optional flexible tasks.
int _maxP
Maximum processing time.
virtual bool solution(const Assignment &x) const
Test whether x is solution.
Gecode::IntArgs u
The resource usage.
OptFlexCumulative(int c0, int minP, int maxP, const Gecode::IntArgs &u0, int o0, Gecode::IntPropLevel ipl0)
Create and register test.
static int st(int c, int maxP, const Gecode::IntArgs &u)
Get a reasonable maximal start time.
int _minP
Minimum processing time.
int l
Limit for optional tasks.
virtual Assignment * assignment(void) const
Create and register initial assignment.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Iterator for basic and advanced integer propagation levels.
Definition int.hh:448
Generate random selection of assignments.
Definition int.hh:110
Generate random selection of assignments.
Definition int.hh:130
bool testsearch
Whether to perform search test.
Definition int.hh:285
static std::string str(bool b)
Map bool to string.
Definition int.hpp:278
bool testfix
Whether to perform fixpoint test.
Definition int.hh:287
Gecode::IntPropLevel ipl
Propagation level.
Definition int.hh:281
int arity
Number of variables.
Definition int.hh:273
Gecode::IntSet dom
Domain of variables.
Definition int.hh:275
ConTestLevel contest
Whether to test for certain consistency.
Definition int.hh:283
Set of test tags.
Definition test.hh:105
const int capacity[n_warehouses]
Capacity of a single warehouse.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Definition rel.cpp:68
IntPropLevel
Propagation levels for integer propagators.
Definition int.hh:1274
ArgArray< TaskType > TaskTypeArgs
Argument arrays for passing task type arguments.
Definition int.hh:1316
@ IRT_EQ
Equality ( ).
Definition int.hh:1226
@ TT_FIXE
Definition int.hh:1308
@ IPL_BASIC
Use basic propagation algorithm.
Definition int.hh:1281
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
Definition int.hh:1279
@ IPL_ADVANCED
Use advanced propagation algorithm.
Definition int.hh:1282
virtual Space * copy(void)=0
Copying member function.
Space * clone(void) const
Clone space.
Definition core.hpp:3384
SpaceStatus status(StatusStatistics &stat)
Query space status.
Definition core.cpp:281
@ SS_FAILED
Space is failed
Definition core.hpp:1727
const int min
Smallest allowed integer value.
Definition int.hh:123
const int max
Largest allowed integer value.
Definition int.hh:121
Gecode toplevel namespace
IntVar expr(Home home, const LinIntExpr &e, const IntPropLevels &ipls=IntPropLevels::def)
Post linear expression and return its value.
Definition int-expr.cpp:988
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition dom.cpp:40
void cumulative(Home home, int c, const TaskTypeArgs &t, const IntVarArgs &flex, const IntArgs &fix, const IntArgs &u, IntPropLevel ipl=IPL_DEF)
Post propagators for scheduling tasks on cumulative resources.
Tests for cumulative scheduling constraints.
KnapsackAugmentedOverload knapsackAugmentedOverload
ManFixECumulative manFixECumulative
Testing finite domain integers.
Definition int.cpp:41
@ CTL_NONE
No consistency-test.
Definition int.hh:154
General test support.
Definition afc.cpp:41
@ check
Basic integrity tests.
Definition test.hh:99
@ standard
Standard test suite.
Definition test.hh:100
@ sweep
Really heavy sweep tests.
Definition test.hh:101