Beispiel #1
0
 def test_determine_scaling_factor(self):
     """Test the determine_scaling_factor of Helpers module."""
     money_endowment = 53730411
     scaling_factor = determine_scaling_factor(money_endowment)
     assert scaling_factor == 10000000.0
Beispiel #2
0
    def _generate(self):
        """Generate a TAC game."""
        parameters = cast(Parameters, self.context.parameters)

        self._conf = Configuration(
            parameters.version_id,
            parameters.tx_fee,
            self.registration.agent_addr_to_name,
            parameters.nb_goods,
        )

        scaling_factor = determine_scaling_factor(parameters.money_endowment)

        agent_addr_to_currency_endowments = generate_currency_endowments(
            list(self.conf.agent_addr_to_name.keys()),
            list(self.conf.currency_id_to_name.keys()),
            parameters.money_endowment,
        )

        agent_addr_to_exchange_params = generate_exchange_params(
            list(self.conf.agent_addr_to_name.keys()),
            list(self.conf.currency_id_to_name.keys()),
        )

        agent_addr_to_good_endowments = generate_good_endowments(
            list(self.conf.agent_addr_to_name.keys()),
            list(self.conf.good_id_to_name.keys()),
            parameters.base_good_endowment,
            parameters.lower_bound_factor,
            parameters.upper_bound_factor,
        )

        agent_addr_to_utility_params = generate_utility_params(
            list(self.conf.agent_addr_to_name.keys()),
            list(self.conf.good_id_to_name.keys()),
            scaling_factor,
        )

        (
            good_id_to_eq_prices,
            agent_addr_to_eq_good_holdings,
            agent_addr_to_eq_currency_holdings,
        ) = generate_equilibrium_prices_and_holdings(
            agent_addr_to_good_endowments,
            agent_addr_to_utility_params,
            agent_addr_to_currency_endowments,
            agent_addr_to_exchange_params,
            scaling_factor,
        )

        self._initialization = Initialization(
            agent_addr_to_currency_endowments,
            agent_addr_to_exchange_params,
            agent_addr_to_good_endowments,
            agent_addr_to_utility_params,
            good_id_to_eq_prices,
            agent_addr_to_eq_good_holdings,
            agent_addr_to_eq_currency_holdings,
        )

        self._initial_agent_states = dict((
            agent_addr,
            AgentState(
                agent_addr,
                self.initialization.
                agent_addr_to_currency_endowments[agent_addr],
                self.initialization.agent_addr_to_exchange_params[agent_addr],
                self.initialization.agent_addr_to_good_endowments[agent_addr],
                self.initialization.agent_addr_to_utility_params[agent_addr],
            ),
        ) for agent_addr in self.conf.agent_addr_to_name.keys())

        self._current_agent_states = dict((
            agent_addr,
            AgentState(
                agent_addr,
                self.initialization.
                agent_addr_to_currency_endowments[agent_addr],
                self.initialization.agent_addr_to_exchange_params[agent_addr],
                self.initialization.agent_addr_to_good_endowments[agent_addr],
                self.initialization.agent_addr_to_utility_params[agent_addr],
            ),
        ) for agent_addr in self.conf.agent_addr_to_name.keys())