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

common.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  *
00006  *  Contributing authors:
00007  *     Gabor Szokoli <szokoli@gecode.org>
00008  *
00009  *  Copyright:
00010  *     Guido Tack, 2004
00011  *     Christian Schulte, 2004
00012  *     Gabor Szokoli, 2004
00013  *
00014  *  Last modified:
00015  *     $Date: 2006-08-25 17:31:32 +0200 (Fri, 25 Aug 2006) $ by $Author: tack $
00016  *     $Revision: 3573 $
00017  *
00018  *  This file is part of Gecode, the generic constraint
00019  *  development environment:
00020  *     http://www.gecode.org
00021  *
00022  *  See the file "LICENSE" for information on usage and
00023  *  redistribution of this file, and for a
00024  *     DISCLAIMER OF ALL WARRANTIES.
00025  *
00026  */
00027 
00028 namespace Gecode { namespace Set { namespace Sequence {
00029 
00030   forceinline
00031   ExecStatus propagateSeq(Space* home,
00032                           bool& modified, bool& assigned,
00033                           ViewArray<SetView>& x) {
00034 
00035     int lastElem = x.size()-1;
00036     int cur_max = BndSet::MAX_OF_EMPTY;
00037     int cur_min = BndSet::MIN_OF_EMPTY;
00038 
00039     for (int i=0; i<lastElem; i++) {
00040       if (x[i].glbSize() > 0) {
00041         int glbMax = x[i].glbMax();
00042         cur_max = std::max(cur_max, glbMax);
00043       }
00044       if (cur_max>=Limits::Set::int_min)
00045         GECODE_SET_ME_CHECK_VAL_B(modified,
00046                               x[i+1].exclude(home, Limits::Set::int_min,
00047                                              cur_max),
00048                               assigned);
00049 
00050       if (x[lastElem-i].lubSize() > 0) {
00051         int glbMin = x[lastElem-i].glbMin();
00052         cur_min = std::min(cur_min, glbMin);
00053       }
00054       if (Limits::Set::int_max>=cur_min)
00055         GECODE_SET_ME_CHECK_VAL_B(modified,
00056                               x[lastElem-i-1].exclude(home, cur_min,
00057                                                       Limits::Set::int_max),
00058                               assigned);
00059     }
00060     return ES_FIX;
00061   }
00062 
00063   forceinline
00064   ExecStatus propagateSeqUnion(Space* home,
00065                       bool& modified, ViewArray<SetView>& x, SetView& y) {
00066 
00067     GECODE_AUTOARRAY(GlbRanges<SetView>, XLBs,x.size());
00068     for (int i=x.size(); i--; ){
00069       GlbRanges<SetView> lb(x[i]);
00070       XLBs[i]=lb;
00071     }
00072     Iter::Ranges::NaryAppend<GlbRanges<SetView> > u(XLBs,x.size());
00073     GECODE_ME_CHECK_MODIFIED(modified, y.includeI(home,u));
00074     return ES_FIX;
00075   }
00076 
00077 }}}
00078 
00079 // STATISTICS: set-prop