Exemple #1
0
import copy


def demo(family: Family, goods: set):
    family1 = copy.copy(family)
    family1.name = "Group 1"
    family2 = copy.copy(family)
    family2.name = "Group 2"
    utils.demo(twothirds_protocol.allocate, [family1, family2], goods)
    print("\n")


twothirds_protocol.logger.setLevel(logging.INFO)

# Define fairness criteria:
fairness_1_of_best_2 = fairness_criteria.OneOfBestC(2)
goods = "vwxyz"

family1 = Family([
    BinaryAgent("wx", 2),
    BinaryAgent("xy", 1),
    BinaryAgent("yz", 5),
    BinaryAgent("zw", 3)
], fairness_1_of_best_2)
demo(family1, "wxyz")

family2 = Family(
    [BinaryAgent("wz", 2), BinaryAgent("zy", 3)], fairness_1_of_best_2)
demo(family2, "wxyz")

family3 = Family([
Demonstration of the RWAV protocol - Round-Robin with Approval Voting - for two families.

See: https://arxiv.org/abs/1709.02564 subsection 5.4 for details.
"""

import fairness_criteria, rwav_protocol, logging
from agents import BinaryAgent
from families import Family
from utils import demo

rwav_protocol.logger.setLevel(logging.INFO)
rwav_protocol.choose_good.logger.setLevel(logging.INFO)
rwav_protocol.member_weight.logger.setLevel(logging.INFO)

# define fairness criteria:
fairness_1_of_best_3 = fairness_criteria.OneOfBestC(c=3)

# Define families:
family1 = Family([
    BinaryAgent("vx", 2),
    BinaryAgent("vxy", 1),
    BinaryAgent("wxyz", 5),
    BinaryAgent("zwv", 3)
],
                 fairness_1_of_best_3,
                 name="Group 1")
family2 = Family(
    [BinaryAgent("wxy", 2), BinaryAgent("vzx", 3)],
    fairness_1_of_best_3,
    name="Group 2")
family3 = Family([