A Golang module to rank candidates using Majority Judgment, using a score-based algorithm for performance and scalability
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Dominique Merle 8c076bbd0f
fix(docs): perfunctory and apparently mandatory copyright notice
3 years ago
.github/workflows feat(ci): build & test 3 years ago
docs docs: explain the score calculus 3 years ago
LICENSE.md fix(docs): perfunctory and apparently mandatory copyright notice 3 years ago
README.md docs: move the license file so that github finds it (hopefully) 3 years ago
analysis.go feat: initial implementation 3 years ago
analysis_test.go feat: initial implementation 3 years ago
go.mod chore: go mod tidy 3 years ago
go.sum chore: go mod tidy 3 years ago
majorityjudgment.go feat: add the Index and Analysis to the ProposalResult 3 years ago
majorityjudgment_test.go feat: reject unbalanced tallies as well as mishaped tallies 3 years ago
result.go feat: add the Index and Analysis to the ProposalResult 3 years ago
tally.go feat: add the Index and Analysis to the ProposalResult 3 years ago

README.md

Majority Judgment for Golang

MIT Build Status Discord Chat https://discord.gg/rAAQG9S

WORK IN PROGRESS

A Go library to deliberate using Majority Judgment.

We use a score-based algorithm, for performance and scalability.

Supports billions of judgments and thousands of proposals per poll, if need be.

Installation

go get -u github.com/mieuxvoter/judgment

Usage

Say you have the following tally:

Example of a merit profile

You can compute out the majority judgment rank of each proposal like so:


package main

import (
	"fmt"
	"log"

	"github.com/mieuxvoter/judgment"
)

func main() {

    poll := &(judgment.PollTally{
        AmountOfJudges: 10,
        Proposals: []*judgment.ProposalTally{
            {Tally: []uint64{2, 2, 2, 2, 2}}, // Proposal A   Amount of judgments received for each grade,
            {Tally: []uint64{2, 1, 1, 1, 5}}, // Proposal B   from "worst" grade to "best" grade.
            {Tally: []uint64{2, 1, 1, 2, 4}}, // Proposal C   Make sure all tallies are balanced, that is they
            {Tally: []uint64{2, 1, 5, 0, 2}}, // Proposal D   hold the same total amount of judgments.
            {Tally: []uint64{2, 2, 2, 2, 2}}, // Proposal E   Equal proposals share the same rank.
            // …
        },
    })
    deliberator := &(judgment.MajorityJudgment{})
    result, err := deliberator.Deliberate(poll)

    if nil != err {
        log.Fatalf("Deliberation failed: %v", err)
    }
    
    // Proposals results are ordered like tallies, but Rank is available. 
    // result.Proposals[0].Rank == 4
    // result.Proposals[1].Rank == 1
    // result.Proposals[2].Rank == 2
    // result.Proposals[4].Rank == 3
    // result.Proposals[5].Rank == 4

}

License

MIT 🐜

Contribute

A review by a seasoned Go veteran would be appreciated.