Ranking mode - Implicit versus Explicit
Impact on an election results
By default, if you do not rank all candidates in a vote, all unranked candidates are implicitly considered last. Optionally, you can prefer to allow voters to not rank all candidates.
You can change this mode. It will reset all computed results and provide a new result, they can be different.
Reference
php
use \CondorcetPHP\Condorcet\Election;
$election = new Election;
$election->parseCandidates('A;B;C');
$election->implicitRankingRule; // True, it's the default.
$election->parseVotes('
A > B * 68
B > C * 72
C > A * 52
');
// Not supporting not ranked candidate. Last candidate is implicitly added at rank 3.
$election->getWinner('Ranked Pairs'); // Return candidate B
// Supporting not ranked candidate
$election->implicitRankingRule = false;
$election->implicitRankingRule; // False.
$election->getWinner('Ranked Pairs'); // Return candidate A
// Rollback
$election->implicitRankingRule = true;
$election->getWinner('Ranked Pairs'); // Return candidate B
At the Vote level
php
use \CondorcetPHP\Condorcet\{Election, Vote};
$election1 = new Election;
$election1->parseCandidates('A;B;C;D');
$vote = new Vote('A>Z>B'); // Candidate Z is not a candidate of this election. C=D is implicit.
$election1->addVote($vote);
$election1->implicitRankingRule; // Return True, it's the default.
$vote->getRankingAsArrayString(context: $election1); // [1 => "A", 2 => "B", 3 => ['C', 'D']]
$vote->getRankingAsString(context: $election1); // 'A > B > C = D'
$vote->getRankingAsString(); // 'A > Z > B > C = D'
$election1->implicitRankingRule = false;
$vote->getRankingAsArrayString(context: $election1); // [1 => "A", 2 => "B"]
$vote->getRankingAsString(context: $election1); // 'A > B'
$vote->getRankingAsString(); // 'A > Z > B > C = D'