Generated on Mon Aug 25 11:35:44 2008 for Gecode by doxygen 1.5.6

nosubset.icc

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *     Christian Schulte <schulte@gecode.org>
00006  *     Gabor Szokoli <szokoli@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Guido Tack, 2004
00010  *     Christian Schulte, 2004
00011  *     Gabor Szokoli, 2004
00012  *
00013  *  Last modified:
00014  *     $Date: 2008-01-31 18:29:16 +0100 (Thu, 31 Jan 2008) $ by $Author: tack $
00015  *     $Revision: 6017 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 namespace Gecode { namespace Set { namespace Rel {
00043 
00044   /*
00045    * "No Subset" propagator
00046    *
00047    */
00048 
00049   template <class View0, class View1>
00050   forceinline
00051   NoSubSet<View0,View1>::NoSubSet(Space* home, View0 y0, View1 y1)
00052     : MixBinaryPropagator<View0,PC_SET_CLUB,
00053                             View1,PC_SET_CGLB>(home,y0,y1) {}
00054 
00055   template <class View0, class View1>
00056   forceinline
00057   NoSubSet<View0,View1>::NoSubSet(Space* home, bool share, 
00058                                   NoSubSet<View0,View1>& p)
00059     : MixBinaryPropagator<View0,PC_SET_CLUB,
00060                             View1,PC_SET_CGLB>(home,share,p) {}
00061 
00062   template <class View0, class View1>
00063   ExecStatus
00064   NoSubSet<View0,View1>::post(Space* home, View0 x, View1 y) {
00065     if (me_failed(x.cardMin(home,1)))
00066       return ES_FAILED;
00067     (void) new (home) NoSubSet<View0,View1>(home,x,y);
00068     return ES_OK;
00069   }
00070 
00071   template <class View0, class View1>
00072   Actor*
00073   NoSubSet<View0,View1>::copy(Space* home, bool share) {
00074     return new (home) NoSubSet<View0,View1>(home,share,*this);
00075   }
00076 
00077   template <class View0, class View1>
00078   Support::Symbol
00079   NoSubSet<View0,View1>::ati(void) {
00080     return Reflection::mangle<View0,View1>("Gecode::Set::Rel::NoSubSet");
00081   }
00082 
00083   template <class View0, class View1>
00084   Reflection::ActorSpec
00085   NoSubSet<View0,View1>::spec(const Space* home,
00086                               Reflection::VarMap& m) const {
00087     return MixBinaryPropagator<View0,PC_SET_CLUB,View1,PC_SET_CGLB>
00088       ::spec(home, m, ati());
00089   }
00090 
00091   template <class View0, class View1>
00092   void
00093   NoSubSet<View0,View1>::post(Space* home, Reflection::VarMap& vars,
00094                               const Reflection::ActorSpec& spec) {
00095     spec.checkArity(2);
00096     View0 x0(home, vars, spec[0]);
00097     View1 x1(home, vars, spec[1]);
00098     (void) new (home) NoSubSet(home,x0,x1);
00099   }
00100 
00101   template <class View0, class View1>
00102   ExecStatus
00103   NoSubSet<View0,View1>::propagate(Space* home, ModEventDelta) {
00104     GlbRanges<View0> x0lb(x0);
00105     LubRanges<View1> x1ub(x1);
00106     if (!Iter::Ranges::subset(x0lb, x1ub))
00107       return ES_SUBSUMED(this,home);
00108     if (x0.cardMin()>x1.cardMax()) { return ES_SUBSUMED(this,home); }
00109     LubRanges<View0> x0ub(x0);
00110     GlbRanges<View1> x1lb(x1);
00111     Iter::Ranges::Diff<LubRanges<View0>,GlbRanges<View1> >
00112       breakers(x0ub,x1lb);
00113     if (!breakers()) { return ES_FAILED; }
00114     if (breakers.min() == breakers.max()) {
00115       int b1 = breakers.min();
00116       ++breakers;
00117       if (breakers()) { return ES_FIX; }
00118       //Only one subsetness-breaker element left:
00119       GECODE_ME_CHECK( x0.include(home,b1) );
00120       GECODE_ME_CHECK( x1.exclude(home,b1) );
00121       return ES_SUBSUMED(this,home);
00122     }
00123     return ES_FIX;
00124   }
00125 
00126 }}}
00127 
00128 // STATISTICS: set-prop