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

Method propagate

gecode/float/linear/nary.hpp:146–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144
145 template<class P, class N>
146 ExecStatus
147 Eq<P,N>::propagate(Space& home, const ModEventDelta& med) {
148 // Eliminate singletons
149 Rounding r;
150 eliminate_p<P>(med, x, c);
151 eliminate_n<N>(med, y, c);
152
153 if ((FloatView::me(med) == ME_FLOAT_VAL) && ((x.size() + y.size()) <= 1)) {
154 if (x.size() == 1) {
155 GECODE_ME_CHECK(x[0].eq(home,c));
156 return home.ES_SUBSUMED(*this);
157 }
158 if (y.size() == 1) {
159 GECODE_ME_CHECK(y[0].eq(home,-c));
160 return home.ES_SUBSUMED(*this);
161 }
162 return (c.in(0.0)) ? home.ES_SUBSUMED(*this) : ES_FAILED;
163 }
164
165 ExecStatus es = ES_FIX;
166 bool assigned = true;
167
168 // Propagate max bound for positive variables
169 for (int i = x.size(); i--; ) {
170 // Compute bound
171 FloatNum sl = c.max();
172 for (int j = x.size(); j--; ) {
173 if (i == j) continue;
174 sl = r.sub_up(sl,x[j].min());
175 }
176 for (int j = y.size(); j--; )
177 sl = r.add_up(sl,y[j].max());
178 ModEvent me = x[i].lq(home,sl);
179 if (me_failed(me))
180 return ES_FAILED;
181 if (me != ME_FLOAT_VAL)
182 assigned = false;
183 if (me_modified(me))
184 es = ES_NOFIX;
185 }
186 // Propagate min bound for negative variables
187 for (int i = y.size(); i--; ) {
188 // Compute bound
189 FloatNum sl = -c.max();
190 for (int j = x.size(); j--; )
191 sl = r.add_down(sl,x[j].min());
192 for (int j = y.size(); j--; ) {
193 if (i == j) continue;
194 sl = r.sub_down(sl,y[j].max());
195 }
196 ModEvent me = y[i].gq(home,sl);
197 if (me_failed(me))
198 return ES_FAILED;
199 if (me != ME_FLOAT_VAL)
200 assigned = false;
201 if (me_modified(me))
202 es = ES_NOFIX;
203 }

Callers

nothing calls this directly

Calls 15

me_failedFunction · 0.85
me_modifiedFunction · 0.85
ES_SUBSUMEDMethod · 0.80
sizeMethod · 0.45
eqMethod · 0.45
inMethod · 0.45
maxMethod · 0.45
sub_upMethod · 0.45
minMethod · 0.45
add_upMethod · 0.45
lqMethod · 0.45
add_downMethod · 0.45

Tested by

no test coverage detected