feat(elections): STV tabulation engine with test fixtures

Đang mở
#1,944 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
HTML
Star
33
Fork
107
Merge trung bình
14 giờ 6 phút
Pull request đã merge (30 ngày)
19

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của USRSE/usrse.github.io

Tất cả issue của USRSE/usrse.github.io

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.