Skip to content

Commit

Permalink
25% overhang seems too much
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Aug 10, 2013
1 parent 42a3773 commit 17d0176
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Packer.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function packBox(Box $aBox, ItemList $aItems) {

$fitsSameGap = min($remainingWidth - $itemWidth, $remainingLength - $itemLength);
$fitsRotatedGap = min($remainingWidth - $itemLength, $remainingLength - $itemWidth);
$notTooMuchShallower = ($layerDepth ? $aItems->top()->getDepth() > ($layerDepth * 0.75) : true);
$notTooMuchShallower = ($layerDepth ? $aItems->top()->getDepth() > ($layerDepth * 0.9) : true);

if ($notTooMuchShallower && $fitsSameGap >= 0 && $fitsRotatedGap < 0) {
$this->logger->debug("fits only without rotation");
Expand Down Expand Up @@ -215,8 +215,8 @@ public function packBox(Box $aBox, ItemList $aItems) {
$this->logger->debug("doesn't fit at all");

if ($layerWidth) {
$remainingWidth = min(floor($layerWidth * 1.25), $horizontalDimensions[0]);
$remainingLength = min(floor($layerLength * 1.25), $horizontalDimensions[1]);
$remainingWidth = min(floor($layerWidth * 1.1), $horizontalDimensions[0]);
$remainingLength = min(floor($layerLength * 1.1), $horizontalDimensions[1]);
$layerWidth = 0;
$layerLength = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Principles
* Pack largest (by volume) items first
* Pack vertically up the side of the box
* Pack side-by-side of where item under consideration fits alongside the previous item
* Only very small overhangs are allowed (25%) to prevent items bending in transit
* Only very small overhangs are allowed (10%) to prevent items bending in transit
* The available width/height for each layer will therefore decrease as the stack of items gets taller
* [TODO] If more then 1 box is needed to accommodate all of the items, then aim for
boxes of roughly equal weight
Expand Down
4 changes: 2 additions & 2 deletions tests/PackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ public function testPackThreeItemsBottom2FitSideBySideWithSpareSpaceOneOverhangS

$items = new ItemList;
$items->insert(new TestItem('Item 1', 200, 200, 4, 200));
$items->insert(new TestItem('Item 2', 120, 120, 4, 200));
$items->insert(new TestItem('Item 3', 120, 120, 4, 200));
$items->insert(new TestItem('Item 2', 110, 110, 4, 200));
$items->insert(new TestItem('Item 3', 110, 110, 4, 200));

$packer = new Packer();
$packedItems = $packer->packBox($box, $items);
Expand Down

0 comments on commit 17d0176

Please sign in to comment.