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

nosubset.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Gabor Szokoli <szokoli@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Guido Tack, 2004
00009  *     Christian Schulte, 2004
00010  *     Gabor Szokoli, 2004
00011  *
00012  *  Last modified:
00013  *     $Date: 2005-08-01 08:20:10 +0200 (Mon, 01 Aug 2005) $ by $Author: tack $
00014  *     $Revision: 2098 $
00015  *
00016  *  This file is part of Gecode, the generic constraint
00017  *  development environment:
00018  *     http://www.gecode.org
00019  *
00020  *  See the file "LICENSE" for information on usage and
00021  *  redistribution of this file, and for a
00022  *     DISCLAIMER OF ALL WARRANTIES.
00023  *
00024  */
00025 
00026 namespace Gecode { namespace Set { namespace Rel {
00027 
00028   /*
00029    * "No Subset" propagator
00030    *
00031    */
00032 
00033   template <class View0, class View1>
00034   forceinline
00035   NoSubSet<View0,View1>::NoSubSet(Space* home, View0 y0, View1 y1)
00036     : InhomBinaryPropagator<View0,PC_SET_CLUB,
00037                             View1,PC_SET_CGLB>(home,y0,y1) {}
00038 
00039   template <class View0, class View1>
00040   forceinline
00041   NoSubSet<View0,View1>::NoSubSet(Space* home, bool share, 
00042                                   NoSubSet<View0,View1>& p)
00043     : InhomBinaryPropagator<View0,PC_SET_CLUB,
00044                             View1,PC_SET_CGLB>(home,share,p) {}
00045 
00046   template <class View0, class View1>
00047   ExecStatus
00048   NoSubSet<View0,View1>::post(Space* home, View0 x, View1 y) {
00049     if (me_failed(x.cardMin(home,1)))
00050       return ES_FAILED;
00051     (void) new (home) NoSubSet<View0,View1>(home,x,y);
00052     return ES_OK;
00053   }
00054 
00055   template <class View0, class View1>
00056   Actor*
00057   NoSubSet<View0,View1>::copy(Space* home, bool share) {
00058     return new (home) NoSubSet<View0,View1>(home,share,*this);
00059   }
00060 
00061   template <class View0, class View1>
00062   ExecStatus
00063   NoSubSet<View0,View1>::propagate(Space* home) {
00064     GlbRanges<View0> x0lb(x0);
00065     LubRanges<View1> x1ub(x1);
00066     if (!Iter::Ranges::subset(x0lb, x1ub))
00067       return ES_SUBSUMED;
00068     if (x0.cardMin()>x1.cardMax()) { return ES_SUBSUMED; }
00069     LubRanges<View0> x0ub(x0);
00070     GlbRanges<View1> x1lb(x1);
00071     Iter::Ranges::Diff<LubRanges<View0>,GlbRanges<View1> >
00072       breakers(x0ub,x1lb);
00073     if (!breakers()) { return ES_FAILED; }
00074     if (breakers.min() == breakers.max()) {
00075       int b1 = breakers.min();
00076       ++breakers;
00077       if (breakers()) { return ES_FIX; }
00078       //Only one subsetness-breaker element left:
00079       GECODE_ME_CHECK( x0.include(home,b1) );
00080       GECODE_ME_CHECK( x1.exclude(home,b1) );
00081       return ES_SUBSUMED;
00082     }
00083     return ES_FIX;
00084   }
00085 
00086 }}}
00087 
00088 // STATISTICS: set-prop