Given a solution set of packed boxes, repack them to achieve optimum weight distribution
public redistributeWeight ( DVDoug\BoxPacker\PackedBoxList $originalBoxes ) : DVDoug\BoxPacker\PackedBoxList | ||
$originalBoxes | DVDoug\BoxPacker\PackedBoxList | |
리턴 | DVDoug\BoxPacker\PackedBoxList |
/** * Pack items into boxes * * @throws \RuntimeException * @return PackedBoxList */ public function pack() { $packedBoxes = $this->doVolumePacking(); //If we have multiple boxes, try and optimise/even-out weight distribution if ($packedBoxes->count() > 1) { $redistributor = new WeightRedistributor($this->boxes); $redistributor->setLogger($this->logger); $packedBoxes = $redistributor->redistributeWeight($packedBoxes); } $this->logger->log(LogLevel::INFO, "packing completed, {$packedBoxes->count()} boxes"); return $packedBoxes; }