Return choice
| 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; |