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 namespace Gecode { namespace Int { namespace NoOverlap {
00039
00040
00041
00042
00043
00044 template<class Dim, int n>
00045 forceinline const Dim&
00046 ManBox<Dim,n>::operator [](int i) const {
00047 assert((i >= 0) && (i < n));
00048 return d[i];
00049 }
00050 template<class Dim, int n>
00051 forceinline Dim&
00052 ManBox<Dim,n>::operator [](int i) {
00053 assert((i >= 0) && (i < n));
00054 return d[i];
00055 }
00056 template<class Dim, int n>
00057 forceinline int
00058 ManBox<Dim,n>::dim(void) {
00059 return n;
00060 }
00061
00062 template<class Dim, int n>
00063 forceinline bool
00064 ManBox<Dim,n>::mandatory(void) const {
00065 return true;
00066 }
00067 template<class Dim, int n>
00068 forceinline bool
00069 ManBox<Dim,n>::excluded(void) const {
00070 return false;
00071 }
00072 template<class Dim, int n>
00073 forceinline bool
00074 ManBox<Dim,n>::optional(void) const {
00075 return false;
00076 }
00077
00078 template<class Dim, int n>
00079 forceinline ExecStatus
00080 ManBox<Dim,n>::exclude(Space&) {
00081 return ES_FAILED;
00082 }
00083
00084 template<class Dim, int n>
00085 forceinline bool
00086 ManBox<Dim,n>::nooverlap(const ManBox<Dim,n>& box) const {
00087 for (int i=0; i<n; i++)
00088 if ((d[i].lec() <= box.d[i].ssc()) || (box.d[i].lec() <= d[i].ssc()))
00089 return true;
00090 return false;
00091 }
00092
00093 template<class Dim, int n>
00094 forceinline bool
00095 ManBox<Dim,n>::overlap(const ManBox<Dim,n>& box) const {
00096 for (int i=0; i<n; i++)
00097 if ((d[i].sec() <= box.d[i].lsc()) || (box.d[i].sec() <= d[i].lsc()))
00098 return false;
00099 return true;
00100 }
00101
00102 template<class Dim, int n>
00103 forceinline ExecStatus
00104 ManBox<Dim,n>::nooverlap(Space& home, ManBox<Dim,n>& box) {
00105 for (int i=0; i<n; i++)
00106 if ((d[i].sec() <= box.d[i].lsc()) ||
00107 (box.d[i].sec() <= d[i].lsc())) {
00108
00109 for (int j=i+1; j<n; j++)
00110 if ((d[j].sec() <= box.d[j].lsc()) ||
00111 (box.d[j].sec() <= d[j].lsc()))
00112 return ES_OK;
00113
00114 d[i].nooverlap(home, box.d[i]);
00115 box.d[i].nooverlap(home, d[i]);
00116 return ES_OK;
00117 }
00118
00119 return ES_FAILED;
00120 }
00121
00122 template<class Dim, int n>
00123 forceinline void
00124 ManBox<Dim,n>::update(Space& home, bool share, ManBox<Dim,n>& b) {
00125 for (int i=0; i<n; i++)
00126 d[i].update(home,share,b.d[i]);
00127 }
00128
00129 template<class Dim, int n>
00130 forceinline void
00131 ManBox<Dim,n>::subscribe(Space& home, Propagator& p) {
00132 for (int i=0; i<n; i++)
00133 d[i].subscribe(home,p);
00134 }
00135 template<class Dim, int n>
00136 forceinline void
00137 ManBox<Dim,n>::cancel(Space& home, Propagator& p) {
00138 for (int i=0; i<n; i++)
00139 d[i].cancel(home,p);
00140 }
00141 template<class Dim, int n>
00142 forceinline void
00143 ManBox<Dim,n>::reschedule(Space& home, Propagator& p) {
00144 for (int i=0; i<n; i++)
00145 d[i].reschedule(home,p);
00146 }
00147
00148
00149
00150
00151
00152
00153 template<class Dim, int n>
00154 forceinline void
00155 OptBox<Dim,n>::optional(BoolView o0) {
00156 o = o0;
00157 }
00158 template<class Dim, int n>
00159 forceinline bool
00160 OptBox<Dim,n>::mandatory(void) const {
00161 return o.one();
00162 }
00163 template<class Dim, int n>
00164 forceinline bool
00165 OptBox<Dim,n>::excluded(void) const {
00166 return o.zero();
00167 }
00168 template<class Dim, int n>
00169 forceinline bool
00170 OptBox<Dim,n>::optional(void) const {
00171 return o.none();
00172 }
00173
00174 template<class Dim, int n>
00175 forceinline ExecStatus
00176 OptBox<Dim,n>::exclude(Space& home) {
00177 GECODE_ME_CHECK(o.zero(home));
00178 return ES_OK;
00179 }
00180
00181 template<class Dim, int n>
00182 forceinline void
00183 OptBox<Dim,n>::update(Space& home, bool share, OptBox<Dim,n>& b) {
00184 ManBox<Dim,n>::update(home, share, b);
00185 o.update(home, share, b.o);
00186 }
00187
00188 template<class Dim, int n>
00189 forceinline void
00190 OptBox<Dim,n>::subscribe(Space& home, Propagator& p) {
00191 ManBox<Dim,n>::subscribe(home,p);
00192 o.subscribe(home, p, PC_BOOL_VAL);
00193 }
00194 template<class Dim, int n>
00195 forceinline void
00196 OptBox<Dim,n>::cancel(Space& home, Propagator& p) {
00197 ManBox<Dim,n>::cancel(home,p);
00198 o.cancel(home, p, PC_BOOL_VAL);
00199 }
00200 template<class Dim, int n>
00201 forceinline void
00202 OptBox<Dim,n>::reschedule(Space& home, Propagator& p) {
00203 ManBox<Dim,n>::reschedule(home,p);
00204 o.reschedule(home, p, PC_BOOL_VAL);
00205 }
00206
00207 }}}
00208
00209
00210