Skip to main content

No project description provided

Project description

bin_packing

Read example in example.py

import random as rd
import binpacking as bp
def create_data_model():
    data = {}
    bins = []
    batches = []
    # number of bins
    nb_bin = 2
    # number of batch
    nb_batch = 3

    for i in range(nb_bin):
        bins.append(
            {
                "length": 20,
                "width": 20,
                "height": 15,
                "index": i,
            }
        )

    for j in range(nb_batch):
        temp = []
        # number of type of item
        nb_item_type = 3
        for i in range(nb_item_type):
            temp.append(
                {
                    "length": rd.randint(1, 5),
                    "width": rd.randint(1, 5),
                    "height": rd.randint(1, 5),
                    "quantity": rd.randint(5, 10),
                    "index": j * 10 + i,
                    "axis_lock": rd.randint(0, 1),
                }
            )
        batches.append(temp)

    # always use 2 key 'bins' and 'batches'
    data["bins"] = bins
    data["batches"] = batches

    return data
# create data for packer
data = create_data_model()

# create packer
packer = bp.create_packer(data)

# pack batch 0 into bin 0
packer.pack(bin_index=0, batch_index=0)

# can draw bin by index to visualize (option)
packer.draw_bin(bin_index=0)

# Get_output
result = []

for bin in packer.bins:
    result.append(bin.packed_items_to_dict())

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

packworker-0.1.3.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

packworker-0.1.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file packworker-0.1.3.tar.gz.

File metadata

  • Download URL: packworker-0.1.3.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.0 Windows/10

File hashes

Hashes for packworker-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1a64daf0e5c6c6734e18ba98fd0f5015e7ddfccd9d5302bc257dc5a04a2c01d5
MD5 8d16f424138ac3f20eade1fa99112533
BLAKE2b-256 d9eb5093be3bb3ed081b120f15bb4b852625b698bc44c5d20283f5860566336d

See more details on using hashes here.

File details

Details for the file packworker-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: packworker-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.0 Windows/10

File hashes

Hashes for packworker-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a5efcb52eabbf169b14c891308fc1b869adb7c7cf8137366819bb6cc98c263af
MD5 2b051a7ba691d9674376130330210257
BLAKE2b-256 2c7eb3f7eba3ce27e4fb5eed1767c00483d1655e491dcc62b3c7bc03d9af1ec8

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