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_ELEMENT_HH__
00041 #define __GECODE_INT_ELEMENT_HH__
00042
00043 #include <gecode/int.hh>
00044 #include <gecode/int/rel.hh>
00045 #include <gecode/int/idx-view.hh>
00046
00052 namespace Gecode { namespace Int { namespace Element {
00053
00060 template<class V0, class V1, class Idx, class Val>
00061 class Int : public Propagator {
00062 protected:
00071 class IdxVal {
00072 public:
00073 Idx idx_next;
00074 Idx val_next;
00075 Idx idx;
00076 Val val;
00077
00078 void mark(void);
00080 bool marked(void) const;
00081 };
00088 class IterIdxUnmark {
00089 private:
00090 IdxVal* iv;
00091 Idx i;
00092 public:
00094 IterIdxUnmark(IdxVal* iv);
00096 bool operator ()(void) const;
00098 void operator ++(void);
00100 Idx val(void) const;
00101 };
00108 class IterVal {
00109 private:
00110 IdxVal* iv;
00111 Idx i;
00112 public:
00114 IterVal(IdxVal* iv);
00116 bool operator ()(void) const;
00118 void operator ++(void);
00120 Val val(void) const;
00121 };
00130 class IterValUnmark {
00131 private:
00132 IdxVal* iv;
00133 Idx i;
00134 public:
00136 IterValUnmark(IdxVal* iv);
00138 bool operator ()(void) const;
00140 void operator ++(void);
00142 Val val(void) const;
00143 };
00145 class ByVal {
00146 protected:
00147 const IdxVal* iv;
00148 public:
00150 ByVal(const IdxVal* iv);
00152 bool operator ()(Idx& i, Idx& j);
00153 };
00154
00156 V0 x0;
00158 typedef typename Gecode::Support::IntTypeTraits<Idx>::utype IdxSize;
00160 IdxSize s0;
00162 V1 x1;
00164 typedef typename Gecode::Support::IntTypeTraits<Val>::utype ValSize;
00166 ValSize s1;
00168 IntSharedArray c;
00170 IdxVal* iv;
00172 void prune_idx(void);
00174 void prune_val(void);
00176 static ExecStatus assigned_val(Space& home, IntSharedArray& c,
00177 V0 x0, V1 x1);
00179 Int(Space& home, bool shared, Int& p);
00181 Int(Home home, IntSharedArray& i, V0 x0, V1 x1);
00182 public:
00184 virtual Actor* copy(Space& home, bool share);
00186 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00188 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00190 static ExecStatus post(Home home, IntSharedArray& i, V0 x0, V1 x1);
00192 virtual size_t dispose(Space& home);
00193 };
00194
00196 template<class V0, class V1>
00197 ExecStatus post_int(Home home, IntSharedArray& c, V0 x0, V1 x1);
00198
00199
00204 template<class VA, class VB, class VC, PropCond pc_ac>
00205 class View : public Propagator {
00206 protected:
00208 IdxViewArray<VA> iv;
00210 VB x0;
00212 VC x1;
00214 View(Space& home, bool share, View& p);
00216 View(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00217 public:
00218
00219 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00221 virtual size_t dispose(Space& home);
00222 };
00223
00224
00231 template<class VA, class VB, class VC>
00232 class ViewBnd : public View<VA,VB,VC,PC_INT_BND> {
00233 protected:
00234 using View<VA,VB,VC,PC_INT_BND>::iv;
00235 using View<VA,VB,VC,PC_INT_BND>::x0;
00236 using View<VA,VB,VC,PC_INT_BND>::x1;
00237
00239 ViewBnd(Space& home, bool share, ViewBnd& p);
00241 ViewBnd(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00242 public:
00244 virtual Actor* copy(Space& home, bool share);
00246 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00248 static ExecStatus post(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00249 };
00250
00261 template<class VA, class VB, class VC>
00262 class ViewDom : public View<VA,VB,VC,PC_INT_DOM> {
00263 protected:
00264 using View<VA,VB,VC,PC_INT_DOM>::iv;
00265 using View<VA,VB,VC,PC_INT_DOM>::x0;
00266 using View<VA,VB,VC,PC_INT_DOM>::x1;
00267
00269 ViewDom(Space& home, bool share, ViewDom& p);
00271 ViewDom(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00272 public:
00274 virtual Actor* copy(Space& home, bool share);
00282 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00284 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00286 static ExecStatus post(Home home, IdxViewArray<VA>& iv,
00287 VB x0, VC x1);
00288 };
00289
00297 class GECODE_VTABLE_EXPORT Pair
00298 : public TernaryPropagator<IntView,PC_INT_DOM> {
00299 protected:
00300 using TernaryPropagator<IntView,PC_INT_DOM>::x0;
00301 using TernaryPropagator<IntView,PC_INT_DOM>::x1;
00302 using TernaryPropagator<IntView,PC_INT_DOM>::x2;
00304 int w;
00306 Pair(Space& home, bool share, Pair& p);
00307 public:
00309 Pair(Home home, IntView x0, IntView x1, IntView x2, int w);
00311 static ExecStatus post(Home home, IntView x0, IntView x1, IntView x2,
00312 int w, int h);
00314 GECODE_INT_EXPORT virtual Actor* copy(Space& home, bool share);
00316 GECODE_INT_EXPORT virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00317 };
00318
00319 }}}
00320
00321 #include <gecode/int/element/int.hpp>
00322 #include <gecode/int/element/view.hpp>
00323 #include <gecode/int/element/pair.hpp>
00324
00325 #endif
00326
00327
00328
00329