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 #include "gecode/set/projectors/propagator.hh"
00023
00024 namespace Gecode { namespace Set { namespace Projection {
00025
00026 size_t
00027 ReNaryProjection::dispose(Space* home) {
00028 if (!home->failed()) {
00029 x.cancel(home,this,PC_SET_ANY);
00030 b.cancel(home,this,Gecode::Int::PC_INT_VAL);
00031 }
00032 ps.~ProjectorSet();
00033 Propagator::dispose(home);
00034 return sizeof(*this);
00035 }
00036
00037 ExecStatus
00038 ReNaryProjection::post(Space* home, ViewArray<SetView>& x,
00039 Gecode::Int::BoolView b, ProjectorSet& ps) {
00040 if (ps.arity() != x.size() - 1)
00041 throw Set::InvalidProjector("");
00042 (void) new (home) ReNaryProjection(home,x,b,ps);
00043 return ES_OK;
00044 }
00045
00046 Actor*
00047 ReNaryProjection::copy(Space* home, bool share) {
00048 return new (home) ReNaryProjection(home,share,*this);
00049 }
00050
00051 ExecStatus
00052 ReNaryProjection::propagate(Space* home) {
00053 if (b.one()) {
00054 GECODE_ES_CHECK((NaryProjection<false>::post(home,x,ps)));
00055 return ES_SUBSUMED;
00056 }
00057 if (b.zero()) {
00058 GECODE_ES_CHECK((NaryProjection<true>::post(home,x,ps)));
00059 return ES_SUBSUMED;
00060 }
00061
00062 switch (ps.check(home, x)) {
00063 case ES_SUBSUMED:
00064 b.t_one_none(home);
00065 return ES_SUBSUMED;
00066 case ES_FAILED:
00067 b.t_zero_none(home);
00068 return ES_SUBSUMED;
00069 default:
00070 return ES_FIX;
00071 }
00072 }
00073
00074 }}}
00075
00076