| 593 | |
| 594 | template<class Card> |
| 595 | ExecStatus |
| 596 | Bnd<Card>::propagate(Space& home, const ModEventDelta& med) { |
| 597 | if (IntView::me(med) == ME_INT_VAL) { |
| 598 | GECODE_ES_CHECK(prop_val<Card>(home,*this,y,k)); |
| 599 | return home.ES_NOFIX_PARTIAL(*this,IntView::med(ME_INT_BND)); |
| 600 | } |
| 601 | |
| 602 | if (Card::propagate) |
| 603 | GECODE_ES_CHECK(pruneCards(home)); |
| 604 | |
| 605 | Region r; |
| 606 | int* count = r.alloc<int>(k.size()); |
| 607 | |
| 608 | for (int i = k.size(); i--; ) |
| 609 | count[i] = 0; |
| 610 | bool all_assigned = true; |
| 611 | int noa = 0; |
| 612 | for (int i = x.size(); i--; ) { |
| 613 | if (x[i].assigned()) { |
| 614 | noa++; |
| 615 | int idx; |
| 616 | // reduction is essential for order on value nodes in dom |
| 617 | // hence introduce test for failed lookup |
| 618 | if (!lookupValue(k,x[i].val(),idx)) |
| 619 | return ES_FAILED; |
| 620 | count[idx]++; |
| 621 | } else { |
| 622 | all_assigned = false; |
| 623 | // We only need the counts in the view case or when all |
| 624 | // x are assigned |
| 625 | if (!Card::propagate) |
| 626 | break; |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | if (Card::propagate) { |
| 631 | // before propagation performs inferences on cardinality variables: |
| 632 | if (noa > 0) |
| 633 | for (int i = k.size(); i--; ) |
| 634 | if (!k[i].assigned()) { |
| 635 | GECODE_ME_CHECK(k[i].lq(home, x.size() - (noa - count[i]))); |
| 636 | GECODE_ME_CHECK(k[i].gq(home, count[i])); |
| 637 | } |
| 638 | |
| 639 | if (!card_consistent<Card>(x, k)) |
| 640 | return ES_FAILED; |
| 641 | |
| 642 | GECODE_ES_CHECK(prop_card<Card>(home, x, k)); |
| 643 | |
| 644 | // Cardinalities may have been modified, so recompute |
| 645 | // count and all_assigned |
| 646 | for (int i = k.size(); i--; ) |
| 647 | count[i] = 0; |
| 648 | all_assigned = true; |
| 649 | for (int i = x.size(); i--; ) { |
| 650 | if (x[i].assigned()) { |
| 651 | int idx; |
| 652 | // reduction is essential for order on value nodes in dom |
nothing calls this directly
no test coverage detected