Post constraint on \a x
| 456 | } |
| 457 | /// Post constraint on \a x |
| 458 | virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) { |
| 459 | int nn = (c >= 0) ? x.size() : x.size()-1; |
| 460 | int n=nn / 3; |
| 461 | int pstart= (c >= 0) ? 2*n : 2*n+1; |
| 462 | |
| 463 | Gecode::IntVarArgs s(n); |
| 464 | Gecode::IntVarArgs px(n); |
| 465 | Gecode::IntVarArgs e(home,n, |
| 466 | Gecode::Int::Limits::min, |
| 467 | Gecode::Int::Limits::max); |
| 468 | for (int i=n; i--;) { |
| 469 | s[i] = expr(home, o+x[i]); |
| 470 | px[i] = x[pstart+i]; |
| 471 | rel(home, s[i]+px[i] == e[i]); |
| 472 | rel(home, _minP <= px[i]); |
| 473 | rel(home, _maxP >= px[i]); |
| 474 | } |
| 475 | Gecode::BoolVarArgs m(n); |
| 476 | for (int i=0; i<n; i++) |
| 477 | m[i]=Gecode::expr(home, (x[n+i] > l)); |
| 478 | if (c >= 0) { |
| 479 | Gecode::cumulative(home, c, s, px, e, u, m, ipl); |
| 480 | } else { |
| 481 | Gecode::rel(home, x[2*n] <= -c); |
| 482 | Gecode::cumulative(home, x[2*n], s, px, e, u, m, ipl); |
| 483 | } |
| 484 | } |
| 485 | }; |
| 486 | |
| 487 | /// Help class to create and register tests |
nothing calls this directly
no test coverage detected