00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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 size_t dispose(Space& home);
00080 };
00081
00082
00087 template<class View> class ValInfo;
00088
00098 template<class View, class Offset, bool shared>
00099 class Val : public Base<ValInfo<View>,Offset,PC_INT_VAL> {
00100 protected:
00101 using Base<ValInfo<View>,Offset,PC_INT_VAL>::n;
00102 using Base<ValInfo<View>,Offset,PC_INT_VAL>::n_na;
00103 using Base<ValInfo<View>,Offset,PC_INT_VAL>::xy;
00104 using Base<ValInfo<View>,Offset,PC_INT_VAL>::ox;
00105 using Base<ValInfo<View>,Offset,PC_INT_VAL>::oy;
00107 Val(Space& home, bool share, Val& p);
00109 Val(Home home, int n, ValInfo<View>* xy, Offset& ox, Offset& oy);
00110 public:
00112 virtual Actor* copy(Space& home, bool share);
00114 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00116 static ExecStatus post(Home home, int n, ValInfo<View>* xy,
00117 Offset& ox, Offset& oy);
00118 };
00119
00124 template<class View, class Offset> class DomInfo;
00125
00135 template<class View, class Offset, bool shared>
00136 class Dom : public Base<DomInfo<View,Offset>,Offset,PC_INT_DOM> {
00137 protected:
00138 using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::n;
00139 using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::n_na;
00140 using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::xy;
00141 using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::ox;
00142 using Base<DomInfo<View,Offset>,Offset,PC_INT_DOM>::oy;
00144 Distinct::DomCtrl<View> dc;
00146 Dom(Space& home, bool share, Dom& p);
00148 Dom(Home home, int n, DomInfo<View,Offset>* xy, Offset& ox, Offset& oy);
00149 public:
00151 virtual Actor* copy(Space& home, bool share);
00158 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00160 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00162 static ExecStatus post(Home home, int n, DomInfo<View,Offset>* xy,
00163 Offset& ox, Offset& oy);
00164 };
00165
00172 class LinkSingle :
00173 public MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL> {
00174 private:
00175 using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x0;
00176 using MixBinaryPropagator<BoolView,PC_BOOL_VAL,IntView,PC_INT_VAL>::x1;
00177
00179 LinkSingle(Space& home, bool share, LinkSingle& p);
00181 LinkSingle(Home home, BoolView x0, IntView x1);
00182 public:
00184 virtual Actor* copy(Space& home, bool share);
00186 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00188 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00190 static ExecStatus post(Home home, BoolView x0, IntView x1);
00191 };
00192
00199 class LinkMulti :
00200 public MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM> {
00201 private:
00202 using MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::x;
00203 using MixNaryOnePropagator<BoolView,PC_BOOL_NONE,IntView,PC_INT_DOM>::y;
00205 Council<Advisor> c;
00207 static const int S_NONE = 0;
00209 static const int S_ONE = 1;
00211 static const int S_RUN = 2;
00213 int status;
00215 int o;
00217 LinkMulti(Space& home, bool share, LinkMulti& p);
00219 LinkMulti(Home home, ViewArray<BoolView>& x, IntView y, int o0);
00220 public:
00222 virtual Actor* copy(Space& home, bool share);
00224 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00226 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00228 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00230 GECODE_INT_EXPORT
00231 static ExecStatus post(Home home,
00232 ViewArray<BoolView>& x, IntView y, int o);
00234 virtual size_t dispose(Space& home);
00235 };
00236
00237 }}}
00238
00239 #include <gecode/int/channel/base.hpp>
00240 #include <gecode/int/channel/val.hpp>
00241 #include <gecode/int/channel/dom.hpp>
00242
00243 #include <gecode/int/channel/link-single.hpp>
00244 #include <gecode/int/channel/link-multi.hpp>
00245
00246 #endif
00247
00248
00249