Generated on Tue Apr 18 10:21:48 2017 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  *  Last modified:
00010  *     $Date: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
00011  *     $Revision: 15137 $
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 Int { namespace Bool {
00039 
00040   /*
00041    * Binary Boolean propagators
00042    *
00043    */
00044   template<class BVA, class BVB>
00045   forceinline
00046   BoolBinary<BVA,BVB>::BoolBinary(Home home, BVA b0, BVB b1)
00047     : Propagator(home), x0(b0), x1(b1) {
00048     x0.subscribe(home,*this,PC_BOOL_VAL);
00049     x1.subscribe(home,*this,PC_BOOL_VAL);
00050   }
00051 
00052   template<class BVA, class BVB>
00053   forceinline
00054   BoolBinary<BVA,BVB>::BoolBinary(Space& home, bool share,
00055                                   BoolBinary<BVA,BVB>& p)
00056     : Propagator(home,share,p) {
00057     x0.update(home,share,p.x0);
00058     x1.update(home,share,p.x1);
00059   }
00060 
00061   template<class BVA, class BVB>
00062   forceinline
00063   BoolBinary<BVA,BVB>::BoolBinary(Space& home, bool share, Propagator& p,
00064                                   BVA b0, BVB b1)
00065     : Propagator(home,share,p) {
00066     x0.update(home,share,b0);
00067     x1.update(home,share,b1);
00068   }
00069 
00070   template<class BVA, class BVB>
00071   PropCost
00072   BoolBinary<BVA,BVB>::cost(const Space&, const ModEventDelta&) const {
00073     return PropCost::unary(PropCost::LO);
00074   }
00075 
00076   template<class BVA, class BVB>
00077   void
00078   BoolBinary<BVA,BVB>::reschedule(Space& home) {
00079     x0.reschedule(home,*this,PC_BOOL_VAL);
00080     x1.reschedule(home,*this,PC_BOOL_VAL);
00081   }
00082 
00083   template<class BVA, class BVB>
00084   forceinline size_t
00085   BoolBinary<BVA,BVB>::dispose(Space& home) {
00086     x0.cancel(home,*this,PC_BOOL_VAL);
00087     x1.cancel(home,*this,PC_BOOL_VAL);
00088     (void) Propagator::dispose(home);
00089     return sizeof(*this);
00090   }
00091 
00092   /*
00093    * Ternary Boolean propagators
00094    *
00095    */
00096   template<class BVA, class BVB, class BVC>
00097   forceinline
00098   BoolTernary<BVA,BVB,BVC>::BoolTernary
00099   (Home home, BVA b0, BVB b1, BVC b2)
00100     : Propagator(home), x0(b0), x1(b1), x2(b2) {
00101     x0.subscribe(home,*this,PC_BOOL_VAL);
00102     x1.subscribe(home,*this,PC_BOOL_VAL);
00103     x2.subscribe(home,*this,PC_BOOL_VAL);
00104   }
00105 
00106   template<class BVA, class BVB, class BVC>
00107   forceinline
00108   BoolTernary<BVA,BVB,BVC>::BoolTernary(Space& home, bool share,
00109                                         BoolTernary<BVA,BVB,BVC>& p)
00110     : Propagator(home,share,p) {
00111     x0.update(home,share,p.x0);
00112     x1.update(home,share,p.x1);
00113     x2.update(home,share,p.x2);
00114   }
00115 
00116   template<class BVA, class BVB, class BVC>
00117   forceinline
00118   BoolTernary<BVA,BVB,BVC>::BoolTernary(Space& home, bool share, Propagator& p,
00119                                         BVA b0, BVB b1, BVC b2)
00120     : Propagator(home,share,p) {
00121     x0.update(home,share,b0);
00122     x1.update(home,share,b1);
00123     x2.update(home,share,b2);
00124   }
00125 
00126   template<class BVA, class BVB, class BVC>
00127   PropCost
00128   BoolTernary<BVA,BVB,BVC>::cost(const Space&, const ModEventDelta&) const {
00129     return PropCost::binary(PropCost::LO);
00130   }
00131 
00132   template<class BVA, class BVB, class BVC>
00133   void
00134   BoolTernary<BVA,BVB,BVC>::reschedule(Space& home) {
00135     x0.reschedule(home,*this,PC_BOOL_VAL);
00136     x1.reschedule(home,*this,PC_BOOL_VAL);
00137     x2.reschedule(home,*this,PC_BOOL_VAL);
00138   }
00139 
00140   template<class BVA, class BVB, class BVC>
00141   forceinline size_t
00142   BoolTernary<BVA,BVB,BVC>::dispose(Space& home) {
00143     x0.cancel(home,*this,PC_BOOL_VAL);
00144     x1.cancel(home,*this,PC_BOOL_VAL);
00145     x2.cancel(home,*this,PC_BOOL_VAL);
00146     (void) Propagator::dispose(home);
00147     return sizeof(*this);
00148   }
00149 
00150 }}}
00151 
00152 // STATISTICS: int-prop