[][src]Struct wybr::methods::minimax::Minimax

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

A builder for the setup of Minimax method

See the module level documentation for more.

Default configuration can be generated with Minimax::new(&tally), where tally is a VoteMatrix object. Count is triggered by the run() method, which returns a solitary winner, or an error.

Methods

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

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

Acquire reference to a vote matrix tally and initiate default configuration, which can be altered with other builder methods. The default configuration involves using Winning pair scoring and random seed of 21.

pub fn pair_score(&mut self, pair_score: PairScore) -> &mut Self[src]

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

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 run(&self) -> Result<GenericOutcome<'a>, ElectionError>[src]

Performs MiniMax election, return winner ID or an ElectionError.

The method considers candidates worse defeats, that is the maximal score of their opponent in one-to-one comparisons, established using given scoring mode. The winner is the candidate with smallest such worse defeat; in case of a tie, it is broken at random based on seed.

Errors

  • NotEnoughCandidates, in case there is no candidates.
  • ArithmeticOverflow, when u64 count in tally is larger than i64 max.

Notes

This is not a good method, yet very simple.

Auto Trait Implementations

impl<'a> Send for Minimax<'a>

impl<'a> Sync for Minimax<'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> Any for T where
    T: 'static + ?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.