Exemple #1
0
    def agent__append_parameters(self, args):
        from sample_agent import Agent
        from sample_config import Config  # needed for the bankDirectory

        text = "This test checks agent.append_parameters \n"
        self.print_info(text)
        #
        # INITIALIZATION
        #
        environment_directory = str(args[0])
        identifier = str(args[1])
        log_directory = str(args[2])

        # Configure logging parameters so we get output while the program runs
        logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %H:%M:%S',
                            filename=log_directory + identifier + ".log", level=logging.INFO)
        logging.info('START logging for test agent__append_parameters in run: %s',
                     environment_directory + identifier + ".xml")

        # Construct firm filename
        config = Config()

        # generate an agent
        agent = Agent("baseagent id", {"test": "parameters"}, {"test": "variables"})
        agent.identifier = "test_agent"
        config.agents.append(agent)

        #
        # TESTING
        #

        text = "Original parameters:"
        print(text)
        agent.set_parameters({'productivity': 1.55, 'active': 1})
        print(agent.get_parameters())
        text = "New parameters:"
        print(text)
        agent.append_parameters({'new': 2.34})
        print(agent.get_parameters())