meekstv

package module
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2025 License: MIT Imports: 9 Imported by: 2

README

meekstv

Go Report Card Build Status

An implementation of single transferable vote by Meek's Method.

References:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Precision     = 8
	MaxIterations = 1000
)

Functions

This section is empty.

Types

type Ballot added in v0.5.0

type Ballot struct {
	Count       int
	Preferences []int
}

type Ballots added in v0.5.0

type Ballots []Ballot

func (Ballots) TotalCount added in v0.5.0

func (b Ballots) TotalCount() int

type Candidate added in v0.5.0

type Candidate struct {
	ID     int
	Name   string
	Weight int64
	Votes  int64
	State  CandidateState
	Rank   int
	// contains filtered or unexported fields
}

type CandidateState added in v0.5.0

type CandidateState uint8
const (
	Hopeful CandidateState = 1 << iota
	Elected
	Excluded
	Lowest
	Random
	Hopeless
	Withdrawn
)

func (CandidateState) Has added in v0.5.0

Returns true if ALL states in s are active. Logical AND.

func (CandidateState) HasAny added in v0.5.0

func (c CandidateState) HasAny(s CandidateState) bool

Returns true if ANY state in s is active. Logical OR.

type Config added in v0.5.0

type Config struct {
	Seats               int
	Ballots             Ballots
	Candidates          []string
	WithdrawnCandidates []int
	DisableDetail       bool
}

type Detail added in v0.5.0

type Detail struct {
	Candidates int
	Ballots    int
	Seats      int
	Precision  int
	Elected    []string
	Withdrawn  []string
	Rounds     []Round
}

func (Detail) WriteReport added in v0.5.0

func (d Detail) WriteReport(wr io.Writer) error

type Result added in v0.5.0

type Result struct {
	Elected   []string
	Withdrawn []string
	Detail    *Detail
}

func Count added in v0.5.0

func Count(config Config) (Result, error)

type Round added in v0.5.0

type Round struct {
	Number     int
	Quota      int64
	Exhausted  int64
	Candidates []Candidate
	// contains filtered or unexported fields
}

func (Round) Describe added in v0.5.0

func (round Round) Describe() string

func (Round) Events added in v0.5.0

func (round Round) Events() []event.Event

type WichmannHillRandom added in v0.4.0

type WichmannHillRandom interface {
	Next() float64
	NextInt(n int) int
}

Implementation based on: "Algorithm AS 183: An Efficient and Portable Pseudo-Random Number Generator" by B. A. Wichmann and I. D. Hill.

func NewWichmannHillRandom added in v0.4.0

func NewWichmannHillRandom(s1, s2, s3 int) WichmannHillRandom

Each seed should be a value between 1 and 30000.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL