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
00037
00038
00039
00040 namespace Gecode {
00041
00058 template<class View, PropCond pc>
00059 class UnaryPropagator : public Propagator {
00060 protected:
00062 View x0;
00064 UnaryPropagator(Space& home, bool share, UnaryPropagator& p);
00066 UnaryPropagator(Space& home, bool share, Propagator& p,
00067 View x0);
00069 UnaryPropagator(Home home, View x0);
00070 public:
00072 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00074 virtual void reschedule(Space& home);
00076 virtual size_t dispose(Space& home);
00077 };
00078
00088 template<class View, PropCond pc>
00089 class BinaryPropagator : public Propagator {
00090 protected:
00092 View x0, x1;
00094 BinaryPropagator(Space& home, bool share, BinaryPropagator& p);
00096 BinaryPropagator(Home home, View x0, View x1);
00098 BinaryPropagator(Space& home, bool share, Propagator& p,
00099 View x0, View x1);
00100 public:
00102 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00104 virtual void reschedule(Space& home);
00106 virtual size_t dispose(Space& home);
00107 };
00108
00118 template<class View, PropCond pc>
00119 class TernaryPropagator : public Propagator {
00120 protected:
00122 View x0, x1, x2;
00124 TernaryPropagator(Space& home, bool share, TernaryPropagator& p);
00126 TernaryPropagator(Home home, View x0, View x1, View x2);
00128 TernaryPropagator(Space& home, bool share, Propagator& p,
00129 View x0, View x1, View x2);
00130 public:
00132 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00134 virtual void reschedule(Space& home);
00136 virtual size_t dispose(Space& home);
00137 };
00138
00148 template<class View, PropCond pc>
00149 class NaryPropagator : public Propagator {
00150 protected:
00152 ViewArray<View> x;
00154 NaryPropagator(Space& home, bool share, NaryPropagator& p);
00156 NaryPropagator(Space& home, bool share, Propagator& p,
00157 ViewArray<View>& x);
00159 NaryPropagator(Home home, ViewArray<View>& x);
00160 public:
00162 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00164 virtual void reschedule(Space& home);
00166 virtual size_t dispose(Space& home);
00167 };
00168
00179 template<class View, PropCond pc>
00180 class NaryOnePropagator : public Propagator {
00181 protected:
00183 ViewArray<View> x;
00185 View y;
00187 NaryOnePropagator(Space& home, bool share, NaryOnePropagator& p);
00189 NaryOnePropagator(Space& home, bool share, Propagator& p,
00190 ViewArray<View>& x, View y);
00192 NaryOnePropagator(Home home, ViewArray<View>& x, View y);
00193 public:
00195 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00197 virtual void reschedule(Space& home);
00199 virtual size_t dispose(Space& home);
00200 };
00201
00212 template<class View0, PropCond pc0, class View1, PropCond pc1>
00213 class MixBinaryPropagator : public Propagator {
00214 protected:
00216 View0 x0;
00218 View1 x1;
00220 MixBinaryPropagator(Space& home,bool,MixBinaryPropagator&);
00222 MixBinaryPropagator(Home home,View0,View1);
00224 MixBinaryPropagator(Space& home, bool share, Propagator& p,
00225 View0 x0, View1 x1);
00226 public:
00228 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00230 virtual void reschedule(Space& home);
00232 virtual size_t dispose(Space& home);
00233 };
00234
00245 template<class View0, PropCond pc0, class View1, PropCond pc1,
00246 class View2, PropCond pc2>
00247 class MixTernaryPropagator : public Propagator {
00248 protected:
00250 View0 x0;
00252 View1 x1;
00254 View2 x2;
00256 MixTernaryPropagator(Space& home, bool share, MixTernaryPropagator& p);
00258 MixTernaryPropagator(Home home, View0 x0, View1 x1, View2 x2);
00260 MixTernaryPropagator(Space& home, bool share, Propagator& p,
00261 View0 x0, View1 x1, View2 x2);
00262 public:
00264 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00266 virtual void reschedule(Space& home);
00268 virtual size_t dispose(Space& home);
00269 };
00270
00281 template<class View0, PropCond pc0, class View1, PropCond pc1>
00282 class MixNaryOnePropagator : public Propagator {
00283 protected:
00285 ViewArray<View0> x;
00287 View1 y;
00289 MixNaryOnePropagator(Space& home, bool share, MixNaryOnePropagator& p);
00291 MixNaryOnePropagator(Home home, ViewArray<View0>& x, View1 y);
00293 MixNaryOnePropagator(Space& home, bool share, Propagator& p,
00294 ViewArray<View0>& x, View1 y);
00295 public:
00297 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00299 virtual void reschedule(Space& home);
00301 virtual size_t dispose(Space& home);
00302 };
00304
00305
00306
00307
00308
00309
00310
00311 template<class View, PropCond pc>
00312 UnaryPropagator<View,pc>::UnaryPropagator(Home home, View y0)
00313 : Propagator(home), x0(y0) {
00314 if (pc != PC_GEN_NONE)
00315 x0.subscribe(home,*this,pc);
00316 }
00317
00318 template<class View, PropCond pc>
00319 forceinline
00320 UnaryPropagator<View,pc>::UnaryPropagator
00321 (Space& home, bool share, UnaryPropagator<View,pc>& p)
00322 : Propagator(home,share,p) {
00323 x0.update(home,share,p.x0);
00324 }
00325
00326 template<class View, PropCond pc>
00327 forceinline
00328 UnaryPropagator<View,pc>::UnaryPropagator
00329 (Space& home, bool share, Propagator& p, View y0)
00330 : Propagator(home,share,p) {
00331 x0.update(home,share,y0);
00332 }
00333
00334 template<class View, PropCond pc>
00335 PropCost
00336 UnaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00337 return PropCost::unary(PropCost::LO);
00338 }
00339
00340 template<class View, PropCond pc>
00341 void
00342 UnaryPropagator<View,pc>::reschedule(Space& home) {
00343 if (pc != PC_GEN_NONE)
00344 x0.reschedule(home,*this,pc);
00345 }
00346
00347 template<class View, PropCond pc>
00348 forceinline size_t
00349 UnaryPropagator<View,pc>::dispose(Space& home) {
00350 if (pc != PC_GEN_NONE)
00351 x0.cancel(home,*this,pc);
00352 (void) Propagator::dispose(home);
00353 return sizeof(*this);
00354 }
00355
00356
00357
00358
00359
00360
00361
00362 template<class View, PropCond pc>
00363 BinaryPropagator<View,pc>::BinaryPropagator(Home home, View y0, View y1)
00364 : Propagator(home), x0(y0), x1(y1) {
00365 if (pc != PC_GEN_NONE) {
00366 x0.subscribe(home,*this,pc);
00367 x1.subscribe(home,*this,pc);
00368 }
00369 }
00370
00371 template<class View, PropCond pc>
00372 forceinline
00373 BinaryPropagator<View,pc>::BinaryPropagator
00374 (Space& home, bool share, BinaryPropagator<View,pc>& p)
00375 : Propagator(home,share,p) {
00376 x0.update(home,share,p.x0);
00377 x1.update(home,share,p.x1);
00378 }
00379
00380 template<class View, PropCond pc>
00381 forceinline
00382 BinaryPropagator<View,pc>::BinaryPropagator
00383 (Space& home, bool share, Propagator& p, View y0, View y1)
00384 : Propagator(home,share,p) {
00385 x0.update(home,share,y0);
00386 x1.update(home,share,y1);
00387 }
00388
00389 template<class View, PropCond pc>
00390 PropCost
00391 BinaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00392 return PropCost::binary(PropCost::LO);
00393 }
00394
00395 template<class View, PropCond pc>
00396 void
00397 BinaryPropagator<View,pc>::reschedule(Space& home) {
00398 if (pc != PC_GEN_NONE) {
00399 x0.reschedule(home,*this,pc);
00400 x1.reschedule(home,*this,pc);
00401 }
00402 }
00403
00404 template<class View, PropCond pc>
00405 forceinline size_t
00406 BinaryPropagator<View,pc>::dispose(Space& home) {
00407 if (pc != PC_GEN_NONE) {
00408 x0.cancel(home,*this,pc);
00409 x1.cancel(home,*this,pc);
00410 }
00411 (void) Propagator::dispose(home);
00412 return sizeof(*this);
00413 }
00414
00415
00416
00417
00418
00419
00420 template<class View, PropCond pc>
00421 TernaryPropagator<View,pc>::TernaryPropagator
00422 (Home home, View y0, View y1, View y2)
00423 : Propagator(home), x0(y0), x1(y1), x2(y2) {
00424 if (pc != PC_GEN_NONE) {
00425 x0.subscribe(home,*this,pc);
00426 x1.subscribe(home,*this,pc);
00427 x2.subscribe(home,*this,pc);
00428 }
00429 }
00430
00431 template<class View, PropCond pc>
00432 forceinline
00433 TernaryPropagator<View,pc>::TernaryPropagator
00434 (Space& home, bool share, TernaryPropagator<View,pc>& p)
00435 : Propagator(home,share,p) {
00436 x0.update(home,share,p.x0);
00437 x1.update(home,share,p.x1);
00438 x2.update(home,share,p.x2);
00439 }
00440
00441 template<class View, PropCond pc>
00442 forceinline
00443 TernaryPropagator<View,pc>::TernaryPropagator
00444 (Space& home, bool share, Propagator& p, View y0, View y1, View y2)
00445 : Propagator(home,share,p) {
00446 x0.update(home,share,y0);
00447 x1.update(home,share,y1);
00448 x2.update(home,share,y2);
00449 }
00450
00451 template<class View, PropCond pc>
00452 PropCost
00453 TernaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00454 return PropCost::ternary(PropCost::LO);;
00455 }
00456
00457 template<class View, PropCond pc>
00458 void
00459 TernaryPropagator<View,pc>::reschedule(Space& home) {
00460 if (pc != PC_GEN_NONE) {
00461 x0.reschedule(home,*this,pc);
00462 x1.reschedule(home,*this,pc);
00463 x2.reschedule(home,*this,pc);
00464 }
00465 }
00466
00467 template<class View, PropCond pc>
00468 forceinline size_t
00469 TernaryPropagator<View,pc>::dispose(Space& home) {
00470 if (pc != PC_GEN_NONE) {
00471 x0.cancel(home,*this,pc);
00472 x1.cancel(home,*this,pc);
00473 x2.cancel(home,*this,pc);
00474 }
00475 (void) Propagator::dispose(home);
00476 return sizeof(*this);
00477 }
00478
00479
00480
00481
00482
00483
00484 template<class View, PropCond pc>
00485 NaryPropagator<View,pc>::NaryPropagator
00486 (Home home, ViewArray<View>& y)
00487 : Propagator(home), x(y) {
00488 if (pc != PC_GEN_NONE)
00489 x.subscribe(home,*this,pc);
00490 }
00491
00492 template<class View, PropCond pc>
00493 forceinline
00494 NaryPropagator<View,pc>::NaryPropagator
00495 (Space& home, bool share, NaryPropagator<View,pc>& p)
00496 : Propagator(home,share,p) {
00497 x.update(home,share,p.x);
00498 }
00499
00500 template<class View, PropCond pc>
00501 forceinline
00502 NaryPropagator<View,pc>::NaryPropagator
00503 (Space& home, bool share, Propagator& p, ViewArray<View>& x0)
00504 : Propagator(home,share,p) {
00505 x.update(home,share,x0);
00506 }
00507
00508 template<class View, PropCond pc>
00509 PropCost
00510 NaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00511 return PropCost::linear(PropCost::LO,x.size());
00512 }
00513
00514 template<class View, PropCond pc>
00515 void
00516 NaryPropagator<View,pc>::reschedule(Space& home) {
00517 if (pc != PC_GEN_NONE)
00518 x.reschedule(home,*this,pc);
00519 }
00520
00521 template<class View, PropCond pc>
00522 forceinline size_t
00523 NaryPropagator<View,pc>::dispose(Space& home) {
00524 if (pc != PC_GEN_NONE)
00525 x.cancel(home,*this,pc);
00526 (void) Propagator::dispose(home);
00527 return sizeof(*this);
00528 }
00529
00530
00531
00532
00533
00534
00535 template<class View, PropCond pc>
00536 NaryOnePropagator<View,pc>::NaryOnePropagator
00537 (Home home, ViewArray<View>& x0, View y0)
00538 : Propagator(home), x(x0), y(y0) {
00539 if (pc != PC_GEN_NONE) {
00540 x.subscribe(home,*this,pc);
00541 y.subscribe(home,*this,pc);
00542 }
00543 }
00544
00545 template<class View, PropCond pc>
00546 forceinline
00547 NaryOnePropagator<View,pc>::NaryOnePropagator
00548 (Space& home, bool share, NaryOnePropagator<View,pc>& p)
00549 : Propagator(home,share,p) {
00550 x.update(home,share,p.x);
00551 y.update(home,share,p.y);
00552 }
00553
00554 template<class View, PropCond pc>
00555 forceinline
00556 NaryOnePropagator<View,pc>::NaryOnePropagator
00557 (Space& home, bool share, Propagator& p, ViewArray<View>& x0, View y0)
00558 : Propagator(home,share,p) {
00559 x.update(home,share,x0);
00560 y.update(home,share,y0);
00561 }
00562
00563 template<class View, PropCond pc>
00564 PropCost
00565 NaryOnePropagator<View,pc>::cost(const Space&, const ModEventDelta&) const {
00566 return PropCost::linear(PropCost::LO,x.size()+1);
00567 }
00568
00569 template<class View, PropCond pc>
00570 void
00571 NaryOnePropagator<View,pc>::reschedule(Space& home) {
00572 if (pc != PC_GEN_NONE) {
00573 x.reschedule(home,*this,pc);
00574 y.reschedule(home,*this,pc);
00575 }
00576 }
00577
00578 template<class View, PropCond pc>
00579 forceinline size_t
00580 NaryOnePropagator<View,pc>::dispose(Space& home) {
00581 if (pc != PC_GEN_NONE) {
00582 x.cancel(home,*this,pc);
00583 y.cancel(home,*this,pc);
00584 }
00585 (void) Propagator::dispose(home);
00586 return sizeof(*this);
00587 }
00588
00589
00590
00591
00592
00593
00594 template<class View0, PropCond pc0, class View1, PropCond pc1>
00595 MixBinaryPropagator<View0,pc0,View1,pc1>::MixBinaryPropagator
00596 (Home home, View0 y0, View1 y1)
00597 : Propagator(home), x0(y0), x1(y1) {
00598 if (pc0 != PC_GEN_NONE)
00599 x0.subscribe(home,*this,pc0);
00600 if (pc1 != PC_GEN_NONE)
00601 x1.subscribe(home,*this,pc1);
00602 }
00603
00604 template<class View0, PropCond pc0, class View1, PropCond pc1>
00605 forceinline
00606 MixBinaryPropagator<View0,pc0,View1,pc1>::MixBinaryPropagator
00607 (Space& home, bool share, MixBinaryPropagator<View0,pc0,View1,pc1>& p)
00608 : Propagator(home,share,p) {
00609 x0.update(home,share,p.x0);
00610 x1.update(home,share,p.x1);
00611 }
00612
00613 template<class View0, PropCond pc0, class View1, PropCond pc1>
00614 forceinline
00615 MixBinaryPropagator<View0,pc0,View1,pc1>::MixBinaryPropagator
00616 (Space& home, bool share, Propagator& p, View0 y0, View1 y1)
00617 : Propagator(home,share,p) {
00618 x0.update(home,share,y0);
00619 x1.update(home,share,y1);
00620 }
00621
00622 template<class View0, PropCond pc0, class View1, PropCond pc1>
00623 PropCost
00624 MixBinaryPropagator<View0,pc0,View1,pc1>::cost(const Space&,
00625 const ModEventDelta&) const {
00626 return PropCost::binary(PropCost::LO);
00627 }
00628
00629 template<class View0, PropCond pc0, class View1, PropCond pc1>
00630 void
00631 MixBinaryPropagator<View0,pc0,View1,pc1>::reschedule(Space& home) {
00632 if (pc0 != PC_GEN_NONE)
00633 x0.reschedule(home,*this,pc0);
00634 if (pc1 != PC_GEN_NONE)
00635 x1.reschedule(home,*this,pc1);
00636 }
00637
00638 template<class View0, PropCond pc0, class View1, PropCond pc1>
00639 forceinline size_t
00640 MixBinaryPropagator<View0,pc0,View1,pc1>::dispose(Space& home) {
00641 if (pc0 != PC_GEN_NONE)
00642 x0.cancel(home,*this,pc0);
00643 if (pc1 != PC_GEN_NONE)
00644 x1.cancel(home,*this,pc1);
00645 (void) Propagator::dispose(home);
00646 return sizeof(*this);
00647 }
00648
00649
00650
00651
00652
00653
00654 template<class View0, PropCond pc0, class View1, PropCond pc1,
00655 class View2, PropCond pc2>
00656 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::
00657 MixTernaryPropagator(Home home, View0 y0, View1 y1, View2 y2)
00658 : Propagator(home), x0(y0), x1(y1), x2(y2) {
00659 if (pc0 != PC_GEN_NONE)
00660 x0.subscribe(home,*this,pc0);
00661 if (pc1 != PC_GEN_NONE)
00662 x1.subscribe(home,*this,pc1);
00663 if (pc2 != PC_GEN_NONE)
00664 x2.subscribe(home,*this,pc2);
00665 }
00666
00667 template<class View0, PropCond pc0, class View1, PropCond pc1,
00668 class View2, PropCond pc2>
00669 forceinline
00670 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::
00671 MixTernaryPropagator(Space& home, bool share,
00672 MixTernaryPropagator<View0,pc0,View1,pc1,
00673 View2,pc2>& p)
00674 : Propagator(home,share,p) {
00675 x0.update(home,share,p.x0);
00676 x1.update(home,share,p.x1);
00677 x2.update(home,share,p.x2);
00678 }
00679
00680 template<class View0, PropCond pc0, class View1, PropCond pc1,
00681 class View2, PropCond pc2>
00682 forceinline
00683 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::MixTernaryPropagator
00684 (Space& home, bool share, Propagator& p, View0 y0, View1 y1, View2 y2)
00685 : Propagator(home,share,p) {
00686 x0.update(home,share,y0);
00687 x1.update(home,share,y1);
00688 x2.update(home,share,y2);
00689 }
00690
00691 template<class View0, PropCond pc0, class View1, PropCond pc1,
00692 class View2, PropCond pc2>
00693 PropCost
00694 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::
00695 cost(const Space&, const ModEventDelta&) const {
00696 return PropCost::ternary(PropCost::LO);
00697 }
00698
00699 template<class View0, PropCond pc0, class View1, PropCond pc1,
00700 class View2, PropCond pc2>
00701 void
00702 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::reschedule(Space& home) {
00703 if (pc0 != PC_GEN_NONE)
00704 x0.reschedule(home,*this,pc0);
00705 if (pc1 != PC_GEN_NONE)
00706 x1.reschedule(home,*this,pc1);
00707 if (pc2 != PC_GEN_NONE)
00708 x2.reschedule(home,*this,pc2);
00709 }
00710
00711 template<class View0, PropCond pc0, class View1, PropCond pc1,
00712 class View2, PropCond pc2>
00713 forceinline size_t
00714 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::dispose(Space& home) {
00715 if (pc0 != PC_GEN_NONE)
00716 x0.cancel(home,*this,pc0);
00717 if (pc1 != PC_GEN_NONE)
00718 x1.cancel(home,*this,pc1);
00719 if (pc2 != PC_GEN_NONE)
00720 x2.cancel(home,*this,pc2);
00721 (void) Propagator::dispose(home);
00722 return sizeof(*this);
00723 }
00724
00725
00726
00727
00728
00729
00730 template<class View0, PropCond pc0, class View1, PropCond pc1>
00731 MixNaryOnePropagator<View0,pc0,View1,pc1>::MixNaryOnePropagator
00732 (Home home, ViewArray<View0>& x0, View1 y0)
00733 : Propagator(home), x(x0), y(y0) {
00734 if (pc0 != PC_GEN_NONE)
00735 x.subscribe(home,*this,pc0);
00736 if (pc1 != PC_GEN_NONE)
00737 y.subscribe(home,*this,pc1);
00738 }
00739
00740 template<class View0, PropCond pc0, class View1, PropCond pc1>
00741 forceinline
00742 MixNaryOnePropagator<View0,pc0,View1,pc1>::MixNaryOnePropagator
00743 (Space& home, bool share, MixNaryOnePropagator<View0,pc0,View1,pc1>& p)
00744 : Propagator(home,share,p) {
00745 x.update(home,share,p.x);
00746 y.update(home,share,p.y);
00747 }
00748
00749 template<class View0, PropCond pc0, class View1, PropCond pc1>
00750 forceinline
00751 MixNaryOnePropagator<View0,pc0,View1,pc1>::MixNaryOnePropagator
00752 (Space& home, bool share, Propagator& p, ViewArray<View0>& x0, View1 y0)
00753 : Propagator(home,share,p) {
00754 x.update(home,share,x0);
00755 y.update(home,share,y0);
00756 }
00757
00758 template<class View0, PropCond pc0, class View1, PropCond pc1>
00759 PropCost
00760 MixNaryOnePropagator<View0,pc0,View1,pc1>::cost(const Space&,
00761 const ModEventDelta&) const {
00762 return PropCost::linear(PropCost::LO,x.size()+1);
00763 }
00764
00765 template<class View0, PropCond pc0, class View1, PropCond pc1>
00766 void
00767 MixNaryOnePropagator<View0,pc0,View1,pc1>::reschedule(Space& home) {
00768 if (pc0 != PC_GEN_NONE)
00769 x.reschedule(home,*this,pc0);
00770 if (pc1 != PC_GEN_NONE)
00771 y.reschedule(home,*this,pc1);
00772 }
00773
00774 template<class View0, PropCond pc0, class View1, PropCond pc1>
00775 forceinline size_t
00776 MixNaryOnePropagator<View0,pc0,View1,pc1>::dispose(Space& home) {
00777 if (pc0 != PC_GEN_NONE)
00778 x.cancel(home,*this,pc0);
00779 if (pc1 != PC_GEN_NONE)
00780 y.cancel(home,*this,pc1);
00781 (void) Propagator::dispose(home);
00782 return sizeof(*this);
00783 }
00784
00785 }
00786
00787