Sha256: c90769ed3eb6a34b576a2dd7bc6322c87cad46a0ea786ea9cb47776aa53729d5

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

/*
 *  Main authors:
 *     Guido Tack <tack@gecode.org>
 *
 *  Copyright:
 *     Guido Tack, 2006
 *
 *  Last modified:
 *     $Date: 2006-08-25 17:31:32 +0200 (Fri, 25 Aug 2006) $ by $Author: tack $
 *     $Revision: 3573 $
 *
 *  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 {

  forceinline
  Projector::Projector(void) : i(0), glb(), lub() {}
  
  forceinline
  Projector::Projector(SetExpr::var_idx x,
		       const SetExpr& sglb, const SetExpr& slub)
    : i(x), glb(sglb.encode()), lub(slub.encode()),
      _arity(std::max(sglb.arity(), slub.arity())) {}

  template <bool negated>
  inline ExecStatus
  Projector::propagate(Space* home, ViewArray<Set::SetView>& x) {
    if (negated) {
      switch (ExecStatus es=check(home, x)) {
      case ES_FAILED: return ES_SUBSUMED;
      case ES_SUBSUMED: return ES_FAILED;
      default: return es;
      }
    } else {
      // Prune greatest lower and least upper bound according to given ranges
      {
	SetExprRanges glbranges(x,glb,false);
	GECODE_ME_CHECK(x[i].includeI(home, glbranges));
      }
      {
	SetExprRanges lubranges(x,lub,true);
	GECODE_ME_CHECK(x[i].intersectI(home, lubranges));
      }
      return ES_NOFIX;
    }
  }

  forceinline unsigned int
  Projector::glbSize(ViewArray<Set::SetView>& x) {
    SetExprRanges glbranges(x, glb, false);
    return Iter::Ranges::size(glbranges);
  }

  forceinline unsigned int
  Projector::lubSize(ViewArray<Set::SetView>& x) {
    SetExprRanges lubranges(x, lub, true);
    return Iter::Ranges::size(lubranges);
  }

  forceinline const SetExprCode&
  Projector::getGlb(void) const { return glb; }

  forceinline const SetExprCode&
  Projector::getLub(void) const { return lub; }

  forceinline int
  Projector::getIdx(void) const { return i; }

}

// STATISTICS: set-prop

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gecoder-with-gecode-0.7.1 ext/gecode-1.3.1/gecode/set/projectors/projector.icc