How to use the indra.utils.run_model function in indra

To help you get started, we’ve selected a few indra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gcallah / indras_net / models / sim_interactive_run.py View on Github external
pa["grid_width"],
                               pa["grid_height"],
                               model_nm=MODEL_NM,
                               props=pa)

    # create given number of slow vehicles
    # print(sm)
    max_speed = pa["max_speed"]
    min_speed = pa["min_speed"]
    for i in range(pa["slow_car_num"]):
        newAgent = sm.Car('Vehicle #' + str(i), random.randint(min_speed,
                                                               max_speed))
        env.add_agent(newAgent)
        env.move(newAgent, i + 2, 50)

    return utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / models / grid_run.py View on Github external
props=pa)

    # Now we loop creating multiple agents with numbered names
    # based on the loop variable:
    for i in range(pa["num_agents"]):
        env.add_agent(gm.TestGridAgent(name="agent" + str(i),
                      goal="taking up a grid space!"))

    # let's test our iterator
    for cell in env:
        (x, y) = cell.coords
        logging.info("Contents of cell x = " + str(x)
              + " and y = " + str(y)
              + " is " + str(cell.contents))

    return utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / models / zombie_run.py View on Github external
postact=True,
                   props=pa)
    # Now we loop creating multiple agents with numbered names
    # based on the number of agents of that type to create:
    for i in range(pa["num_zombies"]):
        env.add_agent(zom.Zombie("Zombie" + str(i), "Eating Human",
                                 pa["zombie_repro"],
                                 pa["zombie_lforce"],
                                 rand_age=True))
    for i in range(pa["num_humans"]):
        env.add_agent(zom.Human("Human" + str(i), "Reproducing",
                                pa["human_repro"],
                                pa["human_lforce"],
                                rand_age=True))

    return utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / models / coop_run.py View on Github external
pa = utils.read_props(MODEL_NM)
    if pa is None:
        pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)
        utils.get_agent_num(pa, "num_agents", "agents", 100)
        pa.ask("min_holdings",
               "What is a co-op member's minimum desired holding of coupons?",
               float, default=7.5, limits=(1.0, 20.0))
    
    env = cm.CoopEnv(model_nm=MODEL_NM, props=pa)
    
    for i in range(pa.get("num_agents")):
        env.add_agent(
            cm.CoopAgent('agent' + str(i), 5, 0))
    
    utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / models / sand_run.py View on Github external
def run(prop_dict=None):
    (prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM)
    
    # Now we create a minimal environment for our agents to act within:
    env = sm.SandEnv("Abelian sand env",
                     pa["grid_width"],
                     pa["grid_height"],
                     model_nm=MODEL_NM,
                     props=pa)
    
    # This env adds agents itself.
    return utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / run.py View on Github external
def run(model_nm, prop_dict):
    (prog_file, log_file, prop_file, results_file) = utils.gen_file_names(model_nm)
    pa = PropArgs(model_nm, prop_dict=prop_dict)
    env = get_env(model_nm, pa)

    utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / models / old_models / menger_run.py View on Github external
#  multiple parameter sets, which is important in simulation work.
#  We can read these in from file or set them here.
pa = utils.read_props(MODEL_NM)
if pa is None:
    pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)
    pa.set("prod_amt", 1)

# Now we create an environment for our agents to act within:
env = mm.MengerEnv("Menger's money model", 50, 50,
                   model_nm=MODEL_NM)
env.fetch_agents_from_file(CSV_FILE, mm.MengerAgent)
env.add_prod_goods()

node.add_prehension(mm.MengerAgent, bm.TRADE, mm.MengerAgent)

utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / models / wolfsheep_markov_run.py View on Github external
postact=True)

# Now we loop creating multiple agents with numbered names
# based on the number of agents of that type to create:
for i in range(pa.get("num_wolves")):
    env.add_agent(wsmm.Wolf("wolf" + str(i), "Eating sheep",
                           pa.get("wolf_repro"),
                           pa.get("wolf_lforce"),
                           rand_age=True))
for i in range(pa.get("num_sheep")):
    env.add_agent(wsmm.Sheep("sheep" + str(i), "Reproducing",
                            pa.get("sheep_repro"),
                            pa.get("sheep_lforce"),
                            rand_age=True))

utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / models / fashion_run.py View on Github external
env = fm.Society("Society",
                 pa.get("grid_height"),
                 pa.get("grid_width"),
                 torus=False,
                 model_nm=MODEL_NM)

# Now we loop creating multiple agents with numbered names
# based on the loop variable:
for i in range(pa.get("num_followers")):
    env.add_agent(fm.Follower("follower" + str(i), "Looking like hipsters",
                              pa.get("fmax_move")))
for i in range(pa.get("num_hipsters")):
    env.add_agent(fm.Hipster("hipster" + str(i), "Looking trendy",
                             pa.get("hmax_move")))

utils.run_model(env, prog_file, results_file)