Generated on Wed Jan 4 17:49:14 2006 for Gecode by doxygen 1.4.6

channelVarVal.cc

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: 2005-11-24 18:03:01 +0100 (Thu, 24 Nov 2005) $ by $Author: tack $
00016  *     $Revision: 2639 $
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 
00029 
00030 #include "set/int.hh"
00031 
00032 #include "iter.hh"
00033 
00034 #include "set/rel.hh"
00035 
00036 namespace Gecode { namespace Set { namespace Int {
00037 
00038   PropCost
00039   ChannelVarVal::cost(void) const {
00040     return PC_QUADRATIC_LO;
00041   }
00042 
00043   ChannelVarVal::~ChannelVarVal(void) {
00044     xs.cancel(this, Gecode::Int::PC_INT_DOM);
00045     ys.cancel(this, PC_SET_ANY);
00046   }
00047 
00048   Actor*
00049   ChannelVarVal::copy(Space* home, bool share) {
00050     return new (home) ChannelVarVal(home,share,*this);
00051   }
00052 
00053   ExecStatus
00054   ChannelVarVal::propagate(Space* home) {
00055     int assigned = 0;
00056     for (int v=xs.size(); v--;) {
00057       if (xs[v].assigned()) {
00058         assigned += 1;
00059         for (int i=ys.size(); i--;) {
00060           if (i==xs[v].val()) {
00061             GECODE_ME_CHECK(ys[i].include(home, v));
00062           }
00063           else {
00064             GECODE_ME_CHECK(ys[i].exclude(home, v));
00065           }
00066         }
00067       } else {
00068 
00069         for (int i=ys.size(); i--;) {
00070           if (ys[i].notContains(v)) {
00071             GECODE_ME_CHECK(xs[v].nq(home, i));
00072           }
00073           if (ys[i].contains(v)) {
00074             GECODE_ME_CHECK(xs[v].eq(home, i));
00075           }
00076         }
00077 
00078         Gecode::Int::ViewRanges<Gecode::Int::IntView> xsv(xs[v]);
00079         int min = 0;
00080         for (; xsv(); ++xsv) {
00081           for (int i=min; i<xsv.min(); i++) {
00082             GECODE_ME_CHECK(ys[i].exclude(home, v));
00083           }
00084           min = xsv.max() + 1;
00085         }
00086 
00087       }
00088     }
00089 
00090     return (assigned==xs.size()) ? ES_SUBSUMED : ES_NOFIX;
00091   }
00092 
00093 
00094 }}}
00095 
00096 // STATISTICS: set-prop