![]() |
![]()
| ![]() |
![]()
NAMEAlgorithm::Pair::Swiss - Generate unique pairings for tournamentsVERSIONThis document describes Algorithm::Pair::Swiss version 0.14SYNOPSISuse Algorithm::Pair::Swiss; my $pairer = Algorithm::Pair::Swiss->new; $pairer->parties(1,2,3,4); @round_1 = $pairer->pairs; $pairer->exclude(@round_1); @round_2 = $pairer->pairs; DESCRIPTIONThis module was created as an alternative for Algorithm::Pair::Best, which probably offers more control over the pairings, in particular regarding ensuring the highest overal quality of pairings. Algorithm::Pair::Swiss is sort of dumb in this regard, but uses a slightly more intuitive interface and an algorithm that should perform noticably faster. The module was primarily designed based on the Swiss rounds system used for Magic: The Gathering tournaments.After creating an Algorithm::Pair::Swiss->new object, use the parties method to supply a list of parties (players or teams) to be paired. At any time the exclude method can be used to indicate which pairs shouldn't be generated (probably because they've already been paired in an earlier round). The list of parties is sorted and the pairer tries to find a set of pairs that respects the exclude list, and tries to pair the parties that appear first in the sorted list with each other most aggresively. To influence the sort order, use objects as parties and overload either the cmp or 0+ operators in the object class to sort as desired. Algorithm::Pair::Swiss->pairs explores the parties and returns the first pairing solution which satisfies the excludes. Because it doesn't exhaustively try all possible solutions, performance is generally pretty reasonable. For a large number of parties, it is generally easy to find a non-excluded pair, and for a smaller number of parties traversal of the possible pairs is done reasonably fast. This module uses the parties as keys in a hash, and uses the empty string ('') as a special case in this same hash. For this reason, please observe the following restrictions regarding your party values:
All the restrictions on the stringifications are compatible with the perl's default stringification of objects, and should be safe for any stringification which returns a unique party-identifier (for instance a primary key from a Class::DBI object). METHODS
EXPORTNone by default.BUGS AND LIMITATIONSNo bugs that I know of...The module's performance will probably break down if you use 1000+ parties and 100+ rounds though... REQUIREMENTSPerl 5.6.0 or later (though it will probably work ok with earlier versions)SEE ALSO
ACKNOWLEDGEMENTSReid Augustin for by Algorithm::Pair::BestElizabeth Mattijsen for giving me some pointers on getting this module CPAN-ready. AUTHORGilion Goudsmit, <ggoudsmit@shebang.nl>I can also be found on http://www.perlmonks.org as Gilimanjaro. You can direct any questions concerning this module there as well. COPYRIGHT AND LICENSECopyright (C) 2006 by Gilion GoudsmitThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.
|