Generated on Mon Aug 25 11:35:34 2008 for Gecode by doxygen 1.5.6

propagators.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Patrick Pekczynski <pekczynski@ps.uni-sb.de>
00005  *
00006  *  Copyright:
00007  *     Patrick Pekczynski, 2006
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-01-29 13:37:51 +0100 (Tue, 29 Jan 2008) $ by $Author: tack $
00011  *     $Revision: 5993 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #ifndef __GECODE_CPLTSETPROP_HH
00039 #define __GECODE_CPLTSETPROP_HH
00040 
00041 #include "gecode/cpltset.hh"
00042 
00043 namespace Gecode { namespace CpltSet { 
00044 
00053   template <class View>
00054   class NaryCpltSetPropagator : public Propagator {
00055   protected:
00057     ViewArray<View> x;
00059     bdd d;
00061     NaryCpltSetPropagator(Space* home, bool share, NaryCpltSetPropagator& p);
00063     NaryCpltSetPropagator(Space* home, ViewArray<View>& x, bdd& d);
00065     bdd bnd_phi(int j);
00067     bdd phi(int i, int j);
00069     ExecStatus 
00070     divide_conquer(Space* home, bdd& p, int i, int j);
00071   public:
00073     virtual PropCost cost(ModEventDelta med) const;
00075     virtual Reflection::ActorSpec spec(const Space* home,
00076                                         Reflection::VarMap& m) const;
00078     static Support::Symbol ati(void);
00079 
00081     virtual size_t dispose(Space* home);
00083     virtual Actor*      copy(Space* home,bool);
00085     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00087     ExecStatus propagate_eeq(Space* home);
00089     ExecStatus propagate_bnd_eeq(Space* home);
00091     ExecStatus propagate_ddc(Space* home);
00093     ExecStatus propagate_bnd_ddc(Space* home);
00094 
00095     static  ExecStatus post(Space* home, ViewArray<View>& x, bdd& d);
00096   };
00097 
00098 
00107   template <class View0, class View1>
00108   class BinaryCpltSetPropagator : public Propagator {
00109   protected:
00111     View0 x;
00113     View1 y;
00115     bdd d;
00117     BinaryCpltSetPropagator(Space* home, bool share,
00118                             BinaryCpltSetPropagator& p);
00120     BinaryCpltSetPropagator(Space* home, View0& x0, View1& y0, bdd& d);
00121   public:
00123     virtual PropCost cost(ModEventDelta med) const;
00125     virtual Reflection::ActorSpec spec(const Space* home,
00126                                         Reflection::VarMap& m) const;
00128     static Support::Symbol ati(void);
00129 
00131     virtual size_t dispose(Space* home);
00133     virtual Actor*      copy(Space* home,bool);
00135     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00136     static  ExecStatus post(Space* home, View0& x0, View1& y0, bdd& d);
00137   };
00138 
00142   template <class View>
00143   class UnaryCpltSetPropagator : public Propagator {
00144   protected:
00146     View x;
00148     bdd d;
00150     UnaryCpltSetPropagator(Space* home, bool share, UnaryCpltSetPropagator& p);
00152     UnaryCpltSetPropagator(Space* home, View& x0, bdd& d);
00153   public:
00155     virtual PropCost cost(ModEventDelta med) const;
00157     virtual Reflection::ActorSpec spec(const Space* home,
00158                                         Reflection::VarMap& m) const;
00160     static Support::Symbol ati(void);
00161 
00163     virtual size_t dispose(Space* home);
00165     virtual Actor*      copy(Space* home,bool);
00167     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00168     static  ExecStatus post(Space* home, View& x0, bdd& d);
00169   };
00170 
00179   template <class View0, class View1>
00180   class NaryOneCpltSetPropagator : 
00181     public MixNaryOnePropagator<View0,PC_CPLTSET_DOM,View1,PC_CPLTSET_DOM> {
00182   protected:
00183     typedef MixNaryOnePropagator<View0, PC_CPLTSET_DOM,
00184                                  View1, PC_CPLTSET_DOM> Super;
00186     bdd d;
00187     using Super::x;
00188     using Super::y;
00190     NaryOneCpltSetPropagator(Space* home, bool share, 
00191                              NaryOneCpltSetPropagator& p);
00193     NaryOneCpltSetPropagator(Space* home, ViewArray<View0>&, View1&, bdd&);
00195     ExecStatus divide_conquer(Space* home, bdd& p, 
00196                               int l, int r, int ypos);
00197   public:
00199     virtual Reflection::ActorSpec spec(const Space* home,
00200                                         Reflection::VarMap& m) const;
00202     static Support::Symbol ati(void);
00204     virtual size_t dispose(Space* home);
00206     virtual Actor*      copy(Space* home,bool);
00208     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00209     static  ExecStatus post(Space* home, ViewArray<View0>& x, View1& y, 
00210                             bdd& d);
00211   };
00212 
00221   template <class View0, class View1>
00222   class NaryTwoCpltSetPropagator : 
00223     public Propagator {
00224   protected:
00226     ViewArray<View0> x;
00228     View1 y;
00230     View1 z;
00232     bdd d;
00234     NaryTwoCpltSetPropagator(Space* home, bool share, 
00235                              NaryTwoCpltSetPropagator& p);
00237     NaryTwoCpltSetPropagator(Space* home,
00238                              ViewArray<View0>&, View1&, View1&, bdd&);
00240     ExecStatus divide_conquer(Space* home, bdd& p, int l, int r, 
00241                               int ypos, int zpos);
00242   public:
00244     virtual Reflection::ActorSpec spec(const Space* home,
00245                                         Reflection::VarMap& m) const;
00247     static Support::Symbol ati(void);
00249     virtual PropCost cost(ModEventDelta med) const;
00251     virtual size_t dispose(Space* home);
00253     virtual Actor*      copy(Space* home,bool);
00255     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00256     static  ExecStatus post(Space* home, ViewArray<View0>& x, 
00257                             View1& y, View1& z, bdd& d);
00258   };
00259   
00268   template <class View0, class View1>
00269   class BinRelDisj : public BinaryCpltSetPropagator<View0,View1> {
00270   protected:
00272     using BinaryCpltSetPropagator<View0,View1>::d;
00273     using BinaryCpltSetPropagator<View0,View1>::x;
00274     using BinaryCpltSetPropagator<View0,View1>::y;
00276     BinRelDisj(Space* home, bool share, BinRelDisj<View0,View1>& p);
00278     BinRelDisj(Space* home, View0& x0, View1& y0, bdd& d);
00279   public:
00281     virtual size_t dispose(Space* home);
00283     virtual Actor*      copy(Space* home,bool);
00285     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00286     static  ExecStatus post(Space* home, View0& x0, View1& y0, bdd& d);
00287   };
00288 
00295   template <class View1, class View2>
00296   class Singleton : public Propagator {
00297   protected:
00299     View1 x;
00301     View2 s;
00303     Singleton(Space* home, bool share, Singleton& p);
00305     Singleton(Space* home, View1& x, View2& s);
00306   public:
00308     virtual PropCost cost(ModEventDelta med) const;
00310     virtual Reflection::ActorSpec spec(const Space* home,
00311                                         Reflection::VarMap& m) const;
00313     static Support::Symbol ati(void);
00314 
00316     virtual size_t dispose(Space* home);
00318     virtual Actor*      copy(Space* home,bool);
00320     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00321     static  ExecStatus post(Space* home, View1& x, View2& s);
00322   }; 
00323 
00324 }}
00325 
00326 #include "gecode/cpltset/propagators/nary.icc"
00327 #include "gecode/cpltset/propagators/naryone.icc"
00328 #include "gecode/cpltset/propagators/narytwo.icc"
00329 #include "gecode/cpltset/propagators/binary.icc"
00330 #include "gecode/cpltset/propagators/unary.icc"
00331 #include "gecode/cpltset/propagators/singleton.icc" 
00332 
00333 #endif
00334 
00335 // STATISTICS: cpltset-prop