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

channel.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: 2006-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $
00014  *     $Revision: 3188 $
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 
00027 
00028 #include "gecode/set.hh"
00029 #include "gecode/int.hh"
00030 
00031 namespace Gecode { namespace Set { namespace Int {
00032 
00033   forceinline
00034   Channel::Channel(Space* home,
00035                    ViewArray< Gecode::Int::IntView >& xs0,
00036                    ViewArray< SetView >& ys0)
00037     : Propagator(home), xs(xs0), ys(ys0) {
00038     xs.subscribe(home,this, Gecode::Int::PC_INT_DOM);
00039     ys.subscribe(home,this, PC_SET_ANY);
00040   }
00041 
00042   forceinline
00043   Channel::Channel(Space* home, bool share,
00044                    Channel& p)
00045     : Propagator(home,share,p) {
00046     xs.update(home,share,p.xs);
00047     ys.update(home,share,p.ys);
00048   }
00049 
00050   forceinline ExecStatus
00051   Channel::post(Space* home, ViewArray<Gecode::Int::IntView>& xs,
00052                 ViewArray<SetView>& ys) {
00053     // Sharing of ys is taken care of in the propagator:
00054     // The ys are propagated to be disjoint, so shared variables
00055     // result in failure.
00056     unsigned int xssize = xs.size();
00057     for (int i=ys.size(); i--;) {
00058       GECODE_ME_CHECK(ys[i].exclude(home, xssize, Limits::Set::int_max));
00059       GECODE_ME_CHECK(ys[i].exclude(home, Limits::Set::int_min, -1));
00060     }
00061     unsigned int yssize = ys.size();
00062     if (yssize > static_cast<unsigned int>(Limits::Int::int_max))
00063       return ES_FAILED;
00064     for (int i=xs.size(); i--;) {
00065       GECODE_ME_CHECK(xs[i].gq(home, 0));
00066       GECODE_ME_CHECK(xs[i].le(home, static_cast<int>(yssize)));
00067     }
00068 
00069     (void) new (home) Channel(home,xs,ys);
00070     return ES_OK;
00071   }
00072 
00073 }}}
00074 
00075 // STATISTICS: set-prop