Post constraint on \a x
| 294 | } |
| 295 | /// Post constraint on \a x |
| 296 | virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) { |
| 297 | using namespace Gecode; |
| 298 | BoolVarArgs y(3); |
| 299 | y[0] = channel(home,x[0]); y[1] = channel(home,x[1]); |
| 300 | y[2] = channel(home,x[2]); |
| 301 | Gecode::LinIntExpr l_reg[3] = {y[0],y[1],y[2]}; |
| 302 | Gecode::LinIntExpr r_reg[3] = {y[0],y[1],y[2]}; |
| 303 | switch (irt) { |
| 304 | case IRT_EQ: |
| 305 | { |
| 306 | IntVar x = Gecode::expr(home,eval(l_lis,l_reg)); |
| 307 | IntVar y = Gecode::expr(home,eval(r_lis,r_reg)); |
| 308 | IntArgs a({-2,2}); |
| 309 | IntVarArgs xy(2); xy[0]=x; xy[1]=y; |
| 310 | Gecode::rel(home, 0 == sum(a,xy)); |
| 311 | } |
| 312 | break; |
| 313 | case IRT_NQ: |
| 314 | Gecode::rel(home, eval(l_lis,l_reg) - eval(r_lis,r_reg) != 0); |
| 315 | break; |
| 316 | case IRT_LQ: |
| 317 | Gecode::rel(home, !(eval(l_lis,l_reg) > eval(r_lis,r_reg))); |
| 318 | break; |
| 319 | case IRT_LE: |
| 320 | Gecode::rel(home, eval(l_lis,l_reg) < eval(r_lis,r_reg)); |
| 321 | break; |
| 322 | case IRT_GQ: |
| 323 | Gecode::rel(home, eval(l_lis,l_reg) >= eval(r_lis,r_reg)); |
| 324 | break; |
| 325 | case IRT_GR: |
| 326 | Gecode::rel(home, !(eval(l_lis,l_reg) <= eval(r_lis,r_reg))); |
| 327 | break; |
| 328 | default: GECODE_NEVER; |
| 329 | } |
| 330 | } |
| 331 | /// Post constraint on \a x for \a r |
| 332 | virtual void post(Gecode::Space& home, Gecode::IntVarArray& x, |
| 333 | Gecode::Reify r) { |