How to run the ../models/segregation model.

First we import all necessary files.


In [ ]:
import random
from models.segregation import set_up

We then initialize global variables.


In [ ]:
from indra.agent import Agent
from indra.composite import Composite
from indra.display_methods import RED, BLUE
from indra.env import Env
from indra.registry import get_env, get_prop
from indra.utils import init_props

MODEL_NAME = "segregation"
DEBUG = True  # Turns debugging code on or off
DEBUG2 = False  # Turns deeper debugging code on or off

NUM_RED = 250
NUM_BLUE = 250

DEF_CITY_DIM = 40

TOLERANCE = "tolerance"
DEVIATION = "deviation"
COLOR = "color"

DEF_HOOD_SIZE = 1
DEF_TOLERANCE = .5
DEF_SIGMA = .2

MAX_TOL = 0.1
MIN_TOL = 0.9

BLUE_TEAM = 0
RED_TEAM = 1

HOOD_SIZE = 4

NOT_ZERO = .001

BLUE_AGENTS = "Blue agents"
RED_AGENTS = "Red agents"

group_names = [BLUE_AGENTS, RED_AGENTS]

hood_size = None

opp_group = None

Next we call the set_up function to set up the environment, groups, and agents of the model.


In [ ]:
set_up()

You can run the model N periods by typing the number you want in the following function and then running it.


In [ ]:
city.runN()

You can view the position of all of the agents in space with the following command:


In [ ]:
city.scatter_graph()

You can view the line graph through the following command:


In [ ]:
city.line_graph()