예제 #1
0
def run(prop_dict=None):
    (prog_file, log_file, prop_file,
     results_file) = utils.gen_file_names(MODEL_NM)

    # now we run some tests:

    # test prop_args as an iterable:
    for prop, val in pa.items():
        print(prop + ": " + str(val))

    # test that props work as a dictionary:
    if "num_agents" in pa:
        print("In is working!")

    # test what pa["num_agents"] is:
    num_agents = pa["num_agents"]
    print("num_agents = " + str(num_agents))

    # make sure we can get props length:
    print("Props length = " + str(len(pa)))

    # Now we create a minimal environment for our agents to act within:
    env = bm.BasicEnv(model_nm=MODEL_NM, props=pa)

    # Now we loop creating multiple agents
    #  with numbered names based on the loop variable:
    for i in range(num_agents):
        env.add_agent(bm.BasicAgent(name="agent" + str(i), goal="acting up!"))

    return utils.run_model(env, prog_file, results_file)
예제 #2
0
    def __init__(self, methodName, prop_file="models/basic_for_test.props"):

        super().__init__(methodName=methodName)

        pa = props.read_props(MODEL_NM, prop_file)
        # if result:
        #     pa.overwrite_props_from_dict(result.props)
        # else:
        #     print("Oh-oh, no props to read in!")
        #     exit(1)

        # Now we create a minimal environment for our agents to act within:
        self.env = bm.BasicEnv(model_nm=MODEL_NM, props=pa)

        # Now we loop creating multiple agents
        #  with numbered names based on the loop variable:
        for i in range(pa.props.get("num_agents").val):
            self.env.add_agent(
                bm.BasicAgent(name="agent" + str(i), goal="acting up!"))
        self.env.add_agent(
            bm.BasicAgent(name="agent for tracking", goal="acting up!"))
예제 #3
0
    def __init__(self, methodName, prop_file="models/basic.props"):

        super().__init__(methodName=methodName)

        result = props.read_props(MODEL_NM, prop_file)
        if result:
            pa.add_props(result.props)
        else:
            print("Oh-oh, no props to read in!")
            exit(1)

        # Now we create a minimal environment for our agents to act within:
        self.env = bm.BasicEnv(model_nm=MODEL_NM, props=pa)

        # Now we loop creating multiple agents
        #  with numbered names based on the loop variable:
        for i in range(pa.get("num_agents")):
            self.env.add_agent(
                bm.BasicAgent(name="agent" + str(i), goal="acting up!"))
        self.env.add_agent(
            bm.BasicAgent(name="agent for tracking", goal="acting up!"))
        self.session_id = random.randint(1, 10)
예제 #4
0
def run(prop_dict=None):
    # We need to create props before we import the basic model,
    # as our choice of display_method is dependent on the user_type.

    pa = props.PropArgs.create_props(MODEL_NM, prop_dict)

    import models.basic as bm
    import indra.utils as utils
    (prog_file, log_file, prop_file,
     results_file) = utils.gen_file_names(MODEL_NM)

    # test prop_args as an iterable:
    for prop, val in pa.items():
        print(prop + ": " + str(val))

    # test that props work as a dictionary:
    if "num_agents" in pa:
        print("In is working!")

    # test what pa["num_agents"] is:
    num_agents = pa["num_agents"]
    print("num_agents = " + str(num_agents))

    # make sure we can get props length:
    print("Props length = " + str(len(pa)))

    # Now we create a minimal environment for our agents to act within:
    env = bm.BasicEnv(model_nm=MODEL_NM, props=pa)

    # Now we loop creating multiple agents
    #  with numbered names based on the loop variable:
    for i in range(num_agents):
        env.add_agent(bm.BasicAgent(name="agent" + str(i),
                                    goal="acting up!"))

    return utils.run_model(env, prog_file, results_file)