[][src]Module wybr::methods::meek

Meek STV method

Meek STV is a popular form of Single Transferable Vote election; it allows for electing multiple candidates.

In this method, vote is spread across candidates specified on the ballot, and this spread is adjusted in a number of rounds as candidates are progressively eliminated or elected. Undecided candidates get the whole part of vote that reaches them, eliminated get none, finally elected are only given enough for its total support to reach quota. Part of vote that reaches the end of the ballot goes to excess and lowers the quota.

In each round, votes are spread, total supports are gathered, and candidates which reach the quota are elected; if all seats are taken, the algorithm stops. If no-one can be elected, candidate with a lowest support is eliminated. Finally, the algorithm loops back to the next round.

This implementation uses fixed point arithmetic with a customisable amount of decimal digits. Similarly, it can use various quota functions; Hagenbach-Bischoff which is used in the AS123 paper, Hare or Droop.

Examples

use wybr::{Tally,Meek,Outcome};

//Load the example from the AS123 paper
let tally=Tally::from_blt_file("examples/a123.blt").unwrap();

//Perform election with default parameters
let outcome=Meek::new(&tally).run().unwrap();
let mut winners:Vec<String>=outcome.elected_names().collect();
//Even though outcome is deterministic...
assert!(outcome.deterministic());
//...order may depend on HashSet order, hence we sort to compare
winners.sort_unstable();
assert_eq!(winners,vec!["Adam","Donald"]);

//Perform election ignoring the withdrawal of Basil from the blt file
let outcome=Meek::new(&tally).withdraw(vec![]).run().unwrap();
let mut winners:Vec<String>=outcome.elected_names().collect();
winners.sort_unstable();
assert_eq!(winners,vec!["Adam","Charlotte"]);

//Also change quota to Hare
use wybr::Quota;
let outcome=Meek::new(&tally).withdraw(vec![]).quota(Quota::Hare).run().unwrap();
let mut winners:Vec<String>=outcome.elected_names().collect();
winners.sort_unstable();
assert_eq!(winners,vec!["Adam","Basil"]);

//Perform Warren election with default parameters
use wybr::Transfer;
let outcome=Meek::new(&tally).transfer(Transfer::Warren).run().unwrap();
let mut winners:Vec<String>=outcome.elected_names().collect();
winners.sort_unstable();
assert_eq!(winners,vec!["Adam","Donald"]);

Structs

Meek

A builder for the setup of a Meek count.