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.1.tar.gz
(6.7 kB
view hashes)
Built Distribution
Close
Hashes for packworker-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e160d24da166afb5f5ae1e1f700ba4565e6b2293a2bf55a869393f93d1e547bc |
|
MD5 | ccd91dc76ee5896c11245309185e6aac |
|
BLAKE2b-256 | 779faafdf371202147199adfb02f37656ef67feb4e526ef954b23afba0091fa9 |