MCPcopy Create free account
hub / github.com/Gecode/gecode / post

Method post

test/int/circuit.cpp:299–319  ·  view source on GitHub ↗

Post circuit constraint on \a x

Source from the content-addressed store, hash-verified

297 }
298 /// Post circuit constraint on \a x
299 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
300 using namespace Gecode;
301 int n=(x.size()-1)/2;
302 IntArgs c(n*n);
303 for (int i=0; i<n; i++)
304 for (int j=0; j<n; j++)
305 c[i*n+j]=(j/2);
306 IntVarArgs y(n), z(n);
307 for (int i=0; i<n; i++) {
308 z[i]=x[n+i];
309 }
310 if (offset > 0) {
311 for (int i=n; i--;)
312 y[i] = Gecode::expr(home, x[i]+offset);
313 Gecode::circuit(home, c, offset, y, z, x[2*n], ipl);
314 } else {
315 for (int i=0; i<n; i++)
316 y[i]=x[i];
317 circuit(home, c, y, z, x[2*n], ipl);
318 }
319 }
320 };
321
322 /// Help class to create and register tests

Callers

nothing calls this directly

Calls 3

circuitFunction · 0.85
exprFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected