NAME

Algorithm::RankAggregate::BordaCount - Pure Perl implementation of Borda count

SYNOPSIS

use Algorithm::RankAggregate::BordaCount;

my @case = (
    [-26.8,  -3.8, -11.2, -9.4, -2.7],
    [-24.8,  18.2, -8.0,  -3.4, 18.0],
    [-17.7,  13.0, -2.4,  -5.7, 12.9],
);

my $bc = Algorithm::RankAggregate::BordaCount->new();

# give point to attribute which is ranked higher than 4
my @result = @{$bc->aggregate(\@case, 4)};

# in this case, @result = (0,11,4,5,10)

DESCRIPTION

Algorithm::RankAggregate::BordaCount is Pure Perl implementation of Borda count. You may read http://en.wikipedia.org/wiki/Borda_count.

EXPORTED FUNCTIONS

new() You can get the instance of this module in following way.

my $bc = Algorithm::RankAggregate::BordaCount->new();

new(\@array) If you want to think of multi voters, you can get the instance of this module in following way.

my @voters = (42, 26, 15, 17);
my $bc = Algorithm::RankAggregate::BordaCount->new(\@voters);

If you want to use weighted borda count, you can get the instance of this module in following way.

my @weights = (0.4, 0.3, 0.2, 0.1);
my $bc = Algorithm::RankAggregate::BordaCount->new(\@weights);

aggregate(\@array_of_array) In first, you should make a array of array which make from real value.

my @case = (
     [-26.8,  -3.8, -11.2, -9.4, -2.7],
     [-24.8,  18.2, -8.0,  -3.4, 18.0],
     [-17.7,  13.0, -2.4,  -5.7, 12.9],
);

And you can get borda counts in following way.

my @result = @{$bc->aggregate(\@case)};

aggregate(\@array_of_array, $positive_int_value, $rank_higher_than) If you want to give the point to candidate which is ranked higher than N, you can get borda counts in following way.

my @result = @{$bc->aggregate(\@case, N)};

By using this parameter, you can give "N - rank + 1" point to candidate.

Example This is example to represent "how to use Algorithm::RankAggregate::BordaCount".

use Algorithm::RankAggregate::BordaCount;

# http://en.wikipedia.org/wiki/Borda_count
# each array of array are (Memphis, Nashville, Chattanooga, Knoxville)
my @case = (
    [4, 3, 2, 1],
    [1, 4, 3, 2],
    [1, 2, 4, 3],
    [1, 2, 3, 4],
);
my @voters = (42,26,15,17);
my $bc = Algorithm::RankAggregate::BordaCount->new(\@voters);
my @result = @{$bc->aggregate(\@case_00, 3);

# in this case, @result = (126, 194, 173, 107)

AUTHOR

Toshinori Sato (@overlast) <overlasting {at} gmail.com>

SEE ALSO

https://github.com/overlast/private/tree/master/lang/perl/CPAN

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.