A hyper-heuristic approach on solving the 2D bin packing problem
Project description
Problem description
The hyperpack library is an API for solving instances of the 2D Binpacking problem. Many different variations can be created and solved, accordind to the instantiation data.
The library is multiprocessing enabled to minize execution times and utilizes only pure python, making the package dependency free.
- The solvable variants can be summarized in the below characteristics:
Any number and sizes of (rectangular) items (small objects).
Any number and sizes of (rectangular) bins (large objects).
The items can be rotated or not.
Currently the library solves only packing problems, but a customization may be made also in the future for strip packing problems.
The bin packing problem has been used in many sectors of the industry, and mostly where manufacturing or industrial management needs arise.
The theory of this library’s implementation can be found in author’s document “A hyper-heuristic for solving variants of the 2D bin packing problem”.
Installation
Install using pip:
pip install hyperpack
Defining the problem
Instantiate your problem with proper arguments
>>> from hyperpack import HyperPack
>>> problem = hyperpack.HyperPack(
>>> containers=containers, # problem parameter
>>> items=items, # problem parameter
>>> settings=settings # solver/figure parameters
>>> )
According to the arguments given, the corresponding problem will be instantiated, ready to be solved with provided guidelines. The items and containers (bins) structure:
containers = {
"container-0-id": {
"W": int, # > 0 container's width
"L": int # > 0 container's length
},
"container-1-id": {
"W": int, # > 0 container's width
"L": int # > 0 container's length
},
# ... rest of the containers
# minimum 1 container must be provided
}
items = {
"item_0_id": {
"w": int, # > 0 item's width
"l": int, # > 0 item's length
},
"item_1_id": {
"w": int, # > 0 item's width
"l": int, # > 0 item's length
},
# ... rest of the items
# minimum 1 item must be provided
}
See documentation for detailed settings structure.
Usage
Do Local search with default settings:
>>> from hyperpack import HyperPack
>>> problem_data = {
>>> "containers": containers,
>>> "items": items,
>>> "settings": settings
>>> }
>>> problem = HyperPack(**problem_data)
>>> problem.local_search()
After solving has finished, the solution can be found in problem.solution instance attribute.
Alternatively for a deep search and maximum bin utilization in mind:
>>> problem = HyperPack(**problem_data)
>>> problem.hypersearch()
Solution logging
Use the log_solution method to log an already found solution:
>>> problem.log_solution()
SOLUTION LOG:
Percent total items stored : 100.0000%
Container: container_0 60x30
[util%] : 100.0000%
Container: container_1 60x50
[util%] : 91.2000%
Remaining items : []
Create a figure
Warning : plotly (5.14.0 or greater) is needed for figure creation and kaleido (0.2.1 or greater) for figure exportation to image. These libraries are not listed as dependencies providing liberty of figure implementation.
>>> problem.create_figure(show=True)
The figure below is opened in default browser:
For more information, visit the documentation page.
Future development
Many ideas and concepts can be implemented in this library. The most propable depending on the community’s interest:
Augmentation of the objective function to deal with a bigger plethora of problems.
Implementation of the strip packing problem.
Django integrations.
Large Neighborhood Search for big instances of the problem.
Other shapes of the container.
A dynamic live terminal display.
Execution speed optimization.
Multiprocessing for the local search alone (combined with LNS).
More detailed figures.
Figures with other libraries (matplotlib).
If interested with development with some of these features please contact me.
Theoretical foundations
This packages inner mechanics and theoretical design are based upon this documentation.
Helping
Creating issues wherever bugs are found, giving suggestions for upcoming versions and donating can surely help in maintaining and growing this package.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for hyperpack-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cb43b4a464671aa663cee7064f91cfa8da7a7ad4e0d4c43509e86b100f8e7fa |
|
MD5 | 7c457be6f3f2e5f6e5f90284e59eb8c0 |
|
BLAKE2b-256 | f40f12da1913ad8b5cae7a038764b05737cb76efbe89093f65ab14b840450465 |