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::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
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
00259