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

channel.hh

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, 2006
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-07-11 09:28:48 +0200 (Fri, 11 Jul 2008) $ by $Author: tack $
00011  *     $Revision: 7285 $
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 #ifndef __GECODE_INT_CHANNEL_HH__
00039 #define __GECODE_INT_CHANNEL_HH__
00040 
00041 #include "gecode/int.hh"
00042 #include "gecode/int/distinct.hh"
00043 
00049 namespace Gecode { namespace Int { namespace Channel {
00050 
00052   typedef Support::SentinelStack<int> ProcessStack;
00053 
00058   template <class Info, PropCond pc>
00059   class Base : public Propagator {
00060   protected:
00062     int n;
00064     int n_na;
00066     Info* xy;
00068     Base(Space* home, bool share, Base<Info,pc>& p);
00070     Base(Space* home, int n, Info* xy);
00071     // Specification for this propagator
00072     Reflection::ActorSpec spec(const Space* home, Reflection::VarMap& m,
00073                                 const Support::Symbol& name) const;
00074   public:
00076     virtual PropCost cost(ModEventDelta med) const;
00079     virtual size_t dispose(Space* home);
00080   };
00081 
00082 
00087   template <class View> class ValInfo;
00088 
00098   template <class View, bool shared>
00099   class Val : public Base<ValInfo<View>,PC_INT_VAL> {
00100  protected:
00101     using Base<ValInfo<View>,PC_INT_VAL>::n;
00102     using Base<ValInfo<View>,PC_INT_VAL>::n_na;
00103     using Base<ValInfo<View>,PC_INT_VAL>::xy;
00105     Val(Space* home, bool share, Val& p);
00107     Val(Space* home, int n, ValInfo<View>* xy);
00108   public:
00110     virtual Actor* copy(Space* home, bool share);
00112     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00114     static  ExecStatus post(Space* home, int n, ValInfo<View>* xy);
00116     virtual Reflection::ActorSpec spec(const Space* home,
00117                                         Reflection::VarMap& m) const;
00119     static void post(Space* home, Reflection::VarMap& vars,
00120                      const Reflection::ActorSpec& spec);
00122     static Support::Symbol ati(void);
00123   };
00124 
00129   template <class View> class DomInfo;
00130 
00140   template <class View, bool shared>
00141   class Dom : public Base<DomInfo<View>,PC_INT_DOM> {
00142   protected:
00143     using Base<DomInfo<View>,PC_INT_DOM>::n;
00144     using Base<DomInfo<View>,PC_INT_DOM>::n_na;
00145     using Base<DomInfo<View>,PC_INT_DOM>::xy;
00147     Distinct::DomCtrl<View> dc;
00149     Dom(Space* home, bool share, Dom& p);
00151     Dom(Space* home, int n, DomInfo<View>* xy);
00152   public:
00154     virtual Actor* copy(Space* home, bool share);
00156     virtual PropCost cost(ModEventDelta med) const;
00158     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00160     static  ExecStatus post(Space* home, int n, DomInfo<View>* xy);
00162     virtual Reflection::ActorSpec spec(const Space* home,
00163                                         Reflection::VarMap& m) const;
00165     static void post(Space* home, Reflection::VarMap& vars,
00166                      const Reflection::ActorSpec& spec);
00168     static Support::Symbol ati(void);
00169   };
00170 
00177   class LinkSingle :
00178     public MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
00179   private:
00180     using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x0;
00181     using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x1;
00182 
00184     LinkSingle(Space* home, bool share, LinkSingle& p);
00186     LinkSingle(Space* home, BoolView x0, IntView x1);
00187   public:
00189     virtual Actor* copy(Space* home, bool share);
00191     virtual PropCost cost(ModEventDelta med) const;
00193     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00195     static  ExecStatus post(Space* home, BoolView x0, IntView x1);
00197     virtual Reflection::ActorSpec spec(const Space* home,
00198                                         Reflection::VarMap& m) const;
00200     GECODE_INT_EXPORT
00201     static void post(Space* home, Reflection::VarMap& vars,
00202                      const Reflection::ActorSpec& spec);
00204     GECODE_INT_EXPORT
00205     static Support::Symbol ati(void);
00206   };
00207 
00214   class LinkMulti :
00215     public MixNaryOnePropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_DOM> {
00216   private:
00217     using MixNaryOnePropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_DOM>::x;
00218     using MixNaryOnePropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_DOM>::y;
00220     int o;
00222     LinkMulti(Space* home, bool share, LinkMulti& p);
00224     LinkMulti(Space* home, ViewArray<BoolView>& x, IntView y, int o0);
00225   public:
00227     virtual Actor* copy(Space* home, bool share);
00229     virtual PropCost cost(ModEventDelta med) const;
00231     virtual ExecStatus propagate(Space* home, ModEventDelta med);
00233     GECODE_INT_EXPORT
00234     static  ExecStatus post(Space* home, 
00235                             ViewArray<BoolView>& x, IntView y, int o);
00237     virtual Reflection::ActorSpec spec(const Space* home,
00238                                         Reflection::VarMap& m) const;
00240     static void post(Space* home, Reflection::VarMap& vars,
00241                      const Reflection::ActorSpec& spec);
00243     GECODE_INT_EXPORT
00244     static Support::Symbol ati(void);
00245   };
00246 
00247 }}}
00248 
00249 #include "gecode/int/channel/base.icc"
00250 #include "gecode/int/channel/val.icc"
00251 #include "gecode/int/channel/dom.icc"
00252 
00253 #include "gecode/int/channel/link-single.icc"
00254 #include "gecode/int/channel/link-multi.icc"
00255 
00256 #endif
00257 
00258 // STATISTICS: int-prop
00259