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 void reschedule(Space& home);
00190 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00192 static ExecStatus post(Home home, IntSharedArray& i, V0 x0, V1 x1);
00194 virtual size_t dispose(Space& home);
00195 };
00196
00198 template<class V0, class V1>
00199 ExecStatus post_int(Home home, IntSharedArray& c, V0 x0, V1 x1);
00200
00201
00206 template<class VA, class VB, class VC, PropCond pc_ac>
00207 class View : public Propagator {
00208 protected:
00210 IdxViewArray<VA> iv;
00212 VB x0;
00214 VC x1;
00216 View(Space& home, bool share, View& p);
00218 View(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00219 public:
00220
00221 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00223 virtual void reschedule(Space& home);
00225 virtual size_t dispose(Space& home);
00226 };
00227
00228
00235 template<class VA, class VB, class VC>
00236 class ViewBnd : public View<VA,VB,VC,PC_INT_BND> {
00237 protected:
00238 using View<VA,VB,VC,PC_INT_BND>::iv;
00239 using View<VA,VB,VC,PC_INT_BND>::x0;
00240 using View<VA,VB,VC,PC_INT_BND>::x1;
00241
00243 ViewBnd(Space& home, bool share, ViewBnd& p);
00245 ViewBnd(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00246 public:
00248 virtual Actor* copy(Space& home, bool share);
00250 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00252 static ExecStatus post(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00253 };
00254
00265 template<class VA, class VB, class VC>
00266 class ViewDom : public View<VA,VB,VC,PC_INT_DOM> {
00267 protected:
00268 using View<VA,VB,VC,PC_INT_DOM>::iv;
00269 using View<VA,VB,VC,PC_INT_DOM>::x0;
00270 using View<VA,VB,VC,PC_INT_DOM>::x1;
00271
00273 ViewDom(Space& home, bool share, ViewDom& p);
00275 ViewDom(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
00276 public:
00278 virtual Actor* copy(Space& home, bool share);
00286 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00288 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00290 static ExecStatus post(Home home, IdxViewArray<VA>& iv,
00291 VB x0, VC x1);
00292 };
00293
00301 class GECODE_VTABLE_EXPORT Pair
00302 : public TernaryPropagator<IntView,PC_INT_DOM> {
00303 protected:
00304 using TernaryPropagator<IntView,PC_INT_DOM>::x0;
00305 using TernaryPropagator<IntView,PC_INT_DOM>::x1;
00306 using TernaryPropagator<IntView,PC_INT_DOM>::x2;
00308 int w;
00310 Pair(Space& home, bool share, Pair& p);
00311 public:
00313 Pair(Home home, IntView x0, IntView x1, IntView x2, int w);
00315 static ExecStatus post(Home home, IntView x0, IntView x1, IntView x2,
00316 int w, int h);
00318 GECODE_INT_EXPORT virtual Actor* copy(Space& home, bool share);
00320 GECODE_INT_EXPORT virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00321 };
00322
00323 }}}
00324
00325 #include <gecode/int/element/int.hpp>
00326 #include <gecode/int/element/view.hpp>
00327 #include <gecode/int/element/pair.hpp>
00328
00329 #endif
00330
00331
00332
00333