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_NO_OVERLAP_HH__
00039 #define __GECODE_INT_NO_OVERLAP_HH__
00040
00041 #include <gecode/int.hh>
00042
00048 namespace Gecode { namespace Int { namespace NoOverlap {
00049
00053 class FixDim {
00054 protected:
00056 IntView c;
00058 int s;
00060 ExecStatus ssc(Space& home, int n);
00062 ExecStatus lec(Space& home, int n);
00064 ExecStatus nooverlap(Space& home, int n, int m);
00065 public:
00067 FixDim(void);
00069 FixDim(IntView c, int s);
00070
00072 int ssc(void) const;
00074 int lsc(void) const;
00076 int sec(void) const;
00078 int lec(void) const;
00079
00081 ExecStatus nooverlap(Space& home, FixDim& d);
00082
00084 void update(Space& home, bool share, FixDim& d);
00085
00087 void subscribe(Space& home, Propagator& p);
00089 void cancel(Space& home, Propagator& p);
00090 };
00091
00095 class FlexDim {
00096 protected:
00098 IntView c0;
00100 IntView s;
00102 IntView c1;
00104 ExecStatus ssc(Space& home, int n);
00106 ExecStatus lec(Space& home, int n);
00108 ExecStatus nooverlap(Space& home, int n, int m);
00109 public:
00111 FlexDim(void);
00113 FlexDim(IntView c0, IntView s, IntView c1);
00114
00116 int ssc(void) const;
00118 int lsc(void) const;
00120 int sec(void) const;
00122 int lec(void) const;
00123
00125 ExecStatus nooverlap(Space& home, FlexDim& d);
00126
00128 void update(Space& home, bool share, FlexDim& d);
00129
00131 void subscribe(Space& home, Propagator& p);
00133 void cancel(Space& home, Propagator& p);
00134 };
00135
00136 }}}
00137
00138 #include <gecode/int/no-overlap/dim.hpp>
00139
00140 namespace Gecode { namespace Int { namespace NoOverlap {
00141
00145 template<class Dim, int n>
00146 class ManBox {
00147 protected:
00149 Dim d[n];
00150 public:
00152 const Dim& operator [](int i) const;
00154 Dim& operator [](int i);
00156 static int dim(void);
00157
00159 bool mandatory(void) const;
00161 bool optional(void) const;
00163 bool excluded(void) const;
00164
00166 ExecStatus exclude(Space& home);
00167
00169 bool nooverlap(const ManBox<Dim,n>& b) const;
00171 bool overlap(const ManBox<Dim,n>& b) const;
00172
00174 ExecStatus nooverlap(Space& home, ManBox<Dim,n>& b);
00175
00177 void update(Space& home, bool share, ManBox<Dim,n>& r);
00178
00180 void subscribe(Space& home, Propagator& p);
00182 void cancel(Space& home, Propagator& p);
00183 };
00184
00188 template<class Dim, int n>
00189 class OptBox : public ManBox<Dim,n> {
00190 protected:
00191 using ManBox<Dim,n>::d;
00193 BoolView o;
00194 public:
00196 void optional(BoolView o);
00198 bool mandatory(void) const;
00200 bool optional(void) const;
00202 bool excluded(void) const;
00203
00205 ExecStatus exclude(Space& home);
00206
00208 void update(Space& home, bool share, OptBox<Dim,n>& r);
00209
00211 void subscribe(Space& home, Propagator& p);
00213 void cancel(Space& home, Propagator& p);
00214 };
00215
00216 }}}
00217
00218 #include <gecode/int/no-overlap/box.hpp>
00219
00220 namespace Gecode { namespace Int { namespace NoOverlap {
00221
00229 template<class Box>
00230 class Base : public Propagator {
00231 protected:
00233 Box* b;
00235 int n;
00237 Base(Home home, Box* b, int n);
00239 Base(Space& home, bool share, Base<Box>& p, int m);
00245 static int partition(Box* b, int i, int n);
00246 public:
00248 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00250 virtual size_t dispose(Space& home);
00251 };
00252
00260 template<class Dim, int d>
00261 class ManProp : public Base<ManBox<Dim,d> > {
00262 protected:
00263 using Base<ManBox<Dim,d> >::b;
00264 using Base<ManBox<Dim,d> >::n;
00266 ManProp(Home home, ManBox<Dim,d>* b, int n);
00268 ManProp(Space& home, bool share, ManProp<Dim,d>& p);
00269 public:
00271 static ExecStatus post(Home home, ManBox<Dim,d>* b, int n);
00273 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00275 virtual Actor* copy(Space& home, bool share);
00277 virtual size_t dispose(Space& home);
00278 };
00279
00287 template<class Dim, int d>
00288 class OptProp : public Base<OptBox<Dim,d> > {
00289 protected:
00290 using Base<OptBox<Dim,d> >::b;
00291 using Base<OptBox<Dim,d> >::n;
00293 int m;
00295 OptProp(Home home, OptBox<Dim,d>* b, int n, int m);
00297 OptProp(Space& home, bool share, OptProp<Dim,d>& p);
00298 public:
00300 static ExecStatus post(Home home, OptBox<Dim,d>* b, int n);
00302 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00304 virtual Actor* copy(Space& home, bool share);
00306 virtual size_t dispose(Space& home);
00307 };
00308
00309 }}}
00310
00311 #include <gecode/int/no-overlap/base.hpp>
00312 #include <gecode/int/no-overlap/man.hpp>
00313 #include <gecode/int/no-overlap/opt.hpp>
00314
00315 #endif
00316
00317
00318