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

First we import all necessary files.


In [ ]:
import random
from models.el_farol 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.registry import get_env, get_group, get_prop
from indra.space import DEF_HEIGHT, DEF_WIDTH
from indra.utils import init_props

DEBUG = False

MODEL_NAME = "el_farol"
DRINKERS = "At bar"
NON_DRINKERS = "At home"

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

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 [ ]:
Env("bar",
.runN()

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


In [ ]:
Env("bar",
.scatter_graph()

You can view the line graph through the following command:


In [ ]:
Env("bar",
.line_graph()