Generated on Wed Nov 1 15:04:45 2006 for Gecode by doxygen 1.4.5

re-nary.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Guido Tack, 2006
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-07-12 15:53:12 +0200 (Wed, 12 Jul 2006) $ by $Author: tack $
00010  *     $Revision: 3349 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
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 // STATISTICS: set-prop