diff --git a/src/OrientatedItemFactory.php b/src/OrientatedItemFactory.php index bbcf2388..e3e9a868 100644 --- a/src/OrientatedItemFactory.php +++ b/src/OrientatedItemFactory.php @@ -286,8 +286,6 @@ protected function calculateAdditionalItemsPackedWithThisOrientation( int $depthLeft, int $currentRowLengthBeforePacking ): int { - $packedCount = 0; - $currentRowLength = max($prevItem->getLength(), $currentRowLengthBeforePacking); $itemsToPack = $nextItems->topN(8); // cap lookahead as this gets recursive and slow @@ -337,9 +335,10 @@ protected function calculateAdditionalItemsPackedWithThisOrientation( $itemsToPack->remove($packedItem->getItem()); } + $packedCount = $nextItems->count() - $itemsToPack->count(); $this->logger->debug('Lookahead with orientation', ['packedCount' => $packedCount, 'orientatedItem' => $prevItem]); - static::$lookaheadCache[$cacheKey] = $nextItems->count() - $itemsToPack->count(); + static::$lookaheadCache[$cacheKey] = $packedCount; } return static::$lookaheadCache[$cacheKey]; diff --git a/src/VolumePacker.php b/src/VolumePacker.php index a32154e7..99f4fa05 100644 --- a/src/VolumePacker.php +++ b/src/VolumePacker.php @@ -110,6 +110,7 @@ public function __construct(Box $box, ItemList $items) } $this->orientatedItemFactory = new OrientatedItemFactory($this->box); + $this->orientatedItemFactory->setLogger($this->logger); } /** @@ -151,7 +152,7 @@ public function pack(): PackedBox $this->stabiliseLayers(); } - $this->logger->debug('done with this box'); + $this->logger->debug('done with this box ' . $this->box->getReference()); return new PackedBox($this->box, $this->getPackedItemList()); } @@ -233,6 +234,7 @@ protected function packLayer(int $startDepth, int $widthLeft, int $lengthLeft, i public function stabiliseLayers(): void { $stabiliser = new LayerStabiliser(); + $stabiliser->setLogger($this->logger); $this->layers = $stabiliser->stabilise($this->layers); } diff --git a/src/WorkingVolume.php b/src/WorkingVolume.php index ab5ef992..1631005a 100644 --- a/src/WorkingVolume.php +++ b/src/WorkingVolume.php @@ -53,7 +53,7 @@ public function __construct( public function getReference(): string { - return 'Working Volume'; + return "Working Volume {$this->width}x{$this->length}x{$this->depth}"; } public function getOuterWidth(): int