def test_generate_utility_params(self): """Test the generate_utility_params of Helpers module.""" utility_function_params = generate_utility_params( ["ag_1_add", "ag_2_add"], ["good_id_1", "good_id_2"], 1000.0) assert "good_id_1" in utility_function_params["ag_1_add"].keys() assert "good_id_2" in utility_function_params["ag_1_add"].keys() assert "good_id_1" in utility_function_params["ag_2_add"].keys() assert "good_id_2" in utility_function_params["ag_2_add"].keys()
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())