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

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  *  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 #ifndef __GECODE_INT_CHANNEL_HH__
00035 #define __GECODE_INT_CHANNEL_HH__
00036 
00037 #include <gecode/int.hh>
00038 #include <gecode/int/distinct.hh>
00039 
00045 namespace Gecode { namespace Int { namespace Channel {
00046 
00048   typedef Support::StaticStack<int,Region> ProcessStack;
00049 
00054   template<class Info, class Offset, PropCond pc>
00055   class Base : public Propagator {
00056   protected:
00058     int n;
00060     int n_na;
00062     Offset ox;
00064     Offset oy;
00066     Info* xy;
00068     Base(Space& home, Base<Info,Offset,pc>& p);
00070     Base(Home home, int n, Info* xy, Offset& ox, Offset& oy);
00071   public:
00073     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00075     virtual void reschedule(Space& home);
00077     virtual size_t dispose(Space& home);
00078   };
00079 
00080 
00085   template<class View> class ValInfo;
00086 
00096   template<class View, class Offset, bool shared>
00097   class Val : public Base<ValInfo<View>,Offset,PC_INT_VAL> {
00098  protected:
00099     using Base<ValInfo<View>,Offset,PC_INT_VAL>::n;
00100     using Base<ValInfo<View>,Offset,PC_INT_VAL>::n_na;
00101     using Base<ValInfo<View>,Offset,PC_INT_VAL>::xy;
00102     using Base<ValInfo<View>,Offset,PC_INT_VAL>::ox;
00103     using Base<ValInfo<View>,Offset,PC_INT_VAL>::oy;
00105     Val(Space& home, Val& p);
00107     Val(Home home, int n, ValInfo<View>* xy, Offset& ox, Offset& oy);
00108   public:
00110     virtual Actor* copy(Space& home);
00112     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00114     static  ExecStatus post(Home home, int n, ValInfo<View>* xy,
00115                             Offset& ox, Offset& oy);
00116   };
00117 
00122   template<class View, class Offset> class DomInfo;
00123 
00133   template<class View, class Offset, bool shared>
00134   class Dom : public Base<DomInfo<View,Offset>,Offset,PC_INT_DOM> {
00135   protected:
00136     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::n;
00137     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::n_na;
00138     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::xy;
00139     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::ox;
00140     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::oy;
00142     Distinct::DomCtrl<View> dc;
00144     Dom(Space& home, Dom& p);
00146     Dom(Home home, int n, DomInfo<View,Offset>* xy, Offset& ox, Offset& oy);
00147   public:
00149     virtual Actor* copy(Space& home);
00156     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00158     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00160     static  ExecStatus post(Home home, int n, DomInfo<View,Offset>* xy,
00161                             Offset& ox, Offset& oy);
00162   };
00163 
00170   class LinkSingle :
00171     public MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
00172   private:
00173     using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x0;
00174     using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x1;
00175 
00177     LinkSingle(Space& home, LinkSingle& p);
00179     LinkSingle(Home home, BoolView x0, IntView x1);
00180   public:
00182     virtual Actor* copy(Space& home);
00184     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00186     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00188     static  ExecStatus post(Home home, BoolView x0, IntView x1);
00189   };
00190 
00197   class LinkMulti :
00198     public MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM> {
00199   private:
00200     using MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::x;
00201     using MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::y;
00203     Council<Advisor> c;
00205     static const int S_NONE = 0;
00207     static const int S_ONE  = 1;
00209     static const int S_RUN  = 2;
00211     int status;
00213     int o;
00215     LinkMulti(Space& home, LinkMulti& p);
00217     LinkMulti(Home home, ViewArray<BoolView>& x, IntView y, int o0);
00218   public:
00220     GECODE_INT_EXPORT
00221     virtual Actor* copy(Space& home);
00223     GECODE_INT_EXPORT
00224     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00226     GECODE_INT_EXPORT
00227     virtual void reschedule(Space& home);
00229     GECODE_INT_EXPORT
00230     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00232     GECODE_INT_EXPORT
00233     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00235     static  ExecStatus post(Home home,
00236                             ViewArray<BoolView>& x, IntView y, int o);
00238     GECODE_INT_EXPORT
00239     virtual size_t dispose(Space& home);
00240   };
00241 
00242 }}}
00243 
00244 #include <gecode/int/channel/base.hpp>
00245 #include <gecode/int/channel/val.hpp>
00246 #include <gecode/int/channel/dom.hpp>
00247 
00248 #include <gecode/int/channel/link-single.hpp>
00249 #include <gecode/int/channel/link-multi.hpp>
00250 
00251 #endif
00252 
00253 // STATISTICS: int-prop
00254