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 forceinline
00045 FixDim::FixDim(void)
00046 : s(0) {}
00047 forceinline
00048 FixDim::FixDim(IntView c0, int s0)
00049 : c(c0), s(s0) {}
00050
00051 forceinline int
00052 FixDim::ssc(void) const {
00053 return c.min();
00054 }
00055 forceinline int
00056 FixDim::lsc(void) const {
00057 return c.max();
00058 }
00059 forceinline int
00060 FixDim::sec(void) const {
00061 return c.min() + s;
00062 }
00063 forceinline int
00064 FixDim::lec(void) const {
00065 return c.max() + s;
00066 }
00067
00068 forceinline ExecStatus
00069 FixDim::ssc(Space& home, int n) {
00070 GECODE_ME_CHECK(c.gq(home, n));
00071 return ES_OK;
00072 }
00073 forceinline ExecStatus
00074 FixDim::lec(Space& home, int n) {
00075 GECODE_ME_CHECK(c.lq(home, n - s));
00076 return ES_OK;
00077 }
00078 forceinline ExecStatus
00079 FixDim::nooverlap(Space& home, int n, int m) {
00080 if (n <= m) {
00081 Iter::Ranges::Singleton r(n-s+1,m);
00082 GECODE_ME_CHECK(c.minus_r(home,r,false));
00083 }
00084 return ES_OK;
00085 }
00086 forceinline ExecStatus
00087 FixDim::nooverlap(Space& home, FixDim& d) {
00088 if (d.sec() > lsc()) {
00089
00090 GECODE_ES_CHECK(lec(home,d.lsc()));
00091 GECODE_ES_CHECK(d.ssc(home,sec()));
00092 } else {
00093 nooverlap(home, d.lsc(), d.sec()-1);
00094 }
00095 return ES_OK;
00096 }
00097
00098 forceinline void
00099 FixDim::update(Space& home, bool share, FixDim& d) {
00100 c.update(home,share,d.c);
00101 s = d.s;
00102 }
00103
00104 forceinline void
00105 FixDim::subscribe(Space& home, Propagator& p) {
00106 c.subscribe(home,p,PC_INT_DOM);
00107 }
00108 forceinline void
00109 FixDim::cancel(Space& home, Propagator& p) {
00110 c.cancel(home,p,PC_INT_DOM);
00111 }
00112
00113
00114
00115
00116
00117
00118 forceinline
00119 FlexDim::FlexDim(void) {}
00120 forceinline
00121 FlexDim::FlexDim(IntView c00, IntView s0, IntView c10)
00122 : c0(c00), s(s0), c1(c10) {}
00123
00124 forceinline int
00125 FlexDim::ssc(void) const {
00126 return c0.min();
00127 }
00128 forceinline int
00129 FlexDim::lsc(void) const {
00130 return c0.max();
00131 }
00132 forceinline int
00133 FlexDim::sec(void) const {
00134 return c1.min();
00135 }
00136 forceinline int
00137 FlexDim::lec(void) const {
00138 return c1.max();
00139 }
00140
00141 forceinline ExecStatus
00142 FlexDim::ssc(Space& home, int n) {
00143 GECODE_ME_CHECK(c0.gq(home, n));
00144 return ES_OK;
00145 }
00146 forceinline ExecStatus
00147 FlexDim::lec(Space& home, int n) {
00148 GECODE_ME_CHECK(c1.lq(home, n));
00149 return ES_OK;
00150 }
00151 forceinline ExecStatus
00152 FlexDim::nooverlap(Space& home, int n, int m) {
00153 if (n <= m) {
00154 Iter::Ranges::Singleton r0(n-s.min()+1,m);
00155 GECODE_ME_CHECK(c0.minus_r(home,r0,false));
00156 Iter::Ranges::Singleton r1(n+1,s.min()+m);
00157 GECODE_ME_CHECK(c1.minus_r(home,r1,false));
00158 }
00159 return ES_OK;
00160 }
00161 forceinline ExecStatus
00162 FlexDim::nooverlap(Space& home, FlexDim& d) {
00163 if (d.sec() > lsc()) {
00164
00165 GECODE_ES_CHECK(lec(home,d.lsc()));
00166 GECODE_ES_CHECK(d.ssc(home,sec()));
00167 } else {
00168 nooverlap(home, d.lsc(), d.sec()-1);
00169 }
00170 return ES_OK;
00171 }
00172
00173
00174 forceinline void
00175 FlexDim::update(Space& home, bool share, FlexDim& d) {
00176 c0.update(home,share,d.c0);
00177 s.update(home,share,d.s);
00178 c1.update(home,share,d.c1);
00179 }
00180
00181 forceinline void
00182 FlexDim::subscribe(Space& home, Propagator& p) {
00183 c0.subscribe(home,p,PC_INT_DOM);
00184 s.subscribe(home,p,PC_INT_BND);
00185 c1.subscribe(home,p,PC_INT_DOM);
00186 }
00187 forceinline void
00188 FlexDim::cancel(Space& home, Propagator& p) {
00189 c0.cancel(home,p,PC_INT_DOM);
00190 s.cancel(home,p,PC_INT_BND);
00191 c1.cancel(home,p,PC_INT_DOM);
00192 }
00193
00194 }}}
00195
00196
00197