Skip to main content

An algorithm to optimize already arrnaged bins into n-1 bins

Project description

Testing Documentation Status codecov

bin_optimize

This project is an extension to binpacking problem. The utility provides ability to optimize existing bins which are already allocated using any bin_packing algorithm into n-1 bins.

The items in the bins are presented as a tuple of an identifier and volume of the item.

Usage:

>>> from bin_optimize import optimize
>>> bins = {'b1': [('a1', 6), ('a5', 4.5), ('a9', 4)],
            'b2': [('a2', 4), ('a6', 5), ('a10', 2)],
            'b3': [('a3', 7), ('a7', 2), ('a11', 3)],
            'b4': [('a4', 2), ('a8', 2), ('a12', 2), ('a13', 2), ('a15', 4)]}
>>> bin_to_reduce = 'b4'
>>> optimize(bins, bin_to_reduce)
    {'b1': [('a1', 6), ('a5', 4.5), ('a9', 4), ('a8', 2)],
     'b2': [('a2', 4), ('a6', 5), ('a10', 2), ('a12', 2), ('a15', 4)],
     'b3': [('a3', 7), ('a7', 2), ('a11', 3), ('a13', 2), ('a4', 2)]}

The input bins can also have an empty bin.

>>> from bin_optimize import optimize
>>> bins = {'b1': [('a1', 6), ('a5', 4.5), ('a9', 4)],
            'b2': [('a2', 4), ('a6', 5), ('a10', 2)],
            'b3': [],
            'b4': [('a4', 2), ('a8', 2), ('a12', 2), ('a13', 2), ('a15', 4)]}
>>> bin_to_reduce = 'b4'
>>> optimize(bins, bin_to_reduce)
{'b1': [('a1', 6), ('a5', 4.5), ('a9', 4)],
 'b2': [('a2', 4), ('a6', 5), ('a10', 2)],
 'b3': [('a12', 2), ('a13', 2), ('a15', 4), ('a4', 2), ('a8', 2)]}

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

bin_optimize-0.0.10.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file bin_optimize-0.0.10.tar.gz.

File metadata

  • Download URL: bin_optimize-0.0.10.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.5

File hashes

Hashes for bin_optimize-0.0.10.tar.gz
Algorithm Hash digest
SHA256 41a57e95beb31702f86ea1ab40749b396c89496851c3b6fa1972403b271b6d16
MD5 db378a5836df3492ca00d4a5489875d4
BLAKE2b-256 8bf4a971e3f557eb187487445747fdf6c5ef20ef69c910f698151772bf6c0ac6

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