Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.9%) to scientific vocabulary
Repository
Number partitioning in Python
Basic Info
- Host: GitHub
- Owner: coin-or
- License: mit
- Language: Python
- Default Branch: main
- Size: 2.92 MB
Statistics
- Stars: 51
- Watchers: 3
- Forks: 22
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
prtpy
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
Basic installation:
pip install prtpy
To run simulation experiments:
pip install prtpy[simulations]
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.partitioning.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.partitioning.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:
- Number-partitioning algorithms;
- Bin-packing algorithms;
- Bin-covering algorithms;
- Input formats;
- Optimization objectives;
- Output formats.
Adding new algorithms
To add a new algorithm for number partitioning, write a function that accepts the following parameters:
binner- an item of classBinnerstructure (see below).numbins- an integer - how many bins to put the items into.items- a list of item-names (the item values are given by the functionbinner.valueof).- Any other parameters that are required by your algorithm.
For an example, see the implementation of existing algorithms, e.g. greedy.
To add a new algorithm for bin packing or bin covering, write a function that accepts the following parameters:
binner- an item of classBinnerstructure (see below).binsize- the capacity of a bin (maximum sum in bin-packing; minimum sum in bin-covering).items- a list of item-names (the item values are given by the functionbinner.valueof).- Any other parameters that are required by your algorithm.
For an example, see the implementation of existing algorithms, e.g. first_fit.
The Binner class contains methods for handling bins in a generic way --- handling both item-names and item-values with a single interface. The main supported methods are:
bins = binner.new_bins(numbins)--- constructs a new array of empty bins.binner.add_item_to_bin(bins, item, index)--- updates the givenbinsarray by adding the given item to the bin with the given index.binner.sums(bins)--- extracts, from the bins array, only the array of sums.bins = binner.add_empty_bins(bins, numbins)--- creates a newbinsarray with some additional empty bins at the end.bins = binner.remove_bins(bins, numbins)--- creates a newbinsarray with some bins removed at the end.binner.valueof(item)--- returns the value (size) of the given item.
Related libraries
- numberpartitioning by Søren Fuglede Jørgensen - the code for complete_greedy and completekarmarkarkarp was originally adapted from there.
- binpacking by Ben Maier.
Limitations
The package is tested on Python versions 3.8, 3.9 and 3.10. Other versions are not supported.
Owner
- Name: COIN-OR Foundation
- Login: coin-or
- Kind: organization
- Email: info@coin-or.org
- Location: United States of America
- Website: https://www.coin-or.org
- Twitter: coin_or
- Repositories: 80
- Profile: https://github.com/coin-or
Computational Infrastructure for Operations Research.
GitHub Events
Total
- Issues event: 4
- Watch event: 5
- Issue comment event: 2
- Push event: 2
- Pull request event: 1
- Fork event: 2
Last Year
- Issues event: 4
- Watch event: 5
- Issue comment event: 2
- Push event: 2
- Pull request event: 1
- Fork event: 2
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 5
- Total pull requests: 24
- Average time to close issues: 8 months
- Average time to close pull requests: 25 days
- Total issue authors: 5
- Total pull request authors: 12
- Average comments per issue: 4.2
- Average comments per pull request: 1.21
- Merged pull requests: 13
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 2
- Average time to close issues: 4 days
- Average time to close pull requests: 7 days
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 1.0
- Average comments per pull request: 0.5
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- traversc (1)
- Isaac-D-Cohen (1)
- TotalDK (1)
- mostpalonen (1)
- MarvinWalther (1)
Pull Request Authors
- 8onlichtman (8)
- yoelchemla (3)
- MiriamNagar (2)
- ishay320 (2)
- samuelharroch (2)
- nirson123 (1)
- eloblo (1)
- SamuelBismuth (1)
- kggold4 (1)
- avsha114 (1)
- edutco (1)
- dinkubag (1)