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

Method propagate

gecode/set/element/unionConst.hpp:114–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112
113 template<class SView, class RView>
114 ExecStatus
115 ElementUnionConst<SView,RView>::propagate(Space& home, const ModEventDelta&) {
116 Region r;
117
118 bool* stillSelected = r.alloc<bool>(n_iv);
119
120 bool loopVar;
121 do {
122 loopVar = false;
123 for (int i=n_iv; i--;)
124 stillSelected[i] = false;
125
126 // Cache the upper bound iterator, as we have to
127 // modify the upper bound while iterating
128 LubRanges<RView> x1ub(x1);
129 Iter::Ranges::Cache x1ubc(r,x1ub);
130 Iter::Ranges::ToValues<Iter::Ranges::Cache>
131 vx1ub(x1ubc);
132
133 GlbRanges<RView> x1lb(x1);
134 Iter::Ranges::Cache x1lbc(r,x1lb);
135 Iter::Ranges::ToValues<Iter::Ranges::Cache>
136 vx1(x1lbc);
137
138 // In the first iteration, compute in before[i] the union
139 // of all the upper bounds of the x_i. At the same time,
140 // exclude inconsistent x_i from x1.
141
142 GLBndSet sofarBefore(home);
143 LUBndSet selectedInter(home, IntSet (Limits::min,
144 Limits::max));
145 GLBndSet* before =
146 static_cast<GLBndSet*>(r.ralloc(sizeof(GLBndSet)*n_iv));
147
148 unsigned int maxCard = 0;
149 unsigned int minCard = Limits::card;
150
151 while (vx1ub()) {
152 int i = vx1ub.val();
153
154 IntSetRanges candCardR(iv[i]);
155 unsigned int candidateCard = Iter::Ranges::size(candCardR);
156
157 IntSetRanges candlb(iv[i]);
158 LubRanges<SView> x0ub(x0);
159 Iter::Ranges::Diff<IntSetRanges,
160 LubRanges<SView> > diff(candlb, x0ub);
161
162 bool selectSingleInconsistent = false;
163 if (x1.cardMax() <= 1) {
164 GlbRanges<SView> x0lb(x0);
165 IntSetRanges candub(iv[i]);
166 Iter::Ranges::Diff<GlbRanges<SView>,
167 IntSetRanges > diff2(x0lb, candub);
168 selectSingleInconsistent = diff2() || candidateCard < x0.cardMin();
169 }
170
171 // exclude inconsistent x_i

Callers

nothing calls this directly

Calls 15

IntSetClass · 0.85
me_modifiedFunction · 0.85
ES_SUBSUMEDMethod · 0.80
sizeFunction · 0.50
maxFunction · 0.50
minFunction · 0.50
subsetFunction · 0.50
rallocMethod · 0.45
valMethod · 0.45
cardMaxMethod · 0.45
cardMinMethod · 0.45
excludeMethod · 0.45

Tested by

no test coverage detected