Generated on Thu Apr 11 13:59:04 2019 for Gecode by doxygen 1.6.3

base.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2004
00008  *
00009  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 namespace Gecode { namespace Int { namespace Bool {
00035 
00036   /*
00037    * Binary Boolean propagators
00038    *
00039    */
00040   template<class BVA, class BVB>
00041   forceinline
00042   BoolBinary<BVA,BVB>::BoolBinary(Home home, BVA b0, BVB b1)
00043     : Propagator(home), x0(b0), x1(b1) {
00044     x0.subscribe(home,*this,PC_BOOL_VAL);
00045     x1.subscribe(home,*this,PC_BOOL_VAL);
00046   }
00047 
00048   template<class BVA, class BVB>
00049   forceinline
00050   BoolBinary<BVA,BVB>::BoolBinary(Space& home, BoolBinary<BVA,BVB>& p)
00051     : Propagator(home,p) {
00052     x0.update(home,p.x0);
00053     x1.update(home,p.x1);
00054   }
00055 
00056   template<class BVA, class BVB>
00057   forceinline
00058   BoolBinary<BVA,BVB>::BoolBinary(Space& home, Propagator& p,
00059                                   BVA b0, BVB b1)
00060     : Propagator(home,p) {
00061     x0.update(home,b0);
00062     x1.update(home,b1);
00063   }
00064 
00065   template<class BVA, class BVB>
00066   PropCost
00067   BoolBinary<BVA,BVB>::cost(const Space&, const ModEventDelta&) const {
00068     return PropCost::unary(PropCost::LO);
00069   }
00070 
00071   template<class BVA, class BVB>
00072   void
00073   BoolBinary<BVA,BVB>::reschedule(Space& home) {
00074     x0.reschedule(home,*this,PC_BOOL_VAL);
00075     x1.reschedule(home,*this,PC_BOOL_VAL);
00076   }
00077 
00078   template<class BVA, class BVB>
00079   forceinline size_t
00080   BoolBinary<BVA,BVB>::dispose(Space& home) {
00081     x0.cancel(home,*this,PC_BOOL_VAL);
00082     x1.cancel(home,*this,PC_BOOL_VAL);
00083     (void) Propagator::dispose(home);
00084     return sizeof(*this);
00085   }
00086 
00087   /*
00088    * Ternary Boolean propagators
00089    *
00090    */
00091   template<class BVA, class BVB, class BVC>
00092   forceinline
00093   BoolTernary<BVA,BVB,BVC>::BoolTernary
00094   (Home home, BVA b0, BVB b1, BVC b2)
00095     : Propagator(home), x0(b0), x1(b1), x2(b2) {
00096     x0.subscribe(home,*this,PC_BOOL_VAL);
00097     x1.subscribe(home,*this,PC_BOOL_VAL);
00098     x2.subscribe(home,*this,PC_BOOL_VAL);
00099   }
00100 
00101   template<class BVA, class BVB, class BVC>
00102   forceinline
00103   BoolTernary<BVA,BVB,BVC>::BoolTernary(Space& home,
00104                                         BoolTernary<BVA,BVB,BVC>& p)
00105     : Propagator(home,p) {
00106     x0.update(home,p.x0);
00107     x1.update(home,p.x1);
00108     x2.update(home,p.x2);
00109   }
00110 
00111   template<class BVA, class BVB, class BVC>
00112   forceinline
00113   BoolTernary<BVA,BVB,BVC>::BoolTernary(Space& home, Propagator& p,
00114                                         BVA b0, BVB b1, BVC b2)
00115     : Propagator(home,p) {
00116     x0.update(home,b0);
00117     x1.update(home,b1);
00118     x2.update(home,b2);
00119   }
00120 
00121   template<class BVA, class BVB, class BVC>
00122   PropCost
00123   BoolTernary<BVA,BVB,BVC>::cost(const Space&, const ModEventDelta&) const {
00124     return PropCost::binary(PropCost::LO);
00125   }
00126 
00127   template<class BVA, class BVB, class BVC>
00128   void
00129   BoolTernary<BVA,BVB,BVC>::reschedule(Space& home) {
00130     x0.reschedule(home,*this,PC_BOOL_VAL);
00131     x1.reschedule(home,*this,PC_BOOL_VAL);
00132     x2.reschedule(home,*this,PC_BOOL_VAL);
00133   }
00134 
00135   template<class BVA, class BVB, class BVC>
00136   forceinline size_t
00137   BoolTernary<BVA,BVB,BVC>::dispose(Space& home) {
00138     x0.cancel(home,*this,PC_BOOL_VAL);
00139     x1.cancel(home,*this,PC_BOOL_VAL);
00140     x2.cancel(home,*this,PC_BOOL_VAL);
00141     (void) Propagator::dispose(home);
00142     return sizeof(*this);
00143   }
00144 
00145 }}}
00146 
00147 // STATISTICS: int-prop