Generated on Tue Apr 18 10:21:38 2017 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  *  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 #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::StaticStack<int,Region> ProcessStack;
00053 
00058   template<class Info, class Offset, PropCond pc>
00059   class Base : public Propagator {
00060   protected:
00062     int n;
00064     int n_na;
00066     Offset ox;
00068     Offset oy;
00070     Info* xy;
00072     Base(Space& home, bool share, Base<Info,Offset,pc>& p);
00074     Base(Home home, int n, Info* xy, Offset& ox, Offset& oy);
00075   public:
00077     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00079     virtual void reschedule(Space& home);
00081     virtual size_t dispose(Space& home);
00082   };
00083 
00084 
00089   template<class View> class ValInfo;
00090 
00100   template<class View, class Offset, bool shared>
00101   class Val : public Base<ValInfo<View>,Offset,PC_INT_VAL> {
00102  protected:
00103     using Base<ValInfo<View>,Offset,PC_INT_VAL>::n;
00104     using Base<ValInfo<View>,Offset,PC_INT_VAL>::n_na;
00105     using Base<ValInfo<View>,Offset,PC_INT_VAL>::xy;
00106     using Base<ValInfo<View>,Offset,PC_INT_VAL>::ox;
00107     using Base<ValInfo<View>,Offset,PC_INT_VAL>::oy;
00109     Val(Space& home, bool share, Val& p);
00111     Val(Home home, int n, ValInfo<View>* xy, Offset& ox, Offset& oy);
00112   public:
00114     virtual Actor* copy(Space& home, bool share);
00116     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00118     static  ExecStatus post(Home home, int n, ValInfo<View>* xy,
00119                             Offset& ox, Offset& oy);
00120   };
00121 
00126   template<class View, class Offset> class DomInfo;
00127 
00137   template<class View, class Offset, bool shared>
00138   class Dom : public Base<DomInfo<View,Offset>,Offset,PC_INT_DOM> {
00139   protected:
00140     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::n;
00141     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::n_na;
00142     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::xy;
00143     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::ox;
00144     using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::oy;
00146     Distinct::DomCtrl<View> dc;
00148     Dom(Space& home, bool share, Dom& p);
00150     Dom(Home home, int n, DomInfo<View,Offset>* xy, Offset& ox, Offset& oy);
00151   public:
00153     virtual Actor* copy(Space& home, bool share);
00160     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00162     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00164     static  ExecStatus post(Home home, int n, DomInfo<View,Offset>* xy,
00165                             Offset& ox, Offset& oy);
00166   };
00167 
00174   class LinkSingle :
00175     public MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
00176   private:
00177     using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x0;
00178     using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x1;
00179 
00181     LinkSingle(Space& home, bool share, LinkSingle& p);
00183     LinkSingle(Home home, BoolView x0, IntView x1);
00184   public:
00186     virtual Actor* copy(Space& home, bool share);
00188     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00190     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00192     static  ExecStatus post(Home home, BoolView x0, IntView x1);
00193   };
00194 
00201   class LinkMulti :
00202     public MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM> {
00203   private:
00204     using MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::x;
00205     using MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::y;
00207     Council<Advisor> c;
00209     static const int S_NONE = 0;
00211     static const int S_ONE  = 1;
00213     static const int S_RUN  = 2;
00215     int status;
00217     int o;
00219     LinkMulti(Space& home, bool share, LinkMulti& p);
00221     LinkMulti(Home home, ViewArray<BoolView>& x, IntView y, int o0);
00222   public:
00224     GECODE_INT_EXPORT
00225     virtual Actor* copy(Space& home, bool share);
00227     GECODE_INT_EXPORT
00228     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00230     GECODE_INT_EXPORT
00231     virtual void reschedule(Space& home);
00233     GECODE_INT_EXPORT
00234     virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00236     GECODE_INT_EXPORT
00237     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00239     static  ExecStatus post(Home home,
00240                             ViewArray<BoolView>& x, IntView y, int o);
00242     GECODE_INT_EXPORT
00243     virtual size_t dispose(Space& home);
00244   };
00245 
00246 }}}
00247 
00248 #include <gecode/int/channel/base.hpp>
00249 #include <gecode/int/channel/val.hpp>
00250 #include <gecode/int/channel/dom.hpp>
00251 
00252 #include <gecode/int/channel/link-single.hpp>
00253 #include <gecode/int/channel/link-multi.hpp>
00254 
00255 #endif
00256 
00257 // STATISTICS: int-prop
00258