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);
00091 void reschedule(Space& home, Propagator& p);
00092 };
00093
00097 class FlexDim {
00098 protected:
00100 IntView c0;
00102 IntView s;
00104 IntView c1;
00106 ExecStatus ssc(Space& home, int n);
00108 ExecStatus lec(Space& home, int n);
00110 ExecStatus nooverlap(Space& home, int n, int m);
00111 public:
00113 FlexDim(void);
00115 FlexDim(IntView c0, IntView s, IntView c1);
00116
00118 int ssc(void) const;
00120 int lsc(void) const;
00122 int sec(void) const;
00124 int lec(void) const;
00125
00127 ExecStatus nooverlap(Space& home, FlexDim& d);
00128
00130 void update(Space& home, bool share, FlexDim& d);
00131
00133 void subscribe(Space& home, Propagator& p);
00135 void cancel(Space& home, Propagator& p);
00137 void reschedule(Space& home, Propagator& p);
00138 };
00139
00140 }}}
00141
00142 #include <gecode/int/no-overlap/dim.hpp>
00143
00144 namespace Gecode { namespace Int { namespace NoOverlap {
00145
00149 template<class Dim, int n>
00150 class ManBox {
00151 protected:
00153 Dim d[n];
00154 public:
00156 const Dim& operator [](int i) const;
00158 Dim& operator [](int i);
00160 static int dim(void);
00161
00163 bool mandatory(void) const;
00165 bool optional(void) const;
00167 bool excluded(void) const;
00168
00170 ExecStatus exclude(Space& home);
00171
00173 bool nooverlap(const ManBox<Dim,n>& b) const;
00175 bool overlap(const ManBox<Dim,n>& b) const;
00176
00178 ExecStatus nooverlap(Space& home, ManBox<Dim,n>& b);
00179
00181 void update(Space& home, bool share, ManBox<Dim,n>& r);
00182
00184 void subscribe(Space& home, Propagator& p);
00186 void cancel(Space& home, Propagator& p);
00188 void reschedule(Space& home, Propagator& p);
00189 };
00190
00194 template<class Dim, int n>
00195 class OptBox : public ManBox<Dim,n> {
00196 protected:
00197 using ManBox<Dim,n>::d;
00199 BoolView o;
00200 public:
00202 void optional(BoolView o);
00204 bool mandatory(void) const;
00206 bool optional(void) const;
00208 bool excluded(void) const;
00209
00211 ExecStatus exclude(Space& home);
00212
00214 void update(Space& home, bool share, OptBox<Dim,n>& r);
00215
00217 void subscribe(Space& home, Propagator& p);
00219 void cancel(Space& home, Propagator& p);
00221 void reschedule(Space& home, Propagator& p);
00222 };
00223
00224 }}}
00225
00226 #include <gecode/int/no-overlap/box.hpp>
00227
00228 namespace Gecode { namespace Int { namespace NoOverlap {
00229
00237 template<class Box>
00238 class Base : public Propagator {
00239 protected:
00241 Box* b;
00243 int n;
00245 Base(Home home, Box* b, int n);
00247 Base(Space& home, bool share, Base<Box>& p, int m);
00253 static int partition(Box* b, int i, int n);
00254 public:
00256 virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00258 virtual void reschedule(Space& home);
00260 virtual size_t dispose(Space& home);
00261 };
00262
00270 template<class Box>
00271 class ManProp : public Base<Box> {
00272 protected:
00273 using Base<Box>::b;
00274 using Base<Box>::n;
00276 ManProp(Home home, Box* b, int n);
00278 ManProp(Space& home, bool share, ManProp<Box>& p);
00279 public:
00281 static ExecStatus post(Home home, Box* b, int n);
00283 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00285 virtual Actor* copy(Space& home, bool share);
00287 virtual size_t dispose(Space& home);
00288 };
00289
00297 template<class Box>
00298 class OptProp : public Base<Box> {
00299 protected:
00300 using Base<Box>::b;
00301 using Base<Box>::n;
00303 int m;
00305 OptProp(Home home, Box* b, int n, int m);
00307 OptProp(Space& home, bool share, OptProp<Box>& p);
00308 public:
00310 static ExecStatus post(Home home, Box* b, int n);
00312 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00314 virtual Actor* copy(Space& home, bool share);
00316 virtual size_t dispose(Space& home);
00317 };
00318
00319 }}}
00320
00321 #include <gecode/int/no-overlap/base.hpp>
00322 #include <gecode/int/no-overlap/man.hpp>
00323 #include <gecode/int/no-overlap/opt.hpp>
00324
00325 #endif
00326
00327
00328