channelVarVal.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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