Coder Social home page Coder Social logo

julien-boudry / condorcet Goto Github PK

View Code? Open in Web Editor NEW
118.0 12.0 13.0 15.79 MB

Command line application and PHP library, providing an election engine with a high-level interface. Native support 20+ voting methods, easy to extend. Support simple elections with ease or billions of votes in low resource environment. Intensively tested and highly polyvalent.

Home Page: https://www.condorcet.io

License: MIT License

PHP 99.72% Dockerfile 0.15% Shell 0.13%
condorcet election-polling election election-reform copeland minimax vote ranked-pairs dodgson kemeny-young

condorcet's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

condorcet's Issues

Dodgson

When I use examples from Some Remarks on Dodgson’s Voting Rule then www.condorcet.vote delivers different results than expected. Is it because the implementation provides optimistic estimates on the count of "swaps"? If so, it should be noted in the documentation.

Example 1:

D>A>B>C*1
A>D>B>C*1
A>B>C>D*2
D>B>C>A*2
C>A>B>D*2
B>C>A>D*2
D>C>A>B*2

Expected winner: A
Delivered winner: D

Example 2:

B>A>C>D*5
A>C>B>D*5
A>B>D>C*9
B>D>C>A*9
C>A>D>B*15

Expected winner: A
Delivered winner: C

Syntax Error L.1123 -> Condorcet.php

Parse error: syntax error, unexpected '[' in C:\xampp\htdocs\condorcet\lib\Condorcet\Condorcet.php on line 1123

return $this->getResult($algo)[1] ;

Pb with symphony Command/Command.php

Q A
Type Bug
Condorcet version 2.2.3
PHP version 7.4.3
Installation Method Composer

Using

./vendor/bin/condorcet election --candidates listeLigne.txt --votes voteCA.txt -r

I get the following error:

PHP Fatal error:  Uncaught Error: Call to a member function getName() on null in /home/mc/Bureau/Condorcet-master/Condorcet/vendor/julien-boudry/condorcet/lib/Console/Commands/ElectionCommand.php:254
Stack trace:
#0 /home/mc/Bureau/Condorcet-master/Condorcet/vendor/symfony/console/Command/Command.php(299): CondorcetPHP\Condorcet\Console\Commands\ElectionCommand->execute()
#1 /home/mc/Bureau/Condorcet-master/Condorcet/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run()
#2 /home/mc/Bureau/Condorcet-master/Condorcet/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand()
#3 /home/mc/Bureau/Condorcet-master/Condorcet/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun()
#4 /home/mc/Bureau/Condorcet-master/Condorcet/vendor/julien-boudry/condorcet/lib/Console/CondorcetApplication.php(25): Symfony\Component\Console\Application->run()
#5 /home/mc/Bureau/Condorcet-master/Condorcet/vendor/julien-boudry/condorcet/bin in /home/mc/Bureau/Condorcet-master/Condorcet/vendor/julien-boudry/condorcet/lib/Console/Commands/ElectionCommand.php on line 254

My files are the following (on a simple test, everything works well):

listeLigne.txt

