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 hashes)

Uploaded Source

Supported by

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