Lecture 4, Introduction to Agent-based Modeling. Welcome to the fourth lecture in this series of video lectures created by Nanyang Technological University in Singapore for MOOC on complexity science. In this lecture, we'll understand the basic features of an agent-based model, also known as an ABM, and how we can use the framework to model complex systems. First of all, let's familiarize ourselves with three relevant acronyms. The first ABM stands for agent-based modeling. The second ABS stands for agent-based simulation. Finally, the third ABMS stands for agent-based modeling and simulation. At this point, let's distinguish between agent-based models and multi-agent systems. Multi-agent systems are computerized systems consisting of multiple interacting intelligent agents. Multi-agent systems are designed to solve problems that a single intelligent system or multiple intelligent agents of the same type cannot solve. In spite of their overlap in methodologies, a multi-agent system is not always equivalent to an agent-based model. Another way to understand the differences between them is to think of agent-based models as tools for understanding complex phenomenon. Whereas multi-agent systems are tools for solving problems complex or otherwise. As the name implies, an agent-based model is one where the fundamental entities are agents. But what's an agent? In the literature, we find many different but broadly similar definitions of the notion of an agent. In his 2002 paper on Swarm Intelligence, Eric Bonabeau gave us simple but broadly applicable definition. In a nutshell, an agent is an autonomous decision-making entity. This definition highlights the two most important characteristics of an agent. An agent must be autonomous, meaning that it must be able to process information. An agent must also be capable of making decisions based on the information that it has processed. Within this agent-based modeling framework, we can therefore treat birds and insects as agents, or individual human beings, or even corporations or countries. Computer scientists like this notion of an agent because it can be implemented as an artificial intelligence software object. Computer scientists also like to emphasize three distinct aspects of the autonomy and the decision-making aspects of an agent. First, an agent must be proactive, meaning that it must be able to set goals independent of the environment or other agents. Fortunately, even within this stricter definition of an agent, we can still treat birds, insects, fishes, or even bacteria as agents, if we do not go into the details of how they set goals for themselves. Second, an agent must be reactive, meaning that it must be able to respond to changes in the environment. For example, suppose Alice leaves home every weekday at 7:00 in the morning and takes a 10 minute walk to the train station near her home to take the train to work. This represents her goal. However, if on a particular day it started raining at 10 minutes to 7:00, Alice realizes that she needs an umbrella. At 7:00 AM, she goes into the kitchen to fetch one before leaving home. Then she's responding to a change in the environment by departing from her routine goal and executing a backup plan instead. Third, an agent must be interactive, meaning that it must be able to interact with other agents which may have different goals from itself in order to achieve its own goal or make adjustments to its goals or courses of action. For example, after leaving home at 7:00 AM with her umbrella, Alice passes a kid from the neighborhood walking to school in the rain. Not wanting the child to get wet, Alice changes her plans and shelters the kid to her school, which is not in the same direction as the train station before going to her work itself. In this example, it's also possible for Alice to ignore the kid and go straight to catch her train. In agent-based models, we think that all decisions that the agents make are deliberate. Now that we understand what agents are, let's talk about why we use agent-based models. For many problems, like flocks of birds, swarms of fishes, or pedestrian crowds, the natural description is in terms of agents. However, this is not the most important reason for us to use agent-based models. The main reason agent-based models are popular in the study of complex systems is that a system of agents is complex. When agents are heterogeneous, and when they're engaged in strategic interactions, we frequently observe emergent collective behaviors from the agent-based models. In situations such as these, we find that it's not easy to build systems dynamics models, which are differential equation models describing the dynamics of aggregate quantities. In this sense, agent-based models represent a bottom-up approach, starting from the simulation of microscopic elements to observe different macroscopic outcomes. Another question we should ask ourselves is what are we using agent-based models for? Frequently, in systems with interacting agents, we do not understand the interactions well. We may, for example, believe that certain macroscopic outcomes in a society are due to people being greedy or stupid. If this is the case, we might build an agent-based model. With the interactions that we've identified, run simulations, to see if they do produce the macroscopic outcomes that we're interested to understand. When we use an agent-based model, and it's simulations this way, to find out what is or is not possible given certain microscopic interactions, or to identify the most important microscopic interactions, then we're using the agent-based model as an exploration tool after we have a good understanding of the important microscopic interactions. They're capable of reproducing the known macroscopic outcomes. We can then aim for predictive agent-based models. To use these models, we'll create scenarios that have not happened before. Or create scenarios that happen rarely within which we can apply interventions that have never been tried in the real-world. Such agent-based models then become a useful tool for Public Policy. Now that we understand what agent-based models are and what they can be used for, let's get into the technicalities of how to set one up. First, we need to ask ourselves, how many different types of agents there are, and how many different types of actions they can perform? The different types of agents, for example, can be distinguished by such attributes as gender, age, or preferences. The different types of behaviors might, well using the financial markets as an example, the phenomena like buying, selling, and holding. More importantly, we need to specify the conditions under which actions are taken. Again, using the financial market as an example, an agent may choose to buy if the price of the stock has increased by more than five percent for the past three days or sell if the price of the stock has fallen by more than five percent over the same period. Or hold if the price movements have been between five percent up and five percent down. There are many ways to create these lists of agent types, agent actions, and conditions. The simplest is simply to observe agents in the real world. Based on such observations, we can easily decide how many agent types and how many action types we should include in the model. However, it would be difficult to tell what the conditions for triggering specific actions are. The reason for this difficulty is that more often than not, decision-making takes place in an agent's head. The conditions for triggering different agents are not articulated. To get at those conditions, if the agents are human beings, we need to employ the social science methods of interviews and surveys. Basically, we asked people what they would do under a certain set of conditions and why they choose to do so. Clearly, there are many different types of people in the world. We have babies a couple of months old, up to seniors more than 80 years old. If we're facy, we might even distinguish between someone who is say, a 1000 days old and another person who has 1001 days old. Surely this is overdoing it. For most social science questions, it's unlikely that small age gaps are going to make a difference. Therefore, in a social science agent-based simulation, we might choose to work with agent types comprising young children under seven years of age, school children between eight years and 24 years, working adults between 25 and 65 years of age, and retirees older than 66 years. These agents types are meaningful because the lifestyles of young children are very similar to each other. Whereas there is a market difference between the lifestyles of young children and school children. Similarly, the types of agents and routines that working adults do and follow are very different from those of retirees. By grouping agents of different ages into different age groups characterized by their actions and routines, we have simpler agent-based models to simulate. Similarly, we can also group actions. For example, going to work is going to work. It does not matter whether a person is going to work as a banker or a dentist. Work tends to follow very narrow sets of actions and also very rigid schedules. In contrast, socializing, for example, after work on weekdays or weekends, is very different from going to work. Here the person can go for concerts, visit the park, or patronize a nice restaurant. If it's important for the question that we seek to answer, we might want to have different types of socializing, like concerts, movies, sports or food. If not, we can also group them into a single action type called socializing. Finally, what are the factors that determine the choice of a particular action? Are we talking about one condition triggering one action, or a combination of conditions triggering an action? How many action combinations do we need to keep agent-based simulation to be realistic? The best way to learn the art of agent-based modeling is to learn from good examples. Here let's examine the simple agent-based model of segregation that was proposed by the late Thomas Schelling, who won the 2005 Nobel Memorial Prize in Economics. In Schelling's Segregation model, we initially distribute b blue agents and r red agents randomly over a grid within spaces. Simple two-dimensional grid. For the model to be interesting, we must have b plus r less than m. There have to be some white spaces so that agents can move around if they're unhappy in the company that they're keeping. Now in this model, a blue agent is satisfied and happy if the proportion of the blue neighbors is more than p. We just set p to vary. The same is true for the red agents. Now if we run this simulation long enough, will always end up with clusters of blue agents and clusters of red agents. Segregation persists even when that preference for living with your neighbors is vanishingly small. That's the macroscopic outcome, segregation. No matter what we set p preference to be, except when p preference is identically zero for both agents.