[−][src]Enum tallystick::borda::Variant
Specifies method used to assign points to ranked candidates.
Variants
The standard Borda count where each candidate is assigned a number of points equal to the number of candidates ranked lower than them. It is known as the "Starting at 0" Borda count since the least-significantly ranked candidate is given zero points. Each candidate is given points according to:
number-candidates - candidate-position - 1
Example point allocation for a single ballot:
Position on ballot | Candiate | Points |
---|---|---|
0 | Alice | 3 |
1 | Bob | 2 |
2 | Carlos | 1 |
3 | Dave | 0 |
The classic Borda count as defined in Jean-Charles de Borda's original proposal. It is known as the "Starting at 1" Borda count since the least-significantly ranked candidate is given one point. Each candidate is given points according to:
number-candidates - candidate-position
Example point allocation for a single ballot:
Position on ballot | Candiate | Points |
---|---|---|
0 | Alice | 4 |
1 | Bob | 3 |
2 | Carlos | 2 |
3 | Dave | 1 |
In the Dowdall system, the highest-ranked candidate obtains 1 point, while the 2nd-ranked candidate receives ½ a point, the 3rd-ranked candidate receives ⅓ of a point, etc. An important difference of this method from the others is that the number of points assigned to each preference does not depend on the number of candidates. Each candidate is given points according to:
1 / (candidate-position + 1)
If Dowdall is selected, tallystick will panic if an integer count type is used in the tally. This variant should only be used with a float or rational tally.
Example point allocation for a single ballot:
Position on ballot | Candiate | Points |
---|---|---|
0 | Alice | 1 |
1 | Bob | ½ |
2 | Carlos | ⅓ |
3 | Dave | ¼ |
Example:
use tallystick::borda::BordaTally; use tallystick::borda::Variant; // Note use of `f64` as our count type. let mut tally = BordaTally::<&str, f64>::new(1, Variant::Dowdall); tally.add(vec!["Barak Obama", "John McCain"]); tally.add(vec!["Barak Obama", "Mitt Romney"]); let _winners = tally.winners();
In a modified Borda count, the number of points given for a voter's first and subsequent preferences is determined by the total number of candidates they have actually ranked, rather than the total number listed.
This is to say, typically, on a ballot of n
candidates, if a voter casts only m
preferences (where n ≥ m ≥ 1
), a first preference gets m
points, a second preference m – 1
points, and so on.
Modified Borda counts are used to counteract the problem of bullet voting.
Each candidate is given points according to:
number-marked - candidate-position
Custom point assignment using a boxed closure. Takes a closure of the form:
fn(candidate_position: usize, num_candidates: usize, num_marked: usize) -> C
Example:
use tallystick::borda::BordaTally; use tallystick::borda::Variant; let boxed_func = Box::new(|candidate_position, num_candidates, num_marked| { if num_marked == 1 { return 1; } else { return num_marked - candidate_position - 1; } }); let mut tally = BordaTally::<&str, usize>::new(1, Variant::Custom(boxed_func));
Methods
impl<C: Numeric + Num + NumCast> Variant<C>
[src]
pub fn points(
&self,
candidate_position: usize,
num_candidates: usize,
num_marked: usize
) -> C
[src]
&self,
candidate_position: usize,
num_candidates: usize,
num_marked: usize
) -> C
Get the number of points for a candidate at a certain position on a ballot.
candidate_position
is the position of the candidate on the marked ballot. It is0
for the 1st candidate,1
for the second candidate etc.num_candidates
is the total number of candidates in this election.num_marked
is the total number of candidates marked on the ballot.
This method will panic if using Variant::Dowdall
with an integer based vote-count type.
Auto Trait Implementations
impl<C> !RefUnwindSafe for Variant<C>
impl<C> !Send for Variant<C>
impl<C> !Sync for Variant<C>
impl<C> Unpin for Variant<C>
impl<C> !UnwindSafe for Variant<C>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,