Generated on Wed Jan 4 17:49:11 2006 for Gecode by doxygen 1.4.6

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: 2005-10-27 21:01:30 +0200 (Thu, 27 Oct 2005) $ by $Author: schulte $
00010  *     $Revision: 2420 $
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, View x0, CtrlView b, bool fd=false);
00050   public:
00052     virtual PropCost cost(void) const;
00054     virtual ~ReUnaryPropagator(void);
00055   };
00056 
00063   template <class View, PropCond pc, class CtrlView>
00064   class ReBinaryPropagator : public Propagator {
00065   protected:
00067     View x0, x1;
00069     CtrlView b;
00071     ReBinaryPropagator(Space* home, bool share, ReBinaryPropagator& p);
00073     ReBinaryPropagator(Space* home, View x0, View x1,
00074                        CtrlView b, bool fd=false);
00075   public:
00077     virtual PropCost cost(void) const;
00079     virtual ~ReBinaryPropagator(void);
00080   };
00082 
00083 
00084 
00085   /*
00086    * Reified unary propagators
00087    *
00088    */
00089   template <class View, PropCond pc, class CtrlView>
00090   ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
00091   (Space* home, View y0, CtrlView b0, bool fd)
00092     : Propagator(home,fd), x0(y0), b(b0) {
00093     x0.subscribe(home,this,pc);
00094     b.subscribe(home,this,Int::PC_INT_VAL);
00095   }
00096 
00097   template <class View, PropCond pc, class CtrlView>
00098   forceinline
00099   ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
00100   (Space* home, bool share, ReUnaryPropagator<View,pc,CtrlView>& p)
00101     : Propagator(home,share,p) {
00102     x0.update(home,share,p.x0);
00103     b.update(home,share,p.b);
00104   }
00105 
00106   template <class View, PropCond pc, class CtrlView>
00107   PropCost
00108   ReUnaryPropagator<View,pc,CtrlView>::cost(void) const {
00109     return PC_UNARY_LO;
00110   }
00111 
00112   template <class View, PropCond pc, class CtrlView>
00113   ReUnaryPropagator<View,pc,CtrlView>::~ReUnaryPropagator(void) {
00114     x0.cancel(this,pc);
00115     b.cancel(this,Int::PC_INT_VAL);
00116   }
00117 
00118 
00119 
00120   /*
00121    * Reified binary propagators
00122    *
00123    */
00124   template <class View, PropCond pc, class CtrlView>
00125   ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
00126   (Space* home, View y0, View y1, CtrlView b1, bool fd)
00127     : Propagator(home,fd), x0(y0), x1(y1), b(b1) {
00128     x0.subscribe(home,this,pc);
00129     x1.subscribe(home,this,pc);
00130     b.subscribe(home,this,Int::PC_INT_VAL);
00131   }
00132 
00133   template <class View, PropCond pc, class CtrlView>
00134   forceinline
00135   ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
00136   (Space* home, bool share, ReBinaryPropagator<View,pc,CtrlView>& p)
00137     : Propagator(home,share,p) {
00138     x0.update(home,share,p.x0);
00139     x1.update(home,share,p.x1);
00140     b.update(home,share,p.b);
00141   }
00142 
00143   template <class View, PropCond pc, class CtrlView>
00144   PropCost
00145   ReBinaryPropagator<View,pc,CtrlView>::cost(void) const {
00146     return PC_BINARY_LO;
00147   }
00148 
00149   template <class View, PropCond pc, class CtrlView>
00150   ReBinaryPropagator<View,pc,CtrlView>::~ReBinaryPropagator(void) {
00151     x0.cancel(this,pc);
00152     x1.cancel(this,pc);
00153     b.cancel(this,Int::PC_INT_VAL);
00154   }
00155 
00156 }
00157 
00158 // STATISTICS: int-prop
00159