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

Method propagate

gecode/int/bin-packing/propagate.cpp:112–357  ·  view source on GitHub ↗

* Propagation proper * */

Source from the content-addressed store, hash-verified

110 *
111 */
112 ExecStatus
113 Pack::propagate(Space& home, const ModEventDelta& med) {
114 // Number of items
115 int n = bs.size();
116 // Number of bins
117 int m = l.size();
118
119 Region region;
120 {
121
122 // Possible sizes for bins
123 int* s = region.alloc<int>(m);
124
125 for (int j=0; j<m; j++)
126 s[j] = 0;
127
128 // Compute sizes for bins
129 if (OffsetView::me(med) == ME_INT_VAL) {
130 // Also eliminate assigned items
131 int k=0;
132 for (int i=0; i<n; i++)
133 if (bs[i].assigned()) {
134 int j = bs[i].bin().val();
135 l[j].offset(l[j].offset() - bs[i].size());
136 t -= bs[i].size();
137 } else {
138 for (ViewValues<IntView> j(bs[i].bin()); j(); ++j)
139 s[j.val()] += bs[i].size();
140 bs[k++] = bs[i];
141 }
142 n=k; bs.size(n);
143 } else {
144 for (int i=0; i<n; i++) {
145 assert(!bs[i].assigned());
146 for (ViewValues<IntView> j(bs[i].bin()); j(); ++j)
147 s[j.val()] += bs[i].size();
148 }
149 }
150
151 // Propagate bin loads and compute lower and upper bound
152 int min = t, max = t;
153 for (int j=0; j<m; j++) {
154 GECODE_ME_CHECK(l[j].gq(home,0));
155 GECODE_ME_CHECK(l[j].lq(home,s[j]));
156 min -= l[j].max(); max -= l[j].min();
157 }
158
159 // Propagate that load must be equal to total size
160 for (bool mod = true; mod; ) {
161 mod = false; ModEvent me;
162 for (int j=0; j<m; j++) {
163 int lj_min = l[j].min();
164 me = l[j].gq(home, min + l[j].max());
165 if (me_failed(me))
166 return ES_FAILED;
167 if (me_modified(me)) {
168 max += lj_min - l[j].min(); mod = true;
169 }

Callers

nothing calls this directly

Calls 15

jFunction · 0.85
me_failedFunction · 0.85
me_modifiedFunction · 0.85
SizeSetMinusOneClass · 0.85
binMethod · 0.80
ES_SUBSUMEDMethod · 0.80
minusMethod · 0.80
maxFunction · 0.50
sizeMethod · 0.45
assignedMethod · 0.45
valMethod · 0.45
offsetMethod · 0.45

Tested by

no test coverage detected