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 #ifndef __GECODE_INT_REL_HH__
00041 #define __GECODE_INT_REL_HH__
00042
00043 #include <gecode/int.hh>
00044
00050 namespace Gecode { namespace Int { namespace Rel {
00051
00052
00053
00054
00055
00056
00066 template<class View0,class View1>
00067 class EqDom :
00068 public MixBinaryPropagator<View0,PC_INT_DOM,View1,PC_INT_DOM> {
00069 protected:
00070 using MixBinaryPropagator<View0,PC_INT_DOM,View1,PC_INT_DOM>::x0;
00071 using MixBinaryPropagator<View0,PC_INT_DOM,View1,PC_INT_DOM>::x1;
00072
00074 EqDom(Space& home, EqDom<View0,View1>& p);
00075 public:
00077 EqDom(Home home, View0 x0, View1 x1);
00079 EqDom(Space& home, Propagator& p, View0 x0, View1 x1);
00081 virtual Actor* copy(Space& home);
00089 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00091 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00093 static ExecStatus post(Home home, View0 x0, View1 x1);
00094 };
00095
00102 template<class View0, class View1>
00103 class EqVal :
00104 public MixBinaryPropagator<View0,PC_INT_VAL,View1,PC_INT_VAL> {
00105 protected:
00106 using MixBinaryPropagator<View0,PC_INT_VAL,View1,PC_INT_VAL>::x0;
00107 using MixBinaryPropagator<View0,PC_INT_VAL,View1,PC_INT_VAL>::x1;
00108
00110 EqVal(Space& home, EqVal<View0,View1>& p);
00111 public:
00113 EqVal(Home home, View0 x0, View1 x1);
00115 EqVal(Space& home, Propagator& p, View0 x0, View1 x1);
00117 virtual Actor* copy(Space& home);
00119 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00121 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00123 static ExecStatus post(Home home, View0 x0, View1 x1);
00124 };
00125
00132 template<class View0, class View1>
00133 class EqBnd :
00134 public MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND> {
00135 protected:
00136 using MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>::x0;
00137 using MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>::x1;
00138
00140 EqBnd(Space& home, EqBnd<View0,View1>& p);
00141 public:
00143 EqBnd(Home home, View0 x0, View1 x1);
00145 EqBnd(Space& home, Propagator& p, View0 x0, View1 x1);
00147 virtual Actor* copy(Space& home);
00149 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00151 static ExecStatus post(Home home, View0 x0, View1 x1);
00152 };
00153
00163 template<class View>
00164 class NaryEqDom : public NaryPropagator<View,PC_INT_DOM> {
00165 protected:
00166 using NaryPropagator<View,PC_INT_DOM>::x;
00167
00169 NaryEqDom(Space& home, NaryEqDom<View>& p);
00171 NaryEqDom(Home home, ViewArray<View>&);
00172 public:
00174 virtual Actor* copy(Space& home);
00182 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00184 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00186 static ExecStatus post(Home home, ViewArray<View>& x);
00187 };
00188
00195 template<class View>
00196 class NaryEqBnd : public NaryPropagator<View,PC_INT_BND> {
00197 protected:
00198 using NaryPropagator<View,PC_INT_BND>::x;
00199
00201 NaryEqBnd(Space& home, NaryEqBnd<View>& p);
00203 NaryEqBnd(Home home, ViewArray<View>&);
00204 public:
00206 virtual Actor* copy(Space& home);
00213 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00215 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00217 static ExecStatus post(Home home, ViewArray<View>& x);
00218 };
00219
00229 template<class View, int o>
00230 class NaryLqLe : public NaryPropagator<View,PC_INT_NONE> {
00231 protected:
00232 using NaryPropagator<View,PC_INT_NONE>::x;
00234 class Index : public Advisor {
00235 public:
00237 int i;
00239 Index(Space& home, Propagator& p, Council<Index>& c, int i);
00241 Index(Space& home, Index& a);
00242 };
00244 Council<Index> c;
00246 class Pos : public FreeList {
00247 public:
00249 int p;
00250
00252
00253
00254 Pos(int p, Pos* n);
00256
00258
00259
00260 Pos* next(void) const;
00262
00264
00265
00266 void dispose(Space& home);
00267
00269 static void* operator new(size_t s, Space& home);
00271 static void operator delete(void* p);
00273 static void operator delete(void* p, Space& home);
00275 };
00277 Pos* pos;
00279 bool empty(void) const;
00281 int pop(Space& home);
00283 void push(Space& home, int p);
00285 bool run;
00287 int n_subsumed;
00289 static const int n_threshold = 7;
00291 NaryLqLe(Space& home, NaryLqLe<View,o>& p);
00293 NaryLqLe(Home home, ViewArray<View>&);
00294 public:
00296 virtual Actor* copy(Space& home);
00298 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00300 virtual void reschedule(Space& home);
00302 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00304 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00306 virtual size_t dispose(Space& home);
00308 static ExecStatus post(Home home, ViewArray<View>& x);
00309 };
00310
00317 template<class View>
00318 class NaryNq : public NaryPropagator<View,PC_INT_VAL> {
00319 protected:
00320 using NaryPropagator<View,PC_INT_VAL>::x;
00322 NaryNq(Home home, ViewArray<View>& x);
00324 NaryNq(Space& home, NaryNq<View>& p);
00325 public:
00327 virtual Actor* copy(Space& home);
00329 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00331 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00333 static ExecStatus post(Home home, ViewArray<View>& x);
00335 virtual size_t dispose(Space& home);
00336 };
00337
00338
00345 template<class View, class CtrlView, ReifyMode rm>
00346 class ReEqDom : public ReBinaryPropagator<View,PC_INT_DOM,CtrlView> {
00347 protected:
00348 using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::x0;
00349 using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::x1;
00350 using ReBinaryPropagator<View,PC_INT_DOM,CtrlView>::b;
00351
00353 ReEqDom(Space& home, ReEqDom& p);
00355 ReEqDom(Home home, View x0, View x1, CtrlView b);
00356 public:
00358 virtual Actor* copy(Space& home);
00360 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00362 static ExecStatus post(Home home, View x0, View x1, CtrlView b);
00363 };
00364
00371 template<class View, class CtrlView, ReifyMode rm>
00372 class ReEqBnd : public ReBinaryPropagator<View,PC_INT_BND,CtrlView> {
00373 protected:
00374 using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00375 using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x1;
00376 using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::b;
00377
00379 ReEqBnd(Space& home, ReEqBnd& p);
00381 ReEqBnd(Home home, View x0, View x1, CtrlView b);
00382 public:
00384 virtual Actor* copy(Space& home);
00386 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00388 static ExecStatus post(Home home, View x0, View x1, CtrlView b);
00389 };
00390
00397 template<class View, class CtrlView, ReifyMode rm>
00398 class ReEqDomInt : public ReUnaryPropagator<View,PC_INT_DOM,CtrlView> {
00399 protected:
00400 using ReUnaryPropagator<View,PC_INT_DOM,CtrlView>::x0;
00401 using ReUnaryPropagator<View,PC_INT_DOM,CtrlView>::b;
00402
00404 int c;
00406 ReEqDomInt(Space& home, ReEqDomInt& p);
00408 ReEqDomInt(Home home, View x, int c, CtrlView b);
00409 public:
00411 virtual Actor* copy(Space& home);
00413 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00415 static ExecStatus post(Home home, View x, int c, CtrlView b);
00416 };
00417
00424 template<class View, class CtrlView, ReifyMode rm>
00425 class ReEqBndInt : public ReUnaryPropagator<View,PC_INT_BND,CtrlView> {
00426 protected:
00427 using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00428 using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::b;
00429
00431 int c;
00433 ReEqBndInt(Space& home, ReEqBndInt& p);
00435 ReEqBndInt(Home home, View x, int c, CtrlView b);
00436 public:
00438 virtual Actor* copy(Space& home);
00440 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00442 static ExecStatus post(Home home, View x, int c, CtrlView b);
00443 };
00444
00445
00446
00447
00448
00449
00450
00451
00452
00459 template<class V0, class V1>
00460 class Nq : public MixBinaryPropagator<V0,PC_INT_VAL,V1,PC_INT_VAL> {
00461 protected:
00462 using MixBinaryPropagator<V0,PC_INT_VAL,V1,PC_INT_VAL>::x0;
00463 using MixBinaryPropagator<V0,PC_INT_VAL,V1,PC_INT_VAL>::x1;
00464
00466 Nq(Space& home, Nq<V0,V1>& p);
00468 Nq(Home home, V0 x0, V1 x1);
00469 public:
00471 virtual Actor* copy(Space& home);
00473 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00475 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00477 static ExecStatus post(Home home, V0 x0, V1 x1);
00478 };
00479
00480
00481
00482
00483
00484
00492 template<class V0, class V1>
00493 class Lq : public MixBinaryPropagator<V0,PC_INT_BND,V1,PC_INT_BND> {
00494 protected:
00495 using MixBinaryPropagator<V0,PC_INT_BND,V1,PC_INT_BND>::x0;
00496 using MixBinaryPropagator<V0,PC_INT_BND,V1,PC_INT_BND>::x1;
00498 static bool same(V0 x0, V1 x1);
00500 Lq(Space& home, Lq& p);
00502 Lq(Home home, V0 x0, V1 x1);
00503 public:
00505 virtual Actor* copy(Space& home);
00507 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00509 static ExecStatus post(Home home, V0 x0, V1 x1);
00510 };
00511
00518 template<class V0, class V1>
00519 class Le : public MixBinaryPropagator<V0,PC_INT_BND,V1,PC_INT_BND> {
00520 protected:
00521 using MixBinaryPropagator<V0,PC_INT_BND,V1,PC_INT_BND>::x0;
00522 using MixBinaryPropagator<V0,PC_INT_BND,V1,PC_INT_BND>::x1;
00524 static bool same(V0 x0, V1 x1);
00526 Le(Space& home, Le& p);
00528 Le(Home home, V0 x0, V1 x1);
00529 public:
00531 virtual Actor* copy(Space& home);
00533 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00535 static ExecStatus post(Home home, V0 x0, V1 x1);
00536 };
00537
00538
00539
00540
00541
00542
00543
00551 template<class View, class CtrlView, ReifyMode rm>
00552 class ReLq : public ReBinaryPropagator<View,PC_INT_BND,CtrlView> {
00553 protected:
00554 using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00555 using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::x1;
00556 using ReBinaryPropagator<View,PC_INT_BND,CtrlView>::b;
00557
00559 ReLq(Space& home, ReLq& p);
00561 ReLq(Home home, View x0, View x1, CtrlView b);
00562 public:
00564 virtual Actor* copy(Space& home);
00566 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00568 static ExecStatus post(Home home, View x0, View x1, CtrlView b);
00569 };
00570
00578 template<class View, class CtrlView, ReifyMode rm>
00579 class ReLqInt : public ReUnaryPropagator<View,PC_INT_BND,CtrlView> {
00580 protected:
00581 using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::x0;
00582 using ReUnaryPropagator<View,PC_INT_BND,CtrlView>::b;
00583
00585 int c;
00587 ReLqInt(Space& home, ReLqInt& p);
00589 ReLqInt(Home home, View x, int c, CtrlView b);
00590 public:
00592 virtual Actor* copy(Space& home);
00594 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00596 static ExecStatus post(Home home, View x, int c, CtrlView b);
00597 };
00598
00599
00600
00601
00602
00626 template<class VX, class VY>
00627 class LexLqLe : public Propagator {
00628 protected:
00630 ViewArray<VX> x;
00631 ViewArray<VY> y;
00633 bool strict;
00635 LexLqLe(Space& home, LexLqLe<VX,VY>& p);
00637 LexLqLe(Home home, ViewArray<VX>& x, ViewArray<VY>& y, bool strict);
00638 public:
00640 virtual Actor* copy(Space& home);
00642 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00644 virtual void reschedule(Space& home);
00646 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00648 static ExecStatus post(Home home, ViewArray<VX>& x, ViewArray<VY>& y,
00649 bool strict);
00651 virtual size_t dispose(Space& home);
00652 };
00653
00660 template<class VX, class VY>
00661 class LexNq : public Propagator {
00662 protected:
00664 VX x0;
00666 VY y0;
00668 VX x1;
00670 VY y1;
00672 ViewArray<VX> x;
00674 ViewArray<VY> y;
00676 ExecStatus resubscribe(Space& home,
00677 RelTest rt, VX& x0, VY& y0, VX x1, VY y1);
00679 LexNq(Home home, ViewArray<VX>& x, ViewArray<VY>& y);
00681 LexNq(Space& home, LexNq<VX,VY>& p);
00682 public:
00684 virtual Actor* copy(Space& home);
00686 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00688 virtual void reschedule(Space& home);
00690 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00692 static ExecStatus post(Home home, ViewArray<VX>& x, ViewArray<VY>& y);
00694 virtual size_t dispose(Space& home);
00695 };
00696
00697 }}}
00698
00699 #include <gecode/int/rel/eq.hpp>
00700 #include <gecode/int/rel/nq.hpp>
00701 #include <gecode/int/rel/lq-le.hpp>
00702 #include <gecode/int/rel/lex.hpp>
00703
00704 #endif
00705
00706
00707
00708