GithubHelp home page GithubHelp logo

Not packing optimally about boxpacker HOT 7 CLOSED

dvdoug avatar dvdoug commented on August 26, 2024
Not packing optimally

from boxpacker.

Comments (7)

dvdoug avatar dvdoug commented on August 26, 2024

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.

RobinTail avatar RobinTail commented on August 26, 2024

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).

image

from boxpacker.

dvdoug avatar dvdoug commented on August 26, 2024

@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.

dvdoug avatar dvdoug commented on August 26, 2024

@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.

RobinTail avatar RobinTail commented on August 26, 2024

@dvdoug i'm on commit ca74d34
Also, i'm using Length as the longest dimension for Box and Item.

from boxpacker.

RobinTail avatar RobinTail commented on August 26, 2024

@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.

dvdoug avatar dvdoug commented on August 26, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.