コード例 #1
0
    def su_add_to_network(params, step, sL, s, _input, **kwargs):
        network = s["network"]
        if _input["new_participant"]:
            network, i = add_participant(
                network,
                Participant(TokenBatch(0, _input["new_participant_tokens"])))

            if params.get("debug"):
                print(
                    "GenerateNewParticipant: A new Participant {} invested {}DAI for {} tokens"
                    .format(i, _input['new_participant_investment'],
                            _input['new_participant_tokens']))
        return "network", network
コード例 #2
0
    def test_add_participant(self):
        """
        This test ensures that the Participant was added and that
        setup_influence_edges and setup_support_edges was executed for that
        particular node.
        """
        n1, j = add_participant(self.network, Participant(TokenBatch(0, 0)))
        self.assertIsInstance(n1.nodes[j]["item"], Participant)

        self.assertEqual(len(n1.edges), 5)
        for u, v, t in n1.edges(data="type"):
            self.assertEqual(u, 10)
            self.assertIn(v, [1, 3, 5, 7, 9])
            self.assertEqual(t, "support")
コード例 #3
0
ファイル: policies.py プロジェクト: mcb1977/commons-simulator
    def su_add_to_network(params, step, sL, s, _input, **kwargs):
        network = s["network"]
        probability_func = params["probability_func"]
        exponential_func = params["exponential_func"]
        random_number_func = params["random_number_func"]

        for i in _input:
            ans = _input[i]
            if ans != 0:
                network, i = add_participant(network, Participant(TokenBatch(
                    0, ans["new_participant_tokens"]), probability_func,
                    random_number_func), exponential_func, random_number_func)

                if params.get("debug"):
                    print("GenerateNewParticipant: A new Participant {} invested {}DAI for {} tokens".format(
                        i, ans['new_participant_investment'], ans['new_participant_tokens']))
        return "network", network