It doesn't (yet) have an algorithm except "brute force" and "random", but
Algorithm::Bucketizer provides a framework for solving tasks like these:
my @values = (10,40,30,14,50,29,59,20,59,20,10,1,3,5,2,4);
use Algorithm::Bucketizer;
# Create a bucketizer
my $bucketizer = Algorithm::Bucketizer->new(bucketsize => 291);
for my $value (@values) {
# Add items to it
$bucketizer->add_item($value, $value);
}
$bucketizer->optimize(maxrounds => 1000, algorithm => "brute_force");
for my $bucket ($bucketizer->buckets()) {
my @items = $bucket->items();
print $bucket->level(), ": @items\n";
}
1000 Rounds:
286: 4 2 5 3 1 10 20 59 20 59 29 50 14 10
70: 30 40
10,000 Rounds:
286: 4 2 5 3 1 10 20 59 20 59 29 50 14 10
70: 30 40
If you find a usable algorithm, it can be plugged into
Algorithm::Bucketizer as a standard choice.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.