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

Method propagate

gecode/set/convex/conv.cpp:47–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 }
46
47 ExecStatus
48 Convex::propagate(Space& home, const ModEventDelta&) {
49 //I, drop ranges from UB that are shorter than cardMin
50 //II, add range LB.smallest to LB.largest to LB
51 //III, Drop ranges from UB that do not contain all elements of LB
52 //that is: range.min()>LB.smallest or range.max()<LB.largest
53 //This leaves only one range.
54 //II
55 if (x0.glbSize()>0) {
56 GECODE_ME_CHECK( x0.include(home,x0.glbMin(),x0.glbMax()) );
57 } else {
58 //If lower bound is empty, we can still constrain the cardinality
59 //maximum with the width of the longest range in UB.
60 //No need to do this if there is anything in LB because UB
61 //becomes a single range then.
62 LubRanges<SetView> ubRangeIt(x0);
63 unsigned int maxWidth = 0;
64 for (;ubRangeIt();++ubRangeIt) {
65 assert(ubRangeIt());
66 maxWidth = std::max(maxWidth, ubRangeIt.width());
67 }
68 GECODE_ME_CHECK( x0.cardMax(home,maxWidth) );
69 }
70
71
72 //I + III
73
74 Region r;
75 LubRanges<SetView> ubRangeIt(x0);
76 Iter::Ranges::Cache ubRangeItC(r,ubRangeIt);
77
78 for (; ubRangeItC(); ++ubRangeItC) {
79 if (ubRangeItC.width() < (unsigned int) x0.cardMin()
80 || ubRangeItC.min() > x0.glbMin() //No need to test for empty lb.
81 || ubRangeItC.max() < x0.glbMax()
82 ) {
83 GECODE_ME_CHECK( x0.exclude(home,ubRangeItC.min(), ubRangeItC.max()) );
84 }
85 }
86 if (x0.assigned())
87 return home.ES_SUBSUMED(*this);
88 return ES_FIX;
89 }
90
91}}}
92

Callers

nothing calls this directly

Calls 13

ES_SUBSUMEDMethod · 0.80
maxFunction · 0.50
glbSizeMethod · 0.45
includeMethod · 0.45
glbMinMethod · 0.45
glbMaxMethod · 0.45
widthMethod · 0.45
cardMaxMethod · 0.45
cardMinMethod · 0.45
minMethod · 0.45
maxMethod · 0.45
excludeMethod · 0.45

Tested by

no test coverage detected