Files
jugement_majoritaire/etude/existant.md
2025-07-03 13:00:00 +02:00

14 KiB

contexte

Choix des noms de mentions

https://fr.wikipedia.org/wiki/Jugement_majoritaire vs https://en.wikipedia.org/wiki/Jugement_majoritaire

index fr en
0 Très Bien Excellent
1 Bien Very Good
2 Assez Bien Good
3 Passable Acceptable
4 Insuffisant Poor
5 A Rejeter Reject

Recherche des projets de code autours du jugement majoritaire sur githbu

source info interet
https://github.com/MieuxVoter/mieuxvoter.fr 18/20
https://github.com/CitoyensDeDemain/JugementMajoritaire Il y a un algo, mais pas de format de donnée, données hardcodées / API et pas de procédure d'install 11/20
https://github.com/flaviencathala/jugement-majoritaire-daml Smart contract 10/20
https://github.com/ostix360/JugementMajoritaire Où est l'algo ? 2/20
https://github.com/AlexJade23/JugementMajoritaire RAS VIDE 1/20

https://mieuxvoter.fr/en

C'est la référence, les théoriciens du vote majoritaire ont été invités à participer à l'élaboration de ce site.

Par contre pour trouver la librairie de base...

https://github.com/MieuxVoter/mieuxvoter.fr

image docker

https://app.mieuxvoter.fr/en/votes/ult-kxm-vzcr

https://app.mieuxvoter.fr/en/results/ult-kxm-vzcr

https://app.mieuxvoter.fr/en/admin/ult-kxm-vzcr/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6dHJ1ZSwiZWxlY3Rpb24iOiJ1bHRreG12emNyIn0.TzkM380pk0eVo8_iHJGYANxlapVbp5Z3jxLQSzqLpRM

https://app.mieuxvoter.fr/fr/votes/ult-kxm-vzcr : même en français 'Very good' ...

Obligation de noter tous les participants.

Librairie python

https://github.com/MieuxVoter/majority-judgment-library-python

Très courte ( ./majority_judgment/init.py 145 lignes )

>>> from majority_judgment import majority_judgment
>>> data = {
...    'Pizza': [!, 0, 3, 0, 2, 0, 3, 1, 2, 3], 
...    'Chips': [0, 1, 0, 2, 1, 2, 2, 3, 2, 3],
...    'Pasta': [0, 1, 0, 1, 2, 1, 3, 2, 3, 3],
...    'Bread': [0, 1, 2, 1, 1, 2, 1, 2, 2, 3],
... }
>>> majority_judgment(data, reverse=False)
{'Chips': 0, 'Pasta': 1, 'Pizza': 2, 'Bread': 3}

(!) ?

/!\ Attention à l'ordre : par défaut le plus grand est le meilleur , il faut utiliser reverse=True pour l'inverser.

API REST python

https://github.com/MieuxVoter/majority-judgment-api-python

License: GNU aGPLV3 / CECILL variant affero compliant

|postgres|| |python| >= 3.11 |

serveur uvicorn

uvicorn app.main:app --reload --env-file .env.local

profiles :

|core| if you only need the backend and database| |dashboard| if you only need Metabase| |image| if you only need to store images| |backup| for restic|

Election Candidat Grade Vote

david chavalarias

https://github.com/davidchavalarias/jugement-majoritaire

Dans le cadre d'une soutenance en 2014 le projet n'a pas été maintenu ni forké.

Une application sous symfony2 ( php Doctrine )

mysql / apache

./Polytech/Bundle/JMBundle

