| 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()) |
nothing calls this directly
no test coverage detected