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 namespace Gecode {
00039
00057 template <class View, PropCond pc, class CtrlView>
00058 class ReUnaryPropagator : public Propagator {
00059 protected:
00061 View x0;
00063 CtrlView b;
00065 ReUnaryPropagator(Space* home, bool share, ReUnaryPropagator& p);
00067 ReUnaryPropagator(Space* home, bool share, Propagator& p,
00068 View x0, CtrlView b);
00070 ReUnaryPropagator(Space* home, View x0, CtrlView b);
00071 public:
00073 virtual PropCost cost(ModEventDelta med) const;
00075 virtual size_t dispose(Space* home);
00077 Reflection::ActorSpec spec(const Space* home, Reflection::VarMap& m,
00078 const Support::Symbol& name) const;
00079 };
00080
00091 template <class View, PropCond pc, class CtrlView>
00092 class ReBinaryPropagator : public Propagator {
00093 protected:
00095 View x0, x1;
00097 CtrlView b;
00099 ReBinaryPropagator(Space* home, bool share, ReBinaryPropagator& p);
00101 ReBinaryPropagator(Space* home, bool share, Propagator& p,
00102 View x0, View x1, CtrlView b);
00104 ReBinaryPropagator(Space* home, View x0, View x1, CtrlView b);
00105 public:
00107 virtual PropCost cost(ModEventDelta med) const;
00109 virtual size_t dispose(Space* home);
00111 Reflection::ActorSpec spec(const Space* home, Reflection::VarMap& m,
00112 const Support::Symbol& name) const;
00113 };
00115
00116
00117
00118
00119
00120
00121
00122 template <class View, PropCond pc, class CtrlView>
00123 ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
00124 (Space* home, View y0, CtrlView b0)
00125 : Propagator(home), x0(y0), b(b0) {
00126 if (pc != PC_GEN_NONE)
00127 x0.subscribe(home,this,pc);
00128 b.subscribe(home,this,Int::PC_INT_VAL);
00129 }
00130
00131 template <class View, PropCond pc, class CtrlView>
00132 forceinline
00133 ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
00134 (Space* home, bool share, ReUnaryPropagator<View,pc,CtrlView>& p)
00135 : Propagator(home,share,p) {
00136 x0.update(home,share,p.x0);
00137 b.update(home,share,p.b);
00138 }
00139
00140 template <class View, PropCond pc, class CtrlView>
00141 forceinline
00142 ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
00143 (Space* home, bool share, Propagator& p, View y0, CtrlView b0)
00144 : Propagator(home,share,p) {
00145 x0.update(home,share,y0);
00146 b.update(home,share,b0);
00147 }
00148
00149 template <class View, PropCond pc, class CtrlView>
00150 PropCost
00151 ReUnaryPropagator<View,pc,CtrlView>::cost(ModEventDelta) const {
00152 return PC_UNARY_LO;
00153 }
00154
00155 template <class View, PropCond pc, class CtrlView>
00156 forceinline size_t
00157 ReUnaryPropagator<View,pc,CtrlView>::dispose(Space* home) {
00158 if (pc != PC_GEN_NONE)
00159 x0.cancel(home,this,pc);
00160 b.cancel(home,this,Int::PC_INT_VAL);
00161 (void) Propagator::dispose(home);
00162 return sizeof(*this);
00163 }
00164
00165 template <class View, PropCond pc, class CtrlView>
00166 Reflection::ActorSpec
00167 ReUnaryPropagator<View,pc,CtrlView>::spec(const Space* home,
00168 Reflection::VarMap& m, const Support::Symbol& name) const {
00169 Reflection::ActorSpec s(name);
00170 return s << x0.spec(home, m)
00171 << b.spec(home, m);
00172 }
00173
00174
00175
00176
00177
00178 template <class View, PropCond pc, class CtrlView>
00179 ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
00180 (Space* home, View y0, View y1, CtrlView b1)
00181 : Propagator(home), x0(y0), x1(y1), b(b1) {
00182 if (pc != PC_GEN_NONE) {
00183 x0.subscribe(home,this,pc);
00184 x1.subscribe(home,this,pc);
00185 }
00186 b.subscribe(home,this,Int::PC_INT_VAL);
00187 }
00188
00189 template <class View, PropCond pc, class CtrlView>
00190 forceinline
00191 ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
00192 (Space* home, bool share, ReBinaryPropagator<View,pc,CtrlView>& p)
00193 : Propagator(home,share,p) {
00194 x0.update(home,share,p.x0);
00195 x1.update(home,share,p.x1);
00196 b.update(home,share,p.b);
00197 }
00198
00199 template <class View, PropCond pc, class CtrlView>
00200 forceinline
00201 ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
00202 (Space* home, bool share, Propagator& p, View y0, View y1, CtrlView b0)
00203 : Propagator(home,share,p) {
00204 x0.update(home,share,y0);
00205 x1.update(home,share,y1);
00206 b.update(home,share,b0);
00207 }
00208
00209 template <class View, PropCond pc, class CtrlView>
00210 PropCost
00211 ReBinaryPropagator<View,pc,CtrlView>::cost(ModEventDelta) const {
00212 return PC_BINARY_LO;
00213 }
00214
00215 template <class View, PropCond pc, class CtrlView>
00216 forceinline size_t
00217 ReBinaryPropagator<View,pc,CtrlView>::dispose(Space* home) {
00218 if (pc != PC_GEN_NONE) {
00219 x0.cancel(home,this,pc);
00220 x1.cancel(home,this,pc);
00221 }
00222 b.cancel(home,this,Int::PC_INT_VAL);
00223 (void) Propagator::dispose(home);
00224 return sizeof(*this);
00225 }
00226
00227 template <class View, PropCond pc, class CtrlView>
00228 Reflection::ActorSpec
00229 ReBinaryPropagator<View,pc,CtrlView>::spec(const Space* home,
00230 Reflection::VarMap& m, const Support::Symbol& name) const {
00231 Reflection::ActorSpec s(name);
00232 return s << x0.spec(home, m)
00233 << x1.spec(home, m)
00234 << b.spec(home, m);
00235 }
00236
00237 }
00238
00239
00240