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

Method propagate

gecode/int/extensional/compact.hpp:546–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544
545 template<class View, class Table>
546 ExecStatus
547 PosCompact<View,Table>::propagate(Space& home, const ModEventDelta&) {
548 if (table.empty())
549 return ES_FAILED;
550 if (all())
551 return home.ES_SUBSUMED(*this);
552
553 Status touched(status);
554 // Mark as performing propagation
555 status.propagating();
556
557 Region r;
558 // Scan all values of all unassigned variables to see if they
559 // are still supported.
560 for (Advisors<CTAdvisor> as(c); as(); ++as) {
561 CTAdvisor& a = as.advisor();
562 View x = a.view();
563
564 // No point filtering variable if it was the only modified variable
565 if (touched.single(a) || x.assigned())
566 continue;
567
568 if (x.size() == 2) { // Consider min and max values only
569 if (!table.intersects(supports(a,x.min())))
570 GECODE_ME_CHECK(x.eq(home,x.max()));
571 else if (!table.intersects(supports(a,x.max())))
572 GECODE_ME_CHECK(x.eq(home,x.min()));
573 if (!x.assigned())
574 a.adjust();
575 } else { // x.size() > 2
576 // How many values to remove
577 int* nq = r.alloc<int>(x.size());
578 unsigned int n_nq = 0;
579 // The initialization is here just to avoid warnings...
580 int last_support = 0;
581 for (ValidSupports vs(*this,a); vs(); ++vs)
582 if (!table.intersects(vs.supports()))
583 nq[n_nq++] = vs.val();
584 else
585 last_support = vs.val();
586 // Remove collected values
587 if (n_nq > 0U) {
588 if (n_nq == 1U) {
589 GECODE_ME_CHECK(x.nq(home,nq[0]));
590 } else if (n_nq == x.size() - 1U) {
591 GECODE_ME_CHECK(x.eq(home,last_support));
592 goto noadjust;
593 } else {
594 Iter::Values::Array rnq(nq,n_nq);
595 GECODE_ASSUME(n_nq >= 2U);
596 GECODE_ME_CHECK(x.minus_v(home,rnq,false));
597 }
598 a.adjust();
599 noadjust: ;
600 }
601 r.free();
602 }
603 }

Callers

nothing calls this directly

Calls 15

postposcompactFunction · 0.85
postnegcompactFunction · 0.85
ES_SUBSUMEDMethod · 0.80
propagatingMethod · 0.80
singleMethod · 0.80
emptyMethod · 0.45
viewMethod · 0.45
assignedMethod · 0.45
sizeMethod · 0.45
intersectsMethod · 0.45
minMethod · 0.45
eqMethod · 0.45

Tested by

no test coverage detected