BoxPacker
First fit heuristic algorithm for 3D bin-packing with weight limit.
Version 2
For version 2 this entire solution has been rewritten with an emphasis on making a much simpler
and easier to understand implementation. However, I haven't gone to the trouble of reproducing
all the previous functionality, so if you still need that, it can be found here:
1.2.4
Installation
Add to gemfile:
gem 'box_packer'
Usage
require 'box_packer'
packings = BoxPacker.pack(
container: { dimensions: [15, 20, 13], weight_limit: 50 },
items: [
{ dimensions: [2, 3, 5], weight: 47 },
{ dimensions: [2, 3, 5], weight: 47 },
{ dimensions: [3, 3, 1], weight: 24 },
{ dimensions: [1, 1, 4], weight: 7 },
]
)
packings.length
packings[0][:weight]
packings[0][:placements].length
packings[0][:placements][0][:dimensions]
packings[0][:placements][0][:position]
packings[1][:weight]
packings[1][:placements].length
packings[1][:placements][0][:dimensions]
packings[1][:placements][0][:position]
packings[2][:weight]
packings[2][:placements].length
packings[2][:placements][0][:dimensions]
packings[2][:placements][0][:position]
packings[2][:placements][1][:dimensions]
packings[2][:placements][1][:position]