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

Method narrow

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

Source from the content-addressed store, hash-verified

1410
1411 template<class Card> template<BC bc>
1412 inline ExecStatus
1413 VarValGraph<Card>::narrow(Space& home,
1414 ViewArray<IntView>& x, ViewArray<Card>& k) {
1415 for (int i = n_var; i--; )
1416 if (vars[i]->noe == 1) {
1417 ValNode* v = vars[i]->first()->getVal();
1418 vars[i]->first()->free(bc);
1419 GECODE_ME_CHECK(x[i].eq(home, v->val));
1420 v->inc();
1421 }
1422
1423 for (int i = n_val; i--; ) {
1424 ValNode* v = vals[i];
1425 if (Card::propagate && (k[i].counter() == 0))
1426 GECODE_ME_CHECK(k[i].lq(home, v->noe));
1427 if (v->noe > 0) {
1428 if (Card::propagate)
1429 GECODE_ME_CHECK(k[i].lq(home, v->noe));
1430
1431 // If the maximum number of occurrences of a value is reached
1432 // it cannot be consumed by another view
1433
1434 if (v->kcount() == v->kmax()) {
1435 int vidx = v->kindex();
1436
1437 k[i].counter(v->kcount());
1438
1439 if (Card::propagate)
1440 GECODE_ME_CHECK(k[i].eq(home, k[i].counter()));
1441
1442 bool delall = v->card_conflict() && (v->noe > v->kmax());
1443
1444 for (Edge* e = v->last(); e != nullptr; e = e->vprev()) {
1445 VarNode* vrn = e->getVar();
1446 if (vrn->noe == 1) {
1447 vrn->noe--;
1448 v->noe--;
1449 int vi= vrn->index();
1450
1451 x.move_lst(vi);
1452 vars[vi] = vars[--n_var];
1453 vars[vi]->index(vi);
1454 n_node--;
1455 e->del_edge();
1456 e->unlink();
1457
1458 } else if (delall) {
1459 GECODE_ME_CHECK(x[vrn->index()].nq(home, v->val));
1460 vrn->noe--;
1461 v->noe--;
1462 e->del_edge();
1463 e->unlink();
1464 }
1465 }
1466 v->cap(UBC,0);
1467 v->cap(LBC,0);
1468 v->maxlow(0);
1469 if (sum_min >= k[vidx].min())

Callers

nothing calls this directly

Calls 15

firstMethod · 0.80
counterMethod · 0.80
kcountMethod · 0.80
kmaxMethod · 0.80
kindexMethod · 0.80
card_conflictMethod · 0.80
vprevMethod · 0.80
getVarMethod · 0.80
del_edgeMethod · 0.80
capMethod · 0.80
maxlowMethod · 0.80
getValMethod · 0.45

Tested by

no test coverage detected