Giter Club home page Giter Club logo

box_packer's People

Contributors

alchacc avatar mushishi78 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

box_packer's Issues

typeError in container.rb?

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>'

def place not consistant with def break_up_space

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

Don't require container size

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!

Bug for tight container

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.

weird result

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]}
    ]
  }
]

Possible bug in break_up_space

Correct me if I'm wrong, but in the break_up_space method, shouldn't matching dimensions be added and subtracted?

For example:

box_packer/box_packer.rb

Lines 92 to 94 in d840a56

space[:dimensions][0],
space[:dimensions][1],
space[:dimensions][2] - placement[:dimensions][0]

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.

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.