Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanf committed Feb 17, 2020
0 parents commit 280e4a0
Show file tree
Hide file tree
Showing 13,886 changed files with 2,013,731 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --cxxopt='-std=c++14' --compilation_mode=opt
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data/* linguist-vendored
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bazel-*
.vscode
checker/checker
checker/logs/*
log*
checker/*
OLD
instances/*
output/*
12 changes: 12 additions & 0 deletions .ycm_extra_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def Settings( **kwargs ):
return {
'flags': [
'-x', 'c++',
'-Wall', '-Wextra', '-Werror',
'-I', '.',
'-I', './bazel-packingsolver/external/json/single_include',
'-I', './bazel-packingsolver/external/googletest/googletest-release-1.8.0/googletest/include/',
'-I', './bazel-packingsolver/external/',
],
}

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Florian Fontan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# PackingSolver

A state-of-the-art tree search based solver for (geometrical) Packing Problems.

Only rectangle two- and three staged guillotine variants have been implemented yet.

![Example](example.png?raw=true "Example")

* Code author: Florian Fontan
* Algorithm design: [Luc Libralesso](https://github.com/librallu), Florian Fontan

For commercial support, custom developments or industrial collaboration, please do not hesitate to contact me (Florian Fontan).
For academic collaboration, please do not hesitate to contact Luc Libralesso.

## Usage

Note: PackingSolver favours efficiency and flexibility over ease of use. Therefore, some knowledge about tree search algorithms and packing problems is required in order to use it.

Compile:
```shell
bazel build -- //...
```

Execute:
```shell
./bazel-bin/packingsolver/main -v \
--problem-type rectangleguillotine \
--objective knapsack \
--items data/rectangle/alvarez2002/ATP30_items.csv \
--bins data/rectangle/alvarez2002/ATP30_bins.csv \
--certificate ATP30_solution.csv \
--output ATP30_output.json \
--time-limit 2 \
-q "RG -p 3NHO -s 2" -a "MBA* -f 1.5 -c 4" \
-q "RG -p 3NHO -s 3" -a "MBA* -f 1.5 -c 4"
```

Problem types: `rectangleguillotine` (`RG`)

The problem type defines the the certificate format.
Each problem type has a list of available objectives and a list of available branching schemes.

Each branching scheme has a list a compatible algorithms.

Each pair `-q`/`-a` respectively defines the branching scheme and the algorithm for a thread.

Options `--bin-infinite-copies`, `--bin-infinite-width`, `--bin-infinite-height` and `--unweighted` are available to modify the instance properties.

### Problem type rectangleguillotine (RG)

* Available objectives: `default`, `bin-packing` (`BPP`), `knapsack` (`KP`), `strip-packing` (`SPP`), `bin-packing-with-leftovers` (`BPPL`)
* Available branching schemes: `rectangle-guillotine` (`RG`)

### Branching scheme rectangle-guillotine (RG)

options:
* `--cut-type-1`: `three-staged-guillotine`, `two-staged-guillotine`
* `--cut-type-2`: `roadef2018`, `non-exact`, `exact`, `homogenous`
* `--first-stage-orientation`: `vertical`, `horizontal`, `any`
* `--min1cut`, `--max1cut`, `--min2cut`, `--max2cut`: positive integer
* `--min-waste`: positive integer
* `--no-item-rotation`
* `--cut-through-defects`
* `--symmetry`, `-s`: 1, 2, 3 or 4
* `--no-symmetry-2`
* `-p`: predefined configurations. Examples:
* `3RVR`: `--cut-type-1 three-staged-guillotine --cut-type-2 roadef2018 --first-stage-orientation vertical`
* `2NHO`: `--cut-type-1 two-staged-guillotine --cut-type-2 non-exact --first-stage-orientation horizontal --no-item-rotation`
* `3EAR`: `--cut-type-1 three-staged-guillotine --cut-type-2 exact --first-stage-orientation any`
* `roadef2018`

Compatible algorithms: `A*`, `DFS`, `MBA*`, `DPA*`

## Benchmarks

The performances of PackingSolver have been compared to all published results from the scientific literature on corresponding Packing Problems.
Detailed results are available in `results.ods`.
`output.7z` contains all output files and solutions.

Do not hesitate to contact us if you are aware of any variant or article that we missed.

All experiments can be reproduced using the following scripts:
```shell
./packingsolver/scripts/bench "roadef2018_A" "roadef2018_B" "roadef2018_X" # ~50h
./packingsolver/scripts/bench "3NEGH-BPP-O" "3NEGH-BPP-R" "3GH-BPP-O" "3HGV-BPP-O" # ~30h
./packingsolver/scripts/bench "2NEGH-BPP-O" "2NEGH-BPP-R" "2GH-BPP-O" # ~30h
./packingsolver/scripts/bench "3NEG-KP-O" "3NEG-KP-R" "3NEGV-KP-O" "3HG-KP-O" # ~10h
./packingsolver/scripts/bench "2NEG-KP-O" "2NEGH-KP-O" "2NEGV-KP-O" "2NEGH-KP-R" "2G-KP-O" "2GH-KP-O" "2GV-KP-O" # 1h
./packingsolver/scripts/bench "3NEGH-SPP-O" "3NEGH-SPP-R" # ~10h
./packingsolver/scripts/bench "2NEGH-SPP-O" # ~2h
```

53 changes: 53 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository")

http_archive(
name = "googletest",
build_file_content = """
cc_library(
name = "gtest",
srcs = ["googletest-release-1.8.0/googletest/src/gtest-all.cc", "googletest-release-1.8.0/googlemock/src/gmock-all.cc",],
hdrs = glob(["**/*.h", "googletest-release-1.8.0/googletest/src/*.cc", "googletest-release-1.8.0/googlemock/src/*.cc",]),
includes = ["googletest-release-1.8.0/googlemock", "googletest-release-1.8.0/googletest", "googletest-release-1.8.0/googletest/include", "googletest-release-1.8.0/googlemock/include",],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
)
cc_library(
name = "gtest_main",
srcs = ["googletest-release-1.8.0/googlemock/src/gmock_main.cc"],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
deps = [":gtest"],
)
""",
url = "https://github.com/google/googletest/archive/release-1.8.0.zip",
sha256 = "f3ed3b58511efd272eb074a3a6d6fb79d7c2e6a0e374323d1e6bcbcc1ef141bf",
)

http_archive(
name = "json",
build_file_content = """
cc_library(
name = "json",
hdrs = ["single_include/nlohmann/json.hpp"],
visibility = ["//visibility:public"],
strip_include_prefix = "single_include/"
)
""",
urls = ["https://github.com/nlohmann/json/releases/download/v3.7.3/include.zip"],
sha256 = "87b5884741427220d3a33df1363ae0e8b898099fbc59f1c451113f6732891014",
)

git_repository(
name = "benchtools",
remote = "https://github.com/fontanf/benchtools.git",
commit = "fe56ed683d32f70cd248d77cd4107e57eee05758",
shallow_since = "1576623294 +0100",
)

local_repository(
name = "benchtools_",
path = "/home/florian/Dev/benchtools/",
)

6 changes: 6 additions & 0 deletions data/rectangle/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
filegroup(
name = "rectangle",
srcs = glob(["**/*.csv"]),
visibility = ["//visibility:public"],
)

