Skip to main content

Number partitioning in Python

Project description

prtpy

Pytest result PyPI version

Python code for multiway number partitioning and bin packing algorithms.

Supports several exact and approximate algorithms, with several input formats, optimization objectives and output formats.

Installation

pip install prtpy

If you want to speed up the ILP code, you can install the GUROBI solver. See the documentation of Python-MIP for more information.

Usage

The function prtpy.partition can be used to activate all number-partitioning algorithms. For example, to partition the values [1,2,3,4,5] into two bins using the greedy approximation algorithm, do:

import prtpy
prtpy.partition(algorithm=prtpy.approx.greedy, numbins=2, items=[1,2,3,4,5])

To use the exact algorithm based on ILP, and maximize the smallest sum:

prtpy.partition(algorithm=prtpy.exact.ilp, numbins=2, items=[1,2,3,4,5], objective=prtpy.obj.MaximizeSmallestSum)

Similarly, the function prtpy.packing can be used to activate all bin-packing algorithms.

For more features and examples, see:

  1. Number-partitioning algorithms;
  2. Bin-packing algorithms;
  3. Input formats;
  4. Optimization objectives;
  5. Output formats.

Related libraries

Limitations

The package is tested only on Python 3.8 and 3.9. Earlier versions, as well as 3.10, are not supported.

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

prtpy-0.3.0.tar.gz (30.1 kB view hashes)

Uploaded Source

Built Distribution

prtpy-0.3.0-py3-none-any.whl (17.5 kB view hashes)

Uploaded Python 3

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