association-gut.eu;association-gut.fr;association-gut.info;association-gut.net;association-gut.org;association-gutenberg.eu;association-gutenberg.info;associationgutenberg.eu;associationgutenberg.fr;associationgutenberg.info;associationgutenberg.net;associationgutenberg.org;asso-gut.eu;asso-gut.fr;asso-gut.info;asso-gut.net;asso-gut.org;asso-gutenberg.eu;asso-gutenberg.info;fr.tug.org;francogut.eu;francogut.fr;francogut.info;francogut.net;francogut.org;francotug.eu;francotug.fr;francotug.info;francotug.net;francotug.org;groupetex.eu;groupetex.fr;groupetex.info;groupetex.net;groupetex.org;grtex.eu;grtex.fr;grtex.info;grtex.net;grtex.org;grutex.eu;grutex.fr;grutex.info;grutex.net;grutex.org;gutambergue.eu;gutambergue.fr;gutambergue.info;gutambergue.net;gutambergue.org;gutanbergue.eu;gutanbergue.fr;gutanbergue.info;gutanbergue.net;gutanbergue.org;gut-asso.eu;gut-asso.fr;gut-asso.info;gut-asso.net;gut-asso.org;gut-association.eu;gut-association.fr;gut-association.info;gut-association.net;gut-association.org;gutemberg.eu;gutemberg.info;gutenber.eu;gutenber.fr;gutenber.info;gutenber.net;gutenberg.fr;gutenberg-asso.eu;gutenberg-asso.fr;gutenberg-asso.info;gutenberg-asso.net;gutenberg-asso.org;gutenberg-association.eu;gutenberg-association.fr;gutenberg-association.info;gutenberg-association.net;gutenberg-association.org;gutenberg-france.eu;gutenberg-france.fr;gutenberg-france.info;gutenberg-france.net;gutenberg-france.org;gutenberg-latex.eu;gutenberg-latex.fr;gutenberg-latex.info;gutenberg-latex.net;gutenberg-latex.org;gutenberglatex.eu;gutenberglatex.fr;gutenberglatex.info;gutenberglatex.net;gutenberglatex.org;gutenberg-tex.eu;gutenberg-tex.fr;gutenberg-tex.info;gutenberg-tex.net;gutenberg-tex.org;gutenferg.eu;gutenferg.fr;gutenferg.info;gutenferg.net;gutenferg.org;gutenfr.eu;gutenfr.fr;gutenfr.info;gutenfr.net;gutenfr.org;gutenvers.eu;gutenvers.fr;gutenvers.info;gutenvers.net;gutenvers.org;gutex.fr;gutexberg.eu;gutexberg.fr;gutexberg.info;gutexberg.net;gutexberg.org;gut-fr.eu;gut-fr.fr;gut-fr.info;gut-fr.net;gut-fr.org;gut-latex.eu;gut-latex.fr;gut-latex.info;gut-latex.net;gut-latex.org;gutnber.eu;gutnber.fr;gutnber.info;gutnber.net;gutnber.org;gutnberg.eu;gutnberg.fr;gutnberg.info;gutnberg.net;gut-tex.eu;gut-tex.fr;gut-tex.info;gut-tex.net;gut-tex.org;jgutenberg.eu;jgutenberg.fr;jgutenberg.info;jgutenberg.net;jgutenberg.org;texgutenberg.eu;texgutenberg.fr;texgutenberg.info;texgutenberg.net;texgutenberg.org;tug-fr.eu;tug-fr.fr;tug-fr.info;tug-fr.net;tug-fr.org;tug-french.eu;tug-french.fr;tug-french.info;tug-french.net;tug-french.org

and voteCA.txt

