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

Method propagate

gecode/int/distinct/bnd.hpp:380–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378
379 template<class View>
380 ExecStatus
381 Bnd<View>::propagate(Space& home, const ModEventDelta& med) {
382 assert(x.size() > 1);
383
384 if (View::me(med) == ME_INT_VAL) {
385 ExecStatus es = prop_val<View,false>(home,y);
386 GECODE_ES_CHECK(es);
387 if (y.size() < 2)
388 return home.ES_SUBSUMED(*this);
389 if (es == ES_FIX)
390 return home.ES_FIX_PARTIAL(*this,View::med(ME_INT_BND));
391 }
392
393 if (y.size() == 2)
394 GECODE_REWRITE(*this,(Rel::Nq<View,View>::post(home(*this),y[0],y[1])));
395
396 ExecStatus es = prop_bnd<View>(home,x,min_x,max_x);
397
398 GECODE_ES_CHECK(es);
399 if (es == ES_NOFIX && View::me(modeventdelta()) == ME_INT_VAL)
400 return es;
401
402 const int n = x.size();
403
404 if ((n > 2*y.size()) && (n > 6)) {
405 // If there are many assigned views, try to eliminate them
406 unsigned int d = static_cast<unsigned int>(max_x - min_x) + 1;
407 if (d > 2*static_cast<unsigned int>(n)) {
408 MinInc<View> min_inc;
409 Support::quicksort<View,MinInc<View> >(&x[0], n, min_inc);
410 } else {
411 Region r;
412 int* minbucket = r.alloc<int>(d);
413 View* minsorted = r.alloc<View>(n);
414
415 for (unsigned int i=0; i<d; i++)
416 minbucket[i]=0;
417 for (int i=0; i<n; i++)
418 minbucket[x[i].min() - min_x]++;
419
420 int c_min = 0;
421 for (unsigned int i=0; i<d; i++) {
422 int t_min = minbucket[i];
423 minbucket[i] = c_min; c_min += t_min;
424 }
425 assert(c_min == n);
426
427 for (int i=0; i<n; i++)
428 minsorted[minbucket[x[i].min() - min_x]++] = x[i];
429 for (int i=0; i<n; i++)
430 x[i] = minsorted[i];
431 }
432
433 int i = 0;
434 int j = 0;
435 int max = x[0].max()-1;
436 while (i < n-1) {
437 if (!x[i].assigned() ||

Callers

nothing calls this directly

Calls 9

ES_SUBSUMEDMethod · 0.80
ES_FIX_PARTIALMethod · 0.80
postFunction · 0.50
maxFunction · 0.50
sizeMethod · 0.45
minMethod · 0.45
maxMethod · 0.45
assignedMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected