Home Download Help Forum Resources Extensions FAQ NetLogo Publications Contact Us Donate Models: Library Community Modeling Commons Beginners Interactive NetLogo Dictionary (BIND) NetLogo Dictionary User Manuals: Web Printable Chinese Czech Farsi / Persian Japanese Spanish

NetLogo Models Library: 
If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web 
This model is from Chapter Three of the book "Introduction to AgentBased Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo", by Uri Wilensky & William Rand.
This model is in the IABM Textbook folder of the NetLogo Models Library. The model, as well as any updates to the model, can also be found on the textbook website: http://www.introtoabm.com/.
El Farol is a bar in Santa Fe, New Mexico. The bar is popular  especially on Thursday nights when they offer Irish music  but sometimes becomes overcrowded and unpleasant. In fact, if the patrons of the bar think it will be overcrowded they stay home; otherwise they go enjoy themselves at El Farol. This model explores what happens to the overall attendance at the bar on these popular Thursday evenings, as the patrons use different strategies for determining how crowded they think the bar will be.
El Farol was originally put forth by Brian Arthur (1994) as an example of how one might model economic systems of boundedly rational agents who use inductive reasoning.
This is a version of the El Farol model in the Social Science Section of the NetLogo Models Library. This version is intended for use with the IABM textbook. It is NOT intended for textbook users to understand all the code in this model as the point in this section of the textbook is to extend the model by adding new output measures to the model, and not to alter the fundamental algorithm of the model.
An agent will go to the bar on Thursday night if they think that there will not be more than a certain number of people there  a number given by the OVERCROWDINGTHRESHOLD. To predict the attendance for any given week, each agent has access to a set of prediction strategies and the actual attendance figures of the bar from previous Thursdays. A prediction strategy is represented as a list of weights that determines how the agent believes that each time period of the historical data affects the attendance prediction for the current week. One of these weights (the first one) is a constant term which allows the baseline of the prediction to be modified. This definition of a strategy is based on an implementation of Arthur's model as revised by David Fogel et al. (1999). The agent decides which one of its strategies to use by determining which one would have done the best had they used it in the preceding weeks.
Interestingly, the optimal strategy from a perfectly rational pointofview would be to always go to the bar since you are not punished for going when it is crowded, but in Arthur's model agents are not optimizing attending when not crowded, instead they are optimizing their prediction of the attendance.
The number of potential strategies an agent has is given by NUMBERSTRATEGIES, and these potential strategies are distributed randomly to the agents during SETUP. As the model runs, at any one tick each agent will only utilize one strategy, based on its previous ability to predict the attendance at the bar. In this version of the El Farol model, agents are given strategies and do not change them once they have them, however since they can change their strategies at any time based on performance, the ecology of strategies being used by the whole population changes over time. The length of the attendance history the agents can use for a prediction or evaluation of a strategy is given by MEMORYSIZE. This evaluation of performance is carried out in UPDATESTRATEGIES, which does not change the strategies, but rather updates the performance of each strategy by testing it, and then selecting the strategy that has the best performance given the current data. In order to test each strategy its performance on MEMORYSIZE past days is computed. To make this work, the model actually records twice the MEMORYSIZE historical data so that a strategy can be tested MEMORYSIZE days into the past still using the full MEMORYSIZE data to make its prediction.
The NUMBERSTRATEGIES slider controls how many strategies each agent keeps in its memory. The OVERCROWDINGTHRESHOLD slider controls when the bar is considered overcrowded. The MEMORY slider controls how far back, in the history of attendance, agents remember. To run the model, set the NUMBERSTRATEGIES, OVERCROWDINGTHRESHOLD and MEMORY size, press SETUP, and then GO.
The BAR ATTENDANCE plot shows the average attendance at the bar over time.
The green part of the world represents the homes of the patrons, while the blue part of the world represents the El Farol Bar. Over time the attendance will increase and decrease but its mean value comes close to the OVERCROWDINGTHRESHOLD.
Try running the model with different settings for MEMORYSIZE and NUMBERSTRATEGIES. What happens to the variability in attendance as you decrease NUMBERSTRATEGIES? What happens to the variability in the plot if you decrease MEMORYSIZE?
Currently the weights that determine each strategy are randomly generated during the model setup. Try altering the weights that are possible during setup so that they only reflect a mix of the following agent strategies:  always predict the same as last week's attendance  an average of the last several week's attendance  the same as 2 weeks ago Can you think of other simple rules one might follow?
At the end of Arthur's original paper, he mentions that though he uses a simple learning technique (the "bag of strategies" method that we use here) almost any other kind of machine learning technique would achieve the same results. This method is particularly limiting in that the strategies an agent is given during the setup are all the strategies they have for the entire run of the model. Most other machine learning methods would enable the agents to change their strategies over time. In fact Fogel et al. (1999) implemented a genetic algorithm and got somewhat different results. Try implementing another machine learning technique and see what the results are.
Can you think of a better way to measure the success of strategies and calculate the beststrategy?
Lists are used to represent strategies and attendance histories.
nvalues
is useful for generating random strategies.
Arthur's original model has been generalized as the Minority Game and is included in the Social Sciences section of the NetLogo models library.
Wilensky, U. (2004). NetLogo Minority Game model. http://ccl.northwestern.edu/netlogo/models/MinorityGame. Center for Connected Learning and ComputerBased Modeling, Northwestern University, Evanston, IL.
There is also a participatory simulation version of the Minority Game model in the models library.
Stouffer, D. & Wilensky, U. (2004). NetLogo Minority Game HubNet model. http://ccl.northwestern.edu/netlogo/models/MinorityGameHubNet. Center for Connected Learning and ComputerBased Modeling, Northwestern University, Evanston, IL.
There is an alternative implementation of this model with more parameters that is part of the NetLogo User Community Models.
This model is adapted from:
Rand, W. and Wilensky, U. (1997). NetLogo El Farol model. http://ccl.northwestern.edu/netlogo/models/ElFarol. Center for Connected Learning and ComputerBased Modeling, Northwestern University, Evanston, IL.
This model is inspired by a paper by W. Brian Arthur. "Inductive Reasoning and Bounded Rationality", W. Brian Arthur, The American Economic Review, 1994, v84n2, p406411.
David Fogel et al. also built a version of this model using a genetic algorithm. "Inductive reasoning and bounded rationality reconsidered", Fogel, D.B.; Chellapilla, K.; Angeline, P.J., IEEE Transactions on Evolutionary Computation, 1999, v3n2, p142146.
This model is part of the textbook, “Introduction to AgentBased Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo.”
If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.
For the model itself:
Please cite the NetLogo software as:
Please cite the textbook as:
Copyright 2007 Uri Wilensky.
This work is licensed under the Creative Commons AttributionNonCommercialShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/byncsa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.
(back to the NetLogo Models Library)