0.03
No commit activity in last 3 years
No release in over 3 years
3D bin-packing with weight limit using first-fit decreasing algorithm and empty maximal spaces
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 3.1.0, ~> 3.1
 Project Readme

EasyBoxPacker

Ref from box_packer

and inspired by A genetic algorithm for the three-dimensional bin packing problem with heterogeneous bins and A New Heuristic Algorithm for the 3D Bin Packing Problem

Installation

Add to gemfile:

gem  'easy-box-packer'

Usage

Check all items can be packed in a container

require 'easy-box-packer'

cont = EasyBoxPacker.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 },
  ]
)

cont[:packings].length # 3
cont[:packings][0][:weight] # 47
cont[:packings][0][:placements].length # 1
cont[:packings][0][:placements][0][:dimensions] # [2, 3, 5]
cont[:packings][0][:placements][0][:position] # [0, 0, 0]
cont[:packings][1][:weight] # 47
cont[:packings][1][:placements].length # 1
cont[:packings][1][:placements][0][:dimensions] # [2, 3, 5]
cont[:packings][1][:placements][0][:position] # [0, 0, 0]
cont[:packings][2][:weight] # 31
cont[:packings][2][:placements].length # 2
cont[:packings][2][:placements][0][:dimensions] # [1, 3, 3]
cont[:packings][2][:placements][0][:position] # [0, 0, 0]
cont[:packings][2][:placements][1][:dimensions] # [4, 1, 1]
cont[:packings][2][:placements][1][:position] # [3, 0, 0]

Get a reasonable smallest container by given boxes

container = EasyBoxPacker.find_smallest_container(
    items: Array.new(1000) {{ dimensions: [1, 1, 1] }}
  )
container # [10, 10, 10]