Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beacon-biosignals/multiwaynumberpartitioning.jl
Solving a partitioning problem exactly
https://github.com/beacon-biosignals/multiwaynumberpartitioning.jl
Last synced: about 5 hours ago
JSON representation
Solving a partitioning problem exactly
- Host: GitHub
- URL: https://github.com/beacon-biosignals/multiwaynumberpartitioning.jl
- Owner: beacon-biosignals
- License: mit
- Created: 2021-08-17T12:45:56.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-31T14:48:14.000Z (over 2 years ago)
- Last Synced: 2024-07-09T19:12:30.780Z (4 months ago)
- Language: Julia
- Homepage:
- Size: 24.4 KB
- Stars: 2
- Watchers: 21
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CI](https://github.com/beacon-biosignals/MultiwayNumberPartitioning.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/beacon-biosignals/MultiwayNumberPartitioning.jl/actions/workflows/CI.yml)
[![codecov](https://codecov.io/gh/beacon-biosignals/MultiwayNumberPartitioning.jl/branch/main/graph/badge.svg?token=VA5FX824N9)](https://codecov.io/gh/beacon-biosignals/MultiwayNumberPartitioning.jl)# MultiwayNumberPartitioning
A simple Julia package to optimally solve the [multiway number partitioning](https://en.wikipedia.org/wiki/Multiway_number_partitioning) problem
using a JuMP model with mixed-integer programming.There is one main function `partition` which tries to accomplish the following task:
given a collection of numbers `S` and a number `k`, try to partition `S` into `k` subsets of roughly equal sum.For example:
```julia
julia> using MultiwayNumberPartitioning, HiGHSjulia> S = [1, 1, 1, 3, 2, 1];
julia> inds = partition(S, 3; optimizer = HiGHS.Optimizer)
6-element Vector{Int64}:
2
2
3
1
3
2julia> S[inds .== 1] # group 1
1-element Vector{Int64}:
3julia> S[inds .== 2] # group 2
3-element Vector{Int64}:
1
1
1julia> S[inds .== 3] # group 3
2-element Vector{Int64}:
1
2
```We can see all three groups here have equal sum.
See the [example](./example/example.jl) for a more detailed usage example.
## Choice of objective function
We can choose various objective functions for the algorithm to use during the optimization procedure when finding a partitioning configuration.
MultiwayNumberPartitioning.jl provides three objective functions:
* `partition_min_largest!`: minimize sum of the largest subset
* `partition_max_smallest!`: maximize the sum of the smallest subset
* `partition_min_range!`: minimize the difference between the sum of the largest subset and the smallest(where here "largest" and "smallest" refer to the sums of the subsets).