mieuxvoter / majority-judgment
使用快速、稳健、面向接口和可扩展的算法进行投票的深思熟虑。
1.0.3
2021-06-02 17:08 UTC
Requires
- php: >=7.4.0
Requires (Dev)
- phpunit/phpunit: ~4.6
This package is auto-updated.
Last update: 2024-09-29 05:29:18 UTC
README
深思熟虑的多数投票⚖.
特性
- 从优点档案中进行多数投票的深思熟虑
- 基于分数,效率应该可以很好地扩展(算法是可并行的)
- 面向接口,测试驱动代码
- 可扩展以获取其他判断(通常、中心等)
- 由MieuxVoter的志愿者制作
使用示例
在您的项目中使用composer要求它
composer require mieuxvoter/majority-judgment
使用它
use MieuxVoter\MajorityJudgment\MajorityJudgmentDeliberator; use MieuxVoter\MajorityJudgment\Model\Settings\MajorityJudgmentSettings; use MieuxVoter\MajorityJudgment\Model\Tally\ArrayPollTally; $tally = new ArrayPollTally([ 'Proposal A' => [1, 1, 4, 3, 7, 4, 1], // amount of judgments for each grade 'Proposal B' => [0, 2, 4, 6, 4, 2, 3], // (worst grade to best grade) ]); $deliberator = new MajorityJudgmentDeliberator(); $result = $deliberator->deliberate($tally); // $result is a PollResultInterface foreach($result->getProposalResults() as $proposalResult) { // … Do something print($proposalResult->getProposal()); print($proposalResult->getRank()); }
面向接口
任何实现PollTallyInterface的对象都可以用作输入。
测试
查看test/中的测试。
composer install --dev
vendor/phpunit/phpunit/phpunit -v test