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

Method sync

gecode/int/gcc/dom-sup.hpp:1232–1409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1230
1231 template<class Card>
1232 inline ExecStatus
1233 VarValGraph<Card>::sync(ViewArray<IntView>& x, ViewArray<Card>& k) {
1234 Region r;
1235 // A node can be pushed twice (once when checking cardinality and later again)
1236 NodeStack re(r,2*n_node);
1237
1238 // synchronize cardinality variables
1239 if (Card::propagate) {
1240 for (int i = n_val; i--; ) {
1241 ValNode* v = vals[i];
1242 int inc_ubc = v->incid_match(UBC);
1243 int inc_lbc = v->incid_match(LBC);
1244 if (v->noe == 0) {
1245 inc_ubc = 0;
1246 inc_lbc = 0;
1247 }
1248 int rm = v->kmax() - k[i].max();
1249 // the cardinality bounds have been modified
1250 if ((k[i].max() < v->kmax()) || (k[i].min() > v->kmin())) {
1251 if ((k[i].max() != k[i].counter()) || (k[i].max() == 0)) {
1252 // update the bounds
1253 v->kmax(k[i].max());
1254 v->kmin(k[i].min());
1255
1256 //everything is fine
1257 if (inc_ubc <= k[i].max()) {
1258 // adjust capacities
1259 v->cap(UBC, k[i].max() - inc_ubc);
1260 v->maxlow(k[i].max() - inc_lbc);
1261 if (v->kmin() == v->kmax())
1262 v->cap(LBC, k[i].max() - inc_lbc);
1263 } else {
1264 // set cap to max and resolve conflicts on view side
1265 // set to full capacity for later rescheduling
1266 if (v->cap(UBC))
1267 v->cap(UBC,k[i].max());
1268 v->maxlow(k[i].max() - (inc_lbc));
1269 if (v->kmin() == v->kmax())
1270 v->cap(LBC,k[i].max() - (inc_lbc));
1271 v->card_conflict(rm);
1272 }
1273 }
1274 }
1275 if (inc_lbc < k[i].min() && v->noe > 0) {
1276 v->cap(LBC, k[i].min() - inc_lbc);
1277 re.push(v);
1278 }
1279 }
1280
1281 for (int i = n_var; i--; ) {
1282 Edge* mub = vars[i]->get_match(UBC);
1283 if (mub != nullptr) {
1284 ValNode* vu = mub->getVal();
1285 if ((vars[i]->noe != 1) && vu->card_conflict()) {
1286 vu->red_conflict();
1287 mub->unmatch(UBC,vars[i]->type());
1288 re.push(vars[i]);
1289 }

Callers 3

propagateMethod · 0.45
propagateMethod · 0.45
propagateMethod · 0.45

Calls 15

incid_matchMethod · 0.80
kmaxMethod · 0.80
kminMethod · 0.80
counterMethod · 0.80
capMethod · 0.80
maxlowMethod · 0.80
card_conflictMethod · 0.80
get_matchMethod · 0.80
red_conflictMethod · 0.80
unmatchMethod · 0.80
firstMethod · 0.80
del_edgeMethod · 0.80

Tested by

no test coverage detected