From 6fab6c70e48abf3178b7471bf52abd191f69096d Mon Sep 17 00:00:00 2001 From: philippe lhardy Date: Thu, 26 Jun 2025 22:57:30 +0200 Subject: [PATCH] update --- etude/existant.md | 446 ++++++++++++++++++++++++++++++++++++++++++++++ samples/5.json | 87 +++++++++ 2 files changed, 533 insertions(+) create mode 100644 etude/existant.md create mode 100644 samples/5.json diff --git a/etude/existant.md b/etude/existant.md new file mode 100644 index 0000000..1f706d2 --- /dev/null +++ b/etude/existant.md @@ -0,0 +1,446 @@ + +Recherche des projets de code autours du jugement majoritaire sur githbu + +|source|info|interet| +|------------------|-----------------------------|-------------| +|https://github.com/AlexJade23/JugementMajoritaire|RAS VIDE|1/20| +|https://github.com/ostix360/JugementMajoritaire|Où est l'algo ?|2/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| + + +# david chavalarias + +https://github.com/davidchavalarias/jugement-majoritaire + +Dans le cadre d'une soutenance en 2014 le porjet 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 + +``` + +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) +); + +``` + +``` + + + + Nom + Très Bien + Bien + Assez Bien + Passable + Insuffisant + À rejeter + Mention finale + Pourcentage des mentions supérieures + + + +``` + +Les mentions sont codées en dur : TB,B,AB,P,I,AR + +resultat ? + +``` + + +``` + + +``` + 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; + + } + + + + + } +``` + +alghorithme harcodé avec les mentions. + + +# 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 fonciton 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/ ? + + +# https://github.com/flaviencathala/jugement-majoritaire-daml + +DAML + +langage for smart contracts : blockchain donc. + + +# https://github.com/jeromeschwaederle/Vote_Jugement_Majoritaire + +python simple + +# https://mieuxvoter.fr/en + + +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. \ No newline at end of file diff --git a/samples/5.json b/samples/5.json new file mode 100644 index 0000000..4887525 --- /dev/null +++ b/samples/5.json @@ -0,0 +1,87 @@ +{ +"candidats":{ + "A":"albert", + "B":"Beatrice", + "C":"Chloé", + "D":"Deborah", + "E":"Eric", + "F":"Francçois", + "G":"Gisèle", + "H":"Hugo" +}, +"votants":{ + "decompte":11 +}, +"mentions":[ + "Très Bien", + "Bien", + "Assez Bien", + "Passable", + "Insuffisant", + "A rejeter" +], +"votation": + { + "date":"14 juin 2025", + "lieu":"liffré", + "votes":[ + { + "A":1, + "C":2, + "D":3 + }, + { + "B":1, + "C":2, + "E":3 + }, + { + "A":1, + "C":2, + "F":3 + }, + { + "G":1, + "C":2, + "D":3 + }, + { + "A":1, + "G":2, + "E":3 + }, + { + "E":1, + "C":2, + "D":3 + }, + { + "E":1, + "C":2, + "D":3 + }, + { + "A":1, + "D":2 + }, + { + "A":5, + "C":2, + "D":3 + }, + { + "A":4, + "B":6 + }, + { + "A":1, + "C":2, + "D":3, + "B":4, + "E":3, + "F":4, + "G":0 + } + ] + } +}