Answers for "bin packing algorithm python bitmasks"

1

bin packing algorithm python

>>> import binpacking
>>>
>>> b = { 'a': 10, 'b': 10, 'c':11, 'd':1, 'e': 2,'f':7 }
>>> bins = binpacking.to_constant_bin_number(b,4) # 4 being the number of bins
>>> print("===== dictn",b,"n",bins)
===== dict
 {'a': 10, 'b': 10, 'c': 11, 'd': 1, 'e': 2, 'f': 7}
 [{'c': 11}, {'b': 10}, {'a': 10}, {'f': 7, 'e': 2, 'd': 1}]
>>>
>>> b = list(b.values())
>>> bins = binpacking.to_constant_volume(b,11) # 11 being the bin volume
>>> print("===== listn",b,"n",bins)
===== list
 [10, 10, 11, 1, 2, 7]
 [[11], [10], [10], [7, 2, 1]]
Posted by: Guest on January-07-2021

Python Answers by Framework

Browse Popular Code Answers by Language