associationgutenberg.fr>associationgutenberg.net>associationgutenberg.org>gutenberg-asso.fr>gutenberg-asso.net>gutenberg-asso.org>gutenberg-association.fr>gutenberg-association.net>gutenberg-association.org>gut-asso.fr>gut-asso.net>gut-asso.org>association-gut.fr>association-gut.net>association-gut.org;
association-gutenberg.info>gutenberg-association.fr>gutenberg-association.org>gutenberg-association.info>gutenberg-association.net>asso-gutenberg.info>gutenberg-asso.fr>gutenberg-asso.org>gutenberg-asso.info>gutenberg-asso.net>gutenberg-latex.fr>gutenberg-latex.org>gutenberg-latex.info>gutenberg-latex.net>gutenberg-tex.fr>gutenberg-tex.org>gutenberg-tex.info>gutenberg-tex.net>associationgutenberg.fr>associationgutenberg.org>associationgutenberg.info>associationgutenberg.net;
associationgutenberg.fr>gutenberg-association.fr>gutenberg-latex.fr>association-gutenberg.info>associationgutenberg.org>associationgutenberg.net>associationgutenberg.info>gutenberg-latex.info>gutenberg-latex.net>gutenberg-latex.org>gutenberg-association.org>gutenberg-association.net>gutenberg-association.info>tug-fr.org>tug-fr.net>groupetex.org;
association-gutenberg.fr>association-gut.fr>asso-gutenberg.fr>asso-gut.fr>gut-asso.fr>gutenberg-association.fr>association-gutenberg.org>association-gut.org>asso-gutenberg.org>asso-gut.org>gut-asso.org>gutenberg-association.org>gutenberg-asso.org;
asso-gut.org>asso-gut.fr>gut-asso.org>gut-asso.fr>association-gut.org>gut-association.org>gut-association.fr>gut-latex.org>gut-latex.fr>gutenberg-latex.org>gutenberg-latex.fr>gutenberg-tex.org>gutenberg-tex.fr>asso-gutenberg.eu
association-gut.fr>association-gut.org>association-gutenberg.fr>association-gutenberg.org>asso-gut.fr>asso-gut.org>asso-gutenberg.fr>asso-gutenberg.org>gutenberg.fr>gutenberg.org>gutenberg-asso.fr>gutenberg-asso.org>gutenberg-association.fr>gutenberg-association.org;
gutenberg.fr>gutex.fr>groupetex.fr>groupetex.org>gutenberg.eu.org>jgutenberg.eu>jgutenberg.fr>jgutenberg.org>grtex.fr>grutex.org;
associationgutenberg.fr>associationgutenberg.org>gutenberg-association.fr>gutenberg-association.org>gutenberg-asso.fr>gutenberg-asso.org>gutenberg-tex.fr>gutenberg-tex.org>association-gut.fr>association-gut.org;
associationgutenberg.fr>associationgutenberg.org>gutenberg-association.fr>gutenberg-association.org>gutenberg-asso.fr>gutenberg-asso.org>gutenberg-asso.fr>gutenberg-asso.org>gutenberg-latex.fr>gutenberg-latex.org>gutenberg-tex.fr>gutenberg-tex.org>gutenberg-latex.net>gutenberg-tex.net>association-gut.fr>association-gut.org>gut-asso.fr>gut-asso.org

Any idea? Maybe is it due to the dots and the dashes in each domain name?

Thx

Rewrite Ranked Pairs (Still experimental to date)

Since his introduction into version 0.10, Randked Pairs method implementation is know as experimental (and clearly marked into the documentation). It's working well in a large majority of case, and in any honest election with many various vote.

But it fail because it can't output tie and chose arbitrary result in this case.

Randked pairs mus be largely rewrite to success this tests :
http://ericgorr.net/condorcet/rankedpairs/example3/
http://ericgorr.net/condorcet/rankedpairs/example4/

One should also consider adding a Randked Pairs variant using the margin in place of the winning majority.

Don't forget the doc :
image

Boring Kemeny-Young... more than 6 candidates...

I am looking for a way to create pre-computed data sets for Kemeny-Young, and election support having more than 6 candidates.

Unfortunately, my solution for calculating permutations sets PHP has its limits. Also, I'm looking at pre-determined this type of data sets:

a: 2: {i: 1; a: 2: {i: 1; s: 2: "C0"; i: 2; s: 2: "C1";} i: 2; a: 2: {i: 1; s: 2: "C1"; i: 2; s: 2: "C0";}}
(Kemeny-Young for two candidates)

It's actually all the possible designation of an election for X candidates.

I schedule to test alternative impentative in Ruby to generate this pre-computed data. Aim it's so boring ... And there he has a chance of easy success?

If someone want to help, he is welcome!

Condorcet/lib/Condorcet/algorithms/KemenyYoung-Data

JIT tracing bug with STV in conjunction with non proportional method (only PHP 8.0 with JIT tracing mode enabled)

Q A
Type Bug / Support / Suggestion / Other
Condorcet version 3.1.0 && 3.2.0
PHP version 8.0.10 (NTS, x64, Linux + Windows) && PHP 8.1-RC6
Installation Method __CondorcetAutoload.php

See this failing code

just git clone from actual master branch for 3.2 branch with PHP 8.1 ; branch dev-3.1 for 3.1 with PHP 8.0

