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

Method post

test/int/cumulative.cpp:344–365  ·  view source on GitHub ↗

Post constraint on \a x

Source from the content-addressed store, hash-verified

342 }
343 /// Post constraint on \a x
344 virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
345 int nn = (c >= 0) ? x.size() : x.size()-1;
346 int n = nn/2;
347 int pstart = (c >= 0) ? n : n+1;
348 Gecode::IntVarArgs s(n);
349 Gecode::IntVarArgs px(x.slice(pstart,1,n));
350 Gecode::IntVarArgs e(home,n,
351 Gecode::Int::Limits::min,
352 Gecode::Int::Limits::max);
353 for (int i=s.size(); i--;) {
354 s[i] = expr(home, o+x[i], Gecode::IPL_DOM);
355 rel(home, s[i]+px[i] == e[i]);
356 rel(home, _minP <= px[i]);
357 rel(home, _maxP >= px[i]);
358 }
359 if (c >= 0) {
360 Gecode::cumulative(home, c, s, px, e, u, ipl);
361 } else {
362 rel(home, x[n] <= -c);
363 Gecode::cumulative(home, x[n], s, px, e, u, ipl);
364 }
365 }
366 };
367
368 /// Test for cumulative constraint with optional flexible tasks

Callers

nothing calls this directly

Calls 5

cumulativeFunction · 0.85
exprFunction · 0.50
relFunction · 0.50
sizeMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected