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

Function propagateSeq

gecode/set/sequence/common.hpp:42–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40namespace Gecode { namespace Set { namespace Sequence {
41
42 inline ExecStatus
43 propagateSeq(Space& home, bool& modified, bool& assigned,
44 ViewArray<SetView>& x) {
45 int lastElem = x.size()-1;
46 int cur_max = BndSet::MAX_OF_EMPTY;
47 int cur_min = BndSet::MIN_OF_EMPTY;
48
49 Region r;
50 Support::DynamicArray<int,Region> ub(r);
51
52 for (int i=0; i<lastElem; i++) {
53 if (x[i].glbSize() > 0)
54 cur_max = std::max(cur_max, x[i].glbMax());
55 if (x[i].cardMin() > 0)
56 cur_max = std::max(cur_max, x[i].lubMinN(x[i].cardMin()-1));
57 if (cur_max >= Limits::min)
58 GECODE_SET_ME_CHECK_VAL_B(modified,
59 x[i+1].exclude(home, Limits::min,
60 cur_max),
61 assigned);
62
63 if (x[lastElem-i].lubSize() > 0) {
64 cur_min = std::min(cur_min, x[lastElem-i].glbMin());
65 if (x[lastElem-i].cardMin() > 0) {
66 // Compute n-th largest element in x[lastElem-i].lub
67 // for n = x[lastElem-i].cardMin()-1
68 int maxN = BndSet::MAX_OF_EMPTY;
69 int j=0;
70 for (LubRanges<SetView> ubr(x[lastElem-i]); ubr(); ++ubr, ++j) {
71 ub[2*j]=ubr.min(); ub[2*j+1]=ubr.max();
72 }
73 unsigned int xcm = x[lastElem-i].cardMin()-1;
74 while (j--) {
75 unsigned int width = static_cast<unsigned int>(ub[2*j+1]-ub[2*j]+1);
76 if (width > xcm) {
77 maxN = static_cast<int>(ub[2*j+1]-xcm);
78 break;
79 }
80 xcm -= width;
81 }
82 cur_min = std::min(cur_min, maxN);
83 }
84 }
85 if (Limits::max>=cur_min)
86 GECODE_SET_ME_CHECK_VAL_B(modified,
87 x[lastElem-i-1].exclude(home, cur_min,
88 Limits::max),
89 assigned);
90 }
91 return ES_NOFIX;
92 }
93
94}}}
95

Callers 2

propagateMethod · 0.85
propagateMethod · 0.85

Calls 12

maxFunction · 0.50
minFunction · 0.50
sizeMethod · 0.45
glbSizeMethod · 0.45
glbMaxMethod · 0.45
cardMinMethod · 0.45
lubMinNMethod · 0.45
excludeMethod · 0.45
lubSizeMethod · 0.45
glbMinMethod · 0.45
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected