multiway
statistics: groupindex = multiway (numbers, num_parts)
statistics: groupindex = multiway (numbers, num_parts, method)
statistics: [groupindex, partition] = multiway (…)
statistics: [groupindex, partition, groupsizes] = multiway (…)
Solve the multiway number partitioning problem.
groupindex = multiway (numbers, num_parts)
splits
a set of numbers in numbers into a number of subsets specified in
num_parts such that the sums of the subsets are nearly as equal as
possible and returns a vector of group indices in groupindex with each
index corresponding to the set of numbers provided as input.
groupindex = multiway (numbers, num_parts,
method)
also specifies the algorithm used for partitioning the set of
numbers. By default, multiway
uses the complete Karmarkar-Karp
algorithm, when the set of numbers contains up to 10 elements and the
requested number of subsets does not exceed 5, otherwise it defaults to the
greedy algorithm, which is optimized for speed, but may not return the
optimal partitioning. The following methods are supported:
'greedy'
(Greedy algorithm)
'completeKK'
(Complete Karmarkar-Karp algorithm)
The multiway
function may return up to three output arguments
described below:
Example:
numbers = [4, 5, 6, 7, 8]; num_parts = 2; [groupindex, partition, groupsizes] = multiway (numbers, num_parts); |
See also: cvpartition
Source Code: multiway