How to use the indra.prop_args.PropArgs 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 / archive / spatial_run.py View on Github external
import indra.utils as utils
import indra.prop_args as props
import indra.spatial_env as se
import models.spatial as sm

# set up some file names:
MODEL_NM = "spatial_model"
(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.
pa = utils.read_props(MODEL_NM)
if pa is None:
    pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)

# Now we create a minimal environment for our agents to act within:
env = se.SpatialEnv("Test spatial env", 100.0, 100.0,
                    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")):
    env.add_agent(
        sm.TestSpatialAgent(name="agent" + str(i),
                            goal="moving around aimlessly!"))

utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / models / fashion_run.py View on Github external
"""

import indra.utils as utils
import indra.prop_args as props
import fashion_model as fm

# set up some file names:
MODEL_NM = "fashion_model"
(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.
pa = utils.read_props(MODEL_NM)
if pa is None:
    pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)
    utils.get_grid_dims(pa, 16)
    utils.get_agent_num(pa, "num_followers", "followers", 48)
    utils.get_agent_num(pa, "num_hipsters", "hipsters", 16)
    utils.get_max_move(pa, "fmax_move", "follower", 4)
    utils.get_max_move(pa, "hmax_move", "hipster", 4)
    pa.ask("min_adv_periods", "What are the minimum adverse periods?", int,
           default=6, limits=(1, 100))


# Now we create a minimal environment for our agents to act within:
env = fm.Society("Society",
                 pa.get("grid_height"),
                 pa.get("grid_width"),
                 torus=False,
                 model_nm=MODEL_NM)
github gcallah / indras_net / models / markov_attempts / fashion_markov_run.py View on Github external
"""

import indra.utils as utils
import indra.prop_args as props
import fashion_markov_model as fmm

# set up some file names:
MODEL_NM = "fashion_markov_model"
(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.
pa = utils.read_props(MODEL_NM)
if pa is None:
    pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)
    utils.get_grid_dims(pa, 16)
    utils.get_agent_num(pa, "num_followers", "followers", 48)
    utils.get_agent_num(pa, "num_hipsters", "hipsters", 16)
    utils.get_max_move(pa, "fmax_move", "follower", 4)
    utils.get_max_move(pa, "hmax_move", "hipster", 4)

# Now we create a minimal environment for our agents to act within:
env = fmm.Society("Society",
                 pa.get("grid_height"),
                 pa.get("grid_width"),
                 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(fmm.Follower("follower" + str(i), "Looking like hipsters",
github gcallah / indras_net / models / spatial_run.py View on Github external
import indra.utils as utils
import indra.prop_args as props
import indra.spatial_env as se
import models.spatial_model as sm

# set up some file names:
MODEL_NM = "spatial_model"
(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.
pa = utils.read_props(MODEL_NM)
if pa is None:
    pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)
    pa.set("num_agents", 2)

# Now we create a minimal environment for our agents to act within:
env = se.SpatialEnv("Test spatial env", 100.0, 100.0,
                    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")):
    env.add_agent(
        sm.TestSpatialAgent(name="agent" + str(i),
                            goal="moving around aimlessly!"))

utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / indra / prop_args.py View on Github external
def __init__(self, model_nm, logfile=None, props=None,
                 loglevel=logging.INFO):
        super().__init__("Properties")
        self.model_nm = model_nm
        # store this instance as the value in the dict for 'model_nm'
        PropArgs.prop_sets[model_nm] = self
        self.graph = nx.Graph()
        if props is None:
            self.props = {}
        else:
            self.props = props
            logfile = self.get("log_fname")
        self.logger = Logger(self, logfile=logfile)
        self.graph.add_edge(self, self.logger)
        self.set("OS", platform.system())
        self.set("model", model_nm)
        # process command line args and set them as properties:
        prop_nm = None
        for arg in sys.argv:
            # the first arg (-prop) names the property
            if arg.startswith(SWITCH):
                prop_nm = arg.lstrip(SWITCH)
github gcallah / indras_net / models / markov_attempts / two_pop_markov_run.py View on Github external
import indra.utils as utils
import indra.prop_args as props
import indra.two_pop_markov as itpm
import two_pop_markov_model as tpm

# set up some file names:
MODEL_NM = "two_pop_markov_model"
(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.
pa = utils.read_props(MODEL_NM)
if pa is None:
    pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)
    utils.get_grid_dims(pa, 6)
    utils.get_agent_num(pa, "num_agents", "agents", 16)

# Now we create a minimal environment for our agents to act within:
env = itpm.TwoPopEnv("Test two pop Markov env",
                 pa.get("grid_width"),
                 pa.get("grid_height"),
                 preact=True,
                 postact=True,
                 trans_str="0.5 0.5; 0.5 0.5",
                 model_nm=MODEL_NM,
                 torus=False,)

# Now we loop creating multiple agents with numbered names
# based on the loop variable:
github gcallah / indras_net / models / menu_run.py View on Github external
def run():
    (prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM)
    
    # We store menu 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.
    pa = utils.read_props(MODEL_NM)
    if pa is None:
        pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)
        pa.set("num_agents", 10)
    
    # Now we create a minimal environment for our agents to act within:
    env = mm.MenuEnv(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")):
        env.add_agent(mm.MenuAgent(name="agent" + str(i),
                                   goal="testing our menu capabilities!"))
    
    utils.run_model(env, prog_file, results_file)
github gcallah / indras_net / models / predprey_run.py View on Github external
"""
predprey_run.py
Script to run our predator-prey model.
"""
import indra.utils as utils
import indra.node as node
import indra.prop_args as props
import predprey_model as ppm


MODEL_NM = "predprey_model"
(prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM)

pa = utils.read_props(MODEL_NM)
if pa is None:
    pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)
    pa.set("model", MODEL_NM)
    pa.set("num_foxes", 16)
    pa.set("num_rabbits", 48)
    pa.set("num_zombies", 6)
    pa.set("fox_repro_age", 11)
    pa.set("rabbit_repro_age", 3.6)
    pa.set("fox_life_force", 32.8)
    pa.set("rabbit_life_force", 22.0)
    pa.set("fox_max_move", 12.8)
    pa.set("rabbit_max_move", 10.2)
    pa.set("fox_decay_rate", 5.8)
    pa.set("rabbit_decay_rate", 3.98)
    pa.set("fox_max_detect", 40.0)

env = ppm.PredPreyEnv("meadow", 50.0, 50.0)
github gcallah / indras_net / models / archive / menu_run.py View on Github external
def run():
    (prog_file, log_file, prop_file, results_file) = utils.gen_file_names(MODEL_NM)
    
    # We store menu 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.
    pa = utils.read_props(MODEL_NM)
    if pa is None:
        pa = props.PropArgs(MODEL_NM, logfile=log_file, props=None)
    
    # Now we create a minimal environment for our agents to act within:
    env = mm.MenuEnv(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")):
        env.add_agent(mm.MenuAgent(name="agent" + str(i),
                                   goal="testing our menu capabilities!"))
    
    utils.run_model(env, prog_file, results_file)