Algorithme principal :

    public function statsAction($idElection)
    {
        $em = $this->getDoctrine()->getManager();
        $currentElections = $em->getRepository('PolytechJMBundle:Election')->findCurrentElections();
        $election = $em->getRepository('PolytechJMBundle:Election')->find($idElection);

        if($election->getFinished() == false)
        {
            return $this->redirect($this->generateUrl('polytech_jm_index'));
        }

        $candidats = $em->getRepository('PolytechJMBundle:Candidat')->findByElection($election->getId());
        $mentions = $em->getRepository('PolytechJMBundle:Mention')->findByElection($election->getId());
        
        $nbrVotes = array();
        $indMentionMaj = array();
        $nbVMention = array();
        
        foreach($candidats as $cand)
        {
            $n = $em->getRepository('PolytechJMBundle:Vote')->countVotesByCandidat($cand->getId());
            $nbrVotes[$cand->getNom()] = $n[1];
            $nbrVotesMentionTmp = array();
            $pourcentageMention = array();
            foreach($mentions as $m)
            {
                $temp = $em->getRepository('PolytechJMBundle:Vote')->countVotesByCandidatAndMention($cand->getId(), $m->getId());
                $nbrVotesMentionTmp[$m->getNom()] = $temp[1];
                if($nbrVotes[$cand->getNom()] == 0)
                {
                    $pourcentageMention[$m->getNom()] = 0;
                }
                else
                {
                    $pourcentageMention[$m->getNom()] = $nbrVotesMentionTmp[$m->getNom()]*100/$nbrVotes[$cand->getNom()];
                }
            }

            $p_maj = 0;
            $i_maj = 0;
            $plus  = 0;
            foreach($mentions as  $m){
                $p_maj +=$pourcentageMention[$m->getNom()];
                $i_maj += 1;
                if($p_maj < 50)
                {
                    $plus += $pourcentageMention[$m->getNom()];
                }
                if($p_maj >= 50) break;
            }
            $moins = 100-($plus+$pourcentageMention[$m->getNom()]);
            $nbVMention[$cand->getNom()] = $nbrVotesMentionTmp;
            
            if(!isset($indMentionMaj[$i_maj]))
            {
                $indMentionMaj[$i_maj]=array();
            }
            if($plus >= $moins)
            {
                if(!isset($indMentionMaj[$i_maj][0]))
                {
                    $indMentionMaj[$i_maj][0] = array();
                }
                $indMentionMaj[$i_maj][0][$cand->getNom()] = $plus;
            }
            else
            {
                if(!isset($indMentionMaj[$i_maj][1]))
                {
                    $indMentionMaj[$i_maj][1] = array();
                }
                $indMentionMaj[$i_maj][1][$cand->getNom()] = $moins;
            }
            
        }

        //asort($indMentionMaj);
        ksort($indMentionMaj);
        foreach($indMentionMaj as &$indV)
        {
            if(isset($indV[0]))
            {
                arsort($indV[0]);
            }

            if(isset($indV[1]))
            {
                asort($indV[1]);
            }
        }

        return $this->render('PolytechJMBundle:Default:stats.html.twig', array('currentElections' => $currentElections, 'election' => $election, 'nbVMention' => $nbVMention, 'mentions' => $mentions, 'indMentionMaj' => $indMentionMaj, 'nbC' => count($candidats)));
    }

Ringayend

2016

https://github.com/Ringayend/Jugement-Majoritaire

Le site utilisant ce code n'existe plus : n'existe https://jugement-majoritaire.herokuapp.com

