maximal-lottery 0.1.1

A Rust library for computing maximal lotteries from preference profiles.
docs.rs failed to build maximal-lottery-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

maximal-lottery

A Rust library for computing maximal lotteries from preference profiles.

Maximal lottery is a probabilistic voting rule: voters express pairwise preferences between candidates, the profile is turned into a margin matrix, and that matrix is treated as a symmetric zero-sum game. A maximal lottery is a maximin strategy of that game.

Ranked ballots

use maximal_lottery::ballot::RankedBallot;
use maximal_lottery::prelude::*;

let n = 3;
let c = Candidate;

let ballot = RankedBallot::total(&[c(0), c(1), c(2)], n).unwrap();

let profile = PreferenceProfile::try_new(vec![ballot]).unwrap();
let margins = profile.tally_margins();
let lottery = CentroidSolver.solve(&margins).unwrap();

Pairwise ballots

use maximal_lottery::ballot::{PairPreference, PairwiseBallot};
use maximal_lottery::prelude::*;

let n = 3;
let c = Candidate;
let ballot = PairwiseBallot::from_pairs(
    &[
        (c(0), c(1), PairPreference::Left),
        (c(1), c(2), PairPreference::Left),
        (c(0), c(2), PairPreference::Left),
    ],
    n,
)
.unwrap();

let profile = PreferenceProfile::try_new(vec![ballot]).unwrap();
let margins = profile.tally_margins();
let lottery = CentroidSolver.solve(&margins).unwrap();