| 69 | |
| 70 | template<class View> |
| 71 | ExecStatus |
| 72 | MinElement<View>::propagate(Space& home, const ModEventDelta&) { |
| 73 | //x1 is an element of x0.ub |
| 74 | //x1 =< smallest element of x0.lb |
| 75 | //x1 =< x0.cardinialityMin-est largest element of x0.ub |
| 76 | //(these 2 take care of determined x0) |
| 77 | //No element in x0 is smaller than x1 |
| 78 | //if x1 is determined, it is part of the ub. |
| 79 | |
| 80 | //Consequently: |
| 81 | //The domain of x1 is a subset of x0.ub up to the first element in x0.lb. |
| 82 | //x0 lacks everything smaller than smallest possible x1. |
| 83 | |
| 84 | { |
| 85 | LubRanges<View> ub(x0); |
| 86 | GECODE_ME_CHECK(x1.inter_r(home,ub,false)); |
| 87 | } |
| 88 | GECODE_ME_CHECK(x1.lq(home,x0.glbMin())); |
| 89 | //if cardMin>lbSize? |
| 90 | assert(x0.cardMin()>=1); |
| 91 | |
| 92 | { |
| 93 | /// Compute n-th largest element in x0.lub for n = x0.cardMin()-1 |
| 94 | unsigned int size = 0; |
| 95 | int maxN = BndSet::MAX_OF_EMPTY; |
| 96 | for (LubRanges<View> ubr(x0); ubr(); ++ubr, ++size) {} |
| 97 | Region r; |
| 98 | int* ub = r.alloc<int>(size*2); |
| 99 | { |
| 100 | int i=0; |
| 101 | for (LubRanges<View> ubr(x0); ubr(); ++ubr, ++i) { |
| 102 | ub[2*i] = ubr.min(); |
| 103 | ub[2*i+1] = ubr.max(); |
| 104 | } |
| 105 | } |
| 106 | unsigned int x0cm = x0.cardMin()-1; |
| 107 | for (unsigned int i=size; i--;) { |
| 108 | unsigned int width = static_cast<unsigned int>(ub[2*i+1]-ub[2*i]+1); |
| 109 | if (width > x0cm) { |
| 110 | maxN = static_cast<int>(ub[2*i+1]-x0cm); |
| 111 | break; |
| 112 | } |
| 113 | x0cm -= width; |
| 114 | } |
| 115 | GECODE_ME_CHECK(x1.lq(home,maxN)); |
| 116 | } |
| 117 | |
| 118 | GECODE_ME_CHECK( x0.exclude(home, |
| 119 | Limits::min, x1.min()-1) ); |
| 120 | |
| 121 | if (x1.assigned()) { |
| 122 | GECODE_ME_CHECK(x0.include(home,x1.val())); |
| 123 | GECODE_ME_CHECK(x0.exclude(home, |
| 124 | Limits::min, x1.val()-1)); |
| 125 | return home.ES_SUBSUMED(*this); |
| 126 | } |
| 127 | |
| 128 | return ES_FIX; |
nothing calls this directly
no test coverage detected