re-nary.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
00031
00032
00033
00034
00035
00036
00037
00038 #include "gecode/set/projectors/propagator.hh"
00039
00040 namespace Gecode { namespace Set { namespace Projection {
00041
00042 size_t
00043 ReNaryProjection::dispose(Space* home) {
00044 unforce(home);
00045 if (!home->failed()) {
00046 x.cancel(home,this,PC_SET_ANY);
00047 b.cancel(home,this,Gecode::Int::PC_INT_VAL);
00048 }
00049 ps.~ProjectorSet();
00050 (void) Propagator::dispose(home);
00051 return sizeof(*this);
00052 }
00053
00054 ExecStatus
00055 ReNaryProjection::post(Space* home, ViewArray<SetView>& x,
00056 Gecode::Int::BoolView b, ProjectorSet& ps) {
00057 if (ps.arity() != x.size() - 1)
00058 throw Set::InvalidProjector("");
00059 (void) new (home) ReNaryProjection(home,x,b,ps);
00060 return ES_OK;
00061 }
00062
00063 Actor*
00064 ReNaryProjection::copy(Space* home, bool share) {
00065 return new (home) ReNaryProjection(home,share,*this);
00066 }
00067
00068 Support::Symbol
00069 ReNaryProjection::ati(void) {
00070 return Support::Symbol("set.projectors.ReNaryProjection");
00071 }
00072
00073 Reflection::ActorSpec
00074 ReNaryProjection::spec(const Space*, Reflection::VarMap&) const {
00075 throw Reflection::ReflectionException("Not implemented");
00076 }
00077
00078 ExecStatus
00079 ReNaryProjection::propagate(Space* home, ModEventDelta) {
00080 ProjectorSet newps(ps);
00081 if (b.one())
00082 GECODE_REWRITE(this,(NaryProjection<false>::post(home,x,newps)));
00083 if (b.zero())
00084 GECODE_REWRITE(this,(NaryProjection<true>::post(home,x,newps)));
00085
00086 switch (ps.check(home, x)) {
00087 case __ES_SUBSUMED:
00088 GECODE_ME_CHECK(b.one_none(home));
00089 return ES_SUBSUMED(this,home);
00090 case ES_FAILED:
00091 GECODE_ME_CHECK(b.zero_none(home));
00092 return ES_SUBSUMED(this,home);
00093 default:
00094 return ES_FIX;
00095 }
00096 }
00097
00098 }}}
00099
00100