examples.el_farol_bar_model.agents package

Submodules

examples.el_farol_bar_model.agents.agents module

Agents for the el farol bar problem

class examples.el_farol_bar_model.agents.agents.LikeCrowdedPlayer(simulation, model, agent_number, agent_def)[source]

Bases: examples.el_farol_bar_model.agents.agents.Player

A player that always defect

select_game()[source]

The agent select a play from a strategy

class examples.el_farol_bar_model.agents.agents.LikeSixtyPercentPlayer(simulation, model, agent_number, agent_def)[source]

Bases: examples.el_farol_bar_model.agents.agents.Player

A player that always defect

class examples.el_farol_bar_model.agents.agents.Player(simulation, model, agent_number, agent_def)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

A basic player in the El Farol Bar Problem

game_payoff()[source]

Get the game payoff

get_frequency(frequency)[source]

“Get the frequency in the bar

play()[source]

The agent plays a strategy

select_game()[source]

The agent select a play from a strategy

step()[source]

agent step

class examples.el_farol_bar_model.agents.agents.RandomPlayer(simulation, model, agent_number, agent_def)[source]

Bases: examples.el_farol_bar_model.agents.agents.Player

A player that always defect

select_game()[source]

Random selection of the game

examples.el_farol_bar_model.agents.el_farol_bar_action_set module

Basic Strategy Class implementation

class examples.el_farol_bar_model.agents.el_farol_bar_action_set.LikeCrowded(agent, recall)[source]

Bases: examples.el_farol_bar_model.agents.el_farol_bar_action_set.Strategy

Strategy Like Crownded

payoff(agent_play)[source]

Specialized by subclass

select_strategy()[source]

Like Crownded Strategy

class examples.el_farol_bar_model.agents.el_farol_bar_action_set.LikeSixtyPercent(agent, recall)[source]

Bases: examples.el_farol_bar_model.agents.el_farol_bar_action_set.Strategy

Strategy under sixty percent

class examples.el_farol_bar_model.agents.el_farol_bar_action_set.RandomPlay(agent)[source]

Bases: examples.el_farol_bar_model.agents.el_farol_bar_action_set.Strategy

Strategy under random

select_strategy()[source]

Random Strategy

class examples.el_farol_bar_model.agents.el_farol_bar_action_set.Strategy(agent, recall)[source]

Bases: object

Implementation of the strategy class

STRATEGY = ['GOING', 'NOT GOING']
get_frequency(frequency)[source]

The strategy gets the current frequency in the bar

payoff(agent_play)[source]

Specialized by subclass

select_game()[source]
select_strategy()[source]
selected_predictor()[source]

Returns the selected predictor and its fitness

set_all_predictors()[source]

set all predictors in the model

set_predictors()[source]

Set the predictors for this strategy

update_fitness()[source]

Updates the payoffs of the strategies

examples.el_farol_bar_model.agents.el_farol_bar_prediction_model module

Prediction Model for the El Farol Problem

class examples.el_farol_bar_model.agents.el_farol_bar_prediction_model.FitnessFunction(owner)[source]

Bases: object

Fitness Function for the el-farol bar model following: Rand, W., & Stonedahl, F. (2007). The El Farol bar problem and computational effort:

Why people fail to use bars efficiently. Northwestern University, Evanston, IL.

f(S,t) = sum_(i=t-L)^(t-1) abs(p(S,i) - a(i)) Where: p(S,i) is the prediction of strategy S on time i and a(i) is the observed attendance on time i and L is the memory reacall lenght.

fitness(observed, predicted)[source]

Calculate Strategy fitness

class examples.el_farol_bar_model.agents.el_farol_bar_prediction_model.PredictionModel(agent, recall)[source]

Bases: object

The prediction model that the agent uses to choose the strategy Arthur’s paper (1994) strategies 1. the same as last week’s 2. a mirror image around 50 of last week’s 3. a (rounded) average of the last four weeks 4. the trend in last 8 weeks, bounded by [0,100] 5. the same as 2 weeks ago (2-period cycle detector) 6. the same as 5 weeks ago (5-period cycle detector)

agent_memory()[source]

Returns the agent memory

get_best_prediction()[source]

Get the prediction from the fittest predictor

get_best_predictor(predictors)[source]

Get the prediction from the fittest predictor

get_fitness(predictor_name)[source]

Get the fitness of one predictor

get_fitness_of_predictor(predictor_name, going, target_no)[source]

Updates the fitness of one predictor

make_prediction(selected_predictors)[source]

The prediction based on the model

no_of_agents()[source]

Returns the number of agents

st_mirror_50_lw()[source]

Strategy 2. a mirror image around 50 of last week’s

st_round_avg_4w()[source]

Strategy 3. a (rounded) average of the last four weeks

st_same_2w()[source]

Strategy 5. the same as 2 weeks ago (2-period cycle detector)

st_same_5w()[source]

Strategy 6. the same as 5 weeks ago (5-period cycle detector)

st_same_lw()[source]

Strategy 1. the same as last week’s

st_trend_8w()[source]

Strategy 4. the trend in last 8 weeks, bounded by [0,100]

step()[source]

get agent step

update_fitness(predictors, going, target_no)[source]

Updates the fitness of the predictors

Module contents

class examples.el_farol_bar_model.agents.Player(simulation, model, agent_number, agent_def)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

A basic player in the El Farol Bar Problem

game_payoff()[source]

Get the game payoff

get_frequency(frequency)[source]

“Get the frequency in the bar

play()[source]

The agent plays a strategy

select_game()[source]

The agent select a play from a strategy

step()[source]

agent step

class examples.el_farol_bar_model.agents.RandomPlayer(simulation, model, agent_number, agent_def)[source]

Bases: examples.el_farol_bar_model.agents.agents.Player

A player that always defect

select_game()[source]

Random selection of the game

class examples.el_farol_bar_model.agents.LikeCrowdedPlayer(simulation, model, agent_number, agent_def)[source]

Bases: examples.el_farol_bar_model.agents.agents.Player

A player that always defect

select_game()[source]

The agent select a play from a strategy

class examples.el_farol_bar_model.agents.LikeSixtyPercentPlayer(simulation, model, agent_number, agent_def)[source]

Bases: examples.el_farol_bar_model.agents.agents.Player

A player that always defect