Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

My First Playground

node v14.20.1
version: 1.0.2
endpointsharetweet
const fill = require('lodash/fill') const { Minimax, utils: votesUtils } = require('votes') const balinski = votesUtils.toWeightedBallots([ ...fill(new Array(33), [['a'], ['b'], ['c'], ['d'], ['e']]), ...fill(new Array(16), [['b'], ['d'], ['c'], ['e'], ['a']]), ...fill(new Array(3), [['c'], ['d'], ['b'], ['a'], ['e']]), ...fill(new Array(8), [['c'], ['e'], ['b'], ['d'], ['a']]), ...fill(new Array(18), [['d'], ['e'], ['c'], ['b'], ['a']]), ...fill(new Array(22), [['e'], ['c'], ['b'], ['d'], ['a']]), ]) // Default variant: MARGINS console.log('MARGINS') const electionMargins = new Minimax( votesUtils.matrixFromBallots(balinski, ['a', 'b', 'c', 'd', 'e']), ) console.log(electionMargins.scores()) console.log(electionMargins.ranking()) // variant: WINNING_VOTES console.log('WINNING_VOTES') const electionWinnigVotes = new Minimax({ ...votesUtils.matrixFromBallots(balinski, ['a', 'b', 'c', 'd', 'e']), variant: 'WINNING_VOTES' }) console.log(electionWinnigVotes.scores()) console.log(electionWinnigVotes.ranking()) // variant: PAIRWISE_OPPOSITION console.log('PAIRWISE_OPPOSITION') const electionPairwiseOpposition = new Minimax({ ...votesUtils.matrixFromBallots(balinski, ['a', 'b', 'c', 'd', 'e']), variant: 'PAIRWISE_OPPOSITION' }) console.log(electionPairwiseOpposition.scores()) console.log(electionPairwiseOpposition.ranking())
Loading…

no comments

    sign in to comment