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.
Credits: This is just a Python Implementation of the code from npm package https://www.npmjs.com/package/@owens3364/3d-bin-packing.
Metadata
Release files for 3d-bin-packer 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| 3d_bin_packer-0.0.5.tar.gz | 8.0 kB | Without provenance | Details for 3d_bin_packer-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 3d_bin_packer-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for 3d_bin_packer-0.0.5-py3-none-any.whl |
Total release size: 16.7 kB
Release files / 3d_bin_packer-0.0.5.tar.gz
| Download URL | 3d_bin_packer-0.0.5.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a97a4a038514054a89364fd5ab0057f82531f5ec2e5361bb6dc7966606f1c8a
|
|
BLAKE2b-256 checksum How to use checksums |
f3d52cfc99f24da7bf58133a38d1c4426fd6b90a23700600563b2b2a2ac85661
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.21
|
Release files / 3d_bin_packer-0.0.5-py3-none-any.whl
| Download URL | 3d_bin_packer-0.0.5-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
232c135d41b2c43cd7d6bcf3582b22e5065bf1fa570461c1ae88037d11ddf20d
|
|
BLAKE2b-256 checksum How to use checksums |
168f884dbdeb669fe20ae11c9e7a3e142b839bb57e0c084177a4ed68ed6509f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.21
|
Security for 3d-bin-packer 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.