Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env python3
"""
This file runs the forestfire_model.
"""
MODEL_NM = "forestfire"
import indra.prop_args2 as props
pa = props.PropArgs.create_props(MODEL_NM)
import indra.utils as utils
import models.forestfire as fm
import os
# set up some file names:
def run(prop_dict=None):
(prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM)
global pa
if pa["user_type"] == props.WEB:
pa["base_dir"] = os.environ["base_dir"]
def run(prop_dict=None):
pa = props.PropArgs.create_props(MODEL_NM, prop_dict)
import indra.utils as utils
import models.hiv as hiv
(prog_file, log_file, prop_file,
results_file) = utils.gen_file_names(MODEL_NM)
grid_x = pa["grid_width"]
grid_y = pa["grid_height"]
ini_ppl = pa["ini_ppl"]
avg_coup_tend = pa["avg_coup_tend"]
avg_test_freq = pa["avg_test_freq"]
avg_commitment = pa["avg_commitment"]
avg_condom_use = pa["avg_condom_use"]
max_ppl = grid_x * grid_y
if ini_ppl > max_ppl:
def run(prop_dict=None):
pa = props.PropArgs.create_props(MODEL_NM, prop_dict)
import indra.utils as utils
import models.fmarket as fm
(prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM)
# Now we create a asset environment for our agents to act within:
env = fm.FinMarket("Financial Market",
pa["grid_height"],
pa["grid_width"],
torus=False,
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["num_followers"]):
def run(prop_dict=None):
pa = props.PropArgs.create_props(MODEL_NM, prop_dict)
import indra.utils as utils
import indra.grid_env as ge
import models.grid as gm
(prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM)
if pa["user_type"] == props.WEB:
pa["base_dir"] = os.environ["base_dir"]
# Now we create a minimal environment for our agents to act within:
env = ge.GridEnv("Test grid env",
pa["grid_width"],
pa["grid_height"],
torus=False,
model_nm=MODEL_NM,
preact=True,
#!/usr/bin/env python3
"""
A script that runs big_box_model. It simulates the market economy
of consumers, mom and pops, and big boxes.
"""
MODEL_NM = "bigbox"
import indra.prop_args2 as props
# we will create props here to set user_type:
pa = props.PropArgs.create_props(MODEL_NM)
import indra.utils as utils
import bigbox as bb
# set up some file names:
def run(prop_dict=None):
(prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM)
# We store basic parameters in a "property" file; this allows us to save
# multiple parameter sets, which is important in simulation work.
# We can read these in from file or set them here.
global pa
# We create a town for our agents to act in:
env = bb.EverytownUSA(pa["grid_width"],
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"]
#!/usr/bin/env python3
"""
A basic zombie model
"""
import indra.prop_args2 as props
import indra.utils as utils
import models.zombie as zom
MODEL_NM = "zombie"
pa = props.PropArgs.create_props(MODEL_NM)
def run(prop_dict=None):
(prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM)
global pa
# we create an Infected Zone for our agents to act within:
env = zom.Zone("Infected Zone",
pa["grid_width"],
pa["grid_height"],
model_nm=MODEL_NM,
preact=True,
postact=True,
props=pa)
# Now we loop creating multiple agents with numbered names
# based on the number of agents of that type to create:
#!/usr/bin/env python3
"""
Set up and run the auditorium model.
"""
MODEL_NM = "auditorium"
import indra.prop_args2 as props
pa = props.PropArgs.create_props(MODEL_NM)
import indra.utils as utils
import schelling.auditorium as am
# set up some file names:
def run(prop_dict=None):
(prog_file, log_file,
prop_file, results_file) = utils.gen_file_names(MODEL_NM)
global pa
# Now we create an environment for our agents to act within:
env = am.Auditorium("Auditorium",
height=pa["grid_height"],
def run(prop_dict=None):
# We need to create props before we import the model,
# as our choice of display_method is dependent on the user_type.
pa = props.PropArgs.create_props(MODEL_NM, prop_dict)
import models.politicalSine as ps
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))