/* * Main authors: * Christian Schulte * * Copyright: * Christian Schulte, 2004 * * Last modified: * $Date: 2006-08-04 16:03:26 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $ * $Revision: 3512 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * See the file "LICENSE" for information on usage and * redistribution of this file, and for a * DISCLAIMER OF ALL WARRANTIES. * */ namespace Gecode { namespace Int { namespace Dom { template forceinline ReRange::ReRange(Space* home, View x, int min0, int max0, BoolView b) : ReUnaryPropagator(home,x,b), min(min0), max(max0) {} template ExecStatus ReRange::post(Space* home, View x, int min, int max, BoolView b) { if (min > max) return ES_FAILED; if ((max < x.min()) || (min > x.max())) { GECODE_ME_CHECK(b.t_zero(home)); } else if ((min <= x.min()) && (x.max() <= max)) { GECODE_ME_CHECK(b.t_one(home)); } else { (void) new (home) ReRange(home,x,min,max,b); } return ES_OK; } template forceinline ReRange::ReRange(Space* home, bool share, ReRange& p) : ReUnaryPropagator(home,share,p), min(p.min), max(p.max) {} template Actor* ReRange::copy(Space* home, bool share) { return new (home) ReRange(home,share,*this); } template ExecStatus ReRange::propagate(Space* home) { if (b.one()) { GECODE_ME_CHECK(x0.gq(home,min)); GECODE_ME_CHECK(x0.lq(home,max)); return ES_SUBSUMED; } if (b.zero()) { Iter::Ranges::Singleton r(min,max); GECODE_ME_CHECK(x0.minus(home,r)); return ES_SUBSUMED; } if ((x0.max() <= max) && (x0.min() >= min)) { b.t_one_none(home); return ES_SUBSUMED; } if ((x0.max() < min) || (x0.min() > max)) { b.t_zero_none(home); return ES_SUBSUMED; } return ES_FIX; } }}} // STATISTICS: int-prop