From 34f62fef8e34ca34c71b22d719e5e1ad6a9c64f7 Mon Sep 17 00:00:00 2001 From: "Wesley H. Holliday" Date: Tue, 11 Jun 2024 15:33:23 -0700 Subject: [PATCH] Added Copeland-Global-Minimax --- .DS_Store | Bin 10244 -> 10244 bytes pref_voting/combined_methods.py | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/.DS_Store b/.DS_Store index 24440e31185a1ff19f69179f683e9fbf1f33d746..f71a9f1ac765c24c6ffbe47e5ba03f4e0f1d31bd 100644 GIT binary patch literal 10244 zcmeHMZ)_Ar6rZ;}V2>_z3q{~;<)A2vmwHEAT0r#LYlZT!*lTG4wcOpVWo2)--0oe$ zN^DGw8b#DkMwG-)7>o#tqWD1*0nw;2iW<-u0Zr6sFwrkYjlP-LtJ|Z8#;B;-Np|1P zy!YnK{N}ycdAo!VXwE7TLV|=45id$*32&nm%BR;kMQ~bXBL&nadS4`-GSmI%NO}z( z0v-Y$0v-Y$0v-bY76kB}O^aB{sdx7f@DT727)F5Z4?(;rjXHFQQ?_;Bjimrceb~$j zKFjn0Y0#ljhYoRy94x?9k#bdVQVihg*dBD`q7EJ6l&cePk`Hh!gOi~EvyS}-nK*$c zr{3K|z(e3%1ZeK=BQ>OtXvB8s?{Mna4mU4twzMR5Gl^~Didj<+zBBzu(@4H@UVi_^ z-@Xk9O)N^wNQ|_TRiu-2kT%jxy6~wD>q~GvX`;00X3DWh#i_NLUs%B>I%);SY!SOa z?&)H3?%9!j$s_JQ+_T&BQ>`{UJI6-a{B3rl@!hi{2VTLh+4xM7BG$<9K^5`}=fUKX z16IE?-xrhpx@Oto@CP82_{NMKCyo>I!#kg=ARSEHJUom zD_6u!!%k?1nqdl>qN2zR-I}481I=dEP%Ne!=M2#=`g`T+gM$ldBcWi!f^DJTV5EM2 zeJB_S*VS#?<`<__U$v;Ccaxqr%zNp~aCdcfVKRZ&hwt~{6I~cKAvfT@ljEOt^W1>H ze9P|e&Yur+cXD*yfRDy^1MWNXD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d{&%T9&h=^ za98z~PMbbsrl+hGLqgs@JV-OaE9O(@=TA}XS+hN5Vjcz!Yu+#yo8vHGSaZI=tW4xE zPFXV$Ec1vt7=?mmyU34Cup2c?JsvR^%7XnZXx1d+w2~7}&7HCD!-V8B_Ti&gsZzsWkd*MFx?+4JscfoGh1AE~y zcp9FC=PWOO!SeE#;Wao4Z^B#fHk^Qy@F9EzAHyeb8oq|}@WU`~UYqUB@blQ->^#*E z1rEvfuh21k-+99SwRYBNKW8tU)ENB^JNdJx@3ve7Tm)PMt{j0Jrs|{b|0~D-|NqK6 zbTwTBTm-H;1R%E|+)#(p&iu?Dz5@Ez?!&wpGfh-)fKkf?3+p)^sr4L>4f-5^BW9|b gx&P35$mR_&iX2S;{GS0?PbI2*|99{I|F`@9pT|AfApigX diff --git a/pref_voting/combined_methods.py b/pref_voting/combined_methods.py index 674cd10..a5a1c12 100644 --- a/pref_voting/combined_methods.py +++ b/pref_voting/combined_methods.py @@ -382,6 +382,32 @@ def copeland_global_borda(profile, curr_cands=None): return voting_method_with_scoring_tiebreaker(copeland, lambda num_cands, rank : num_cands - rank, "Copeland-Global-Borda")(profile, curr_cands=curr_cands) + +@vm(name="Copeland-Global-Minimax", + input_types=[ElectionTypes.PROFILE, ElectionTypes.PROFILE_WITH_TIES, ElectionTypes.MARGIN_GRAPH]) + +def copeland_global_minimax(edata, curr_cands=None): + """From the Copeland winners, return the candidates with the best *global* Minimax score. + + Args: + edata (Profile, ProfileWithTies, MarginGraph): Any edata with a Margin method. + curr_cands (List[int], optional): If set, then find the winners for the profile restricted to the candidates in ``curr_cands`` + + Returns: + A sorted list of candidates + + """ + + curr_cands = edata.candidates if curr_cands is None else curr_cands + + copeland_ws = copeland(edata, curr_cands=curr_cands) + + mm_scores = minimax_scores(edata, curr_cands=curr_cands) + + best_score = max([mm_scores[c] for c in copeland_ws]) + + return sorted([c for c in copeland_ws if mm_scores[c] == best_score]) + def faceoff(vm1, vm2): """If the vm1 and vm2 winners are the same, return that set of winners. Otherwise, for each choice of a vm1 winner A and vm2 winner B, add to the ultimate winners whichever of A or B is majority preferred to the other (or both if they are tied).