Packing differently sized chunks of data into multiple bins

Posted by knizz on Stack Overflow See other posts from Stack Overflow or by knizz
Published on 2010-12-23T18:24:12Z Indexed on 2010/12/23 18:54 UTC
Read the original article Hit count: 271

Filed under:
|
|

EDIT: It seems like this problem is called "Cutting stock problem"

I need an algorithm that gives me the (space-)optimal arrangement of chunks in bins. One way would be put the bigger chunks in first. But see how that algorithm fails in this example:

Chunks        Bins
-----------------------------
AAA BBB CC DD (       ) (   )

Algorithm     Result
-----------------------------
biggest first (AAABBB ) (CC )
optimal       (AAACCDD) (BBB)

"Biggest first" can't fit in DD. Maybe it helps to build a table like this:

Size 1: ---
Size 2: CC, DD
Size 3: AAA, BBB

Size 4: CCDD
Size 5: AAACC, AAADD, BBBCC, BBBDD
Size 6: AAABBB

Size 7: AAACCDD, BBBCCDD
Size 8: AAABBBCC, AAABBBDD
Size 10: AAABBBCCDD

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about packing

  • 2D packing with obstacles

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Anybody know of an efficient algorithm for moving rectangles in a square which contains obstacles? Rectangles: can rotate can move must not collide with obstacles (black squares) Obstacles: can't be moved can be added anywhere Goal: move rectangles until you can >>> More

  • C/C++ packing signed char into int

    as seen on Stack Overflow - Search for 'Stack Overflow'
    hello I have need to pack four signed bytes into 32-bit integral type. this is what I came up to: int byte(char c) { return (unsigned char)c; } int pack(char c0, char c1, ...) { return byte(c0) | byte(c1) << 8 | ...; } is this a good solution? Is it portable? is there a ready-made solution… >>> More

  • Packing a DBF

    as seen on Geeks with Blogs - Search for 'Geeks with Blogs'
    I thought my days of dealing with DBFs as a "production data" source were over, but HA (no such luck). I recently had to retrieve, modify and replace some data that needed to be delivered in a DBF file. Everything was fine until I realized / remembered the DBF driver does not ACTUALLY delete records… >>> More

  • Packing a DBF

    as seen on Geeks with Blogs - Search for 'Geeks with Blogs'
    I thought my days of dealing with DBFs as a "production data" source were over, but HA (no such luck). I recently had to retrieve, modify and replace some data that needed to be delivered in a DBF file. Everything was fine until I realized / remembered the DBF driver does not ACTUALLY delete records… >>> More

  • Bin packing part 6: Further improvements

    as seen on SQL Blog - Search for 'SQL Blog'
    In part 5 of my series on the bin packing problem, I presented a method that sits somewhere in between the true row-by-row iterative characteristics of the first three parts and the truly set-based approach of the fourth part. I did use iteration, but each pass through the loop would use a set-based… >>> More