Generated on Thu Apr 11 13:59:07 2019 for Gecode by doxygen 1.6.3

ter-dom.hpp

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  *
00006  *  Copyright:
00007  *     Christian Schulte, 2003
00008  *
00009  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 namespace Gecode { namespace Int { namespace Distinct {
00035 
00036 
00037   /*
00038    * Ternary domain consistent distinct
00039    *
00040    */
00041 
00042   template<class View>
00043   forceinline
00044   TerDom<View>::TerDom(Home home, View x0, View x1, View x2)
00045     : TernaryPropagator<View,PC_INT_DOM>(home,x0,x1,x2) {}
00046 
00047   template<class View>
00048   ExecStatus
00049   TerDom<View>::post(Home home, View x0, View x1, View x2) {
00050     (void) new (home) TerDom<View>(home,x0,x1,x2);
00051     return ES_OK;
00052   }
00053 
00054   template<class View>
00055   forceinline
00056   TerDom<View>::TerDom(Space& home, TerDom<View>& p)
00057     : TernaryPropagator<View,PC_INT_DOM>(home,p) {}
00058 
00059   template<class View>
00060   Actor*
00061   TerDom<View>::copy(Space& home) {
00062     return new (home) TerDom<View>(home,*this);
00063   }
00064 
00066 #define GECODE_INT_HALL_ONE(x0,x1,x2)           \
00067   if (x0.assigned()) {                          \
00068     GECODE_ME_CHECK(x1.nq(home,x0.val()));      \
00069     GECODE_ME_CHECK(x2.nq(home,x0.val()));      \
00070     if (x1.assigned()) {                        \
00071       GECODE_ME_CHECK(x2.nq(home,x1.val()));    \
00072       return home.ES_SUBSUMED(*this);            \
00073     }                                           \
00074     if (x2.assigned()) {                        \
00075       GECODE_ME_CHECK(x1.nq(home,x2.val()));    \
00076       return home.ES_SUBSUMED(*this);            \
00077     }                                           \
00078     return ES_FIX;                              \
00079   }
00080 
00081 
00083 #define GECODE_INT_HALL_TWO(x0,x1,x2)                           \
00084   if ((x0.size() == 2) && (x1.size() == 2) &&                   \
00085       (x0.min() == x1.min()) && (x0.max() == x1.max())) {       \
00086     GECODE_ME_CHECK(x2.nq(home,x0.min()));                      \
00087     GECODE_ME_CHECK(x2.nq(home,x0.max()));                      \
00088     return ES_FIX;                                              \
00089   }
00090 
00091   template<class View>
00092   ExecStatus
00093   TerDom<View>::propagate(Space& home, const ModEventDelta&) {
00094     GECODE_INT_HALL_ONE(x0,x1,x2);
00095     GECODE_INT_HALL_ONE(x1,x0,x2);
00096     GECODE_INT_HALL_ONE(x2,x0,x1);
00097     GECODE_INT_HALL_TWO(x0,x1,x2);
00098     GECODE_INT_HALL_TWO(x0,x2,x1);
00099     GECODE_INT_HALL_TWO(x1,x2,x0);
00100     return ES_FIX;
00101   }
00102 
00103 #undef GECODE_INT_HALL_ONE
00104 #undef GECODE_INT_HALL_TWO
00105 
00106 }}}
00107 
00108 // STATISTICS: int-prop
00109