00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 namespace Gecode {
00037
00054 template<class View, PropCond pc>
00055 class UnaryPropagator : public Propagator {
00056 protected:
00058 View x0;
00060 UnaryPropagator(Space& home, UnaryPropagator& p);
00062 UnaryPropagator(Space& home, Propagator& p, View x0);
00064 UnaryPropagator(Home home, View x0);
00065 public:
00067 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00069 virtual void reschedule(Space& home);
00071 virtual size_t dispose(Space& home);
00072 };
00073
00083 template<class View, PropCond pc>
00084 class BinaryPropagator : public Propagator {
00085 protected:
00087 View x0, x1;
00089 BinaryPropagator(Space& home, BinaryPropagator& p);
00091 BinaryPropagator(Home home, View x0, View x1);
00093 BinaryPropagator(Space& home, Propagator& p, View x0, View x1);
00094 public:
00096 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00098 virtual void reschedule(Space& home);
00100 virtual size_t dispose(Space& home);
00101 };
00102
00112 template<class View, PropCond pc>
00113 class TernaryPropagator : public Propagator {
00114 protected:
00116 View x0, x1, x2;
00118 TernaryPropagator(Space& home, TernaryPropagator& p);
00120 TernaryPropagator(Home home, View x0, View x1, View x2);
00122 TernaryPropagator(Space& home, Propagator& p, View x0, View x1, View x2);
00123 public:
00125 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00127 virtual void reschedule(Space& home);
00129 virtual size_t dispose(Space& home);
00130 };
00131
00141 template<class View, PropCond pc>
00142 class NaryPropagator : public Propagator {
00143 protected:
00145 ViewArray<View> x;
00147 NaryPropagator(Space& home, NaryPropagator& p);
00149 NaryPropagator(Space& home, Propagator& p, ViewArray<View>& x);
00151 NaryPropagator(Home home, ViewArray<View>& x);
00152 public:
00154 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00156 virtual void reschedule(Space& home);
00158 virtual size_t dispose(Space& home);
00159 };
00160
00171 template<class View, PropCond pc>
00172 class NaryOnePropagator : public Propagator {
00173 protected:
00175 ViewArray<View> x;
00177 View y;
00179 NaryOnePropagator(Space& home, NaryOnePropagator& p);
00181 NaryOnePropagator(Space& home, Propagator& p, ViewArray<View>& x, View y);
00183 NaryOnePropagator(Home home, ViewArray<View>& x, View y);
00184 public:
00186 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00188 virtual void reschedule(Space& home);
00190 virtual size_t dispose(Space& home);
00191 };
00192
00203 template<class View0, PropCond pc0, class View1, PropCond pc1>
00204 class MixBinaryPropagator : public Propagator {
00205 protected:
00207 View0 x0;
00209 View1 x1;
00211 MixBinaryPropagator(Space& home, MixBinaryPropagator& p);
00213 MixBinaryPropagator(Home home, View0 x0, View1 x1);
00215 MixBinaryPropagator(Space& home, Propagator& p, View0 x0, View1 x1);
00216 public:
00218 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00220 virtual void reschedule(Space& home);
00222 virtual size_t dispose(Space& home);
00223 };
00224
00235 template<class View0, PropCond pc0, class View1, PropCond pc1,
00236 class View2, PropCond pc2>
00237 class MixTernaryPropagator : public Propagator {
00238 protected:
00240 View0 x0;
00242 View1 x1;
00244 View2 x2;
00246 MixTernaryPropagator(Space& home, MixTernaryPropagator& p);
00248 MixTernaryPropagator(Home home, View0 x0, View1 x1, View2 x2);
00250 MixTernaryPropagator(Space& home, Propagator& p,
00251 View0 x0, View1 x1, View2 x2);
00252 public:
00254 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00256 virtual void reschedule(Space& home);
00258 virtual size_t dispose(Space& home);
00259 };
00260
00271 template<class View0, PropCond pc0, class View1, PropCond pc1>
00272 class MixNaryOnePropagator : public Propagator {
00273 protected:
00275 ViewArray<View0> x;
00277 View1 y;
00279 MixNaryOnePropagator(Space& home, MixNaryOnePropagator& p);
00281 MixNaryOnePropagator(Home home, ViewArray<View0>& x, View1 y);
00283 MixNaryOnePropagator(Space& home, Propagator& p,
00284 ViewArray<View0>& x, View1 y);
00285 public:
00287 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00289 virtual void reschedule(Space& home);
00291 virtual size_t dispose(Space& home);
00292 };
00294
00295
00296
00297
00298
00299
00300
00301 template<class View, PropCond pc>
00302 UnaryPropagator<View,pc>::UnaryPropagator(Home home, View y0)
00303 : Propagator(home), x0(y0) {
00304 if (pc != PC_GEN_NONE)
00305 x0.subscribe(home,*this,pc);
00306 }
00307
00308 template<class View, PropCond pc>
00309 forceinline
00310 UnaryPropagator<View,pc>::UnaryPropagator
00311 (Space& home, UnaryPropagator<View,pc>& p)
00312 : Propagator(home,p) {
00313 x0.update(home,p.x0);
00314 }
00315
00316 template<class View, PropCond pc>
00317 forceinline
00318 UnaryPropagator<View,pc>::UnaryPropagator
00319 (Space& home, Propagator& p, View y0)
00320 : Propagator(home,p) {
00321 x0.update(home,y0);
00322 }
00323
00324 template<class View, PropCond pc>
00325 PropCost
00326 UnaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00327 return PropCost::unary(PropCost::LO);
00328 }
00329
00330 template<class View, PropCond pc>
00331 void
00332 UnaryPropagator<View,pc>::reschedule(Space& home) {
00333 if (pc != PC_GEN_NONE)
00334 x0.reschedule(home,*this,pc);
00335 }
00336
00337 template<class View, PropCond pc>
00338 forceinline size_t
00339 UnaryPropagator<View,pc>::dispose(Space& home) {
00340 if (pc != PC_GEN_NONE)
00341 x0.cancel(home,*this,pc);
00342 (void) Propagator::dispose(home);
00343 return sizeof(*this);
00344 }
00345
00346
00347
00348
00349
00350
00351
00352 template<class View, PropCond pc>
00353 BinaryPropagator<View,pc>::BinaryPropagator(Home home, View y0, View y1)
00354 : Propagator(home), x0(y0), x1(y1) {
00355 if (pc != PC_GEN_NONE) {
00356 x0.subscribe(home,*this,pc);
00357 x1.subscribe(home,*this,pc);
00358 }
00359 }
00360
00361 template<class View, PropCond pc>
00362 forceinline
00363 BinaryPropagator<View,pc>::BinaryPropagator
00364 (Space& home, BinaryPropagator<View,pc>& p)
00365 : Propagator(home,p) {
00366 x0.update(home,p.x0);
00367 x1.update(home,p.x1);
00368 }
00369
00370 template<class View, PropCond pc>
00371 forceinline
00372 BinaryPropagator<View,pc>::BinaryPropagator
00373 (Space& home, Propagator& p, View y0, View y1)
00374 : Propagator(home,p) {
00375 x0.update(home,y0);
00376 x1.update(home,y1);
00377 }
00378
00379 template<class View, PropCond pc>
00380 PropCost
00381 BinaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00382 return PropCost::binary(PropCost::LO);
00383 }
00384
00385 template<class View, PropCond pc>
00386 void
00387 BinaryPropagator<View,pc>::reschedule(Space& home) {
00388 if (pc != PC_GEN_NONE) {
00389 x0.reschedule(home,*this,pc);
00390 x1.reschedule(home,*this,pc);
00391 }
00392 }
00393
00394 template<class View, PropCond pc>
00395 forceinline size_t
00396 BinaryPropagator<View,pc>::dispose(Space& home) {
00397 if (pc != PC_GEN_NONE) {
00398 x0.cancel(home,*this,pc);
00399 x1.cancel(home,*this,pc);
00400 }
00401 (void) Propagator::dispose(home);
00402 return sizeof(*this);
00403 }
00404
00405
00406
00407
00408
00409
00410 template<class View, PropCond pc>
00411 TernaryPropagator<View,pc>::TernaryPropagator
00412 (Home home, View y0, View y1, View y2)
00413 : Propagator(home), x0(y0), x1(y1), x2(y2) {
00414 if (pc != PC_GEN_NONE) {
00415 x0.subscribe(home,*this,pc);
00416 x1.subscribe(home,*this,pc);
00417 x2.subscribe(home,*this,pc);
00418 }
00419 }
00420
00421 template<class View, PropCond pc>
00422 forceinline
00423 TernaryPropagator<View,pc>::TernaryPropagator
00424 (Space& home, TernaryPropagator<View,pc>& p)
00425 : Propagator(home,p) {
00426 x0.update(home,p.x0);
00427 x1.update(home,p.x1);
00428 x2.update(home,p.x2);
00429 }
00430
00431 template<class View, PropCond pc>
00432 forceinline
00433 TernaryPropagator<View,pc>::TernaryPropagator
00434 (Space& home, Propagator& p, View y0, View y1, View y2)
00435 : Propagator(home,p) {
00436 x0.update(home,y0);
00437 x1.update(home,y1);
00438 x2.update(home,y2);
00439 }
00440
00441 template<class View, PropCond pc>
00442 PropCost
00443 TernaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00444 return PropCost::ternary(PropCost::LO);;
00445 }
00446
00447 template<class View, PropCond pc>
00448 void
00449 TernaryPropagator<View,pc>::reschedule(Space& home) {
00450 if (pc != PC_GEN_NONE) {
00451 x0.reschedule(home,*this,pc);
00452 x1.reschedule(home,*this,pc);
00453 x2.reschedule(home,*this,pc);
00454 }
00455 }
00456
00457 template<class View, PropCond pc>
00458 forceinline size_t
00459 TernaryPropagator<View,pc>::dispose(Space& home) {
00460 if (pc != PC_GEN_NONE) {
00461 x0.cancel(home,*this,pc);
00462 x1.cancel(home,*this,pc);
00463 x2.cancel(home,*this,pc);
00464 }
00465 (void) Propagator::dispose(home);
00466 return sizeof(*this);
00467 }
00468
00469
00470
00471
00472
00473
00474 template<class View, PropCond pc>
00475 NaryPropagator<View,pc>::NaryPropagator
00476 (Home home, ViewArray<View>& y)
00477 : Propagator(home), x(y) {
00478 if (pc != PC_GEN_NONE)
00479 x.subscribe(home,*this,pc);
00480 }
00481
00482 template<class View, PropCond pc>
00483 forceinline
00484 NaryPropagator<View,pc>::NaryPropagator
00485 (Space& home, NaryPropagator<View,pc>& p)
00486 : Propagator(home,p) {
00487 x.update(home,p.x);
00488 }
00489
00490 template<class View, PropCond pc>
00491 forceinline
00492 NaryPropagator<View,pc>::NaryPropagator
00493 (Space& home, Propagator& p, ViewArray<View>& x0)
00494 : Propagator(home,p) {
00495 x.update(home,x0);
00496 }
00497
00498 template<class View, PropCond pc>
00499 PropCost
00500 NaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00501 return PropCost::linear(PropCost::LO,x.size());
00502 }
00503
00504 template<class View, PropCond pc>
00505 void
00506 NaryPropagator<View,pc>::reschedule(Space& home) {
00507 if (pc != PC_GEN_NONE)
00508 x.reschedule(home,*this,pc);
00509 }
00510
00511 template<class View, PropCond pc>
00512 forceinline size_t
00513 NaryPropagator<View,pc>::dispose(Space& home) {
00514 if (pc != PC_GEN_NONE)
00515 x.cancel(home,*this,pc);
00516 (void) Propagator::dispose(home);
00517 return sizeof(*this);
00518 }
00519
00520
00521
00522
00523
00524
00525 template<class View, PropCond pc>
00526 NaryOnePropagator<View,pc>::NaryOnePropagator
00527 (Home home, ViewArray<View>& x0, View y0)
00528 : Propagator(home), x(x0), y(y0) {
00529 if (pc != PC_GEN_NONE) {
00530 x.subscribe(home,*this,pc);
00531 y.subscribe(home,*this,pc);
00532 }
00533 }
00534
00535 template<class View, PropCond pc>
00536 forceinline
00537 NaryOnePropagator<View,pc>::NaryOnePropagator
00538 (Space& home, NaryOnePropagator<View,pc>& p)
00539 : Propagator(home,p) {
00540 x.update(home,p.x);
00541 y.update(home,p.y);
00542 }
00543
00544 template<class View, PropCond pc>
00545 forceinline
00546 NaryOnePropagator<View,pc>::NaryOnePropagator
00547 (Space& home, Propagator& p, ViewArray<View>& x0, View y0)
00548 : Propagator(home,p) {
00549 x.update(home,x0);
00550 y.update(home,y0);
00551 }
00552
00553 template<class View, PropCond pc>
00554 PropCost
00555 NaryOnePropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00556 return PropCost::linear(PropCost::LO,x.size()+1);
00557 }
00558
00559 template<class View, PropCond pc>
00560 void
00561 NaryOnePropagator<View,pc>::reschedule(Space& home) {
00562 if (pc != PC_GEN_NONE) {
00563 x.reschedule(home,*this,pc);
00564 y.reschedule(home,*this,pc);
00565 }
00566 }
00567
00568 template<class View, PropCond pc>
00569 forceinline size_t
00570 NaryOnePropagator<View,pc>::dispose(Space& home) {
00571 if (pc != PC_GEN_NONE) {
00572 x.cancel(home,*this,pc);
00573 y.cancel(home,*this,pc);
00574 }
00575 (void) Propagator::dispose(home);
00576 return sizeof(*this);
00577 }
00578
00579
00580
00581
00582
00583
00584 template<class View0, PropCond pc0, class View1, PropCond pc1>
00585 MixBinaryPropagator<View0,pc0,View1,pc1>::MixBinaryPropagator
00586 (Home home, View0 y0, View1 y1)
00587 : Propagator(home), x0(y0), x1(y1) {
00588 if (pc0 != PC_GEN_NONE)
00589 x0.subscribe(home,*this,pc0);
00590 if (pc1 != PC_GEN_NONE)
00591 x1.subscribe(home,*this,pc1);
00592 }
00593
00594 template<class View0, PropCond pc0, class View1, PropCond pc1>
00595 forceinline
00596 MixBinaryPropagator<View0,pc0,View1,pc1>::MixBinaryPropagator
00597 (Space& home, MixBinaryPropagator<View0,pc0,View1,pc1>& p)
00598 : Propagator(home,p) {
00599 x0.update(home,p.x0);
00600 x1.update(home,p.x1);
00601 }
00602
00603 template<class View0, PropCond pc0, class View1, PropCond pc1>
00604 forceinline
00605 MixBinaryPropagator<View0,pc0,View1,pc1>::MixBinaryPropagator
00606 (Space& home, Propagator& p, View0 y0, View1 y1)
00607 : Propagator(home,p) {
00608 x0.update(home,y0);
00609 x1.update(home,y1);
00610 }
00611
00612 template<class View0, PropCond pc0, class View1, PropCond pc1>
00613 PropCost
00614 MixBinaryPropagator<View0,pc0,View1,pc1>::cost(const Space&,
00615 const ModEventDelta&) const {
00616 return PropCost::binary(PropCost::LO);
00617 }
00618
00619 template<class View0, PropCond pc0, class View1, PropCond pc1>
00620 void
00621 MixBinaryPropagator<View0,pc0,View1,pc1>::reschedule(Space& home) {
00622 if (pc0 != PC_GEN_NONE)
00623 x0.reschedule(home,*this,pc0);
00624 if (pc1 != PC_GEN_NONE)
00625 x1.reschedule(home,*this,pc1);
00626 }
00627
00628 template<class View0, PropCond pc0, class View1, PropCond pc1>
00629 forceinline size_t
00630 MixBinaryPropagator<View0,pc0,View1,pc1>::dispose(Space& home) {
00631 if (pc0 != PC_GEN_NONE)
00632 x0.cancel(home,*this,pc0);
00633 if (pc1 != PC_GEN_NONE)
00634 x1.cancel(home,*this,pc1);
00635 (void) Propagator::dispose(home);
00636 return sizeof(*this);
00637 }
00638
00639
00640
00641
00642
00643
00644 template<class View0, PropCond pc0, class View1, PropCond pc1,
00645 class View2, PropCond pc2>
00646 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::
00647 MixTernaryPropagator(Home home, View0 y0, View1 y1, View2 y2)
00648 : Propagator(home), x0(y0), x1(y1), x2(y2) {
00649 if (pc0 != PC_GEN_NONE)
00650 x0.subscribe(home,*this,pc0);
00651 if (pc1 != PC_GEN_NONE)
00652 x1.subscribe(home,*this,pc1);
00653 if (pc2 != PC_GEN_NONE)
00654 x2.subscribe(home,*this,pc2);
00655 }
00656
00657 template<class View0, PropCond pc0, class View1, PropCond pc1,
00658 class View2, PropCond pc2>
00659 forceinline
00660 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::
00661 MixTernaryPropagator(Space& home,
00662 MixTernaryPropagator<View0,pc0,View1,pc1,
00663 View2,pc2>& p)
00664 : Propagator(home,p) {
00665 x0.update(home,p.x0);
00666 x1.update(home,p.x1);
00667 x2.update(home,p.x2);
00668 }
00669
00670 template<class View0, PropCond pc0, class View1, PropCond pc1,
00671 class View2, PropCond pc2>
00672 forceinline
00673 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::MixTernaryPropagator
00674 (Space& home, Propagator& p, View0 y0, View1 y1, View2 y2)
00675 : Propagator(home,p) {
00676 x0.update(home,y0);
00677 x1.update(home,y1);
00678 x2.update(home,y2);
00679 }
00680
00681 template<class View0, PropCond pc0, class View1, PropCond pc1,
00682 class View2, PropCond pc2>
00683 PropCost
00684 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::
00685 cost(const Space&, const ModEventDelta&) const {
00686 return PropCost::ternary(PropCost::LO);
00687 }
00688
00689 template<class View0, PropCond pc0, class View1, PropCond pc1,
00690 class View2, PropCond pc2>
00691 void
00692 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::reschedule(Space& home) {
00693 if (pc0 != PC_GEN_NONE)
00694 x0.reschedule(home,*this,pc0);
00695 if (pc1 != PC_GEN_NONE)
00696 x1.reschedule(home,*this,pc1);
00697 if (pc2 != PC_GEN_NONE)
00698 x2.reschedule(home,*this,pc2);
00699 }
00700
00701 template<class View0, PropCond pc0, class View1, PropCond pc1,
00702 class View2, PropCond pc2>
00703 forceinline size_t
00704 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::dispose(Space& home) {
00705 if (pc0 != PC_GEN_NONE)
00706 x0.cancel(home,*this,pc0);
00707 if (pc1 != PC_GEN_NONE)
00708 x1.cancel(home,*this,pc1);
00709 if (pc2 != PC_GEN_NONE)
00710 x2.cancel(home,*this,pc2);
00711 (void) Propagator::dispose(home);
00712 return sizeof(*this);
00713 }
00714
00715
00716
00717
00718
00719
00720 template<class View0, PropCond pc0, class View1, PropCond pc1>
00721 MixNaryOnePropagator<View0,pc0,View1,pc1>::MixNaryOnePropagator
00722 (Home home, ViewArray<View0>& x0, View1 y0)
00723 : Propagator(home), x(x0), y(y0) {
00724 if (pc0 != PC_GEN_NONE)
00725 x.subscribe(home,*this,pc0);
00726 if (pc1 != PC_GEN_NONE)
00727 y.subscribe(home,*this,pc1);
00728 }
00729
00730 template<class View0, PropCond pc0, class View1, PropCond pc1>
00731 forceinline
00732 MixNaryOnePropagator<View0,pc0,View1,pc1>::MixNaryOnePropagator
00733 (Space& home, MixNaryOnePropagator<View0,pc0,View1,pc1>& p)
00734 : Propagator(home,p) {
00735 x.update(home,p.x);
00736 y.update(home,p.y);
00737 }
00738
00739 template<class View0, PropCond pc0, class View1, PropCond pc1>
00740 forceinline
00741 MixNaryOnePropagator<View0,pc0,View1,pc1>::MixNaryOnePropagator
00742 (Space& home, Propagator& p, ViewArray<View0>& x0, View1 y0)
00743 : Propagator(home,p) {
00744 x.update(home,x0);
00745 y.update(home,y0);
00746 }
00747
00748 template<class View0, PropCond pc0, class View1, PropCond pc1>
00749 PropCost
00750 MixNaryOnePropagator<View0,pc0,View1,pc1>::cost(const Space&,
00751 const ModEventDelta&) const {
00752 return PropCost::linear(PropCost::LO,x.size()+1);
00753 }
00754
00755 template<class View0, PropCond pc0, class View1, PropCond pc1>
00756 void
00757 MixNaryOnePropagator<View0,pc0,View1,pc1>::reschedule(Space& home) {
00758 if (pc0 != PC_GEN_NONE)
00759 x.reschedule(home,*this,pc0);
00760 if (pc1 != PC_GEN_NONE)
00761 y.reschedule(home,*this,pc1);
00762 }
00763
00764 template<class View0, PropCond pc0, class View1, PropCond pc1>
00765 forceinline size_t
00766 MixNaryOnePropagator<View0,pc0,View1,pc1>::dispose(Space& home) {
00767 if (pc0 != PC_GEN_NONE)
00768 x.cancel(home,*this,pc0);
00769 if (pc1 != PC_GEN_NONE)
00770 y.cancel(home,*this,pc1);
00771 (void) Propagator::dispose(home);
00772 return sizeof(*this);
00773 }
00774
00775 }
00776
00777