2 changes: 2 additions & 0 deletions data/rectangle/alvarez2002/ATP30_bins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ID,WIDTH,HEIGHT
0,927,152
39 changes: 39 additions & 0 deletions data/rectangle/alvarez2002/ATP30_items.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ID,WIDTH,HEIGHT,COPIES
0,324,27,9
1,111,20,8
2,358,13,6
3,74,43,6
4,190,19,3
5,178,37,2
6,254,21,7
7,57,31,3
8,110,7,6
9,172,25,5
10,158,39,9
11,311,39,4
12,158,18,7
13,69,32,6
14,59,28,5
15,345,23,7
16,210,13,5
17,339,20,9
18,332,24,2
19,104,46,3
20,138,12,7
21,212,32,5
22,320,40,1
23,174,14,2
24,343,37,1
25,139,40,3
26,157,19,3
27,360,58,4
28,337,19,6
29,59,55,3
30,319,53,3
31,215,7,7
32,238,14,6
33,243,32,4
34,213,18,6
35,214,34,4
36,328,50,6
37,205,32,9
2 changes: 2 additions & 0 deletions data/rectangle/alvarez2002/ATP31_bins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ID,WIDTH,HEIGHT
0,856,964
52 changes: 52 additions & 0 deletions data/rectangle/alvarez2002/ATP31_items.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ID,WIDTH,HEIGHT,COPIES
0,290,350,4
1,328,292,3
2,240,206,1
3,246,126,9
4,250,279,7
5,71,353,9
6,67,127,9
7,209,275,1
8,317,264,6
9,119,228,2
10,331,50,4
11,138,163,7
12,60,339,2
13,187,298,1
14,73,104,7
15,164,123,8
16,250,189,5
17,228,143,5
18,154,345,5
19,70,297,4
20,198,376,8
21,170,100,7
22,295,292,6
23,238,177,7
24,195,187,3
25,252,132,5
26,313,148,6
27,175,162,6
28,44,206,5
29,164,366,6
30,161,339,9
31,62,81,5
32,304,165,2
33,284,302,6
34,261,376,6
35,183,80,4
36,224,163,2
37,212,366,8
38,46,75,6
39,66,158,5
40,179,207,7
41,314,98,2
42,96,107,1
43,320,380,3
44,211,82,3
45,252,53,6
46,74,183,6
47,274,72,1
48,65,240,7
49,229,321,4
50,265,280,7
2 changes: 2 additions & 0 deletions data/rectangle/alvarez2002/ATP32_bins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ID,WIDTH,HEIGHT
0,307,124
57 changes: 57 additions & 0 deletions data/rectangle/alvarez2002/ATP32_items.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
ID,WIDTH,HEIGHT,COPIES
0,99,18,2
1,80,17,2
2,67,16,2
3,70,44,2
4,23,36,2
5,51,16,2
6,58,8,9
7,53,25,3
8,98,19,6
9,117,21,1
10,52,11,3
11,77,41,2
12,72,27,9
13,92,35,7
14,81,46,6
15,23,18,4
16,64,21,1
17,99,37,1
18,47,34,5
19,109,32,2
20,95,37,7
21,96,29,7
22,105,19,8
23,105,13,1
24,46,19,8
25,55,42,5
26,95,43,6
27,42,6,2
28,49,42,1
29,26,10,2
30,28,19,5
31,59,9,2
32,16,14,5
33,99,37,7
34,55,45,8
35,51,20,7
36,29,26,7
37,39,15,5
38,99,15,8
39,47,39,4
40,84,14,5
41,106,12,6
42,32,14,7
43,72,33,7
44,52,21,2
45,51,26,5
46,62,23,1
47,100,29,4
48,68,32,1
49,37,27,3
50,51,13,4
51,19,30,6
52,60,22,2
53,64,9,4
54,118,28,8
55,120,24,8
2 changes: 2 additions & 0 deletions data/rectangle/alvarez2002/ATP33_bins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ID,WIDTH,HEIGHT
0,241,983
Loading

0 comments on commit 280e4a0

Please sign in to comment.