How to use the indra.utils.init_props 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 / el_farol.py View on Github external
def set_up(props=None):
    """
    A func to set up run that can also be used by test code.
    """
    init_props(MODEL_NAME, props)

    drinkers = Composite(DRINKERS, {"color": RED},
                         member_creator=create_drinker,
                         num_members=get_prop('population',
                                              DEF_POPULATION) // 2)

    non_drinkers = Composite(NON_DRINKERS, {"color": BLUE},
                             member_creator=create_non_drinker,
                             num_members=get_prop('population',
                                                  DEF_POPULATION) // 2)
    bar = Env(MODEL_NAME,
              height=get_prop('grid_height', DEF_HEIGHT),
              width=get_prop('grid_width', DEF_WIDTH),
              members=[drinkers, non_drinkers],
              pop_hist_setup=setup_attendance)
    population = len(drinkers) + len(non_drinkers)
github gcallah / indras_net / models / models_to_rewrite / gameoflife.py View on Github external
def set_up(props=None):
    """
    A func to set up run that can also be used by test code.
    """
    init_props(MODEL_NAME, props)

    height = get_prop("grid_height", DEF_HEIGHT)
    width = get_prop("grid_width", DEF_WIDTH)
    simulation = get_prop("simulation", 0)
    black = Composite("Black", {"color": BLACK, "marker": SQUARE})
    groups = [black]
    Env("Game of Life",
        action=gameoflife_action,
        height=height,
        width=width,
        members=groups,
        attrs={"size": 100,
               "change_grid_spacing": (0.5, 1),
               "hide_xy_ticks": True,
               "hide_legend": True},
        random_placing=False)
github gcallah / indras_net / epidemics / epidemic.py View on Github external
def set_up(props=None):
    """
    A func to set up run that can also be used by test code.
    """
    init_props(MODEL_NAME, props, model_dir="epidemics")

    city_height = get_prop('grid_height', DEF_DIM)
    city_width = get_prop('grid_width', DEF_DIM)
    city_density = get_prop('density', DEF_DENSITY)
    immune_per = get_prop('immune_per', DEF_IMMUNE_PER)
    death_rate = get_prop('death_rate', DEF_DEATH_RATE)
    initial_infected = get_prop('initial_infected', DEF_INFEC)
    infec = get_prop('infec', DEF_INFEC)
    immune_rate = 1 / immune_per

    # Replace state trans values with updated values
    set_trans(STATE_TRANS, EX, IN, infec, HE)
    set_trans(STATE_TRANS, CN, DE, death_rate, IM)
    set_trans(STATE_TRANS, IM, HE, immune_rate, IM)

    pop_cnt = int(city_height * city_width * city_density)
github gcallah / indras_net / capital / edgeworthbox.py View on Github external
def set_up(props=None):
    """
    A func to set up run that can also be used by test code.
    """
    global max_util
    pa = init_props(MODEL_NAME, props, model_dir="capital")
    cheese_group = Composite("Cheese holders", {"color": BLUE},
                             member_creator=create_cagent,
                             props=pa,
                             num_members=get_prop('num_cagents',
                                                  DEF_NUM_CAGENTS))
    wine_group = Composite("Wine holders", {"color": RED},
                           member_creator=create_wagent,
                           props=pa,
                           num_members=get_prop('num_wagents',
                                                DEF_NUM_WAGENTS))

    Env("EdgeworthBox",
        height=get_prop('grid_height', DEF_HEIGHT),
        width=get_prop('grid_width', DEF_WIDTH),
        members=[cheese_group, wine_group])
github gcallah / indras_net / models / fashion.py View on Github external
def set_up(props=None):
    """
    A func to set up run that can also be used by test code.
    """
    init_props(MODEL_NAME, props)
    groups = []

    groups.append(Composite(BLUE_TSETTERS, {"color": NAVY}))
    groups.append(Composite(RED_TSETTERS, {"color": DARKRED},
                            member_creator=create_tsetter,
                            num_members=get_prop('num_tsetters',
                                                 NUM_TSETTERS)))

    groups.append(Composite(RED_FOLLOWERS, {"color": RED}))
    groups.append(Composite(BLUE_FOLLOWERS, {"color": BLUE},
                            member_creator=create_follower,
                            num_members=get_prop('num_followers',
                                                 NUM_FOLLOWERS)))

    Env(MODEL_NAME, members=groups, attrs={OPP_GROUP: opp_group})
github gcallah / indras_net / capital / trade.py View on Github external
def set_up(props=None):
    """
    A func to set up run that can also be used by test code.
    """
    global max_utility
    pa = init_props(MODEL_NAME, props, model_dir="capital")
    trader_group = Composite("trader", {"color": BLUE},
                             member_creator=create_trader,
                             props=pa,
                             num_members=get_prop('num_traders',
                                                  DEF_NUM_TRADER))
    Env("env",
        height=get_prop('grid_height', DEF_HEIGHT),
        width=get_prop('grid_width', DEF_WIDTH),
        members=[trader_group])
    for trader in trader_group:
        allocate_resources(trader_group[trader], GOODS)
        user_log_notif(trader_group[trader]["goods"])
    return (trader_group, max_utility)
github gcallah / indras_net / models / halfdone / ex_boyfriend.py View on Github external
def set_up(props=None):
    """
    A func to set up run that can also be used by test code.
    """
    global period

    period = 0

    init_props(MODEL_NAME, props)

    newly_freed = Composite("Girlfriend", {"color": BLUE},
                            member_creator=create_newly_freed,
                            num_members=1)

    ex_boyfriend = Composite("Ex-Boyfriend", {"color": RED},
                             member_creator=create_boyfriend,
                             num_members=1)

    Env("bar",
        height=get_prop('grid_height', DEF_HEIGHT),
        width=get_prop('grid_width', DEF_WIDTH),
        members=[ex_boyfriend, newly_freed])
github gcallah / indras_net / models / fmarket.py View on Github external
def set_up(props=None):
    """
    A func to set up run that can also be used by test code.
    """
    init_props(MODEL_NAME, props)
    groups = []

    groups.append(Composite("value_investors", {"color": BLUE},
                            member_creator=create_value_investor,
                            num_members=get_prop("value_investors",
                                                 DEF_NUM_VALUE_INVESTOR)))
    groups.append(Composite("trend_followers", {"color": RED},
                            member_creator=create_trend_follower,
                            num_members=get_prop("trend_followers",
                                                 DEF_NUM_TREND_FOLLOWER)))
    groups.append(create_market_maker(MARKET_MAKER))
    Env(MODEL_NAME,
        members=groups,
        width=UNLIMITED,
        height=UNLIMITED,
        pop_hist_setup=initial_price)