The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Vote::Count::IRV

VERSION 0.015

IRV

Implements Instant Runoff Voting.

SYNOPSIS

  use Vote::Count::Method::IRV;
  use Vote::Count::ReadBallots 'read_ballots';

  my $Election = Vote::Count::Method::IRV->new(
    BallotSet => read_ballots('%path_to_my_ballots'), );

  my $result = $Election->RunIRV();
  my $winner = $result->{'winner'};

  say $Election->logv(); # Print the full Log.

Method Summary

Instant Runoff Voting Looks for a Majority Winner. If one isn't present the choice with the lowest Top Count is removed.

Instant Runoff Voting is easy to count by hand and meets the Later Harm and Condorcet Loser Criteria. It, unfortunately, fails a large number of consistency criteria; the order of candidate dropping matters and small changes to the votes of non-winning choices that result in changes to the dropping order can change the outcome.

Tie Handling

There is no standard accepted method for IRV tie resolution, Eliminate All is a common one and the default.

If there is a tie for lowest Top Count the default is 'all' of the tied choices. Returns a tie when all of the remaining choices are in a tie. An optional value to RunIRV is to specify tiebreaker, see _TieBreaker.

_TieBreaker

Implements some basic methods for resolving ties. By default RunIRV sets a variable of $tiebreaker = 'all', which is to delete all tied choices. Alternate values that can be set are 'borda' (Borda Count the currently active choices), 'borda_all' (Borda Count all of the Choices on the Ballots), and Approval. The Borda Count methods use the defaults.

Tie Break Methods not provided can be implemented by extending Vote::Count::Method::IRV and over-writing the _TieBreaker Method.

  my @remove = $self->_TieBreaker( $tiebreaker, $active, @choices );

RunIRV

  $ElectionRunIRV();

  $ElectionRunIRV( $active )

  $ElectionRunIRV( $active, 'approval' )

Runs IRV on the provided Ballot Set. Takes an optional parameter of $active which is a hashref for which the keys are the currently active choices.

Returns results in a hashref which will be the results of Vote::Count::TopCount->EvaluateTopCountMajority, if there is no winner hash will instead be: tie => [true or false], tied => [ array of tied choices ], winner => a false value

Supports the Vote::Count logt, logv, and logd methods for providing details of the method.

BUG TRACKER

https://github.com/brainbuz/Vote-Count/issues

AUTHOR

John Karr (BRAINBUZ) brainbuz@cpan.org

CONTRIBUTORS

Copyright 2019 by John Karr (BRAINBUZ) brainbuz@cpan.org.

LICENSE

This module is released under the GNU Public License Version 3. See license file for details. For more information on this license visit http://fsf.org.