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

bool.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Guido Tack <tack@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Christian Schulte, 2002
00009  *     Guido Tack, 2004
00010  *
00011  *  Last modified:
00012  *     $Date: 2008-01-29 13:37:51 +0100 (Tue, 29 Jan 2008) $ by $Author: tack $
00013  *     $Revision: 5993 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  Permission is hereby granted, free of charge, to any person obtaining
00020  *  a copy of this software and associated documentation files (the
00021  *  "Software"), to deal in the Software without restriction, including
00022  *  without limitation the rights to use, copy, modify, merge, publish,
00023  *  distribute, sublicense, and/or sell copies of the Software, and to
00024  *  permit persons to whom the Software is furnished to do so, subject to
00025  *  the following conditions:
00026  *
00027  *  The above copyright notice and this permission notice shall be
00028  *  included in all copies or substantial portions of the Software.
00029  *
00030  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00031  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00032  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00033  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00034  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00035  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00036  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00037  *
00038  */
00039 
00040 #ifndef __GECODE_INT_BOOL_HH__
00041 #define __GECODE_INT_BOOL_HH__
00042 
00043 #include "gecode/int.hh"
00044 
00050 namespace Gecode { namespace Int { namespace Bool {
00051 
00052   /*
00053    * Base Classes
00054    *
00055    */
00056 
00058   template<class BVA, class BVB>
00059   class BoolBinary : public Propagator {
00060   protected:
00061     BVA x0; 
00062     BVB x1; 
00063 
00064     BoolBinary(Space* home, BVA b0, BVB b1);
00066     BoolBinary(Space* home, bool share, BoolBinary& p);
00068     BoolBinary(Space* home, bool share, Propagator& p,
00069                BVA b0, BVB b1);
00071     Reflection::ActorSpec spec(const Space* home, Reflection::VarMap& m, 
00072                                 const Support::Symbol& name) const;
00073   public:
00075     virtual PropCost cost(ModEventDelta med) const;
00077     virtual size_t dispose(Space* home);
00078   };
00079 
00081   template<class BVA, class BVB, class BVC>
00082   class BoolTernary : public Propagator {
00083   protected:
00084     BVA x0; 
00085     BVB x1; 
00086     BVC x2; 
00087 
00088     BoolTernary(Space* home, BVA b0, BVB b1, BVC b2);
00090     BoolTernary(Space* home, bool share, BoolTernary& p);
00092     Reflection::ActorSpec spec(const Space* home, Reflection::VarMap& m,
00093                                 const Support::Symbol& name) const;
00094   public:
00096     BoolTernary(Space* home, bool share, Propagator& p,
00097                 BVA b0, BVB b1, BVC b2);
00099     virtual PropCost cost(ModEventDelta med) const;
00101     virtual size_t dispose(Space* home);
00102   };
00103 
00110   template<class BVA, class BVB>
00111   class Eq : public BoolBinary<BVA,BVB> {
00112   protected:
00113     using BoolBinary<BVA,BVB>::x0;
00114     using BoolBinary<BVA,BVB>::x1;
00116     Eq(Space* home, BVA b0, BVB b1);
00118     Eq(Space* home, bool share, Eq& p);
00119   public:
00121     Eq(Space* home, bool share, Propagator& p,
00122        BVA b0, BVB b1);
00124     virtual Actor* copy(Space* home, bool share);
00126     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00128     static  ExecStatus post(Space* home, BVA b0, BVB b1);
00130     virtual Reflection::ActorSpec spec(const Space* home,
00131                                         Reflection::VarMap& m) const;
00133     static void post(Space* home, Reflection::VarMap& vars,
00134                      const Reflection::ActorSpec& spec);
00136     static Support::Symbol ati(void);
00137   };
00138 
00139 
00146   template<class BV>
00147   class NaryEq : public NaryPropagator<BV,PC_BOOL_VAL> {
00148   protected:
00149     using NaryPropagator<BV,PC_BOOL_VAL>::x;
00151     NaryEq(Space* home, ViewArray<BV>& x);
00153     NaryEq(Space* home, bool share, NaryEq& p);
00154   public:
00156     virtual Actor* copy(Space* home, bool share);
00158     virtual PropCost cost(ModEventDelta med) const;
00160     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00162     static  ExecStatus post(Space* home, ViewArray<BV>& x);
00164     static void post(Space* home, Reflection::VarMap& vars,
00165                      const Reflection::ActorSpec& spec);
00167     virtual Reflection::ActorSpec spec(const Space* home,
00168                                         Reflection::VarMap& m) const;
00170     static Support::Symbol ati(void);
00171   };
00172 
00173 
00180   template<class BV>
00181   class Lq : public BoolBinary<BV,BV> {
00182   protected:
00183     using BoolBinary<BV,BV>::x0;
00184     using BoolBinary<BV,BV>::x1;
00186     Lq(Space* home, BV b0, BV b1);
00188     Lq(Space* home, bool share, Lq& p);
00189   public:
00191     virtual Actor* copy(Space* home, bool share);
00193     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00195     static  ExecStatus post(Space* home, BV b0, BV b1);
00197     virtual Reflection::ActorSpec spec(const Space* home,
00198                                         Reflection::VarMap& m) const;
00200     static void post(Space* home, Reflection::VarMap& vars,
00201                      const Reflection::ActorSpec& spec);
00203     static Support::Symbol ati(void);
00204   };
00205 
00206 
00213   template<class BV>
00214   class Le {
00215   public:
00217     static  ExecStatus post(Space* home, BV b0, BV b1);
00218   };
00219 
00220 
00227   template<class BVA, class BVB>
00228   class BinOrTrue : public BoolBinary<BVA,BVB> {
00229   protected:
00230     using BoolBinary<BVA,BVB>::x0;
00231     using BoolBinary<BVA,BVB>::x1;
00233     BinOrTrue(Space* home, BVA b0, BVB b1);
00235     BinOrTrue(Space* home, bool share, BinOrTrue& p);
00236   public:
00238     BinOrTrue(Space* home, bool share, Propagator& p,
00239               BVA b0, BVB b1);
00241     virtual Actor* copy(Space* home, bool share);
00243     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00245     static  ExecStatus post(Space* home, BVA b0, BVB b1);
00247     virtual Reflection::ActorSpec spec(const Space* home,
00248                                         Reflection::VarMap& m) const;
00250     static void post(Space* home, Reflection::VarMap& vars,
00251                      const Reflection::ActorSpec& spec);
00253     static Support::Symbol ati(void);
00254   };
00255 
00262   template<class BV>
00263   class TerOrTrue : public BoolBinary<BV,BV> {
00264   protected:
00265     using BoolBinary<BV,BV>::x0;
00266     using BoolBinary<BV,BV>::x1;
00268     BV x2;
00270     TerOrTrue(Space* home, BV b0, BV b1, BV b2);
00272     TerOrTrue(Space* home, bool share, TerOrTrue& p);
00273   public:
00275     TerOrTrue(Space* home, bool share, Propagator& p,
00276               BV b0, BV b1, BV b2);
00278     virtual Actor* copy(Space* home, bool share);
00280     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00282     static  ExecStatus post(Space* home, BV b0, BV b1, BV b2);
00284     virtual size_t dispose(Space* home);
00286     virtual Reflection::ActorSpec spec(const Space* home,
00287                                         Reflection::VarMap& m) const;
00289     static void post(Space* home, Reflection::VarMap& vars,
00290                      const Reflection::ActorSpec& spec);
00292     static Support::Symbol ati(void);
00293   };
00294 
00301   template<class BV>
00302   class QuadOrTrue : public BoolBinary<BV,BV> {
00303   protected:
00304     using BoolBinary<BV,BV>::x0;
00305     using BoolBinary<BV,BV>::x1;
00307     BV x2;
00309     BV x3;
00311     QuadOrTrue(Space* home, BV b0, BV b1, BV b2, BV b3);
00313     QuadOrTrue(Space* home, bool share, QuadOrTrue& p);
00314   public:
00316     QuadOrTrue(Space* home, bool share, Propagator& p,
00317                BV b0, BV b1, BV b2, BV b3);
00319     virtual Actor* copy(Space* home, bool share);
00321     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00323     static  ExecStatus post(Space* home, BV b0, BV b1, BV b2, BV b3);
00325     virtual Reflection::ActorSpec spec(const Space* home,
00326                                         Reflection::VarMap& m) const;
00328     static Support::Symbol ati(void);
00330     static void post(Space* home, Reflection::VarMap& vars,
00331                      const Reflection::ActorSpec& spec);
00333     virtual size_t dispose(Space* home);
00334   };
00335 
00342   template<class BVA, class BVB, class BVC>
00343   class Or : public BoolTernary<BVA,BVB,BVC> {
00344   protected:
00345     using BoolTernary<BVA,BVB,BVC>::x0;
00346     using BoolTernary<BVA,BVB,BVC>::x1;
00347     using BoolTernary<BVA,BVB,BVC>::x2;
00349     Or(Space* home, BVA b0, BVB b1, BVC b2);
00351     Or(Space* home, bool share, Or& p);
00352   public:
00354     Or(Space* home, bool share, Propagator& p, BVA b0, BVB b1, BVC b2);
00356     virtual Actor* copy(Space* home, bool share);
00358     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00360     static  ExecStatus post(Space* home, BVA b0, BVB b1, BVC b2);
00362     virtual Reflection::ActorSpec spec(const Space* home,
00363                                         Reflection::VarMap& m) const;
00365     static void post(Space* home, Reflection::VarMap& vars,
00366                      const Reflection::ActorSpec& spec);
00368     static Support::Symbol ati(void);
00369   };
00370 
00377   template<class BV>
00378   class NaryOr : public NaryOnePropagator<BV,PC_BOOL_VAL> {
00379   protected:
00380     using NaryOnePropagator<BV,PC_BOOL_VAL>::x;
00381     using NaryOnePropagator<BV,PC_BOOL_VAL>::y;
00383     NaryOr(Space* home,  ViewArray<BV>& b, BV c);
00385     NaryOr(Space* home, bool share, NaryOr<BV>& p);
00386   public:
00388     virtual Actor* copy(Space* home, bool share);
00390     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00392     static  ExecStatus post(Space* home, ViewArray<BV>& b, BV c);
00394     virtual Reflection::ActorSpec spec(const Space* home,
00395                                         Reflection::VarMap& m) const;
00397     static void post(Space* home, Reflection::VarMap& vars,
00398                      const Reflection::ActorSpec& spec);
00400     static Support::Symbol ati(void);
00401   };
00402 
00403 
00410   template<class BV>
00411   class NaryOrTrue : public BinaryPropagator<BV,PC_BOOL_VAL> {
00412   protected:
00413     using BinaryPropagator<BV,PC_BOOL_VAL>::x0;
00414     using BinaryPropagator<BV,PC_BOOL_VAL>::x1;
00416     ViewArray<BV> x;
00418     ExecStatus resubscribe(Space* home, BV& x0, BV x1);
00420     NaryOrTrue(Space* home,  ViewArray<BV>& b);
00422     NaryOrTrue(Space* home, bool share, NaryOrTrue<BV>& p);
00423   public:
00425     virtual Actor* copy(Space* home, bool share);
00427     virtual PropCost cost(ModEventDelta med) const;
00429     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00431     static  ExecStatus post(Space* home, ViewArray<BV>& b);
00433     virtual Reflection::ActorSpec spec(const Space* home,
00434                                         Reflection::VarMap& m) const;
00436     static void post(Space* home, Reflection::VarMap& vars,
00437                      const Reflection::ActorSpec& spec);
00439     static Support::Symbol ati(void);
00440   };
00441 
00442 
00449   template<class BVA, class BVB, class BVC>
00450   class Eqv : public BoolTernary<BVA,BVB,BVC> {
00451   protected:
00452     using BoolTernary<BVA,BVB,BVC>::x0;
00453     using BoolTernary<BVA,BVB,BVC>::x1;
00454     using BoolTernary<BVA,BVB,BVC>::x2;
00456     Eqv(Space* home, bool share, Eqv& p);
00458     Eqv(Space* home, BVA b0 ,BVB b1, BVC b2);
00459   public:
00461     virtual Actor* copy(Space* home, bool share);
00463     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00465     static  ExecStatus post(Space* home, BVA b0, BVB b1, BVC b2);
00467     virtual Reflection::ActorSpec spec(const Space* home,
00468                                         Reflection::VarMap& m) const;
00470     static void post(Space* home, Reflection::VarMap& vars,
00471                      const Reflection::ActorSpec& spec);
00473     static Support::Symbol ati(void);
00474   };
00475 
00476 }}}
00477 
00478 #include "gecode/int/bool/base.icc"
00479 #include "gecode/int/bool/eq.icc"
00480 #include "gecode/int/bool/lq.icc"
00481 #include "gecode/int/bool/or.icc"
00482 #include "gecode/int/bool/eqv.icc"
00483 
00484 #endif
00485 
00486 // STATISTICS: int-prop
00487