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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 namespace Gecode { namespace CpltSet {
00041
00042 template <class View0, class View1>
00043 forceinline
00044 NaryOneCpltSetPropagator<View0, View1>
00045 ::NaryOneCpltSetPropagator(Space* home, ViewArray<View0>& x,
00046 View1& y, bdd& d0) : Super(home, x, y), d(d0) {
00047 Super::force(home);
00048 }
00049
00050 template <class View0, class View1>
00051 forceinline
00052 NaryOneCpltSetPropagator<View0, View1>
00053 ::NaryOneCpltSetPropagator(Space* home, bool share,
00054 NaryOneCpltSetPropagator& p)
00055 : Super(home, share, p), d(p.d) {}
00056
00057 template <class View0, class View1>
00058 forceinline ExecStatus
00059 NaryOneCpltSetPropagator<View0, View1>::post(Space* home,
00060 ViewArray<View0>& x, View1& y,
00061 bdd& d0) {
00062 (void) new (home) NaryOneCpltSetPropagator(home, x, y, d0);
00063 return ES_OK;
00064 }
00065
00066 template <class View0, class View1>
00067 Support::Symbol
00068 NaryOneCpltSetPropagator<View0, View1>::ati(void) {
00069 return
00070 Reflection::mangle<View0,View1>("Gecode::CpltSet::NaryOneCpltSetPropagator");
00071 }
00072
00073 template <class View0, class View1>
00074 Reflection::ActorSpec
00075 NaryOneCpltSetPropagator<View0,View1>::spec(const Space* home,
00076 Reflection::VarMap& m) const {
00077 throw Reflection::ReflectionException("Not implemented");
00078 }
00079
00080 template <class View0, class View1>
00081 forceinline Actor*
00082 NaryOneCpltSetPropagator<View0, View1>::copy(Space* home, bool share) {
00083 return new (home) NaryOneCpltSetPropagator(home, share, *this);
00084 }
00085
00086 template <class View0, class View1>
00087 ExecStatus
00088 NaryOneCpltSetPropagator<View0, View1>::divide_conquer(Space* home, bdd& p,
00089 int l, int r,
00090 int ypos) {
00091 if (l == r) {
00092 ModEvent me = ME_CPLTSET_NONE;
00093 if (l == ypos) {
00094 GECODE_ME_CHECK(me = y.intersect(home, p));
00095 } else {
00096 GECODE_ME_CHECK(me = x[l].intersect(home, p));
00097 }
00098 return ES_OK;
00099 }
00100
00101 int h = (r + l) / 2;
00102
00103
00104 bdd left = p;
00105 for (int i = r; i >= h + 1; i--) {
00106 if (i == ypos) {
00107 quantify(left, y);
00108 } else {
00109 quantify(left, x[i]);
00110 }
00111 }
00112
00113 ExecStatus es = ES_OK;
00114 GECODE_ES_CHECK(es = divide_conquer(home, left, l, h, ypos));
00115
00116 bdd right = p;
00117 for (int i = h; i >= l; i-- ) {
00118 if (i == ypos) {
00119 quantify(right, y);
00120 } else {
00121 quantify(right, x[i]);
00122 }
00123 }
00124
00125 GECODE_ES_CHECK(es = divide_conquer(home, right, h + 1, r, ypos));
00126 return es;
00127 }
00128
00129 template <class View0, class View1>
00130 forceinline ExecStatus
00131 NaryOneCpltSetPropagator<View0, View1>::propagate(Space* home, ModEventDelta) {
00132 bool assigned = true;
00133 int n = x.size();
00134 ExecStatus es = ES_OK;
00135 int ypos = n;
00136
00137 GECODE_ES_CHECK(es = divide_conquer(home, d, 0, n, ypos));
00138
00139 assigned = true;
00140 for (int i = x.size(); i--; ) {
00141 assigned &= x[i].assigned();
00142 }
00143 if (assigned) {
00144 return ES_SUBSUMED(this, home);
00145 }
00146
00147 return ES_FIX;
00148 }
00149
00150 template <class View0, class View1>
00151 size_t
00152 NaryOneCpltSetPropagator<View0, View1>::dispose(Space* home) {
00153 Super::unforce(home);
00154 if (!home->failed()) {
00155 x.cancel(home, this, PC_CPLTSET_DOM);
00156 y.cancel(home, this, PC_CPLTSET_DOM);
00157 }
00158 manager.dispose(d);
00159 Super::dispose(home);
00160 return sizeof(*this);
00161 }
00162
00163 }}
00164
00165