/* * Main authors: * Guido Tack * Christian Schulte * Gabor Szokoli * * Copyright: * Guido Tack, 2004 * Christian Schulte, 2004 * Gabor Szokoli, 2004 * * Last modified: * $Date: 2005-08-01 08:20:10 +0200 (Mon, 01 Aug 2005) $ by $Author: tack $ * $Revision: 2098 $ * * 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 Set { namespace Rel { /* * "No Subset" propagator * */ template forceinline NoSubSet::NoSubSet(Space* home, View0 y0, View1 y1) : InhomBinaryPropagator(home,y0,y1) {} template forceinline NoSubSet::NoSubSet(Space* home, bool share, NoSubSet& p) : InhomBinaryPropagator(home,share,p) {} template ExecStatus NoSubSet::post(Space* home, View0 x, View1 y) { if (me_failed(x.cardMin(home,1))) return ES_FAILED; (void) new (home) NoSubSet(home,x,y); return ES_OK; } template Actor* NoSubSet::copy(Space* home, bool share) { return new (home) NoSubSet(home,share,*this); } template ExecStatus NoSubSet::propagate(Space* home) { GlbRanges x0lb(x0); LubRanges x1ub(x1); if (!Iter::Ranges::subset(x0lb, x1ub)) return ES_SUBSUMED; if (x0.cardMin()>x1.cardMax()) { return ES_SUBSUMED; } LubRanges x0ub(x0); GlbRanges x1lb(x1); Iter::Ranges::Diff,GlbRanges > breakers(x0ub,x1lb); if (!breakers()) { return ES_FAILED; } if (breakers.min() == breakers.max()) { int b1 = breakers.min(); ++breakers; if (breakers()) { return ES_FIX; } //Only one subsetness-breaker element left: GECODE_ME_CHECK( x0.include(home,b1) ); GECODE_ME_CHECK( x1.exclude(home,b1) ); return ES_SUBSUMED; } return ES_FIX; } }}} // STATISTICS: set-prop