card.icc
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
00031
00032
00033
00034
00035
00036
00037
00038 namespace Gecode { namespace Set { namespace Projection {
00039
00040 forceinline
00041 CardProjection::CardProjection
00042 (Space* home, ViewArray<SetView>& x0, Gecode::Int::IntView i0, Projector& p0)
00043 : Propagator(home), x(x0), i(i0), pc(x.size()), proj(p0) {
00044 force(home);
00045 Support::DynamicArray<int> scope;
00046 for (int i=x0.size(); i--;)
00047 scope[i] = PC_SET_ANY + 1;
00048 p0.scope(scope);
00049 for (int i=x0.size(); i--;) {
00050 pc[i] = scope[i];
00051 if (pc[i] != PC_SET_ANY + 1)
00052 x[i].subscribe(home, this, pc[i]);
00053 }
00054 }
00055
00056 forceinline
00057 CardProjection::CardProjection
00058 (Space* home, bool share, CardProjection& p)
00059 : Propagator(home,share,p), proj(p.proj) {
00060 x.update(home,share,p.x);
00061 i.update(home,share,p.i);
00062 pc.update(home,share, p.pc);
00063 }
00064
00065 forceinline PropCost
00066 CardProjection::cost(ModEventDelta) const {
00067 switch (x.size()) {
00068 case 1: return PC_UNARY_HI;
00069 case 2: return PC_BINARY_HI;
00070 case 3: return PC_TERNARY_HI;
00071 default: return PC_LINEAR_HI;
00072 }
00073 }
00074
00075 inline Support::Symbol
00076 CardProjection::ati(void) {
00077 return Support::Symbol("set.projectors.CardProjection");
00078 }
00079
00080 forceinline Reflection::ActorSpec
00081 CardProjection::spec(const Space*, Reflection::VarMap&) const {
00082 throw Reflection::ReflectionException("Not implemented");
00083 }
00084
00085 inline size_t
00086 CardProjection::dispose(Space* home) {
00087 unforce(home);
00088 if (!home->failed()) {
00089 for (int i=x.size(); i--;)
00090 if (pc[i] != PC_SET_ANY + 1)
00091 x[i].cancel(home, this, pc[i]);
00092 }
00093 proj.~Projector();
00094 pc.~SharedArray();
00095 (void) Propagator::dispose(home);
00096 return sizeof(*this);
00097 }
00098
00099 inline ExecStatus
00100 CardProjection::post(Space* home,
00101 ViewArray<SetView>& x, Gecode::Int::IntView i,
00102 Projector& p) {
00103 (void) new (home) CardProjection(home,x,i,p);
00104 return ES_OK;
00105 }
00106
00107 inline Actor*
00108 CardProjection::copy(Space* home, bool share) {
00109 return new (home) CardProjection(home,share,*this);
00110 }
00111
00112 inline ExecStatus
00113 CardProjection::propagate(Space* home, ModEventDelta) {
00114 bool done = true;
00115 for (int j=x.size(); j--;)
00116 if (pc[j] != PC_SET_ANY + 1)
00117 done = done && x[j].assigned();
00118
00119 {
00120 GECODE_ME_CHECK(i.gq(home, static_cast<int>(proj.glbSize(x))));
00121 GECODE_ME_CHECK(i.lq(home, static_cast<int>(proj.lubSize(x))));
00122 }
00123 return done ? ES_SUBSUMED(this,home) : ES_FIX;
00124 }
00125
00126 }}}
00127
00128