docs: add a sample merit profile

main
Dominique Merle 3 years ago
parent cf4b7c7a6c
commit 01d13315ef

@ -16,6 +16,12 @@ Supports billions of judgments and thousands of proposals per poll, if need be.
## Usage
Say you have the following tally:
![Example of a merit profile](./docs/2-2-2-2-2_2-1-1-1-5_2-1-1-2-4_2-1-5-0-2_2-2-2-2-2.png)
You can compute out the majority judgment rank of each proposal like so:
```go
package main
@ -29,27 +35,32 @@ import (
func main() {
poll := &judgment.PollTally{
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{}
})
deliberator := &(judgment.MajorityJudgment{})
result, err := deliberator.Deliberate(poll)
if nil != err {
log.Fatalf("Deliberation failed: %v", err)
}
fmt.Printf("Result: %v\n", result) // proposals results are ordered like tallies, but Rank is available
// 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
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Loading…
Cancel
Save