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

projector.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Guido Tack, 2006
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-08-25 17:31:32 +0200 (Fri, 25 Aug 2006) $ by $Author: tack $
00010  *     $Revision: 3573 $
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 {
00023 
00024   forceinline
00025   Projector::Projector(void) : i(0), glb(), lub() {}
00026   
00027   forceinline
00028   Projector::Projector(SetExpr::var_idx x,
00029                        const SetExpr& sglb, const SetExpr& slub)
00030     : i(x), glb(sglb.encode()), lub(slub.encode()),
00031       _arity(std::max(sglb.arity(), slub.arity())) {}
00032 
00033   template <bool negated>
00034   inline ExecStatus
00035   Projector::propagate(Space* home, ViewArray<Set::SetView>& x) {
00036     if (negated) {
00037       switch (ExecStatus es=check(home, x)) {
00038       case ES_FAILED: return ES_SUBSUMED;
00039       case ES_SUBSUMED: return ES_FAILED;
00040       default: return es;
00041       }
00042     } else {
00043       // Prune greatest lower and least upper bound according to given ranges
00044       {
00045         SetExprRanges glbranges(x,glb,false);
00046         GECODE_ME_CHECK(x[i].includeI(home, glbranges));
00047       }
00048       {
00049         SetExprRanges lubranges(x,lub,true);
00050         GECODE_ME_CHECK(x[i].intersectI(home, lubranges));
00051       }
00052       return ES_NOFIX;
00053     }
00054   }
00055 
00056   forceinline unsigned int
00057   Projector::glbSize(ViewArray<Set::SetView>& x) {
00058     SetExprRanges glbranges(x, glb, false);
00059     return Iter::Ranges::size(glbranges);
00060   }
00061 
00062   forceinline unsigned int
00063   Projector::lubSize(ViewArray<Set::SetView>& x) {
00064     SetExprRanges lubranges(x, lub, true);
00065     return Iter::Ranges::size(lubranges);
00066   }
00067 
00068   forceinline const SetExprCode&
00069   Projector::getGlb(void) const { return glb; }
00070 
00071   forceinline const SetExprCode&
00072   Projector::getLub(void) const { return lub; }
00073 
00074   forceinline int
00075   Projector::getIdx(void) const { return i; }
00076 
00077 }
00078 
00079 // STATISTICS: set-prop