[][src]Struct wybr::methods::meek::Meek

pub struct Meek<'a> { /* fields omitted */ }

A builder for the setup of a Meek count.

See the module level documentation for more.

Default configuration can be generated with Meek::new(tally), where tally is a VoteTree object. Count is triggered by the run() method, which returns a vector of winners, or an error.

Methods

impl<'a> Meek<'a>[src]

pub fn new(tally: &'a VoteTree) -> Self[src]

Acquire reference to a vote tally and initiate default configuration, which can be altered with other builder methods. The default configuration involves using Hagenbach-Bischoff quota, Meek vote transfer mode, seats number and withdraw list pulled from the tally, 6 digits of fixed-point arithmetic, finally seed set to 21.

pub fn seed(&mut self, seed: u32) -> &mut Self[src]

Alters the random seed potentially used by the election algorithm to break ties.

pub fn seats(&mut self, seats: u32) -> &mut Self[src]

Alters the number of seats (candidates to be elected).

pub fn digits(&mut self, digits: u32) -> &mut Self[src]

Alters the number of fixed-point digits used.

Seventeen is max (enforced in run()); also, 10 ^ digits * total votes in tally must be smaller than 2 ^ 64.

pub fn quota(&mut self, quota: Quota) -> &mut Self[src]

Alter the quota calculation method; see Quota type for details.

The default is HagenbachBischoff in compatibility with Algorithm 123, but it is good to consider using Hare in order to get most of STV.

pub fn transfer(&mut self, transfer: Transfer) -> &mut Self[src]

Alter the vote transfer method; see Transfer type for details.

In general, Meek algorithm is Meek with the default Transfer::Meek; with Transfer::Warren is becomes Warren STV. The naming in wybr reflects the fact that Warren proposed a relatively small change to the Meek idea; not insignificant, however. Also because this method is much more recognisable as Meek STV.

pub fn withdraw<I>(&mut self, withdraw: I) -> &mut Self where
    I: IntoIterator<Item = u32>, 
[src]

Alter a list of withdrawn candidates, which are not considered in count.

pub fn run(&self) -> Result<GenericOutcome<'a>, ElectionError>[src]

Performs Meek STV election, returns Vec<u32> with IDs of winners, or an ElectionError.

Aims to be compatible with Algorithm 123, though uses fixed-point arithmetic.

Errors

  • NotEnoughCandidates, in case there is less candidates then seats or no votes,
  • FixedPointDigitsTooMany, in case there is too many ballots for a given digits value, or when digits is higher than 17, which is somewhat insane.

Notes

In a pathological case, it may take a lot of time, but not infinite (at most ~ number of candidates ^ 2 * 10 ^ digits). Fixed point stuff works by multiplying almost everything by 10^base and fitting the result in u64; when you have like billions of ballots and digits of 9, it may become tight.

Votes are also compared to be greater or equal with quota, even when quota is HagenbachBischoff; when it seems that more candidates then seats are going to be elected, random tie breaking is used.

For seats==1, result will be almost certainly identical to this of irv, depending on the quota method (IRV effectively uses Hare).

Auto Trait Implementations

impl<'a> Send for Meek<'a>

impl<'a> Sync for Meek<'a>

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]