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

range.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-04 16:03:26 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $
00010  *     $Revision: 3512 $
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 Dom {
00023 
00024   template <class View>
00025   forceinline
00026   ReRange<View>::ReRange(Space* home, View x, int min0, int max0, BoolView b)
00027     : ReUnaryPropagator<View,PC_INT_BND,BoolView>(home,x,b),
00028       min(min0), max(max0) {}
00029 
00030   template <class View>
00031   ExecStatus
00032   ReRange<View>::post(Space* home, View x, int min, int max, BoolView b) {
00033     if (min > max)
00034       return ES_FAILED;
00035     if ((max < x.min()) || (min > x.max())) {
00036       GECODE_ME_CHECK(b.t_zero(home));
00037     } else if ((min <= x.min()) && (x.max() <= max)) {
00038       GECODE_ME_CHECK(b.t_one(home));
00039     } else {
00040       (void) new (home) ReRange<View>(home,x,min,max,b);
00041     }
00042     return ES_OK;
00043   }
00044 
00045 
00046   template <class View>
00047   forceinline
00048   ReRange<View>::ReRange(Space* home, bool share, ReRange& p)
00049     : ReUnaryPropagator<View,PC_INT_BND,BoolView>(home,share,p),
00050       min(p.min), max(p.max) {}
00051 
00052   template <class View>
00053   Actor*
00054   ReRange<View>::copy(Space* home, bool share) {
00055     return new (home) ReRange<View>(home,share,*this);
00056   }
00057 
00058 
00059   template <class View>
00060   ExecStatus
00061   ReRange<View>::propagate(Space* home) {
00062     if (b.one()) {
00063       GECODE_ME_CHECK(x0.gq(home,min));
00064       GECODE_ME_CHECK(x0.lq(home,max));
00065       return ES_SUBSUMED;
00066     }
00067     if (b.zero()) {
00068       Iter::Ranges::Singleton r(min,max);
00069       GECODE_ME_CHECK(x0.minus(home,r));
00070       return ES_SUBSUMED;
00071     }
00072     if ((x0.max() <= max) && (x0.min() >= min)) {
00073       b.t_one_none(home); return ES_SUBSUMED;
00074     }
00075     if ((x0.max() < min) || (x0.min() > max)) {
00076       b.t_zero_none(home); return ES_SUBSUMED;
00077     }
00078     return ES_FIX;
00079   }
00080 
00081 
00082 }}}
00083 
00084 // STATISTICS: int-prop
00085