Skip to main content

3D Bin Packing Library, Useful for Container Loading Problem (CLP)

Project description

Simple 3D Bin Packing

This library provides a simple implementation of the 3D Bin Packing problem, which is useful for solving the Container Loading Problem (CLP).

Installation

To install the library, you can use pip:

pip install 3d_bin_packer

Usage

Importing the Library

from bin_packer import Bin, Item, Packer

Creating an instance of the BinPacking class

bin1 = Bin('Le grande box', 100, 100, 300)
item1 = Item('Item 1', 150, 50, 50)

Packing Items into Bins To pack items into bins, you need to create a Packer instance, add bins and items to it, and then call the pack method:

packer = Packer()
packer.add_bin(bin1)
packer.add_item(item1)
packer.pack()

Checking the Results You can check the packed items and unfit items using the bins and unfit_items properties of the Packer class:

for bin_ in packer.bins:
    print(f"Bin: {bin_.name}")
    for item in bin_.items:
        print(f"  Packed item: {item.name}")

print("Unfit items:")
for item in packer.unfit_items:
    print(f"  Unfit item: {item.name}")

Example Here is a complete example that demonstrates how to use the library:

from bin_packer import Packer, Bin, Item

# Create bins
bin1 = Bin('Le grande box', 100, 100, 300)

# Create items
items = [Item('Item 1', 150, 50, 50) for i in range(1000)]

# Create packer and add bins and items
packer = Packer()
packer.add_bin(bin1)
for item in items:
    packer.add_item(item)

# Pack items into bins
packer.pack()

# Check the results
for bin_ in packer.bins:
    print(f"Bin: {bin_.name}")
    for item in bin_.items:
        print(f"  Packed item: {item.name}")
        print(f"    Position: {item.position}")


print("Unfit items:", len(packer.unfit_items))

Running Tests To run the tests, you can use the unittest module:

python -m unittest discover tests

License This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

3d_bin_packer-0.0.2.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

3d_bin_packer-0.0.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file 3d_bin_packer-0.0.2.tar.gz.

File metadata

  • Download URL: 3d_bin_packer-0.0.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for 3d_bin_packer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3cdc71025efb78b0a5203a146af8f6594608ed5daf5c5608beaa3c2ee2c69f4d
MD5 961656989510be8d59b6fd40aff8fb82
BLAKE2b-256 27e231207008d88b9ad3f1690de3a811b8600355db96b1bb00ab01a93f75a779

See more details on using hashes here.

File details

Details for the file 3d_bin_packer-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: 3d_bin_packer-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for 3d_bin_packer-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0ee95ce30fcf9b02979c4dbb78690f8f26092e1d95169cefb2ec657ed8eda795
MD5 f2eaafe2bfc33fd6213ce98e4702b633
BLAKE2b-256 3f74945e579d2a7f97ed7f3ddcb8cda9ededd828b267b8e4ca09649cca7082ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page