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

Method propagate

gecode/set/element/inter.hpp:111–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109
110 template<class View, class View0, class View1>
111 ExecStatus
112 ElementIntersection<View,View0,View1>::propagate(Space& home,
113 const ModEventDelta&) {
114 Region r;
115 int n = iv.size();
116
117 bool loopVar;
118 do {
119 loopVar = false;
120
121 // Cache the upper bound iterator, as we have to
122 // modify the upper bound while iterating
123 LubRanges<View0> x0ub(x0);
124 Iter::Ranges::Cache x0ubc(r,x0ub);
125 Iter::Ranges::ToValues<Iter::Ranges::Cache> vx0ub(x0ubc);
126
127 GlbRanges<View0> x0lb(x0);
128 Iter::Ranges::Cache x0lbc(r,x0lb);
129 Iter::Ranges::ToValues<Iter::Ranges::Cache> vx0(x0lbc);
130
131 // In the first iteration, compute in before[i] the intersection
132 // of all the lower bounds of the x_i. At the same time,
133 // exclude inconsistent x_i from x0 and remove them from
134 // the list, cancel their dependencies.
135
136 LUBndSet sofarBefore(home,universe);
137 LUBndSet* before = r.alloc<LUBndSet>(n);
138
139 int j = 0;
140 int i = 0;
141 while ( vx0ub() ) {
142
143 // Remove vars at indices not in the upper bound
144 if (iv[i].idx < vx0ub.val()) {
145 iv[i].view.cancel(home,*this, PC_SET_ANY);
146 ++i;
147 continue;
148 }
149 assert(iv[i].idx == vx0ub.val());
150 iv[j] = iv[i];
151
152 View candidate = iv[j].view;
153 int candidateInd = iv[j].idx;
154
155 // inter = glb(x1) & complement(lub(candidate))
156 GlbRanges<View1> x1lb(x1);
157 LubRanges<View> candub(candidate);
158 Iter::Ranges::Diff<GlbRanges<View1>,LubRanges<View> >
159 inter(x1lb, candub);
160
161 // exclude inconsistent x_i
162 // an x_i is inconsistent if
163 // * its max cardinality is less than minCard of x1
164 // * inter is not empty (there are elements in x_0
165 // that can't be in x_i)
166 if (candidate.cardMax() < x1.cardMin() ||
167 inter()) {
168 ModEvent me = (x0.exclude(home,candidateInd));

Callers

nothing calls this directly

Calls 15

interFunction · 0.85
me_modifiedFunction · 0.85
ES_SUBSUMEDMethod · 0.80
postFunction · 0.50
sizeMethod · 0.45
valMethod · 0.45
cancelMethod · 0.45
cardMaxMethod · 0.45
cardMinMethod · 0.45
excludeMethod · 0.45
includeIMethod · 0.45
intersectIMethod · 0.45

Tested by

no test coverage detected