votesim.votesystems.voterunner

General purpose election running function

Class Summary

eRunner([etype, method, btype, scores, …])

Run the election & obtain results.

Module Classes

eRunner

class votesim.votesystems.voterunner.eRunner(etype=None, method=None, btype=None, scores=None, ranks=None, votes=None, ratings=None, numwinners=1, seed=None, rstate=None, kwargs=None)

Run the election & obtain results. For ties, randomly choose winner.

Parameters

etype (str) –

Name of election type. Mutually exclusive with method and btype Supports the following election types:

  • ’approval100’ - approval voting, 100% acceptance of nonzero score

  • ’approval50’ - approval voting, 50% acceptance of nonzero score

  • ’irv’ – Instant runoff.

  • ’irv_stv’ – Instant runoff with single-transferable vote.

  • ’rrv’ – Reweighted range voting.

  • ’plurality’ – Traditional plurality & Single No Transferable Vote.

  • ’sequential_monroe’ – PR scored method

  • ’score’ – traditional score voting

  • ’smith_minimax’ - Smith minimax condorcet voting

  • ’star’ – STAR voting variant of score

methodfunc

Voting method function. Takes in argument data array shaped (a, b) for (voters, candidates) as well as additional kwargs. Mutually exclusive with etype.

>>> out = method(data, numwin=self.numwinneres, **kwargs)
btypestr

Voting method’s ballot type. Mutually exclusive with etype, use with method.

  • ‘rank’ – Use candidate ranking from 1 (first place) to n (last plast), with 0 for unranked.

  • ‘score’ – Use candidate integer rating/scored method.

  • ‘vote’ – Use traditional, single-selection vote. Vote for one (1), everyone else zero (0).

  • ‘rating’ – Use raw ratings data.

scoresarray shape (a, b)

Score ballots

ranksarray shape (a, b)

Ranked ballots

votesarray shape (a, b)

Plurality voting ballots

winners

Winning candidate indices

Type

array shape (c,)

ties

Tie candidate indices

Type

array shape (d,)

output

Election output

Type

dict

ballots

Voter ballots

Type

array shape (a, b)

btype

Ballot type

Type

str

Method/Attribute Summary