Generated on Mon Aug 25 11:35:43 2008 for Gecode by doxygen 1.5.6

re-nary.cc

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2006
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-01-29 13:37:51 +0100 (Tue, 29 Jan 2008) $ by $Author: tack $
00011  *     $Revision: 5993 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 // STATISTICS: set-prop