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

eq.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2004
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-08-25 10:15:00 +0200 (Fri, 25 Aug 2006) $ by $Author: schulte $
00010  *     $Revision: 3566 $
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 { namespace Int { namespace Bool {
00023 
00024   template<class BVA, class BVB>
00025   forceinline
00026   Eq<BVA,BVB>::Eq(Space* home, BVA b0, BVB b1)
00027     : BoolBinary<BVA,BVB>(home,b0,b1) {}
00028 
00029   template<class BVA, class BVB>
00030   inline ExecStatus
00031   Eq<BVA,BVB>::post(Space* home, BVA b0, BVB b1) {
00032     switch (bool_test(b0,b1)) {
00033     case BT_SAME: return ES_OK;
00034     case BT_COMP: return ES_FAILED;
00035     case BT_NONE:
00036       if (b0.zero()) {
00037         GECODE_ME_CHECK(b1.t_zero(home));
00038       } else if (b0.one()) {
00039         GECODE_ME_CHECK(b1.t_one(home));
00040       } else if (b1.zero()) {
00041         GECODE_ME_CHECK(b0.t_zero(home));
00042       } else if (b1.one()) {
00043         GECODE_ME_CHECK(b0.t_one(home));
00044       } else {
00045         (void) new (home) Eq<BVA,BVB>(home,b0,b1);
00046       }
00047       break;
00048     default: GECODE_NEVER;
00049     }
00050     return ES_OK;
00051   }
00052 
00053   template<class BVA, class BVB>
00054   forceinline
00055   Eq<BVA,BVB>::Eq(Space* home, bool share, Eq<BVA,BVB>& p)
00056     : BoolBinary<BVA,BVB>(home,share,p) {}
00057 
00058   template<class BVA, class BVB>
00059   forceinline
00060   Eq<BVA,BVB>::Eq(Space* home, bool share, Propagator& p,
00061                   BVA b0, BVB b1)
00062     : BoolBinary<BVA,BVB>(home,share,p,b0,b1) {}
00063 
00064   template<class BVA, class BVB>
00065   Actor*
00066   Eq<BVA,BVB>::copy(Space* home, bool share) {
00067     return new (home) Eq<BVA,BVB>(home,share,*this);
00068   }
00069 
00070   template<class BVA, class BVB>
00071   ExecStatus
00072   Eq<BVA,BVB>::propagate(Space* home) {
00073     if (x0.zero()) {
00074       GECODE_ME_CHECK(x1.t_zero(home));
00075     } else if (x0.one()) {
00076       GECODE_ME_CHECK(x1.t_one(home));
00077     } else if (x1.zero()) {
00078       x0.t_zero_none(home);
00079     } else {
00080       assert(x1.one());
00081       x0.t_one_none(home);
00082     }
00083     return ES_SUBSUMED;
00084   }
00085 
00086 }}}
00087 
00088 // STATISTICS: int-prop
00089