各种选举方法的一种实现,最显著的是schulze方法和schulze stv。--仅限Python 3
python3-vote-core的Python项目详细描述
python vote core实现各种选举方法,提供 根据提供的一组选票和选项计算出的结果。这个 fork只实现python3兼容性!
- 项目页面:http://github.com/the-maldridge/python-vote-core
- 问题跟踪器:http://github.com/the-maldridge/python-vote-core/issues
Python3
这个fork通过使用2to3实现python3功能,然后 从别人的叉子上摘樱桃。这当然不是 一个干净的方法,但100%的测试通过Python3。
此叉只存在于有一个发行版下。实现的方法
- 单赢家方法
- 多人(亦称第一个通过岗位或FPTP)
- 即时决选投票(也称为IRV)
- Schulze方法(又名BeatPath)
- 多个赢家方法
- 多数票在逃(又称分组投票)
- 单一可转让投票(也称为STV)
- 舒尔茨STV
- 排序方法
- 舒尔茨比例表示法
- Schulze非比例代表
基本用法
schulze方法示例:
>>> from pyvotecore.schulze_method import SchulzeMethod >>> from pyvotecore.condorcet import CondorcetHelper >>> ballots = [ ... { "count":3, "ballot":[["A"], ["C"], ["D"], ["B"]] }, ... { "count":9, "ballot":[["B"], ["A"], ["C"], ["D"]] }, ... { "count":8, "ballot":[["C"], ["D"], ["A"], ["B"]] }, ... { "count":5, "ballot":[["D"], ["A"], ["B"], ["C"]] }, ... { "count":5, "ballot":[["D"], ["B"], ["C"], ["A"]] } ... ] >>> SchulzeMethod(ballots, ballot_notation = CondorcetHelper.BALLOT_NOTATION_GROUPING).as_dict() {'actions': [{'edges': {('A', 'B')}}, {'edges': {('A', 'C')}}, {'nodes': {'A'}}, {'edges': {('B', 'C')}}, {'nodes': {'B', 'D'}}], 'candidates': {'A', 'B', 'C', 'D'}, 'pairs': {('A', 'B'): 16, ('A', 'C'): 17, ('A', 'D'): 12, ('B', 'A'): 14, ('B', 'C'): 19, ('B', 'D'): 9, ('C', 'A'): 13, ('C', 'B'): 11, ('C', 'D'): 20, ('D', 'A'): 18, ('D', 'B'): 21, ('D', 'C'): 10}, 'strong_pairs': {('A', 'B'): 16, ('A', 'C'): 17, ('B', 'C'): 19, ('C', 'D'): 20, ('D', 'A'): 18, ('D', 'B'): 21}, 'winner': 'C'}
20110509.1年 -
-
固定PyPI释放< /LI>
20110509.0年 -
- 初始PYPI版本
许可证
版权所有(c)2009,Brad Beattie
此程序是免费软件:您可以重新分发和/或修改 根据由 自由软件基金会,或者许可证的第3版,或者 (由您选择)任何更高版本。
这个程序的发布是希望它能有用, 但没有任何保证;甚至没有 适销性或适合某一特定目的的适销性。见 GNU通用公共许可证了解更多详细信息。
你应该收到GNU通用公共许可证的副本 还有这个节目。如果没有,请参阅http://www.gnu.org/licenses。