channel.hh
Go to the documentation of this file.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_SET_CHANNEL_HH__
00039 #define __GECODE_SET_CHANNEL_HH__
00040
00041 #include <gecode/set.hh>
00042
00043 namespace Gecode { namespace Set { namespace Channel {
00044
00059 template<class View>
00060 class ChannelSorted : public Propagator {
00061 protected:
00063 View x0;
00065 ViewArray<Gecode::Int::IntView> xs;
00066
00068 ChannelSorted(Space& home, ChannelSorted& p);
00070 ChannelSorted(Home home, View, ViewArray<Gecode::Int::IntView>&);
00071 public:
00073 virtual Actor* copy(Space& home);
00075 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00077 virtual void reschedule(Space& home);
00079 virtual size_t dispose(Space& home);
00081 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00083 static ExecStatus post(Home home, View s,
00084 ViewArray<Gecode::Int::IntView>& x);
00085 };
00086
00104 template<class View>
00105 class ChannelInt : public Propagator {
00106 protected:
00108 ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> > xs;
00110 ViewArray<CachedView<View> > ys;
00111
00113 ChannelInt(Space& home, ChannelInt& p);
00115 ChannelInt(Home home,
00116 ViewArray<Gecode::Int::CachedView<Gecode::Int::IntView> >&,
00117 ViewArray<CachedView<View> >&);
00118 public:
00120 virtual Actor* copy(Space& home);
00122 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00124 virtual void reschedule(Space& home);
00126 virtual size_t dispose(Space& home);
00128 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00130 static ExecStatus post(Home home,
00131 ViewArray<Gecode::Int::CachedView<
00132 Gecode::Int::IntView> >& x,
00133 ViewArray<CachedView<View> >& y);
00134 };
00135
00147 template<class View>
00148 class ChannelBool
00149 : public MixNaryOnePropagator<Gecode::Int::BoolView,
00150 Gecode::Int::PC_BOOL_VAL,
00151 View,PC_GEN_NONE> {
00152 protected:
00153 typedef MixNaryOnePropagator<Gecode::Int::BoolView,
00154 Gecode::Int::PC_BOOL_VAL,
00155 View,PC_GEN_NONE> Super;
00156 using Super::x;
00157 using Super::y;
00158
00160 ChannelBool(Space& home, ChannelBool& p);
00162 ChannelBool(Home home,ViewArray<Gecode::Int::BoolView>&,
00163 View);
00164
00166 class IndexAdvisor : public Advisor {
00167 protected:
00169 int idx;
00170 public:
00172 template<class A>
00173 IndexAdvisor(Space& home, ChannelBool<View>& p, Council<A>& c,
00174 int index);
00176 IndexAdvisor(Space& home, IndexAdvisor& a);
00178 int index(void) const;
00180 template<class A>
00181 void dispose(Space& home, Council<A>& c);
00182 };
00183
00185 Council<IndexAdvisor> co;
00187 SetDelta delta;
00189 GLBndSet zeros;
00191 GLBndSet ones;
00193 bool running;
00194 public:
00196 virtual Actor* copy(Space& home);
00198 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00200 virtual void reschedule(Space& home);
00202 virtual size_t dispose(Space& home);
00204 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00206 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00208 static ExecStatus post(Home home,ViewArray<Gecode::Int::BoolView>& x,
00209 View y);
00210 };
00211
00225 template<typename View>
00226 class ChannelSet: public Propagator {
00227 protected:
00229 ViewArray<CachedView<View> > xs;
00231 ViewArray<CachedView<View> > ys;
00232
00234 ChannelSet(Space& home, ChannelSet& p);
00236 ChannelSet(Home home,
00237 ViewArray<CachedView<View> >&,
00238 ViewArray<CachedView<View> >&);
00239 public:
00241 virtual Actor* copy(Space& home);
00243 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00245 virtual void reschedule(Space& home);
00247 virtual size_t dispose(Space& home);
00249 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00251 static ExecStatus post(Home home,
00252 ViewArray<CachedView<View> >& x,
00253 ViewArray<CachedView<View> >& y);
00254 };
00255
00256 }}}
00257
00258 #include <gecode/set/channel/sorted.hpp>
00259 #include <gecode/set/channel/int.hpp>
00260 #include <gecode/set/channel/bool.hpp>
00261 #include <gecode/set/channel/set.hpp>
00262
00263 #endif
00264
00265