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

Method choice

examples/steel-mill.cpp:395–423  ·  view source on GitHub ↗

Return choice

Source from the content-addressed store, hash-verified

393 }
394 /// Return choice
395 virtual Gecode::Choice* choice(Space& home) {
396 SteelMill& sm = static_cast<SteelMill&>(home);
397 assert(!sm.slab[start].assigned());
398 // Find order with a) minimum size, b) largest weight
399 unsigned int size = sm.norders;
400 int weight = 0;
401 unsigned int pos = start;
402 for (unsigned int i = start; i<sm.norders; ++i) {
403 if (!sm.slab[i].assigned()) {
404 if (sm.slab[i].size() == size &&
405 sm.orders[i][order_weight] > weight) {
406 weight = sm.orders[i][order_weight];
407 pos = i;
408 } else if (sm.slab[i].size() < size) {
409 size = sm.slab[i].size();
410 weight = sm.orders[i][order_weight];
411 pos = i;
412 }
413 }
414 }
415 unsigned int val = sm.slab[pos].min();
416 // Find first still empty slab (all such slabs are symmetric)
417 unsigned int firstzero = 0;
418 while (firstzero < sm.nslabs && sm.slabload[firstzero].min() > 0)
419 ++firstzero;
420 assert(pos < sm.nslabs &&
421 val < sm.norders);
422 return new Choice(*this, (val<firstzero) ? 2 : 1, pos, val);
423 }
424 virtual Choice* choice(const Space&, Archive& e) {
425 unsigned int alt; int pos, val;
426 e >> alt >> pos >> val;

Callers

nothing calls this directly

Calls 3

assignedMethod · 0.45
sizeMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected