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 #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
00254