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

ter-dom.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2003
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-07-24 16:50:30 +0200 (Mon, 24 Jul 2006) $ by $Author: schulte $
00010  *     $Revision: 3446 $
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 Distinct {
00023 
00024 
00025   /*
00026    * Ternary domain-consistent distinct
00027    *
00028    */
00029 
00030   template <class View>
00031   forceinline
00032   TerDom<View>::TerDom(Space* home, View x0, View x1, View x2)
00033     : TernaryPropagator<View,PC_INT_DOM>(home,x0,x1,x2) {}
00034 
00035   template <class View>
00036   ExecStatus
00037   TerDom<View>::post(Space* home, View x0, View x1, View x2) {
00038     (void) new (home) TerDom<View>(home,x0,x1,x2);
00039     return ES_OK;
00040   }
00041 
00042   template <class View>
00043   forceinline
00044   TerDom<View>::TerDom(Space* home, bool share, TerDom<View>& p)
00045     : TernaryPropagator<View,PC_INT_DOM>(home,share,p) {}
00046 
00047   template <class View>
00048   Actor*
00049   TerDom<View>::copy(Space* home, bool share) {
00050     return new (home) TerDom<View>(home,share,*this);
00051   }
00052 
00053   // Check whether x0 forms a Hall set of cardinality one
00054 #define GECODE_INT_HALL_ONE(x0,x1,x2)                           \
00055   if (x0.assigned()) {                                          \
00056     GECODE_ME_CHECK(x1.nq(home,x0.val()));                      \
00057     GECODE_ME_CHECK(x2.nq(home,x0.val()));                      \
00058     if (x1.assigned()) {                                        \
00059       GECODE_ME_CHECK(x2.nq(home,x1.val()));                    \
00060       return ES_SUBSUMED;                                       \
00061     }                                                           \
00062     if (x2.assigned()) {                                        \
00063       GECODE_ME_CHECK(x1.nq(home,x2.val()));                    \
00064       return ES_SUBSUMED;                                       \
00065     }                                                           \
00066     return ES_FIX;                                              \
00067   }
00068 
00069 
00070   // Check whether x0 and x1 form a Hall set of cardinality two
00071 #define GECODE_INT_HALL_TWO(x0,x1,x2)                           \
00072   if ((x0.size() == 2) && (x1.size() == 2) &&                   \
00073       (x0.min() == x1.min()) && (x0.max() == x1.max())) {       \
00074     GECODE_ME_CHECK(x2.nq(home,x0.min()));                      \
00075     GECODE_ME_CHECK(x2.nq(home,x0.max()));                      \
00076     return ES_FIX;                                              \
00077   }
00078 
00079   template <class View>
00080   ExecStatus
00081   TerDom<View>::propagate(Space* home) {
00082     GECODE_INT_HALL_ONE(x0,x1,x2);
00083     GECODE_INT_HALL_ONE(x1,x0,x2);
00084     GECODE_INT_HALL_ONE(x2,x0,x1);
00085     GECODE_INT_HALL_TWO(x0,x1,x2);
00086     GECODE_INT_HALL_TWO(x0,x2,x1);
00087     GECODE_INT_HALL_TWO(x1,x2,x0);
00088     return ES_FIX;
00089   }
00090 
00091 #undef GECODE_INT_HALL_ONE
00092 #undef GECODE_INT_HALL_TWO
00093 
00094 }}}
00095 
00096 // STATISTICS: int-prop
00097