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

Method print

examples/bin-packing.cpp:515–541  ·  view source on GitHub ↗

Print solution

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
assignedMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected