Algorithm-Pair-Best2

 view release on metacpan or  search on metacpan

lib/Algorithm/Pair/Best2.pm  view on Meta::CPAN

sliding window to get good 'local' results.

The B<-E<gt>new> method accepts a B<window> option to limit the number
of pairs in the sliding window.  The B<window> option can also be
overridden by calling B<pick> with an explicit window argument:

    $pair->pick($window);

The list should be at least partially sorted so that reasonable
pairing candidates are within the 'sliding window' of each other.
Otherwise the final results may not be globally 'best', but only
locally good.  For (e.g.) a tournament, sorting by rank is sufficient.

Here's how a window value of 5 works:  the best list for items 1
through 10 (5 pairs) is found.  Save the pairing for the top two items
and then slide the window down to pair items 2 through 12.  Save the
top pairing from this result and slide down again to items 4 through
14.  Keep sliding the window down until we reach the last 10 items
(which are completed in one iteration).  In this way, a large number
of pairings can be completed without taking factorial time.



( run in 0.761 second using v1.01-cache-2.11-cpan-49f99fa48dc )