Linux:
php -dzend_extension=opcache -dopcache.enable_cli=1 -dopcache.jit_buffer_size=100M -dopcache.jit=tracing Dev/bugs/JitBug.php

Windows:
php -d zend_extension=opcache -d opcache.enable_cli=1 -d opcache.jit_buffer_size=100M -d opcache.jit=tracing Dev/bugs/JitBug.php

Unable to reproduce in theoric PHP (after many trials), it's a JIT optimization bug that only happens in Condorcet when using STV in conjunction with a non-proportional method.

  • The bug only with jit "tracing" mode (working with jit "function" mode) (test on PHP 8.0.10 NTS on x64)
  • Working with or without opcache, the bug only if using jit tracing mode (which is the default for JIT)
  • It's working fine with PHP 8.1-RC1... and it's buggy with RC6
  • No bug if you remove named parameter from the call (new Result ([...])

The bug:

PHP Fatal error:  Uncaught TypeError: CondorcetPHP\Condorcet\Result::__construct(): Argument #6 ($seats) must be of type ?int, CondorcetPHP\Condorcet\Election given, called in C:\dev_scripts\Condorcet\lib\Algo\Method.php on line 84 and defined in C:\dev_scripts\Condorcet\lib\Result.php:89
Stack trace:
#0 C:\dev_scripts\Condorcet\lib\Algo\Method.php(84): CondorcetPHP\Condorcet\Result->__construct()
#1 C:\dev_scripts\Condorcet\lib\Algo\Methods\STV\SingleTransferableVote.php(91): CondorcetPHP\Condorcet\Algo\Method->createResult()
#2 C:\dev_scripts\Condorcet\lib\Algo\Method.php(63): CondorcetPHP\Condorcet\Algo\Methods\STV\SingleTransferableVote->compute()
#3 C:\dev_scripts\Condorcet\lib\ElectionProcess\ResultsProcess.php(80): CondorcetPHP\Condorcet\Algo\Method->getResult()
#4 C:\dev_scripts\Condorcet\Dev\bugs\JitBug.php(37): CondorcetPHP\Condorcet\Election->getResult()
#5 {main}

It looks impossible if you have a look on Condorcet\lib\Algo\Method.php(84): CondorcetPHP\Condorcet\Result->__construct() and Election->getNumberOfSeats() which is typed to integer.

Is it possible to use ranking for a single candidate?

Q A
Type Support
Concorcet version 2.2.3
PHP version 7.4
Installation Method __CondorcetAutoload.php

Imagine we have only one candidate and users vote for it from 1= worst to 5 = the best. Then how to use Condorcet? I used below but it seems I am wrong, please advise.

    $election->addCandidate(new Candidate ('Candidate1'));
    $json_votes = json_encode([
	['vote' => '1'], // A user voted 1 as the worst.
	['vote' => '2'],
	['vote' => '3']]); // Another user voted 5 as the best.
   $vote = new Vote('Candidate1');
   $ranking = $vote->setRanking ($json_votes);

change of pdo_sqlite to pdo_mysql

Q A
Type Bug / Support
Concorcet version 2.x.x
PHP version 7.4
Installation Method __CondorcetAutoload.php

I changed this

$pdo_object = new \PDO ('sqlite:'.__DIR__.'/bdd.sqlite');

to this:

    $pdo_object = new \PDO('mysql:host=127.0.0.1;dbname=dbtest', 'dbuser', 'dbpass');

and I got below. What should I do?

[26-Apr-2021 07:53:34 America/Chicago] PHP Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT INTEGER PRIMARY KEY NOT NULL , data BLOB NOT NULL )' at line 1 in vendor/julien-boudry/condorcet/lib/DataManager/DataHandlerDrivers/PdoDriver/PdoHandlerDriver.php:70
Stack trace:
#0 vendor/julien-boudry/condorcet/lib/DataManager/DataHandlerDrivers/PdoDriver/PdoHandlerDriver.php(70): PDO->exec('CREATE TABLE IF...')
#1 vendor/julien-boudry/condorcet/lib/DataManager/DataHandlerDrivers/PdoDriver/PdoHandlerDriver.php(48): CondorcetPHP\Condorcet\DataManager\DataHandlerDrivers\PdoDriver\PdoHandlerDriver->createTable()
#2 vendor/julien-boudry/condorcet/Examples/Specifics_Examples/use_large_election_external_database_drivers.php(44): CondorcetPHP\Condo in vendor/julien-boudry/condorcet/lib/DataManager/DataHandlerDrivers/PdoDriver/PdoHandlerDriver.php on line 70

