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

Method post

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

Source from the content-addressed store, hash-verified

357 }
358
359 ExecStatus
360 Pack::post(Home home, ViewArray<OffsetView>& l, ViewArray<Item>& bs) {
361 // Sort according to size
362 Support::quicksort(&bs[0], bs.size());
363 // Total size of items
364 int s = 0;
365 // Constrain bins
366 for (int i=0; i<bs.size(); i++) {
367 s += bs[i].size();
368 GECODE_ME_CHECK(bs[i].bin().gq(home,0));
369 GECODE_ME_CHECK(bs[i].bin().le(home,l.size()));
370 }
371 // Eliminate zero sized items (which are at the end as the size are sorted)
372 {
373 int n = bs.size();
374 while ((n > 0) && (bs[n-1].size() == 0))
375 n--;
376 bs.size(n);
377 }
378 if (bs.size() == 0) {
379 // No items to be packed
380 for (int i=0; i<l.size(); i++)
381 GECODE_ME_CHECK(l[i].eq(home,0));
382 return ES_OK;
383 } else if (l.size() == 0) {
384 // No bins available
385 return ES_FAILED;
386 } else {
387 // Constrain load
388 for (int j=0; j<l.size(); j++) {
389 GECODE_ME_CHECK(l[j].gq(home,0));
390 GECODE_ME_CHECK(l[j].lq(home,s));
391 }
392 (void) new (home) Pack(home,l,bs);
393 return ES_OK;
394 }
395 }
396
397}}}
398

Callers

nothing calls this directly

Calls 7

quicksortFunction · 0.85
binMethod · 0.80
sizeMethod · 0.45
gqMethod · 0.45
leMethod · 0.45
eqMethod · 0.45
lqMethod · 0.45

Tested by

no test coverage detected