Skip to content

Vote Methods Options & Warning

Methods Options

A method option allows you to adjust some parameters for the voting methods. Most often, methods provide subclasses when possible; otherwise, they are options, which we will explore. The options are documented for each method in the voting methods documentation. Options always have a default value.

A method option is set at the election object to ensure that the correct cache management tasks are performed. It is possible to set them statistically at the level of the algorithms, but this approach will not be explored here.

Example with Borda

php
$electionWithVotes->setMethodOption('Borda Count', 'Starting', 0);

// The result object keeps metadata about options passed in a readonly property
$electionWithVotes->getResult('Borda Count')->methodOptions; // ['Starting' => 0]

Results Warning

Kemeny-Young

Currently, Kemeny-Young is potentially subject to conflicts leading to a relatively arbitrary final choice. This is very likely in the case of a very small number of voters. The current implementation does not include any trick for the resolver.
The next option allows you to get, rather than a ranking, information on the existence or absence of these conflicts. The following example shows how to use it.

php
use \CondorcetPHP\Condorcet\Algo\Methods\KemenyYoung\KemenyYoung;

$result = $electionWithVotes->getResult('KemenyYoung');

if (!empty($result->getWarning(KemenyYoung::CONFLICT_WARNING_CODE))) {
    $kemeny_conflicts = explode(';', $result->getWarning(KemenyYoung::CONFLICT_WARNING_CODE)[0]['msg']);
    $conclusion = 'Arbitrary results, Kemeny-Young has ' . $kemeny_conflicts[0] . ' possible solutions at score ' . $kemeny_conflicts[1];
} else {
    // $result is the usual result
}

Released under the MIT License.