Post circuit constraint on \a x
| 176 | } |
| 177 | /// Post circuit constraint on \a x |
| 178 | virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) { |
| 179 | using namespace Gecode; |
| 180 | int n=x.size()-1; |
| 181 | IntArgs c(n*n); |
| 182 | for (int i=0; i<n; i++) |
| 183 | for (int j=0; j<n; j++) |
| 184 | c[i*n+j]=j; |
| 185 | IntVarArgs y(n); |
| 186 | if (offset > 0) { |
| 187 | for (int i=n; i--;) |
| 188 | y[i] = Gecode::expr(home, x[i]+offset); |
| 189 | Gecode::circuit(home, c, offset, y, x[n], ipl); |
| 190 | } else { |
| 191 | for (int i=0; i<n; i++) |
| 192 | y[i]=x[i]; |
| 193 | circuit(home, c, y, x[n], ipl); |
| 194 | } |
| 195 | } |
| 196 | }; |
| 197 | |
| 198 | /// Simple test for path constraint with total cost |