| 165 | |
| 166 | template<class ViewM, class ViewP, class ViewU, class View> |
| 167 | ExecStatus |
| 168 | Val<ViewM,ViewP,ViewU,View>::prune(Space& home, int low, int up, int r, |
| 169 | int ntask, int su, |
| 170 | int* contribution, |
| 171 | int* prune_tasks, int& prune_tasks_size) { |
| 172 | |
| 173 | if (ntask > 0 && (at_most ? su > c[r] : su < c[r])) { |
| 174 | return ES_FAILED; |
| 175 | } |
| 176 | |
| 177 | int pti = 0; |
| 178 | while (pti != prune_tasks_size) { |
| 179 | int t = prune_tasks[pti]; |
| 180 | |
| 181 | // Algorithm 2. |
| 182 | // Prune the machine, start, and end for required |
| 183 | // tasks for machine r that have heights possibly greater than 0. |
| 184 | if (ntask != 0 && |
| 185 | (at_most ? u[t].min() < 0 |
| 186 | : u[t].max() > 0) && |
| 187 | (at_most ? su-contribution[t] > c[r] |
| 188 | : su-contribution[t] < c[r])) { |
| 189 | if (me_failed(m[t].eq(home, r))|| |
| 190 | me_failed(s[t].gq(home, up-p[t].max()+1))|| |
| 191 | me_failed(s[t].lq(home, low))|| |
| 192 | me_failed(e[t].lq(home,low+p[t].max()))|| |
| 193 | me_failed(e[t].gq(home, up+1))|| |
| 194 | me_failed(p[t].gq(home,std::min(up-s[t].max()+1,e[t].min()-low))) |
| 195 | ) { |
| 196 | return ES_FAILED; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | // Algorithm 3. |
| 201 | // Remove values that prevent us from reaching the limit |
| 202 | if (at_most ? u[t].min() > std::min(0, c[r]) |
| 203 | : u[t].max() < std::max(0, c[r])) { |
| 204 | if (at_most ? su-contribution[t]+u[t].min() > c[r] |
| 205 | : su-contribution[t]+u[t].max() < c[r]) { |
| 206 | if (e[t].min() > low && |
| 207 | s[t].max() <= up && |
| 208 | p[t].min() > 0) { |
| 209 | if (me_failed(m[t].nq(home, r))) { |
| 210 | return ES_FAILED; |
| 211 | } |
| 212 | } else if (m[t].assigned()) { |
| 213 | int ptmin = p[t].min(); |
| 214 | if (ptmin > 0) { |
| 215 | Iter::Ranges::Singleton |
| 216 | a(low-ptmin+1, up), b(low+1, up+ptmin); |
| 217 | if (me_failed(s[t].minus_r(home,a,false)) || |
| 218 | me_failed(e[t].minus_r(home, b,false))) |
| 219 | return ES_FAILED; |
| 220 | } |
| 221 | if (me_failed(p[t].lq(home,std::max(std::max(low-s[t].min(), |
| 222 | e[t].max()-up-1), |
| 223 | 0)))) { |
| 224 | return ES_FAILED; |