EDIT:
The query '...AUTO_INCREMENT INTEGER PRIMARY KEY NOT NULL , data BLOB
NOT NULL...' doesn't seem to be valid on MySQL.

You mentioned "We will use PDO SQLITE, but can
be MySQL or else" but it doesn't seem to be true if the project uses
queries that are not supported.

Implement PHP 8.1 new features

  • Readonly Properties

  • Final Class Constants

  • Never return Type (especially for tests)

  • New in initializers?

  • Deprecation & Others minors changes

  • Enum for Election State?

  • Enum with STV Quotas

  • Restrict method options to Enum|int value?

  • Fix documentation for Enum

  • Update Wiki documentation for StvQuotas

  • Github Workflow

  • Composer Requierements

  • Docker File (final release, not RC)

fetched votes from db and taking the vote

Q A
Type Support
Concorcet version 2.x
PHP version 7.4
Installation Method Composer

I have this:

    use CondorcetPHP\Condorcet\Condorcet;
    use CondorcetPHP\Condorcet\Election;
    use CondorcetPHP\Condorcet\Candidate;
    use CondorcetPHP\Condorcet\CondorcetUtil;
    use CondorcetPHP\Condorcet\Vote;

    require_once ("./vendor/autoload.php");
    
    Condorcet::setDefaultMethod('Schulze'); 

    $election = new Election ();

   $votes = $em->getRepository('Entities\Vote')->findBy(['categoryId' => $_GET['id']]);
   foreach ($votes as $vote){
            $result[] = $vote->getVote();
            $vote1 = new Vote ( $vote->getVote() );
            $election->addVote($vote1); 
   }
   
 
 print_r($election->countVotes ());

print("<br />");
foreach ($election->getResult('Schulze') as $rank => $candidates) :

    echo 'Rank ' . $rank . ': ';
    echo implode(', ', $candidates);
    echo '<br />';
    
endforeach;

echo 'Schulze winner is : ' . $election->getWinner('Schulze')->getName() . '<br />';

//print_r($result);

This $vote->getVote() returns votes from db with this format:
Brass Birmingham = Scythe > Concordia = Gaia Project = On Mars > Power Grid = Terraforming Mars > A Feast for Odin = Everdell = Spirit Island = Through the Ages > Terra Mystica = Wingspan > Gloomhaven

I get:
Uncaught CondorcetPHP\Condorcet\Throwable\CondorcetException: [20]: You need to specify one or more candidates before voting (line: /home2/phplicen/public_html/shultze/vendor/julien-boudry/condorcet/lib/Election.php:320) thrown in vendor/julien-boudry/condorcet/lib/Election.php on line 320

Does this mean that I should define each individual candidate items again? why for getting the final result I should define individual candidates again?

English

Improvement of the english of the documentation.

Add Vote method: Ranking from a simple string

Q A
Type Support
Concorcet version 3
PHP version 7.4
Installation Method Composer

I need clarification about below. For example if candidate1 gets 1 from a voter and gets 2 from another voter, how should I use > among them? How do I know if this is A > B or B >A?

  // Add some votes, by some ways
  $myElection1->addVote(  [
                              $candidate2, // 1
                              [$candidate1, $candidate4] // 2 - Tie
                              // Last rank is optionnal. By default, it will be implicitly completed in $candidate3. This behaviour can be changed by election, before, during or after the vote. The initial submission being preserved.
                          ]
  );

  $myElection1->addVote('Candidate 2 > Candidate 3 > Candidate 4 = Candidate 1'); // Last rank can also be omitted

  $myElection1->parseVotes(
              'Candidate 1 > Candidate 2 = Candidate 4 > Candidate 3 * 4
              Candidate 3 > Candidate 1 * 3'
  );

