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_COUNT_HH__
00041 #define __GECODE_INT_COUNT_HH__
00042
00043 #include <gecode/int.hh>
00044
00050 namespace Gecode { namespace Int { namespace Count {
00051
00057
00058 template<class VX>
00059 RelTest holds(VX x, VX y);
00061 template<class VX>
00062 RelTest holds(VX x, ConstIntView y);
00064 template<class VX>
00065 bool post_true(Home home, ViewArray<VX>& x, VX y);
00067 template<class VX>
00068 bool post_true(Home home, ViewArray<VX>& x, ConstIntView y);
00070 template<class VX>
00071 bool post_false(Home home, ViewArray<VX>& x, VX y);
00073 template<class VX>
00074 bool post_false(Home home, ViewArray<VX>& x, ConstIntView y);
00076
00077 }}}
00078
00079 #include <gecode/int/count/rel.hpp>
00080
00081
00082 namespace Gecode { namespace Int { namespace Count {
00083
00088 template<class VX, class VY>
00089 class BaseInt : public Propagator {
00090 protected:
00092 ViewArray<VX> x;
00094 int n_s;
00096 VY y;
00098 int c;
00100 BaseInt(Space& home, bool share, BaseInt& p);
00102 BaseInt(Home home, ViewArray<VX>& x, int n_s, VY y, int c);
00103 public:
00105 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00107 virtual size_t dispose(Space& home);
00108 };
00109
00119 template<class VX, class VY>
00120 class EqInt : public BaseInt<VX,VY> {
00121 protected:
00122 using BaseInt<VX,VY>::x;
00123 using BaseInt<VX,VY>::n_s;
00124 using BaseInt<VX,VY>::y;
00125 using BaseInt<VX,VY>::c;
00127 EqInt(Space& home, bool share, EqInt& p);
00129 EqInt(Home home, ViewArray<VX>& x, int n_s, VY y, int c);
00130 public:
00132 virtual Actor* copy(Space& home, bool share);
00134 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00136 static ExecStatus post(Home home, ViewArray<VX>& x, VY y, int c);
00137 };
00138
00148 template<class VX, class VY>
00149 class GqInt : public BaseInt<VX,VY> {
00150 protected:
00151 using BaseInt<VX,VY>::x;
00152 using BaseInt<VX,VY>::n_s;
00153 using BaseInt<VX,VY>::y;
00154 using BaseInt<VX,VY>::c;
00156 GqInt(Space& home, bool share, GqInt& p);
00158 GqInt(Home home, ViewArray<VX>& x, int n_s, VY y, int c);
00159 public:
00161 virtual Actor* copy(Space& home, bool share);
00163 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00165 static ExecStatus post(Home home, ViewArray<VX>& x, VY y, int c);
00166 };
00167
00177 template<class VX, class VY>
00178 class LqInt : public BaseInt<VX,VY> {
00179 protected:
00180 using BaseInt<VX,VY>::x;
00181 using BaseInt<VX,VY>::n_s;
00182 using BaseInt<VX,VY>::y;
00183 using BaseInt<VX,VY>::c;
00185 LqInt(Space& home, bool share, LqInt& p);
00187 LqInt(Home home, ViewArray<VX>& x, int n_s, VY y, int c);
00188 public:
00190 virtual Actor* copy(Space& home, bool share);
00192 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00194 static ExecStatus post(Home home, ViewArray<VX>& x, VY y, int c);
00195 };
00196
00206 template<class VX, class VY>
00207 class NqInt : public BinaryPropagator<VX,PC_INT_DOM> {
00208 protected:
00209 using BinaryPropagator<VX,PC_INT_DOM>::x0;
00210 using BinaryPropagator<VX,PC_INT_DOM>::x1;
00212 ViewArray<VX> x;
00214 VY y;
00216 int c;
00218 bool resubscribe(Space& home, VX& z);
00220 NqInt(Home home, ViewArray<VX>& x, VY y, int c);
00222 NqInt(Space& home, bool share, NqInt& p);
00223 public:
00225 virtual Actor* copy(Space& home, bool share);
00227 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00229 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00231 static ExecStatus post(Home home, ViewArray<VX>& x, VY y, int c);
00233 virtual size_t dispose(Space& home);
00234 };
00235
00236 }}}
00237
00238 #include <gecode/int/count/int.hpp>
00239
00240
00241 namespace Gecode { namespace Int { namespace Count {
00242
00247 template<class VX, class VY, class VZ, bool shr>
00248 class BaseView : public Propagator {
00249 protected:
00251 ViewArray<VX> x;
00253 VY y;
00255 VZ z;
00257 int c;
00259 BaseView(Space& home, bool share, BaseView& p);
00261 BaseView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00262 public:
00264 virtual size_t dispose(Space& home);
00266 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00267 protected:
00269 void count(Space& home);
00271 int atleast(void) const;
00273 int atmost(void) const;
00275 static bool sharing(const ViewArray<VX>& x, const VY& y, const VZ& z);
00276 };
00277
00287 template<class VX, class VY, class VZ, bool shr>
00288 class EqView : public BaseView<VX,VY,VZ,shr> {
00289 protected:
00290 using BaseView<VX,VY,VZ,shr>::x;
00291 using BaseView<VX,VY,VZ,shr>::z;
00292 using BaseView<VX,VY,VZ,shr>::c;
00293 using BaseView<VX,VY,VZ,shr>::y;
00294 using BaseView<VX,VY,VZ,shr>::count;
00295 using BaseView<VX,VY,VZ,shr>::atleast;
00296 using BaseView<VX,VY,VZ,shr>::atmost;
00297 using BaseView<VX,VY,VZ,shr>::sharing;
00298
00300 EqView(Space& home, bool share, EqView& p);
00301 public:
00303 EqView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00305 virtual Actor* copy(Space& home, bool share);
00307 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00309 static ExecStatus post(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00310 };
00311
00321 template<class VX, class VY, class VZ, bool shr>
00322 class NqView : public BaseView<VX,VY,VZ,shr> {
00323 protected:
00324 using BaseView<VX,VY,VZ,shr>::x;
00325 using BaseView<VX,VY,VZ,shr>::z;
00326 using BaseView<VX,VY,VZ,shr>::c;
00327 using BaseView<VX,VY,VZ,shr>::y;
00328 using BaseView<VX,VY,VZ,shr>::count;
00329 using BaseView<VX,VY,VZ,shr>::atleast;
00330 using BaseView<VX,VY,VZ,shr>::atmost;
00331 using BaseView<VX,VY,VZ,shr>::sharing;
00332
00334 NqView(Space& home, bool share, NqView& p);
00335 public:
00337 NqView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00339 virtual Actor* copy(Space& home, bool share);
00341 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00343 static ExecStatus post(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00344 };
00345
00355 template<class VX, class VY, class VZ, bool shr>
00356 class LqView : public BaseView<VX,VY,VZ,shr> {
00357 protected:
00358 using BaseView<VX,VY,VZ,shr>::x;
00359 using BaseView<VX,VY,VZ,shr>::z;
00360 using BaseView<VX,VY,VZ,shr>::c;
00361 using BaseView<VX,VY,VZ,shr>::y;
00362 using BaseView<VX,VY,VZ,shr>::count;
00363 using BaseView<VX,VY,VZ,shr>::atleast;
00364 using BaseView<VX,VY,VZ,shr>::atmost;
00365 using BaseView<VX,VY,VZ,shr>::sharing;
00366
00368 LqView(Space& home, bool share, LqView& p);
00369 public:
00371 LqView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00373 virtual Actor* copy(Space& home, bool share);
00375 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00377 static ExecStatus post(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00378 };
00379
00389 template<class VX, class VY, class VZ, bool shr>
00390 class GqView : public BaseView<VX,VY,VZ,shr> {
00391 protected:
00392 using BaseView<VX,VY,VZ,shr>::x;
00393 using BaseView<VX,VY,VZ,shr>::z;
00394 using BaseView<VX,VY,VZ,shr>::c;
00395 using BaseView<VX,VY,VZ,shr>::y;
00396 using BaseView<VX,VY,VZ,shr>::count;
00397 using BaseView<VX,VY,VZ,shr>::atleast;
00398 using BaseView<VX,VY,VZ,shr>::atmost;
00399 using BaseView<VX,VY,VZ,shr>::sharing;
00400
00402 GqView(Space& home, bool share, GqView& p);
00403 public:
00405 GqView(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00407 virtual Actor* copy(Space& home, bool share);
00409 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00411 static ExecStatus post(Home home, ViewArray<VX>& x, VY y, VZ z, int c);
00412 };
00413
00414 }}}
00415
00416 #include <gecode/int/count/view.hpp>
00417
00418 #endif
00419
00420
00421