00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 namespace Gecode {
00023
00039 template <class View, PropCond pcs, PropCond pci>
00040 class IntSetPropagator : public Propagator {
00041 protected:
00042 View x0;
00043 Gecode::Int::IntView x1;
00045 IntSetPropagator(Space* home,bool,IntSetPropagator&);
00047 IntSetPropagator(Space* home,View,Gecode::Int::IntView,bool=false);
00048 public:
00050 virtual PropCost cost(void) const;
00051 virtual ~IntSetPropagator(void);
00052 };
00053
00060 template <class View0, PropCond pc0, class View1, PropCond pc1>
00061 class InhomBinaryPropagator : public Propagator {
00062 protected:
00063 View0 x0;
00064 View1 x1;
00066 InhomBinaryPropagator(Space* home,bool,InhomBinaryPropagator&);
00068 InhomBinaryPropagator(Space* home,View0,View1,bool=false);
00069 public:
00071 virtual PropCost cost(void) const;
00072 virtual ~InhomBinaryPropagator(void);
00073 };
00074
00081 template <class View0, PropCond pc0, class View1, PropCond pc1,
00082 class View2, PropCond pc2>
00083 class InhomTernaryPropagator : public Propagator {
00084 protected:
00085 View0 x0;
00086 View1 x1;
00087 View2 x2;
00089 InhomTernaryPropagator(Space* home,bool,InhomTernaryPropagator&);
00091 InhomTernaryPropagator(Space* home,View0,View1,View2,bool=false);
00092 public:
00094 virtual PropCost cost(void) const;
00095 virtual ~InhomTernaryPropagator(void);
00096 };
00097
00104 template <class View0, PropCond pc0, class View1, PropCond pc1>
00105 class InhomNaryOnePropagator : public Propagator {
00106 protected:
00108 ViewArray<View0> x;
00110 View1 y;
00112 InhomNaryOnePropagator(Space* home, bool share, InhomNaryOnePropagator& p);
00114 InhomNaryOnePropagator(Space* home, ViewArray<View0>& x, View1 y,
00115 bool fd=false);
00116 public:
00118 virtual PropCost cost(void) const;
00120 virtual ~InhomNaryOnePropagator(void);
00121 };
00123
00124 template <class View, PropCond pcs, PropCond pci>
00125 IntSetPropagator<View,pcs,pci>::IntSetPropagator
00126 (Space* home, View y0, Gecode::Int::IntView y1, bool fd)
00127 : Propagator(home,fd || View::destruct()), x0(y0), x1(y1) {
00128 x0.subscribe(home,this,pcs);
00129 x1.subscribe(home,this,pci);
00130 }
00131
00132 template <class View, PropCond pcs, PropCond pci>
00133 forceinline
00134 IntSetPropagator<View,pcs,pci>::IntSetPropagator
00135 (Space* home, bool share, IntSetPropagator<View,pcs,pci>& p)
00136 : Propagator(home,share,p) {
00137 x0.update(home,share,p.x0);
00138 x1.update(home,share,p.x1);
00139 }
00140
00141 template <class View, PropCond pcs, PropCond pci>
00142 PropCost
00143 IntSetPropagator<View,pcs,pci>::cost(void) const {
00144 return PC_BINARY_LO;
00145 }
00146
00147 template <class View, PropCond pcs, PropCond pci>
00148 IntSetPropagator<View,pcs,pci>::~IntSetPropagator(void) {
00149 x0.cancel(this,pcs);
00150 x1.cancel(this,pci);
00151 }
00152
00153 template <class View0, PropCond pc0, class View1, PropCond pc1>
00154 InhomBinaryPropagator<View0,pc0,View1,pc1>::InhomBinaryPropagator
00155 (Space* home, View0 y0, View1 y1, bool fd)
00156 : Propagator(home,fd || View0::destruct() || View1::destruct()),
00157 x0(y0), x1(y1) {
00158 x0.subscribe(home,this,pc0);
00159 x1.subscribe(home,this,pc1);
00160 }
00161
00162 template <class View0, PropCond pc0, class View1, PropCond pc1>
00163 forceinline
00164 InhomBinaryPropagator<View0,pc0,View1,pc1>::InhomBinaryPropagator
00165 (Space* home, bool share, InhomBinaryPropagator<View0,pc0,View1,pc1>& p)
00166 : Propagator(home,share,p) {
00167 x0.update(home,share,p.x0);
00168 x1.update(home,share,p.x1);
00169 }
00170
00171 template <class View0, PropCond pc0, class View1, PropCond pc1>
00172 PropCost
00173 InhomBinaryPropagator<View0,pc0,View1,pc1>::cost(void) const {
00174 return PC_BINARY_LO;
00175 }
00176
00177 template <class View0, PropCond pc0, class View1, PropCond pc1>
00178 InhomBinaryPropagator<View0,pc0,View1,pc1>::~InhomBinaryPropagator(void) {
00179 x0.cancel(this,pc0);
00180 x1.cancel(this,pc1);
00181 }
00182
00183 template <class View0, PropCond pc0, class View1, PropCond pc1,
00184 class View2, PropCond pc2>
00185 InhomTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::
00186 InhomTernaryPropagator(Space* home, View0 y0, View1 y1, View2 y2, bool fd)
00187 : Propagator(home,fd || View0::destruct() || View1::destruct() ||
00188 View2::destruct()), x0(y0), x1(y1), x2(y2) {
00189 x0.subscribe(home,this,pc0);
00190 x1.subscribe(home,this,pc1);
00191 x2.subscribe(home,this,pc2);
00192 }
00193
00194 template <class View0, PropCond pc0, class View1, PropCond pc1,
00195 class View2, PropCond pc2>
00196 forceinline
00197 InhomTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::
00198 InhomTernaryPropagator(Space* home, bool share,
00199 InhomTernaryPropagator<View0,pc0,View1,pc1,
00200 View2,pc2>& p)
00201 : Propagator(home,share,p) {
00202 x0.update(home,share,p.x0);
00203 x1.update(home,share,p.x1);
00204 x2.update(home,share,p.x2);
00205 }
00206
00207 template <class View0, PropCond pc0, class View1, PropCond pc1,
00208 class View2, PropCond pc2>
00209 PropCost
00210 InhomTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::cost(void) const {
00211 return PC_BINARY_LO;
00212 }
00213
00214 template <class View0, PropCond pc0, class View1, PropCond pc1,
00215 class View2, PropCond pc2>
00216 InhomTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::
00217 ~InhomTernaryPropagator(void) {
00218 x0.cancel(this,pc0);
00219 x1.cancel(this,pc1);
00220 x2.cancel(this,pc2);
00221 }
00222
00223
00224
00225
00226
00227
00228 template <class View0, PropCond pc0, class View1, PropCond pc1>
00229 InhomNaryOnePropagator<View0,pc0,View1,pc1>::InhomNaryOnePropagator
00230 (Space* home, ViewArray<View0>& x0, View1 y0, bool fd)
00231 : Propagator(home,fd || View0::destruct() || View1::destruct()),
00232 x(x0), y(y0) {
00233 x.subscribe(home,this,pc0);
00234 y.subscribe(home,this,pc1);
00235 }
00236
00237 template <class View0, PropCond pc0, class View1, PropCond pc1>
00238 forceinline
00239 InhomNaryOnePropagator<View0,pc0,View1,pc1>::InhomNaryOnePropagator
00240 (Space* home, bool share, InhomNaryOnePropagator<View0,pc0,View1,pc1>& p)
00241 : Propagator(home,share,p) {
00242 x.update(home,share,p.x);
00243 y.update(home,share,p.y);
00244 }
00245
00246 template <class View0, PropCond pc0, class View1, PropCond pc1>
00247 PropCost
00248 InhomNaryOnePropagator<View0,pc0,View1,pc1>::cost(void) const {
00249 return cost_lo(x.size()+1, PC_LINEAR_LO);
00250 }
00251
00252 template <class View0, PropCond pc0, class View1, PropCond pc1>
00253 InhomNaryOnePropagator<View0,pc0,View1,pc1>::~InhomNaryOnePropagator(void) {
00254 x.cancel(this,pc0);
00255 y.cancel(this,pc1);
00256 }
00257
00258 }
00259
00260
00261