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

First we import all necessary files.


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

We then initialize global variables.


In [ ]:
from indra.agent import Agent
from indra.composite import Composite
from indra.display_methods import BLUE, RED
from indra.env import Env
from indra.space import DEF_HEIGHT, DEF_WIDTH
from indra.utils import get_props

DEBUG = False

MODEL_NAME = "drunks"

DEF_POPULATION = 10
DEF_OPTIMAL_OCCUPANCY = int(0.6 * DEF_POPULATION)
MOTIVATION = [0.6] * DEF_POPULATION
NUM_DRINKERS = DEF_POPULATION // 2
NUM_NON_DRINKERS = DEF_POPULATION - NUM_DRINKERS

population = 0
optimal_occupancy = 0
attendance_record = []
attendance = 0
agents_decided = 0

drinkers = None
non_drinkers = None
bar = None

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


In [ ]:
(bar, drinkers, non_drinkers) = set_up()

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


In [ ]:
bar.runN()

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


In [ ]:
bar.scatter_graph()

You can view the line graph through the following command:


In [ ]:
bar.line_graph()