def test_indegree_trivial(self):
        votes = VoteMatrix(4)

        votes.positive[0, 1] = 1
        votes.positive[1, 2] = 1
        votes.positive[2, 3] = 1
        votes.positive[3, 0] = 1

        in_degree = InDegree()

        m = in_degree.apply(votes)

        assert len(m) == 4
        for score in m:
            assert score == 0.25
    def test_indegree(self):
        votes = VoteMatrix(4)

        votes.positive[0, 1] = 1
        votes.positive[0, 2] = 1
        votes.positive[2, 1] = 1
        votes.positive[3, 0] = 1
        votes.positive[3, 2] = 4

        in_degree = InDegree()

        m = in_degree.apply(votes)

        assert numpy.abs(m[0] - 0.125) < 0.001
        assert numpy.abs(m[1] - 0.250) < 0.001
        assert numpy.abs(m[2] - 0.625) < 0.001
        assert numpy.abs(m[3] - 0.000) < 0.001
from simulation.community import ActionProfile
from simulation.member import Member

if __name__ == '__main__':
    """
    In this test, it is evaluated how many friends who are significantly less competent
    than their peers are required to trick the system so that they reach top position
    in the reputation ranking.
    """

    test_name = "Friends"
    community = OnlineDiscussionGroup()

    ALL_CENTRALITY_SCORES = [
        PageRank(), EigenTrust(),
        InDegree(), InDegreePositive()
    ]

    # Possible Actions
    actions: ActionProfile = community.action_profile

    # Group unaffiliated
    num_unaffiliated = 25

    unaffiliated = Member("unaffiliated", [
        (0.27, actions.post_good_comment),
        (0.03, actions.post_bad_comment),
        (0.32, actions.vote_bad_comment_negative),
        (0.03, actions.vote_any_comment_negative),
        (0.32, actions.vote_good_comment_positive),
        (0.03, actions.vote_any_comment_positive),
Beispiel #4
0
from simulation.member import Member

if __name__ == '__main__':
    """
    The more basic tests are concluded with the Productivity Test, which investigates
    what kind of effect different levels of productivity, all other parameters being equal,
    have on the reputation score.
    """

    test_name = "Productivity-high"
    community = OnlineDiscussionGroup()

    ALL_CENTRALITY_SCORES = [
        PageRank(),
        EigenTrust(),
        InDegree(),
        InDegreePositive()
    ]

    # Possible Actions
    actions = community.action_profile

    # Group low
    low_student = Member("low", [
            (0.19, actions.post_good_comment),
            (0.01, actions.post_bad_comment),
            (0.38, actions.vote_bad_comment_negative),
            (0.02, actions.vote_any_comment_negative),
            (0.38, actions.vote_good_comment_positive),
            (0.02, actions.vote_any_comment_positive),
        ])