feat(elections): STV tabulation engine with test fixtures

オープン
#1,944 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か

調査の方向性

Start in the packages/tabulation/ package and read the IRV sibling issue and the schema issue first. Define the server-side STV API, then add hand-calculated golden fixtures and compare at least three cases with OpenSTV. Done means deterministic quota, transfers, eliminations, exhaustion, auto-election, and documented WIG behavior in code and docs/elections/tabulation.md.

索引モデルが issue の本文から書いたものです。

説明

Summary

Implement a Single Transferable Vote tabulation engine that elects multiple winners using the Droop quota and surplus transfer.

Part of #1933.

Requirements

  • Pure function: `tabulateSTV(ballots, candidates, seats) → { rounds[], winners[], exhaustedBallots }`
  • Compute Droop quota: `floor(validBallots / (seats + 1)) + 1`
  • Elect any candidate reaching quota; transfer surplus using a documented method (Meek, Gregory, or Weighted Inclusive Gregory — pick and document one)
  • When no candidate reaches quota, eliminate lowest and redistribute
  • Handle tie-breaks deterministically (same rule as IRV)
  • Handle exhausted ballots explicitly
  • Stop when all seats filled, or when remaining candidates ≤ remaining seats (auto-elect)
  • Document the chosen surplus-transfer method in code comments AND in `docs/elections/tabulation.md`
  • Golden fixture tests with hand-calculated multi-seat elections
  • Tabulation runs server-side only

Context

  • Epic: #1933
  • Depends on schema issue
  • STV handles multi-seat races (board elections)
  • IRV issue: see sibling issue

Implementation notes

  • Start with Weighted Inclusive Gregory (WIG) — simpler to explain publicly than Meek, widely used (e.g., Scottish local elections)
  • Same `packages/tabulation/` package as IRV
  • Compare against a reference (e.g., OpenSTV) for at least 3 test cases
主要言語
HTML
スター
33
フォーク
107
平均マージ
14時間 6分
マージ済み PR(30日)
19

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

USRSE/usrse.github.io のほかの issue

USRSE/usrse.github.io の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。