Main > Programming > Libraries >

Algorithm::BinPack 0.5

Algorithm::BinPack 0.5

Sponsored Links

Algorithm::BinPack 0.5 Ranking & Summary

RankingClick at the star to rank
Ranking Level
User Review: 0 (0 times)
File size: 0.004 MB
Platform: Any Platform
License: Perl Artistic License
Price:
Downloads: 893
Date added: 2007-05-16
Publisher: Carey Tilden

Algorithm::BinPack 0.5 description

Algorithm::BinPack is a Perl module that can efficiently pack items into bins.

SYNOPSIS

Algorithm::BinPack efficiently packs items into bins. The bins are given a maximum size, and items are packed in with as little empty space as possible. An example use would be backing up files to CD, while minimizing the number of discs required.

my $bp = Algorithm::BinPack->new(binsize => 4);

$bp->add_item(label => "one", size => 1);
$bp->add_item(label => "two", size => 2);
$bp->add_item(label => "three", size => 3);
$bp->add_item(label => "four", size => 4);

for ($bp->pack_bins) {
print "Bin size: ", $_->{size}, "n";
print " Item: ", $_->{label}, "n" for @{ $_->{items} };
}

METHODS

new

Creates a new Algorithm::BinPack object. The maximum bin size is specified as a named argument binsize, and is required. A fudge factor may be specified as a named argument fudge. If a fudge factor is specified, item sizes will be rounded up to a number divisible by the fudge factor. This can help keep items with similar sizes in order by their labels.

my $bp = Algorithm::BinPack->new(binsize => 4);
my $bp = Algorithm::BinPack->new(binsize => 100, fudge => 10);

add_item

Adds an item to be packed into a bin. Required named arguments are label and size, but any others can be specified, and will be saved. An optional bin argument can be used to manually put an item into the specified bin.

$bp->add_item(label => one, size => 1);
$bp->add_item(label => two, size => 2, desc => The second numeral);
$bp->add_item(label => zero, size => 3, bin => 0);
$bp->add_item(qw(label three size 3));
$bp->add_item(qw(label four size 4 random key));

prefill_bin

(Deprecated method) add_item now knows how to handle the bin argument directly, so this method is redundant.

pack_bins

Packs the items into bins. This method tries to leave as little empty space in each bin as possible. It returns a list of hashrefs with the key size containing the total bin size, and items containing an arrayref holding the items in the bin. Each item is in turn a hashref containing the keys label, size, and any others added to the item. If a fudge factor was used, each item will contain a key fudgesize, which is the size this item was fudged to.

for my $bin ($bp->pack_bins) {
print "Bin size: ", $bin->{size}, "n";

for my $item (@{ $bin->{items} }) {
printf " %-6s %-20sn", $_, $item->{$_} for keys %{ $item };
print " ---n";
}
}

Algorithm::BinPack 0.5 Screenshot

Advertisements

Algorithm::BinPack 0.5 Keywords

Bookmark Algorithm::BinPack 0.5

Hyperlink code:
Link for forum:

Algorithm::BinPack 0.5 Copyright

WareSeeker periodically updates pricing and software information of Algorithm::BinPack 0.5 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of Algorithm::BinPack 0.5 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed

Allok Video Splitter 2.2.0 Review:

Name (Required)
Email(Required)
Captcha
Featured Software

Want to place your software product here?
Please contact us for consideration.

Contact WareSeeker.com
Related Software
Algorithm::Knapsack is a brute-force algorithm for the knapsack problem. Free Download
Algorithm::Combinatorics Perl module is an efficient generator of combinatorial sequences. Free Download
Algorithm::DiffOld is a Perl module to compute `intelligent differences between two files / lists but use the old interface. Free Download
Algorithm::Permute is a Perl module with handy and fast permutation with object oriented interface. Free Download
Algorithm::LUHN is a Perl module to calculate the modulus 10 double add double checksum. Free Download
Algorithm::Line::Bresenham is a Perl module that contains a simple pixellated line-drawing algorithm. Free Download
Algorithm::Merge is a Perl module package that provides three-way merge and diff. Free Download
Algorithm::Diff::Apply is a Perl module to apply one or more Algorithm::Diff diffs. Free Download