mushishi78 / box_packer Goto Github PK
View Code? Open in Web Editor NEW3D bin packing algorithm
License: MIT License
3D bin packing algorithm
License: MIT License
I cloned & installed the gem, but I'm having some trouble getting the examples to run. Here's the console output for the first example:
true
2
false
(5,0,0)
/Users/neal/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/box_packer-1.2.1/lib/box_packer/container.rb:58:in `to_s': no implicit conversion of true into String (TypeError)
from b.rb:14:in `puts'
from b.rb:14:in `puts'
from b.rb:14:in `block in <main>'
from /Users/neal/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/box_packer-1.2.1/lib/box_packer/container.rb:17:in `instance_exec'
from /Users/neal/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/box_packer-1.2.1/lib/box_packer/container.rb:17:in `initialize'
from /Users/neal/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/box_packer-1.2.1/lib/box_packer/container.rb:3:in `new'
from /Users/neal/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/box_packer-1.2.1/lib/box_packer/container.rb:3:in `container'
from b.rb:3:in `<main>'
Hi,
I have an issue with 2.0.0 l.28 in box_packer.rb
place
returns an array of array of int but break_up_space
expects a hash.
space = "{:dimensions=>[11, 11, 1], :position=>[10, 0, 0]}"
item = "{:dimensions=>[10, 6, 2], :weight=>50}"
# placement = place(item, space) returns "[[10, 6, 2], [10, 2, 6], [6, 10, 2], [6, 2, 10], [2, 10, 6], [2, 6, 10]]"
break_up_space(space, place(item, space))
Given a set of items, is there a way to calculate the smallest container that would hold all of them using this gem?
Really cool gem btw!
Hi,
I don't understand why Boxpacker is not able to pack those items into the container.
require 'box_packer'
BoxPacker.container [12, 10, 10], packings_limit: 1 do
add_item [6,6,6]
add_item [10,10,6]
pack!
puts packed_successfully # false
end
It's working with [12, 12, 12] container.
Hi @mushishi78
Please check this case:
packings = BoxPacker.pack(
container: { dimensions: [15, 20, 13], weight_limit: 50 },
items: [
{ dimensions: [2, 3, 5], weight: 1 },
{ dimensions: [2, 3, 5], weight: 1 },
{ dimensions: [3, 3, 1], weight: 1 },
{ dimensions: [1, 1, 4], weight: 1 },
]
)
I expect the result should be
expect(packings.length).to eql(1)
expect(packings[0][:placements].length).to eql(4)
Right?
But the packing result I got is
[
{ :placements=>
[
{:dimensions=>[5, 3, 2], :position=>[0, 0, 0], :weight=>1 },
{:dimensions=>[5, 3, 2], :position=>[5, 0, 0], :weight=>1 }
],
:weight=>2,
:spaces=>
[
{:dimensions=>[5, 15, 10], :position=>[0, 3, 0]},
{:dimensions=>[5, 3, 11], :position=>[0, 0, 2]},
{:dimensions=>[20, 15, 3], :position=>[10, 0, 0]},
{:dimensions=>[5, 15, 5], :position=>[5, 3, 0]},
{:dimensions=>[5, 3, 6], :position=>[5, 0, 2]}
]
}
]
Correct me if I'm wrong, but in the break_up_space
method, shouldn't matching dimensions be added and subtracted?
For example:
Lines 92 to 94 in d840a56
Shouldn't this rather be
space[:dimensions][0] - placement[:dimensions][0],
space[:dimensions][1],
space[:dimensions][2]
I created a pull request, but it has an additional change that may not be desired behaviour.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.