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
00142
00143
00144
00145
00146
00147 template<class Dim, int n>
00148 forceinline void
00149 OptBox<Dim,n>::optional(BoolView o0) {
00150 o = o0;
00151 }
00152 template<class Dim, int n>
00153 forceinline bool
00154 OptBox<Dim,n>::mandatory(void) const {
00155 return o.one();
00156 }
00157 template<class Dim, int n>
00158 forceinline bool
00159 OptBox<Dim,n>::excluded(void) const {
00160 return o.zero();
00161 }
00162 template<class Dim, int n>
00163 forceinline bool
00164 OptBox<Dim,n>::optional(void) const {
00165 return o.none();
00166 }
00167
00168 template<class Dim, int n>
00169 forceinline ExecStatus
00170 OptBox<Dim,n>::exclude(Space& home) {
00171 GECODE_ME_CHECK(o.zero(home));
00172 return ES_OK;
00173 }
00174
00175 template<class Dim, int n>
00176 forceinline void
00177 OptBox<Dim,n>::update(Space& home, bool share, OptBox<Dim,n>& b) {
00178 ManBox<Dim,n>::update(home, share, b);
00179 o.update(home, share, b.o);
00180 }
00181
00182 template<class Dim, int n>
00183 forceinline void
00184 OptBox<Dim,n>::subscribe(Space& home, Propagator& p) {
00185 ManBox<Dim,n>::subscribe(home,p);
00186 o.subscribe(home, p, PC_BOOL_VAL);
00187 }
00188 template<class Dim, int n>
00189 forceinline void
00190 OptBox<Dim,n>::cancel(Space& home, Propagator& p) {
00191 ManBox<Dim,n>::cancel(home,p);
00192 o.cancel(home, p, PC_BOOL_VAL);
00193 }
00194
00195 }}}
00196
00197
00198