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

Method propagate

gecode/int/element/int.hpp:281–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279
280 template<class V0, class V1, class Idx, class Val>
281 ExecStatus
282 Int<V0,V1,Idx,Val>::propagate(Space& home, const ModEventDelta&) {
283 if (x0.assigned()) {
284 GECODE_ME_CHECK(x1.eq(home,c[x0.val()]));
285 return home.ES_SUBSUMED(*this);
286 }
287
288 if (x1.assigned() && (iv == nullptr)) {
289 GECODE_ES_CHECK(assigned_val(home,c,x0,x1));
290 return home.ES_SUBSUMED(*this);
291 }
292
293 if ((static_cast<ValSize>(x1.size()) == s1) &&
294 (static_cast<IdxSize>(x0.size()) != s0)) {
295 assert(iv != nullptr);
296 assert(!shared(x0,x1));
297
298 prune_idx();
299
300 IterValUnmark v(iv);
301 GECODE_ME_CHECK(x1.narrow_v(home,v,false));
302
303 s1=static_cast<ValSize>(x1.size());
304
305 assert(!x0.assigned());
306 return x1.assigned() ? home.ES_SUBSUMED(*this) : ES_FIX;
307 }
308
309 if ((static_cast<IdxSize>(x0.size()) == s0) &&
310 (static_cast<ValSize>(x1.size()) != s1)) {
311 assert(iv != nullptr);
312 assert(!shared(x0,x1));
313
314 prune_val();
315
316 IterIdxUnmark i(iv);
317 GECODE_ME_CHECK(x0.narrow_v(home,i,false));
318
319 s0=static_cast<IdxSize>(x0.size());
320
321 return (x0.assigned() || x1.assigned()) ?
322 home.ES_SUBSUMED(*this) : ES_FIX;
323 }
324
325 bool assigned = x0.assigned() && x1.assigned();
326 if (iv == nullptr) {
327 // Initialize data structure
328 iv = home.alloc<IdxVal>(x0.size() + 1);
329
330 // The first element in iv[0] is used as sentinel
331 // Enter information sorted by idx
332 IdxVal* by_idx = &iv[1];
333 Idx size = 0;
334 for (ViewValues<V0> v(x0); v(); ++v)
335 if ((x1.min() <= c[v.val()]) && (x1.max() >= c[v.val()])) {
336 by_idx[size].idx = static_cast<Idx>(v.val());
337 by_idx[size].val = static_cast<Val>(c[v.val()]);
338 size++;

Callers

nothing calls this directly

Calls 11

ES_SUBSUMEDMethod · 0.80
sharedFunction · 0.50
assignedMethod · 0.45
eqMethod · 0.45
valMethod · 0.45
sizeMethod · 0.45
narrow_vMethod · 0.45
minMethod · 0.45
maxMethod · 0.45
widthMethod · 0.45
inter_vMethod · 0.45

Tested by

no test coverage detected