bin_packing 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/bin_packing/box.rb +6 -5
- data/lib/bin_packing/heuristics/base.rb +4 -1
- data/lib/bin_packing/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54d605afad8bf79dcfb7abb3cc589b54e2ea9ab298cb75d32570c13ecbbec7d6
|
4
|
+
data.tar.gz: d9262871c5bc9c33bf68d5c2caebc647c42fa99ea8c364b3f35bd8f6296fa636
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f860651a0707f34f385235d899dfe2b1ff2132b0f69e7e81782257d4110ad95ad1b8df90ed81c741c4a80d4cf03173149205bbdadea1f124323b1c5fe7063f
|
7
|
+
data.tar.gz: cb3ad7491d7ca39d4f90060c28d747cf0ae0156e8a342b34e7f8bc1806a858f22282fecc0cce91bb6e452ea114897ca4da1eaac1e0b8681cfe4d8f9cfcaa7143
|
data/lib/bin_packing/box.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module BinPacking
|
2
2
|
class Box
|
3
|
-
attr_accessor :width, :height, :x, :y, :packed
|
3
|
+
attr_accessor :width, :height, :x, :y, :packed, :can_rotate
|
4
4
|
|
5
5
|
def initialize(width, height)
|
6
6
|
@width = width
|
@@ -8,20 +8,21 @@ module BinPacking
|
|
8
8
|
@x = 0
|
9
9
|
@y = 0
|
10
10
|
@packed = false
|
11
|
+
@can_rotate = true
|
11
12
|
end
|
12
13
|
|
13
14
|
def area
|
14
15
|
@area ||= @width * @height
|
15
16
|
end
|
16
17
|
|
17
|
-
def rotate
|
18
|
-
@width, @height = [@height, @width]
|
19
|
-
end
|
20
|
-
|
21
18
|
def packed?
|
22
19
|
@packed
|
23
20
|
end
|
24
21
|
|
22
|
+
def can_rotate?
|
23
|
+
@can_rotate
|
24
|
+
end
|
25
|
+
|
25
26
|
def label
|
26
27
|
"#{@width}x#{@height} at [#{@x},#{@y}]"
|
27
28
|
end
|
@@ -8,7 +8,10 @@ module BinPacking
|
|
8
8
|
|
9
9
|
free_rectangles.each do |free_rect|
|
10
10
|
try_place_rect_in(free_rect, box, width, height, best_score)
|
11
|
-
|
11
|
+
|
12
|
+
if box.can_rotate?
|
13
|
+
try_place_rect_in(free_rect, box, height, width, best_score)
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
best_score
|
data/lib/bin_packing/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bin_packing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MAK IT
|
@@ -30,8 +30,10 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.0.0
|
33
|
-
description:
|
34
|
-
|
33
|
+
description: 'Provides algorithm for placing rectangles (box-es) in one or multiple
|
34
|
+
rectangular areas (bins) with reasonable allocation efficiency.
|
35
|
+
|
36
|
+
'
|
35
37
|
email: info@makit.lv
|
36
38
|
executables: []
|
37
39
|
extensions: []
|
@@ -75,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
77
|
version: '0'
|
76
78
|
requirements: []
|
77
79
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.7.6
|
79
81
|
signing_key:
|
80
82
|
specification_version: 4
|
81
83
|
summary: 2D bin packing algorithm
|