Skip to main content
hyperpack
https://img.shields.io/badge/License-Apache_2.0-blue.svg https://img.shields.io/badge/python-3.7|3.8|3.9|3.10|3.11-blue.svg https://img.shields.io/badge/maintainer-alkiviadis.aliferis@gmail.com-blue.svg https://img.shields.io/badge/pypi-v1.3.0-blue.svg https://static.pepy.tech/badge/hyperpack https://static.pepy.tech/badge/hyperpack/month

Hyperpack is the first open-source 2D-Binpacking problem solver and optimizer in Python, based on my personally developed heuristics. If you are curious on the heuristics or the python implementation, please contact me.

Problem description

The hyperpack library is an API for solving instances of the 2D Binpacking problem and also - as of v1.1.0 - strip packing instances!

The library is multiprocessing enabled to minimize execution times and utilizes only pure python, making the package dependency free.

Many different variations can be created and solved, accordind to the instantiation data. The solvable variants can be summarized in the below characteristics: - Any number and sizes of (rectangular) items. - Any number and sizes of (rectangular) bins (containers). - The items can be rotated or not.

The above items’ charascteristics can also be applied to strip packing problems.

The bin/strip 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 and mechanics 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

Quickstart

A quickstart for testing the library can be made through the generate_problem_data utility function.

>>> from hyperpack import generate_problem_data, HyperPack
>>> problem_data = hyperpack.generate_problem_data(containers_num=2)
Containers number =  2
Containers:
{
    "container-0": {
        "W": 48,
        "L": 53
    },
    "container-1": {
        "W": 53,
        "L": 49
    }
}
Items number =  60
>>> problem = HyperPack(**problem_data)
>>> problem.hypersearch()
>>> problem.create_figure(show=True)
>>> # figure opened in default browser
>>>
>>> # to see parameter explanation do:
>>> help(generate_problem_data)

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-id 60x30
        [util%] : 100.0000%
Container: container-1-id 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:

example_figure

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 Large Neighborhood Search).

  • 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 and giving suggestions for upcoming versions can surely help in maintaining and growing this package.

Release files for hyperpack 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hyperpack 1.3.0
File Size Uploaded
hyperpack-1.3.0.tar.gz 44.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hyperpack 1.3.0
File Interpreter ABI Platform
hyperpack-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 91.9 kB

Release files / hyperpack-1.3.0.tar.gz

Download URL hyperpack-1.3.0.tar.gz
Size 44.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ccd87850fa3251496376e8069e86959f9235dd5555ba051cde4bc4ed4b3f7011
BLAKE2b-256 checksum
How to use checksums
97909ff695119aa210606cf99c38f1506c0d7136809796407c31be26c0aec822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / hyperpack-1.3.0-py3-none-any.whl

Download URL hyperpack-1.3.0-py3-none-any.whl
Size 47.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e6e3e3221c7b7fdd04b2baf5ca26b1c1008385a0e98e7cd8540c6fe93251c17
BLAKE2b-256 checksum
How to use checksums
08d574297076c2b169d557e43220ca078ae2830477d6c50ffd1f42753b301d94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

1 release file

1.1.0

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page