예제 #1
0
def irv_sucks(votes):
    try:
        pl = plurality_winner(votes)
        if condorcet_winner(votes) != pl:
            return False
        if irv_winner(votes) != pl:
            print(votes)
            return True
    except Ambiguous:
        return False
def irv_works(votes):
    try:
        iv = irv_winner(votes)
        if condorcet_winner(votes) != iv:
            return False
        if plurality_winner(votes) != iv:
            print(votes)
            return True
    except Ambiguous:
        return False
예제 #3
0
def distinct_from_condorcet(votes):
    try:
        p = plurality_winner(votes)
        c = condorcet_winner(votes)
        if c == p:
            return False
        s = simple_irv_winner(votes)
        if s == c:
            return False
        irv = irv_winner(votes)
        return (
            (p != irv) and (p != s) and (s != irv)
        )
    except Ambiguous:
        return False
예제 #4
0
       [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3],
       [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3],
       [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3],
       [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3],
       [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3],
       [1, 0, 2, 3], [1, 0, 2, 3], [2, 0, 1, 3], [2, 0, 1, 3], [2, 3, 0, 1],
       [2, 3, 0, 1], [2, 3, 0, 1], [2, 3, 0, 1], [2, 3, 0, 1], [2, 3, 0, 1],
       [2, 3, 0, 1], [2, 3, 0, 1], [3, 1, 0, 2], [3, 1, 0, 2], [3, 1, 0, 2],
       [3, 1, 0, 2], [3, 1, 0, 2], [3, 1, 0, 2], [3, 1, 0, 2], [3, 1, 0, 2],
       [3, 1, 0, 2], [3, 1, 0, 2], [3, 1, 0, 2], [3, 1, 0, 2]]

if __name__ == '__main__':
    from vbe.output import output_election, name
    result = ex2

    print("\n------------\n")
    print(result)
    print("\n------------\n")

    output_election(result, 1)

    print()
    print("The Plurality winner is %s." % (name(plurality_winner(result)), ))
    print()
    print("The IRV winner is %s." % (name(irv_winner(result)), ))
    print()
    print("The Condorcet winner is %s." % (name(condorcet_winner(result)), ))
    from vbe.simple_runoff_example import simple_irv_winner

    assert simple_irv_winner(result) == plurality_winner(result)
예제 #5
0
                                                            0], [2, 1, 0],
                          [2, 1, 0], [2, 1, 0], [2, 1, 0], [2, 1, 0],
                          [2, 1, 0]]

assert is_splitting_example(non_condorcet_splitter)

if __name__ == '__main__':
    from vbe.output import output_votes, name, joined_list

    result = non_condorcet_splitter

    winner = list(stv(result, 1))[0]
    house = sorted(stv(result, 2))
    assert len(house) == 2

    assert winner != condorcet_winner(non_condorcet_splitter)

    print("\n------------\n")
    print(result)
    print("\n------------\n")

    print("%d voters are choosing between %d candidates: %s." %
          (len(result), len(result[0]), joined_list(sorted(result[0]))))
    print()

    output_votes(result)

    print()

    print(("The IRV winner is %s, but when electing two candidates "
           "we elect %s and %s") %