Exemplo n.º 1
0
 def __init__(self, *args, converter: ConverterBallot = None, matrix_weighted_majority: Matrix = None, **kwargs):
     if converter is None:
         converter = ConverterBallotToOrder()
     if matrix_weighted_majority is None:
         matrix_weighted_majority = MatrixWeightedMajority()
     self.matrix_weighted_majority = matrix_weighted_majority
     super().__init__(*args, converter=converter, **kwargs)
Exemplo n.º 2
0
 def __init__(self, *args, converter: ConverterBallot = None, matrix_schulze: Matrix = None, **kwargs):
     if converter is None:
         converter = ConverterBallotToOrder()
     if matrix_schulze is None:
         matrix_schulze = MatrixSchulze()
     self.matrix_schulze = matrix_schulze
     super().__init__(*args, converter=converter, **kwargs)
Exemplo n.º 3
0
 def __init__(self,
              *args,
              converter: ConverterBallot = None,
              higher_vs_lower: Union[Number, None] = 1,
              lower_vs_higher: Union[Number, None] = 0,
              indifference: Union[Number, None] = Fraction(1, 2),
              ordered_vs_unordered: Union[Number, None] = 1,
              unordered_vs_ordered: Union[Number, None] = 0,
              unordered_vs_unordered: Union[Number, None] = Fraction(1, 2),
              ordered_vs_absent: Union[Number, None] = None,
              absent_vs_ordered: Union[Number, None] = None,
              unordered_vs_absent: Union[Number, None] = None,
              absent_vs_unordered: Union[Number, None] = None,
              absent_vs_absent: Union[Number, None] = None,
              diagonal_score: Number = 0,
              default_score: Number = 0,
              antisymmetric: bool = False,
              **kwargs):
     if converter is None:
         converter = ConverterBallotToOrder()
     self.higher_vs_lower = convert_number(higher_vs_lower)
     self.lower_vs_higher = convert_number(lower_vs_higher)
     self.indifference = convert_number(indifference)
     self.ordered_vs_unordered = convert_number(ordered_vs_unordered)
     self.unordered_vs_ordered = convert_number(unordered_vs_ordered)
     self.unordered_vs_unordered = convert_number(unordered_vs_unordered)
     self.ordered_vs_absent = convert_number(ordered_vs_absent)
     self.absent_vs_ordered = convert_number(absent_vs_ordered)
     self.unordered_vs_absent = convert_number(unordered_vs_absent)
     self.absent_vs_unordered = convert_number(absent_vs_unordered)
     self.absent_vs_absent = convert_number(absent_vs_absent)
     self.diagonal_score = convert_number(diagonal_score)
     self.default_score = convert_number(default_score)
     self.antisymmetric = antisymmetric
     super().__init__(*args, converter=converter, **kwargs)
def test():
    converter = ConverterBallotToOrder()
    assert converter(BallotOneName('a', candidates={'a', 'b', 'c'}),
                     candidates={'b', 'c',
                                 'd'}) == BallotOrder('b ~ c',
                                                      candidates={'b', 'c'})
    assert converter(BallotVeto('a', candidates={'a', 'b', 'c'}),
                     candidates={'b', 'c',
                                 'd'}) == BallotOrder('b ~ c',
                                                      candidates={'b', 'c'})
Exemplo n.º 5
0
 def __init__(self,
              *args,
              converter: ConverterBallot = None,
              matrix: Matrix = None,
              **kwargs):
     if converter is None:
         converter = ConverterBallotToOrder()
     if matrix is None:
         matrix = MatrixMajority()
     super().__init__(*args, converter=converter, matrix=matrix, **kwargs)
 def __call__(self, x: object, candidates: set = None) -> BallotOrder:
     x = ConverterBallotToOrder()(x, candidates=candidates)
     if x.is_strict:
         return x
     else:
         return BallotOrder(
             list(
                 chain(*[
                     self.priority.sort(indifference_class)
                     for indifference_class in x.as_weak_order
                 ])))
 def __init__(self, *args, converter: ConverterBallot = None, scorer: Scorer = None, default_median: object = 0,
              **kwargs):
     # Default value
     if converter is None:
         converter = ConverterBallotToOrder()
     if scorer is None:
         scorer = ScorerBorda(absent_give_points=True, absent_receive_points=None,
                              unordered_give_points=True, unordered_receive_points=False)
     # Parameters
     self.scorer = scorer
     self.default_median = default_median
     super().__init__(*args, converter=converter, **kwargs)
 def __init__(self,
              *args,
              converter: ConverterBallot = None,
              matrix_weighted_majority: Matrix = None,
              tie_break: Priority = Priority.UNAMBIGUOUS,
              **kwargs):
     if converter is None:
         converter = ConverterBallotToOrder()
     if matrix_weighted_majority is None:
         matrix_weighted_majority = MatrixWeightedMajority()
     self.tie_break = tie_break
     self.matrix_weighted_majority = matrix_weighted_majority
     super().__init__(*args, converter=converter, **kwargs)
 def __init__(self,
              *args,
              converter: ConverterBallot = None,
              scorer: ScorerBucklin = None,
              **kwargs):
     # Default value
     if converter is None:
         converter = ConverterBallotToOrder()
     if scorer is None:
         scorer = ScorerBucklin()
     # Parameters
     self.scorer = scorer
     super().__init__(*args, converter=converter, **kwargs)
Exemplo n.º 10
0
 def __init__(self,
              *args,
              converter: ConverterBallot = None,
              matrix: Matrix = None,
              **kwargs):
     if converter is None:
         converter = ConverterBallotToOrder()
     if matrix is None:
         tie_break = kwargs.get('tie_break')
         if tie_break is None:
             matrix = MatrixRankedPairs()
         else:
             matrix = MatrixRankedPairs(tie_break=tie_break)
     super().__init__(*args, converter=converter, matrix=matrix, **kwargs)
Exemplo n.º 11
0
 def __init__(self,
              *args,
              converter: ConverterBallot = None,
              matrix_weighted_majority: Matrix = None,
              greater: Number = 1,
              lower: Number = 0,
              equal: Number = Fraction(1, 2),
              diagonal: Number = Fraction(1, 2),
              **kwargs):
     if converter is None:
         converter = ConverterBallotToOrder()
     if matrix_weighted_majority is None:
         matrix_weighted_majority = MatrixWeightedMajority()
     self.matrix_weighted_majority = matrix_weighted_majority
     self.greater = convert_number(greater)
     self.lower = convert_number(lower)
     self.equal = convert_number(equal)
     self.diagonal = convert_number(diagonal)
     super().__init__(*args, converter=converter, **kwargs)
Exemplo n.º 12
0
 def __init__(self, *args, converter: ConverterBallot = None, scorer: Scorer = None, **kwargs):
     if converter is None:
         converter = ConverterBallotToOrder()
     if scorer is None:
         scorer = ScorerBorda()
     super().__init__(*args, converter=converter, scorer=scorer, **kwargs)