コード例 #1
0
ファイル: tests_agent.py プロジェクト: cogeorg/abm_template
    def agent__append_state_variables(self, args):
        from sample_agent import Agent
        from sample_config import Config  # needed for the bankDirectory

        text = "This test checks agent.append_state_variables \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_state_variables 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 state variables:"
        print(text)
        agent.set_state_variables({'test': 0.66})
        print(agent.get_state_variables())
        text = "New state variables:"
        print(text)
        agent.append_state_variables({'new': 0.77})
        print(agent.get_state_variables())