예제 #1
0
파일: Election.py 프로젝트: szufix/mapel
    def compute_alternative_winners(self,
                                    method=None,
                                    party_id=None,
                                    num_winners=None):

        election_without_party_id = remove_candidate_from_election(
            copy.deepcopy(self), party_id, num_winners)
        election_without_party_id = map_the_votes(election_without_party_id,
                                                  party_id, num_winners)

        if method == 'sntv':
            winners_without_party_id = compute_sntv_winners(
                election=election_without_party_id, num_winners=num_winners)
        elif method == 'borda':
            winners_without_party_id = compute_borda_winners(
                election=election_without_party_id, num_winners=num_winners)
        elif method == 'stv':
            winners_without_party_id = compute_stv_winners(
                election=election_without_party_id, num_winners=num_winners)
        elif method in {'approx_cc', 'approx_hb', 'approx_pav'}:
            winners_without_party_id = generate_winners(
                election=election_without_party_id,
                num_winners=num_winners,
                method=method)
        else:
            winners_without_party_id = []

        winners_without_party_id = unmap_the_winners(winners_without_party_id,
                                                     party_id, num_winners)

        self.alternative_winners[party_id] = winners_without_party_id
예제 #2
0
파일: scores.py 프로젝트: szufix/mapel
def highest_pav_score(election, feature_params):
    if election.model_id in LIST_OF_FAKE_MODELS:
        return 'None', 'None'
    winners, total_time = win.generate_winners(
        election=election,
        num_winners=feature_params['committee_size'],
        ballot="ordinal",
        type='bloc_owa',
        name='hb')
    return get_pav_score(election, winners), total_time
예제 #3
0
    def compute_winners(self, method=None, num_winners=None):

        self.borda_points = get_borda_points(self.votes, self.num_voters,
                                             self.num_candidates)

        if method == 'sntv':
            self.winners = compute_sntv_winners(election=self,
                                                num_winners=num_winners)
        if method == 'borda':
            self.winners = compute_borda_winners(election=self,
                                                 num_winners=num_winners)
        if method == 'stv':
            self.winners = compute_stv_winners(election=self,
                                               num_winners=num_winners)
        if method in {'approx_cc', 'approx_hb', 'approx_pav'}:
            self.winners = generate_winners(election=self,
                                            num_winners=num_winners,
                                            method=method)