mieuxvoter / majority-judgment
Deliberate your polls using Majority Judgment with a fast, robust, interface-oriented and scalable algorithm.
Package info
github.com/MieuxVoter/majority-judgment-library-php
pkg:composer/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: 2026-06-06 15:25:00 UTC
README
Deliberate majority judgment polls ⚖.
Features
- Majority judgment deliberation from merit profiles
- Score based, efficiency should scale well (algo is parallelizable)
- Interface-oriented, test-driven code
- Extensible to get other judgments (usual, central, etc.)
- Made by MieuxVoter's volunteers
Usage example
Require it in your own project, using composer:
composer require mieuxvoter/majority-judgment
Use it:
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()); }
Unbalanced Tallies
If your tally is unbalanced, because some proposals received more judgments than others, you will need to balance the tally using one of the provided balancing methods (or your own):
use MieuxVoter\MajorityJudgment\Model\Tally\Balancer; $tally = Balancer::applyStaticDefault($tally); // or $tally = Balancer::applyMedianDefault($tally); // or $tally = Balancer::applyNormalization($tally);
Interface-oriented
Any object implementing PollTallyInterface may be used as input.
Testing
See the tests in test/.
composer install --dev
vendor/phpunit/phpunit/phpunit -v test