Site php simple, pas de framework postgres uniquement, en direct ( https://www.php.net/manual/en/function.pg-query.php pas d'ORM )

Permet l'export en excel

<code>
plhardy@t540p:~/clients/astrolabe/nextcloud/poll/existant/Ringayend.Jugement-Majoritaire.$ cat models/JM.sql 
DROP TABLE ELECTEUR;
DROP TABLE CANDIDAT;
DROP TABLE BULLETIN;

CREATE TABLE ELECTEUR (
	IDENTIFIANT varchar(255), 
	NOM varchar(255),
	PRENOM varchar(255),
	DONE boolean,
	ADMIN boolean,
	PASSWORD varchar(255),
	CONSTRAINT electeur_pk primary key (IDENTIFIANT)
);

CREATE TABLE CANDIDAT (
	ID bigserial,
	NAME varchar(255) constraint nameCandidat not null,
	TB bigint,
	B bigint,
	AB bigint,
	P bigint,
	I bigint,
	AR bigint,
	CONSTRAINT candidat_pk primary key (ID)
);

CREATE TABLE BULLETIN(
	IDENTIFIANT varchar(255),
	ID bigserial,
	TB bigint,
	B bigint,
	AB bigint,
	P bigint,
	I bigint,
	AR bigint,
	constraint bulletin_pk primary key (IDENTIFIANT,ID),
	CONSTRAINT bulletin_fk1 FOREIGN KEY (IDENTIFIANT) REFERENCES ELECTEUR(IDENTIFIANT),
	CONSTRAINT bulletin_fk2 FOREIGN KEY (ID) REFERENCES CANDIDAT(ID)
);
</code>
<code>

				          <tr>
				              <th data-field="name">Nom</th>
				              <th data-field="TB">Très Bien</th>
				              <th data-field="B">Bien</th>
				              <th data-field="AB">Assez Bien</th>
				              <th data-field="P">Passable</th>
				              <th data-field="I">Insuffisant</th>
				              <th data-field="AR">À rejeter</th>
				              <th data-field="note"> Mention finale</th>
				              <th data-field="note"> Pourcentage des mentions supérieures</th>
				          </tr>

</code>

Les mentions sont codées en dur : TB,B,AB,P,I,AR

resultat ?

				           	<td><?php echo Candidat::note_global($candidat);?></td>
				           	<td><?php echo round(Candidat::per_sup($candidat), 2);?></td>
      public static function note_global($candidat){
       $valTB = $candidat->TB;
       $valB = $candidat->B;
       $valAB = $candidat->AB;
       $valP = $candidat->P;
       $valI = $candidat->I;
       $valAR = $candidat->AR;
       $sum = $valTB + $valB + $valAB + $valP + $valI + $valAR;

if ($sum != 0){
       $perTB = ($valTB/$sum)*100;
       $perB = ($valB/$sum)*100;
       $perAB = ($valAB/$sum)*100;
       $perP = ($valP/$sum)*100;
       $perI = ($valI/$sum)*100;
       $perAR = ($valAR/$sum)*100;


       $per = $perTB;
       if ($per >= 50){
        return 'Très Bien';
       } 
       else {
          $per = $perTB + $perB ;
          if ($per >= 50){
            if($perTB > ($perAB + $perP + $perI + $perAR)){
              return "Bien +";
            }
            else{
              return "Bien -";
            }
          }
          else {
            $per = $perTB + $perB + $perAB;
            if ($per >= 50){
              if(($perTB + $perB) > ($perP + $perI + $perAR)){
              return "Assez Bien +";
            }
            else{
                return "Assez Bien -";
              }
            } 
            else {
              $per = $perTB + $perB + $perAB + $perP;
              if ($per >= 50){
                if(($perTB + $perB + $perAB) > ($perI + $perAR)){
                  return "Passable +";
                }
                else{
                  return "Passable -";
                }
               } 
               else {
                  $per = $perTB + $perB + $perAB + $perP + $perI;
                  if ($per >= 50){
                    if(($perTB + $perB + $perAB + $perP) > ($perAR)){
                      return "Insuffisant +";
                    }
                    else{
                      return "Insuffisant -";
                    }
                   } 
                   else {
                    return 'À Rejeter';
                  }
                }
               }
              } 
            }
          }
        else {
            return'À Rejeter';

          }
        
       


    }


    public static function per_sup($candidat){
       $valTB = $candidat->TB;
       $valB = $candidat->B;
       $valAB = $candidat->AB;
       $valP = $candidat->P;
       $valI = $candidat->I;
       $valAR = $candidat->AR;
       $sum = $valTB + $valB + $valAB + $valP + $valI + $valAR;

if ($sum != 0){
       $perTB = ($valTB/$sum)*100;
       $perB = ($valB/$sum)*100;
       $perAB = ($valAB/$sum)*100;
       $perP = ($valP/$sum)*100;
       $perI = ($valI/$sum)*100;
       $perAR = ($valAR/$sum)*100;


       $per = $perTB;
       if ($per >= 50){
        return $per;
       } 
       else {
          $per = $perTB + $perB ;
          if ($per >= 50){
            if($perTB > ($perAB + $perP + $perI + $perAR)){
              return $per;
            }
            else{
              return $per;
            }
          }
          else {
            $per = $perTB + $perB + $perAB;
            if ($per >= 50){
              if(($perTB + $perB) > ($perP + $perI + $perAR)){
              return $per;
            }
            else{
                return $per;
              }
            } 
            else {
              $per = $perTB + $perB + $perAB + $perP;
              if ($per >= 50){
                if(($perTB + $perB + $perAB) > ($perI + $perAR)){
                  return $per;
                }
                else{
                  return $per;
                }
               } 
               else {
                  $per = $perTB + $perB + $perAB + $perP + $perI;
                  if ($per >= 50){
                    if(($perTB + $perB + $perAB + $perP) > ($perAR)){
                      return $per;
                    }
                    else{
                      return $per;
                    }
                   } 
                   else {
                    return $per;
                  }
                }
               }
              } 
            }
          }
        else {
            return $per;

          }
        
       


    }

algorithme harcodé avec les mentions.

https://github.com/flaviencathala/jugement-majoritaire-daml

DAML

langage for smart contracts : blockchain donc.

https://github.com/jeromeschwaederle/Vote_Jugement_Majoritaire

python simple

OpenClassRooms Jugement Majoritaire

https://openclassrooms.com/fr/courses/7527306-decouvrez-le-fonctionnement-des-algorithmes?archived-source=4366701

Le programme classes des candidats après un vote par jugement majoritaire (cour openclassrooms "Découvrez le fonctionnement des algorithmes")

Vote par jugement majoritaire : https://www.youtube.com/watch?v=ZoGH7d51bvc

voici les règles de notre programme : Chaque candidat a une mention entre Excellent et A rejeter. La mention majoritaire de chaque candidat est calculée sur une médiane et non sur une moyenne. 50% au moins des votants trouvent cette mention valable. En cas d'égalité de mentions majoritaires : celle ou celui ayant le pourcentage de mentions supérieures à la mention majoritaire le plus important est le mieux classé.

Les mentions : Excellent [0] Très bien [1] Bien [2] Assez Bien [3] Passable [4] Insuffisant [5] A rejeter [6]

s-t-e-v.jugement_majoritaire

https://github.com/s-t-e-v/jugement_majoritaire

python

Il y a une fonction de deparatage.

mrflofinou Suffrage_jugement_majoritaire

python, algorithme et jeu de test pratiquement hardcodé mélangé.

https://github.com/mrflofinou/Suffrage_jugement_majoritaire

https://github.com/mrflofinou/Suffrage_jugement_majoritaire/blob/master/jugement_majoritaire.py

https://github.com/E-Bellec/majoritary-judgment

https://github.com/mstoure/Algorithme_de_jugement_majoritaire

https://github.com/LucileDT/vux

Projet symfony GNU Affero General Public License v3.0

Il ne semble pas y avoir de code pour l'algorithme, est-ce une tentative sans achèvement ?

https://www.linkedin.com/in/lucile-decrozant-triquenaux/ ?