Print solution
| 513 | } |
| 514 | /// Print solution |
| 515 | virtual void |
| 516 | print(std::ostream& os) const { |
| 517 | int n = bin.size(); |
| 518 | int m = load.size(); |
| 519 | os << "Bins used: " << bins << " (from " << m << " bins)." << std::endl; |
| 520 | for (int j=0; j<m; j++) { |
| 521 | bool fst = true; |
| 522 | os << "\t[" << j << "]={"; |
| 523 | for (int i=0; i<n; i++) |
| 524 | if (bin[i].assigned() && (bin[i].val() == j)) { |
| 525 | if (fst) { |
| 526 | fst = false; |
| 527 | } else { |
| 528 | os << ","; |
| 529 | } |
| 530 | os << i; |
| 531 | } |
| 532 | os << "} #" << load[j] << std::endl; |
| 533 | } |
| 534 | if (!bin.assigned()) { |
| 535 | os << std::endl |
| 536 | << "Unpacked items:" << std::endl; |
| 537 | for (int i=0;i<n; i++) |
| 538 | if (!bin[i].assigned()) |
| 539 | os << "\t[" << i << "] = " << bin[i] << std::endl; |
| 540 | } |
| 541 | } |
| 542 | }; |
| 543 | |
| 544 | /** \brief Main-function |