Skip to main content

Aims at optimal distribution of weighted items to bins (either a fixed number of bins or a fixed number of volume per bin). Data may be in form of list, dictionary, list of tuples or csvfile.

Project description

# Bin Packing
This package contains greedy algorithms to solve two typical bin packing problems. Consider you have a list of items, each carrying a weight *w_i*. Typical questions are

1. How can we distribute the items to a minimum number of bins *N* of equal volume *V*?
2. How can we distribute the items to exactly *N* bins where each carries items that sum up to approximately equal weight?

The package provides the command line tool "binpacking" using which one can easily bin pack csv-files. To see the usage enter

$ binpacking -h

## Install

$ sudo python setup.py install

## Examples

In the package's folder, do

```
cd examples/
binpacking -f hamlet_word_count.csv -V 2000 -H -c count -l 10 -u 1000
binpacking -f hamlet_word_count.csv -N 4 -H -c count
```

or in python, do

```python
import binpacking

b = { 'a': 10, 'b': 10, 'c':11, 'd':1, 'e': 2,'f':7 }
bins = binpacking.to_constant_bin_number(b,4)
print "===== dict\n",b,"\n",bins

b = b.values()
bins = binpacking.to_constant_volume(b,11)
print "===== list\n",b,"\n",bins

```

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

binpacking-1.0.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file binpacking-1.0.tar.gz.

File metadata

  • Download URL: binpacking-1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for binpacking-1.0.tar.gz
Algorithm Hash digest
SHA256 9bacc9b5a3c1bdab30e8e3ed9a046e185ad7e7cf34923929cbdada8981a45f6f
MD5 43da4d16eaa6c39ef225d76cce25a610
BLAKE2b-256 d0eb7a7e6f4be7376260e97879cf51f1e3b9ff614f31e97355b3e26a587a2535

See more details on using hashes here.

Supported by

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