Generated on Wed Nov 1 15:04:37 2006 for Gecode by doxygen 1.4.5

propagator.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2002
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-05-29 09:42:21 +0200 (Mon, 29 May 2006) $ by $Author: schulte $
00010  *     $Revision: 3246 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 namespace Gecode {
00023 
00039   template <class View, PropCond pc, class CtrlView>
00040   class ReUnaryPropagator : public Propagator {
00041   protected:
00043     View x0;
00045     CtrlView b;
00047     ReUnaryPropagator(Space* home, bool share, ReUnaryPropagator& p);
00049     ReUnaryPropagator(Space* home, bool share, Propagator& p,
00050                       View x0, CtrlView b);
00052     ReUnaryPropagator(Space* home, View x0, CtrlView b, bool fd=false);
00053   public:
00055     virtual PropCost cost(void) const;
00057     virtual size_t dispose(Space* home);
00058   };
00059 
00066   template <class View, PropCond pc, class CtrlView>
00067   class ReBinaryPropagator : public Propagator {
00068   protected:
00070     View x0, x1;
00072     CtrlView b;
00074     ReBinaryPropagator(Space* home, bool share, ReBinaryPropagator& p);
00076     ReBinaryPropagator(Space* home, bool share, Propagator& p,
00077                        View x0, View x1, CtrlView b);
00079     ReBinaryPropagator(Space* home, View x0, View x1,
00080                        CtrlView b, bool fd=false);
00081   public:
00083     virtual PropCost cost(void) const;
00085     virtual size_t dispose(Space* home);
00086   };
00088 
00089 
00090 
00091   /*
00092    * Reified unary propagators
00093    *
00094    */
00095   template <class View, PropCond pc, class CtrlView>
00096   ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
00097   (Space* home, View y0, CtrlView b0, bool fd)
00098     : Propagator(home,fd), x0(y0), b(b0) {
00099     x0.subscribe(home,this,pc);
00100     b.subscribe(home,this,Int::PC_INT_VAL);
00101   }
00102 
00103   template <class View, PropCond pc, class CtrlView>
00104   forceinline
00105   ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
00106   (Space* home, bool share, ReUnaryPropagator<View,pc,CtrlView>& p)
00107     : Propagator(home,share,p) {
00108     x0.update(home,share,p.x0);
00109     b.update(home,share,p.b);
00110   }
00111 
00112   template <class View, PropCond pc, class CtrlView>
00113   forceinline
00114   ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
00115   (Space* home, bool share, Propagator& p, View y0, CtrlView b0)
00116     : Propagator(home,share,p) {
00117     x0.update(home,share,y0);
00118     b.update(home,share,b0);
00119   }
00120 
00121   template <class View, PropCond pc, class CtrlView>
00122   PropCost
00123   ReUnaryPropagator<View,pc,CtrlView>::cost(void) const {
00124     return PC_UNARY_LO;
00125   }
00126 
00127   template <class View, PropCond pc, class CtrlView>
00128   size_t
00129   ReUnaryPropagator<View,pc,CtrlView>::dispose(Space* home) {
00130     if (!home->failed()) {
00131       x0.cancel(home,this,pc);
00132       b.cancel(home,this,Int::PC_INT_VAL);
00133     }
00134     (void) Propagator::dispose(home);
00135     return sizeof(*this);
00136   }
00137 
00138 
00139 
00140   /*
00141    * Reified binary propagators
00142    *
00143    */
00144   template <class View, PropCond pc, class CtrlView>
00145   ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
00146   (Space* home, View y0, View y1, CtrlView b1, bool fd)
00147     : Propagator(home,fd), x0(y0), x1(y1), b(b1) {
00148     x0.subscribe(home,this,pc);
00149     x1.subscribe(home,this,pc);
00150     b.subscribe(home,this,Int::PC_INT_VAL);
00151   }
00152 
00153   template <class View, PropCond pc, class CtrlView>
00154   forceinline
00155   ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
00156   (Space* home, bool share, ReBinaryPropagator<View,pc,CtrlView>& p)
00157     : Propagator(home,share,p) {
00158     x0.update(home,share,p.x0);
00159     x1.update(home,share,p.x1);
00160     b.update(home,share,p.b);
00161   }
00162 
00163   template <class View, PropCond pc, class CtrlView>
00164   forceinline
00165   ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
00166   (Space* home, bool share, Propagator& p, View y0, View y1, CtrlView b0)
00167     : Propagator(home,share,p) {
00168     x0.update(home,share,y0);
00169     x1.update(home,share,y1);
00170     b.update(home,share,b0);
00171   }
00172 
00173   template <class View, PropCond pc, class CtrlView>
00174   PropCost
00175   ReBinaryPropagator<View,pc,CtrlView>::cost(void) const {
00176     return PC_BINARY_LO;
00177   }
00178 
00179   template <class View, PropCond pc, class CtrlView>
00180   size_t
00181   ReBinaryPropagator<View,pc,CtrlView>::dispose(Space* home) {
00182     if (!home->failed()) {
00183       x0.cancel(home,this,pc);
00184       x1.cancel(home,this,pc);
00185       b.cancel(home,this,Int::PC_INT_VAL);
00186     }
00187     (void) Propagator::dispose(home);
00188     return sizeof(*this);
00189   }
00190 
00191 }
00192 
00193 // STATISTICS: int-prop
00194