condorcet.vote is unfinished

I think condorcet.vote is quite unfinished. You're only allowed to enter alphanumeric characters, and the translation is horrible.

Typos

The result page on https://www.condorcet.vote possibly contains typos:

  1. Optionnal -> Optional
  2. personnal -> personal
  3. This URL can be use by anyone to vote -> This URL can be used by anyone to vote
  4. Schulze (Winning variant, recommand by M.Schulze itself) . -> Schulze (Winning variant, recommended by M. Schulze himself).
  5. Vote tag or number separated by semicolon. -> Vote tags or numbers separated by semicolons.

Zip download is missing most of the folders

Q A
Type Bug
Concorcet version 1.6.0
PHP version N/A
Installation Method N/A

I just downloaded the current zip file and the only folder included it "lib". All other folders including "Examples" appear to be missing from the zip.

getWinner & getName: various questions

Q A
Type Bug / Support
Concorcet version 2.x
PHP version 7.4
Installation Method __CondorcetAutoload.php

Beside my another question regarding = in my another issue, I have another problem too:

if (isset($_POST) && $_POST != "") {

    arsort($_POST['item']);
    foreach ($_POST['item'] as $game => $priority) {
         $games[] = $game;
    }
    Condorcet::setDefaultMethod('Schulze'); // Argument: A supported method  

    $election = new Election ();

    $election->addCandidate(new Candidate ('Wingspan'));
    $election->addCandidate(new Candidate ('Scythe'));
    $election->addCandidate(new Candidate ('Spirit Island'));
    $election->addCandidate(new Candidate ('Everdell'));

    $vote1 = new Vote ( $games );
    $election->addVote($vote1);  

    $vote2 = new Vote ( 'Scythe > Spirit Island = Everdell = Wingspan' );
    $election->addVote($vote2);

   $result = $election->getResult();

   echo 'Schulze winner is : ' . $election->getWinner('Schulze')->getName() . '<br />';
}

If I have only one $vote, it works fine, but if I have both vote as above, I get this error:
Fatal error: Uncaught Error: Call to a member function getName() on array

Isn't it a bug? or I did a mistake?

How do you output election results as a file when using the command line?

Q A
Type Support
Condorcet version 3.0.2
PHP version n/a
Installation Method Docker container public image

When running a simple election command from the command line, is there a way to output the results as a file? I would like to output a simple CSV with rank,candidate headers. Is this possible?

Election.php file giving Parse errors

| Q Election.php throwing Parse Error
| --------------------| ---------------
| Type | Support
| Condorcet version | 3.1.0
| PHP version | 7.3.29
| Installation Method | __CondorcetAutoload.php

protected static ?int $_maxParseIteration = null; protected static ?int $_maxVoteNumber = null;

These two lines are causing the below error. I tried doing some debugging and different methods to fix but had simillar issues across the file. What may be causing me to get this issue and any suggestions on how to fix it? I was given a partially done research project to try and working without any prior instructions other than the errors telling me it couldn't find the __CondorcetAutoload.php so I started trying to get this working.

Thanks!

Parse error: syntax error, unexpected '?', expecting function (T_FUNCTION) or const (T_CONST) in C:\Users\mcurr\Documents\GitHub\CondorcetPHP\lib\Election.php on line 28

Gets stuck at "Results per Methods" when running the program using InstantRunoff

Q A
Type Bug
Condorcet version 3.0.0
PHP version 8.0.0
Installation Method Composer
condorcet election -c c.txt -w w.txt InstantRunoff

Sum Up
------

