Comments (7)
Hello
So it seems your specific example here is something of an edge case as far as the current algorithm is concerned - as you can see in the debug log, the algorithm starts off by deciding that a "rotated" packing is the best way to fit each item which does seem correct. However, after the first few items are packed, the space left is a 165x165 square, and at that point the heuristics switch to deciding that an "unrotated" packing is the best use of the available space (the packing is done item-by-item, with little consideration of what comes next).
I spent some time earlier trying out an approach that would ensure more consistency in orientation of consistently sized items like in your testcase, however although that improved the packing in this case, and in some of my other test samples, it regressed the efficiency in more than it improved.
I'll keep this open though and will try out and figure out a way to detect when consistent orientation is likely to help, and when it won't.
from boxpacker.
Hello. I found that VolumePacker's algorithm does not correctly calculate layer's remaining space. Here is an example. Box size: 23.6875 x 11.75 x 3 inch. Trying to pack 9 items with size: 6.5 x 3.75 x 3 inch. So, this is 2D packaging by the only layer. As you can see, this box could perfectly fit 9 unrotated items: 6.5" x 3pcs = 19.5" < 23.6875", and 3.75" x 3pcs = 11.25" < 11.75", so 3pcs x 3pcs = 9pcs.
I'm attaching VolumePacker log and picture of packaging process. The fourth item packed rotated and on the next step the remaining layer's space calculated incorrectly (by remaining width — 5.25).
from boxpacker.
@RobinTail, just to clarify, the maths seems right here to me - having decided (perhaps non-optimally) to pack box 4 rotated alongside box 3 instead of starting a new row, the space left for row 2 is indeed (11.25-6.5)=5.25
from boxpacker.
@RobinTail, can I check what version of BoxPacker you're using? I created a testcase for this and ran it against 1.5.2 and it produced a 3x3 output like you were expecting.
[2016-05-30 15:57:29] log.INFO: added box Box [] []
[2016-05-30 15:57:29] log.INFO: added 9 x Item [] []
[2016-05-30 15:57:29] log.DEBUG: [EVALUATING BOX] Box [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 23.6875, length: 11.75, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 0, layerLength: 0, layerDepth: 0 [] []
[2016-05-30 15:57:29] log.DEBUG: fits (better) unrotated [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 23.6875, length: 8, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 6.5, layerLength: 3.75, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: fits (better) unrotated [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 23.6875, length: 4.25, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 6.5, layerLength: 7.5, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: fits (better) unrotated [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 23.6875, length: 0.5, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 6.5, layerLength: 11.25, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: No more fit in lengthwise, resetting for new row [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 17.1875, length: 11.75, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 0, layerLength: 0, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: fits (better) unrotated [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 17.1875, length: 8, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 6.5, layerLength: 3.75, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: fits (better) unrotated [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 17.1875, length: 4.25, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 6.5, layerLength: 7.5, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: fits (better) unrotated [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 17.1875, length: 0.5, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 6.5, layerLength: 11.25, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: No more fit in lengthwise, resetting for new row [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 10.6875, length: 11.75, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 0, layerLength: 0, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: fits (better) unrotated [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 10.6875, length: 8, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 6.5, layerLength: 3.75, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: fits (better) unrotated [] []
[2016-05-30 15:57:29] log.DEBUG: evaluating item Item [] []
[2016-05-30 15:57:29] log.DEBUG: remaining width: 10.6875, length: 4.25, depth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: layerWidth: 6.5, layerLength: 7.5, layerDepth: 3 [] []
[2016-05-30 15:57:29] log.DEBUG: fits (better) unrotated [] []
[2016-05-30 15:57:29] log.DEBUG: done with this box [] []
[2016-05-30 15:57:29] log.INFO: packing completed, 1 boxes [] []
from boxpacker.
@dvdoug i'm on commit ca74d34
Also, i'm using Length as the longest dimension for Box and Item.
from boxpacker.
@dvdoug I've downloaded version 1.5.2 and wrote my own test :)
Here is the code inside PackerTest.php, that fails on version 1.5.2
public function testRobin() {
$box = new TestBox('Large Flat Rate Game Box', 11.75, 23.6875, 3, 0, 11.75, 23.6875, 3, 70);
$item = new TestItem('Coffee', 3.75, 6.5, 3, 1.26);
$packer = new Packer();
$packer->addBox($box);
$packer->addItem($item, 9);
$result = $packer->pack();
self::assertEquals(count($result), 1);
}
from boxpacker.
@RobinTail, FYI this works as you expect in this case if you swap the dimensions of the coffee around - 6.5x3.75. However, a global assumption in packing that length/width is the smaller/bigger dimension seems to be harmful to efficiency on a wider scale.
I need to ponder....
from boxpacker.
Related Issues (20)
- Is something wrong with single-product packaging with multiple boxes HOT 5
- Partitioned Boxes HOT 3
- Optimize box suggestion by box cost? HOT 1
- Unexpected box packing result HOT 3
- Its not compatible with php 8.1 version HOT 4
- Spaces between items HOT 2
- Request for Information on Streamlining Product Packing HOT 17
- Can't initialize class (not found). Composer problem? HOT 1
- Problem stacking boxes using BestFit HOT 4
- Uncaught Error: Class "DVDoug\BoxPacker\Test\TestBox" not found (composer/3.12.0)
- Optimizer error HOT 5
- does it has a web service interface ? HOT 1
- Separate Visualiser and BoxPacker
- $packedBoxes only contains one box HOT 2
- Uncaught Error - Classes not found? HOT 1
- Item interface and description property HOT 1
- Feature request: Support for decimals / floating point values HOT 2
- More emphasis on box emptyWeight HOT 1
- Not optimal packing in a box HOT 7
- Diagonal rotations HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boxpacker.