File perl-Algorithm-Pair-Best2.spec of Package perl-Algorithm-Pair-Best2

#
# spec file for package perl-Algorithm-Pair-Best2
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           perl-Algorithm-Pair-Best2
Version:        2.040
Release:        0
%define cpan_name Algorithm-Pair-Best2
Summary:        Select Pairings (Designed for Go Tournaments, but Can Be Used for Anything)
License:        Artistic-1.0 or GPL-1.0+
Group:          Development/Libraries/Perl
Url:            http://search.cpan.org/dist/Algorithm-Pair-Best2/
Source0:        http://www.cpan.org/authors/id/R/RE/REID/%{cpan_name}-%{version}.tar.gz
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  perl
BuildRequires:  perl-macros
%{perl_requires}

%description
This is a re-write of Algorithm::Pair::Best. The interface is simplified
and the implementation is significantly streamlined.

After creating an Algorithm::Pair::Best2 object (with ->*new*), *add* items
to the list of items (i.e: players) to be paired. The final list must
contain an even number of items or *pick*ing the pairs will throw an
exception.

Algorithm::Pair::Best2->*pick* explores all combinations of items and
returns the pairing list with the best (lowest) score. This can be an
expensive proposition - the number of combinations goes up very fast with
respect to the number of items:

    items combinations
      2         1       (1)
      4         3       (1 * 3)
      6        15       (1 * 3 * 5)
      8       105       (1 * 3 * 5 * 7)
     10       945       (1 * 3 * 5 * 7 * 9
     12     10395       (1 * 3 * 5 * 7 * 9 * 11)
     14    135135       (1 * 3 * 5 * 7 * 9 * 11 * 13)

It is clearly unreasonable to try to pair a significant number of items.
Trying to completely pair even 30 items would take too long.

Fortunately, there is a way to get pretty good results for big lists, even
if they're not perfect. Instead of trying to pair the whole list at once,
Algorithm::Pair::Best2 pairs a series of smaller groups in a sliding window
to get good 'local' results.

The *->new* method accepts a *window* option to limit the number of pairs
in the sliding window. The *window* option can also be overridden by
calling *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.

%prep
%setup -q -n %{cpan_name}-%{version}

%build
%{__perl} Makefile.PL INSTALLDIRS=vendor
%{__make} %{?_smp_mflags}

%check
%{__make} test

%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist

%files -f %{name}.files
%defattr(-,root,root,755)
%doc Changes LICENSE README

%changelog
openSUSE Build Service is sponsored by