21 Candidates(s) Registered  ||  32 Vote(s) Registered
==========================
 ------------------------------------------------------------- -------
  Is vote weight allowed?                                       FALSE
 ------------------------------------------------------------- -------
  Votes are evaluated according to the implicit ranking rule?   TRUE
 ------------------------------------------------------------- -------
  Is vote tie in rank allowed?                                  FALSE
 ------------------------------------------------------------- -------

Results per Methods
-------------------

Then it gets stuck. CPU use raises to 30%, and memory use raises as well.

Kemeny-Young : Multiple best score

(Since Version 0.8)

I do not know how in the very unlikely event that several possible classifications have the same highest score.
In the current state, one of them is chosen arbitrarily.

simple explanation

Q A
Type Support
Concorcet version 2.x
PHP version 7.4
Installation Method Composer

Please give simple explanation what are weight and tag and what are their purposes?

incompatible offsetUnset with ArrayManager in VotesManager

Fatal error: Declaration of Condorcet\DataManager\VotesManager::offsetUnset($offset): void must be compatible with Condorcet\DataManager\ArrayManager::offsetUnset($offset): bool in vendor/julien-boudry/condorcet/lib/DataManager/VotesManager.php on line 18

How to have = using a vote form?

Q A
Type Support
Concorcet version 2.x
PHP version 7.4
Installation Method __CondorcetAutoload.php

Consider this form:

<html>
    <body>
        <form method="post">
        Wingspan: <select name="item[Wingspan]" id="Wingspan">
                         <option value="1">1</option>
                         <option value="2">2</option>
                         <option value="3">3</option>
                         <option value="4">4</option>
                 </select><br />
        Scythe:  <select name="item[Scythe]" id="Scythe">
                         <option value="1">1</option>
                         <option value="2">2</option>
                         <option value="3">3</option>
                         <option value="4">4</option>
                 </select><br />
        Spirit Island: <select name="item[Spirit Island]" id="Spirit Island">
                         <option value="1">1</option>
                         <option value="2">2</option>
                         <option value="3">3</option>
                         <option value="4">4</option>
                  </select><br />
        Everdell: <select name="item[Everdell]" id="Everdell">
                         <option value="1">1</option>
                         <option value="2">2</option>
                         <option value="3">3</option>
                         <option value="4">4</option>
                  </select<br />
        <input type="submit" name="submit" value="submit">
        </form>
    </body>
</html>

Then this code

foreach ($_POST['item'] as $game => $priority) {
        $games[] = $game;
}

This outputs:

Array
(
    [0] => Wingspan
    [1] => Scythe
    [2] => Spirit Island
    [3] => Everdell
)

Then this Condorcet:

    Condorcet::setDefaultMethod('Schulze'); // Argument: A supported method  

    $election = new Election ();

    $election->addCandidate(new Candidate ('Wingspan'));
    $election->addCandidate(new Candidate ('Scythe'));
    $election->addCandidate(new Candidate ('Spirit Island'));
    $election->addCandidate(new Candidate ('Everdell'));


$vote = new Vote ( $games );
$election->addVote($vote);  
print_r($vote->getSimpleRanking());

echo 'Schulze winner is : ' . $election->getWinner('Schulze')->getName() . '<br />';

However it works great but what if two candidates got the same rank? and what if have to have = ? I know the solution is with foreach() but I am stuck with it?

Typo in the issue template

Q A
Type Bug / Support / Suggestion / Other
Concorcet version x.y.z
PHP version x.y.z
Installation Method Composer / __CondorcetAutoload.php / Custom

Probably missing attribute classes?

Q A
Type Bug
Concorcet version 3.0.1
PHP version 8.0.3
Installation Method Custom

Hi,

first, thanks a lot for this very nice library. I'm looking into the source code and cloned your repository. While browsing your sources, I noticed that you're using the new attributes feature of PHP8.

However, you write e.g. this:
use CondorcetPHP\Condorcet\CondorcetDocAttributes\{Description, Examples, FunctionReturn, PublicAPI, Related};

There are no corresponding classes, there is not even a "CondorcetDocAttributes" folder in your project. Maybe you've created those files locally and did not yet add them to the git repository?

Regards,
Tobias

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.