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
00039
00040 #ifndef __GECODE_SET_INT_HH__
00041 #define __GECODE_SET_INT_HH__
00042
00043 #include <gecode/set.hh>
00044
00045 namespace Gecode { namespace Set { namespace Int {
00046
00058 template <class View>
00059 class MinElement :
00060 public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND> {
00061 protected:
00062 using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x0;
00063 using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x1;
00065 MinElement(Space& home, bool share,MinElement& p);
00067 MinElement(Space& home, View, Gecode::Int::IntView);
00068 public:
00070 GECODE_SET_EXPORT virtual Actor* copy(Space& home,bool);
00072 GECODE_SET_EXPORT virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00074 static ExecStatus post(Space& home, View s, Gecode::Int::IntView x);
00075 };
00076
00083 template <class View>
00084 class NotMinElement :
00085 public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM> {
00086 protected:
00087 using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x0;
00088 using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x1;
00090 NotMinElement(Space& home, bool share,NotMinElement& p);
00092 NotMinElement(Space& home, View, Gecode::Int::IntView);
00093 public:
00095 GECODE_SET_EXPORT virtual Actor* copy(Space& home,bool);
00097 GECODE_SET_EXPORT virtual ExecStatus propagate(Space& home,
00098 const ModEventDelta& med);
00100 static ExecStatus post(Space& home, View s, Gecode::Int::IntView x);
00101 };
00102
00109 template <class View>
00110 class ReMinElement :
00111 public IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM> {
00112 protected:
00113 using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x0;
00114 using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x1;
00115 using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::b;
00117 ReMinElement(Space& home, bool share,ReMinElement& p);
00119 ReMinElement(Space& home, View, Gecode::Int::IntView,
00120 Gecode::Int::BoolView);
00121 public:
00123 GECODE_SET_EXPORT virtual Actor* copy(Space& home,bool);
00125 GECODE_SET_EXPORT virtual ExecStatus propagate(Space& home,
00126 const ModEventDelta& med);
00128 static ExecStatus post(Space& home, View s, Gecode::Int::IntView x,
00129 Gecode::Int::BoolView b);
00130 };
00131
00138 template <class View>
00139 class MaxElement :
00140 public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND> {
00141 protected:
00142 using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x0;
00143 using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_BND>::x1;
00145 MaxElement(Space& home, bool share,MaxElement& p);
00147 MaxElement(Space& home, View, Gecode::Int::IntView);
00148 public:
00150 GECODE_SET_EXPORT virtual Actor* copy(Space& home,bool);
00152 GECODE_SET_EXPORT virtual ExecStatus propagate(Space& home,
00153 const ModEventDelta& med);
00155 static ExecStatus post(Space& home, View s, Gecode::Int::IntView x);
00156 };
00157
00164 template <class View>
00165 class NotMaxElement :
00166 public IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM> {
00167 protected:
00168 using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x0;
00169 using IntSetPropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x1;
00171 NotMaxElement(Space& home, bool share,NotMaxElement& p);
00173 NotMaxElement(Space& home, View, Gecode::Int::IntView);
00174 public:
00176 GECODE_SET_EXPORT virtual Actor* copy(Space& home,bool);
00178 GECODE_SET_EXPORT virtual ExecStatus propagate(Space& home,
00179 const ModEventDelta& med);
00181 static ExecStatus post(Space& home, View s, Gecode::Int::IntView x);
00182 };
00183
00190 template <class View>
00191 class ReMaxElement :
00192 public IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM> {
00193 protected:
00194 using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x0;
00195 using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::x1;
00196 using IntSetRePropagator<View,PC_SET_ANY,Gecode::Int::PC_INT_DOM>::b;
00198 ReMaxElement(Space& home, bool share,ReMaxElement& p);
00200 ReMaxElement(Space& home, View, Gecode::Int::IntView, Gecode::Int::BoolView);
00201 public:
00203 GECODE_SET_EXPORT virtual Actor* copy(Space& home,bool);
00205 GECODE_SET_EXPORT virtual ExecStatus propagate(Space& home,
00206 const ModEventDelta& med);
00208 static ExecStatus post(Space& home, View s, Gecode::Int::IntView x,
00209 Gecode::Int::BoolView b);
00210 };
00211
00218 template <class View>
00219 class Card :
00220 public IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND> {
00221 protected:
00222 using IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND>::x0;
00223 using IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND>::x1;
00225 Card(Space& home, bool share,Card& p);
00227 Card(Space& home, View, Gecode::Int::IntView);
00228 public:
00230 GECODE_SET_EXPORT virtual Actor* copy(Space& home,bool);
00232 GECODE_SET_EXPORT virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00234 static ExecStatus post(Space& home, View s, Gecode::Int::IntView x);
00235 };
00236
00237
00244 template <class View>
00245 class Match : public Propagator {
00246 protected:
00248 View x0;
00250 ViewArray<Gecode::Int::IntView> xs;
00251
00253 Match(Space& home, bool share,Match& p);
00255 Match(Space& home, View, ViewArray<Gecode::Int::IntView>&);
00256 public:
00258 GECODE_SET_EXPORT virtual Actor* copy(Space& home,bool);
00260 GECODE_SET_EXPORT virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00262 GECODE_SET_EXPORT virtual size_t dispose(Space& home);
00264 GECODE_SET_EXPORT virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00266 static ExecStatus post(Space& home, View s,
00267 ViewArray<Gecode::Int::IntView>& x);
00268 };
00269
00287 template <class View>
00288 class ChannelInt : public Propagator {
00289 protected:
00291 ViewArray<Gecode::Int::IntView> xs;
00293 ViewArray<View> ys;
00294
00296 ChannelInt(Space& home, bool share,ChannelInt& p);
00298 ChannelInt(Space& home,ViewArray<Gecode::Int::IntView>&,
00299 ViewArray<View>&);
00300 public:
00302 virtual Actor* copy(Space& home,bool);
00304 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00306 virtual size_t dispose(Space& home);
00308 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00310 static ExecStatus post(Space& home,ViewArray<Gecode::Int::IntView>& x,
00311 ViewArray<View>& y);
00312 };
00313
00325 template <class View>
00326 class ChannelBool
00327 : public MixNaryOnePropagator<Gecode::Int::BoolView,
00328 Gecode::Int::PC_BOOL_VAL,
00329 View,PC_GEN_NONE> {
00330 protected:
00331 typedef MixNaryOnePropagator<Gecode::Int::BoolView,
00332 Gecode::Int::PC_BOOL_VAL,
00333 View,PC_GEN_NONE> Super;
00334 using Super::x;
00335 using Super::y;
00336
00338 ChannelBool(Space& home, bool share,ChannelBool& p);
00340 ChannelBool(Space& home,ViewArray<Gecode::Int::BoolView>&,
00341 View);
00342
00344 class IndexAdvisor : public Advisor {
00345 protected:
00347 int idx;
00348 public:
00350 template <class A>
00351 IndexAdvisor(Space& home, ChannelBool<View>& p, Council<A>& c,
00352 int index);
00354 IndexAdvisor(Space& home, bool share, IndexAdvisor& a);
00356 int index(void) const;
00358 template <class A>
00359 void dispose(Space& home, Council<A>& c);
00360 };
00361
00363 Council<IndexAdvisor> co;
00365 SetDelta delta;
00367 GLBndSet zeros;
00369 GLBndSet ones;
00371 bool running;
00372 public:
00374 virtual Actor* copy(Space& home,bool);
00376 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00378 virtual size_t dispose(Space& home);
00380 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00382 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
00384 static ExecStatus post(Space& home,ViewArray<Gecode::Int::BoolView>& x,
00385 View y);
00386 };
00387
00394 template <class View>
00395 class Weights : public Propagator {
00396 protected:
00398 SharedArray<int> elements;
00400 SharedArray<int> weights;
00401
00403 View x;
00405 Gecode::Int::IntView y;
00406
00408 Weights(Space& home, bool share,Weights& p);
00410 Weights(Space& home, const SharedArray<int>&, const SharedArray<int>&,
00411 View, Gecode::Int::IntView);
00412 public:
00414 GECODE_SET_EXPORT virtual Actor* copy(Space& home,bool);
00416 GECODE_SET_EXPORT virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00418 GECODE_SET_EXPORT virtual size_t dispose(Space& home);
00420 GECODE_SET_EXPORT virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00422 static ExecStatus post(Space& home,
00423 const SharedArray<int>& elements,
00424 const SharedArray<int>& weights,
00425 View x, Gecode::Int::IntView y);
00426 };
00427
00428 }}}
00429
00430 #include <gecode/set/int/minmax.hpp>
00431 #include <gecode/set/int/card.hpp>
00432 #include <gecode/set/int/match.hpp>
00433 #include <gecode/set/int/channel-int.hpp>
00434 #include <gecode/set/int/channel-bool.hpp>
00435 #include <gecode/set/int/weights.hpp>
00436
00437 #endif
00438
00439