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

unary.icc

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Patrick Pekczynski <pekczynski@ps.uni-sb.de>
00005  *
00006  *  Copyright:
00007  *     Patrick Pekczynski, 2006
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-01-31 18:29:16 +0100 (Thu, 31 Jan 2008) $ by $Author: tack $
00011  *     $Revision: 6017 $
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 namespace Gecode { namespace CpltSet {
00039 
00040   template <class View>
00041   forceinline
00042   UnaryCpltSetPropagator<View>::UnaryCpltSetPropagator(Space* home, View& x0, bdd& d0)
00043     : Propagator(home), x(x0), d(d0) {
00044     force(home);
00045     x.subscribe(home, this, PC_CPLTSET_DOM);
00046   }
00047 
00048   template <class View>
00049   forceinline
00050   UnaryCpltSetPropagator<View>::UnaryCpltSetPropagator(Space* home, bool share, UnaryCpltSetPropagator& p)
00051     : Propagator(home,share,p) {
00052     d = p.d;
00053     x.update(home, share, p.x);
00054   }
00055   
00056   template <class View>
00057   forceinline PropCost
00058   UnaryCpltSetPropagator<View>::cost(ModEventDelta) const {
00059     // we have only linear costs (in terms of the size of a bdd) 
00060     // if one of the bdds is constant
00061     if (manager.ctrue(x.dom()) || manager.ctrue(d)) {
00062       return PC_LINEAR_LO;
00063     } else {
00064       return PC_QUADRATIC_HI;
00065     }
00066   }
00067 
00068   template <class View>
00069   Support::Symbol
00070   UnaryCpltSetPropagator<View>::ati(void) {
00071     return Reflection::mangle<View>("Gecode::CpltSet::UnaryCpltSetPropagator");
00072   }
00073 
00074   template <class View>
00075   Reflection::ActorSpec
00076   UnaryCpltSetPropagator<View>::spec(const Space*,
00077                                      Reflection::VarMap&) const {
00078     throw Reflection::ReflectionException("Not implemented");
00079   } 
00080   
00081   template <class View>
00082   size_t
00083   UnaryCpltSetPropagator<View>::dispose(Space* home) {
00084     // std::cout << "dispose propagator\n";
00085     unforce(home);
00086     if (!home->failed()) {
00087       x.cancel(home, this, PC_CPLTSET_DOM);
00088     }
00089     manager.dispose(d);
00090     Propagator::dispose(home);
00091     return sizeof(*this);
00092   }
00093 
00094   template <class View>
00095   forceinline ExecStatus
00096   UnaryCpltSetPropagator<View>::post(Space* home, View& x0, bdd& d0) {
00097     (void) new (home) UnaryCpltSetPropagator(home, x0, d0);
00098     return ES_OK;
00099   }
00100 
00101   template <class View>
00102   forceinline Actor*
00103   UnaryCpltSetPropagator<View>::copy(Space* home, bool share) {
00104     return new (home) UnaryCpltSetPropagator(home, share, *this);
00105   }
00106 
00107   template <class View>
00108   forceinline ExecStatus 
00109   UnaryCpltSetPropagator<View>::propagate(Space* home, ModEventDelta) {
00110     // std::cerr << "propagate unary: \n";
00111     // std::cerr << x << " " << x.glbSize() << " " << x.unknownSize() << "\n";
00112 //     UnknownRanges<CpltSetView> delta(x);
00113 //     for (; delta(); ++delta) { 
00114 //       std::cerr << delta.min() << ".." << delta.max() <<",";
00115 //     }
00116 //     std::cerr << "\n";
00117     ModEvent me = x.intersect(home, d);
00118     GECODE_ME_CHECK(me);
00119 //     if (x.assigned()) {
00120 //       std::cerr << "SUBS-ASSIGNED\n";
00121 //       return ES_SUBSUMED(this, home);
00122 //     }
00123 //     std::cerr << "tell done\n";
00124     return ES_SUBSUMED(this, home);
00125   }
00126 
00127 
00128 
00129 
00130 }}
00131 
00132 // STATISTICS: cpltset-prop