redistributeWeight() public method

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
return DVDoug\BoxPacker\PackedBoxList
Example #1
0
 /**
  * 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;
 }