Tutorial on agent-based modelling and simulation
This note is a shortened and simplified version of an article in the Journal of Simulation (2010) 4, 151–162, written by C M Macal and M J North. For full details, including contact details and references, please see the full article.
Agent-based modelling and simulation (ABMS) is a relatively new approach to modelling systems composed of autonomous, interacting agents. Agent-based modelling is a way to model the dynamics of complex systems and complex adaptive systems. Such systems often self-organize themselves and create emergent order. Agent-based models also include models of behaviour (human or otherwise) and are used to observe the collective effects of agent behaviours and interactions. The development of agent modelling tools, the availability of micro-data, and advances in computation have made possible a growing number of agent-based applications across a variety of domains and disciplines. This article provides a brief introduction to ABMS, illustrates the main concepts and foundations, discusses some recent applications across a variety of disciplines, and identifies methods and toolkits for developing agent models.
Agent-based modelling and simulation (ABMS) is a relatively new approach to modelling complex systems composed of interacting, autonomous ‘agents’. Agents have behaviours, often described by simple rules, and interactions with other agents, which in turn influence their behaviours. By modelling agents individually, the full effects of the diversity that exists among agents in their attributes and behaviours can be observed as it gives rise to the behaviour of the system as a whole. By modelling systems from the ‘ground up’—agent-by-agent and interaction-by-interaction—self-organization can often be observed in such models. Patterns, structures, and behaviours emerge that were not explicitly programmed into the models, but arise through the agent interactions. The emphasis on modelling the heterogeneity of agents across a population and the emergence of self-organization are two of the distinguishing features of agent-based simulation as compared to other simulation techniques such as discrete-event simulation and system dynamics. Agent-based modelling offers a way to model social systems that are composed of agents who interact with and influence each other, learn from their experiences, and adapt their behaviours so they are better suited to their environment.
Applications of agent-based modelling span a broad range of areas and disciplines. Other agent-based models are large scale in nature, in which a system is modelled in great detail, meaning detailed data are used, the models have been validated, and the results are intended to inform policies and decision making. These applications have been made possible by advances in the development of specialized agent-based modelling software, new approaches to agent-based model development, the availability of data at increasing levels of granularity, and advancements in computer performance.
Several indicators of the growing interest in agent-based modelling include the number of conferences and workshops devoted entirely to or having tracks on agent-based modelling, the growing number of peer-reviewed publications in discipline-specific academic journals across a wide range of application areas as well as in modelling and simulation journals, the growing number of openings for people specializing in agent-based modelling, and interest on the part of funding agencies in supporting programmes that require agent-based models. For example, a perusal of the programme for a recent Winter Simulation Conference revealed that 27 papers had the word ‘agent’ in the title or abstract.
2. Agent-based modelling
2.1. Agent-based modelling and complexity
ABMS can be traced to investigations into complex systems, complex adaptive systems and artificial life. Complex systems consist of interacting, autonomous components; complex adaptive systems have the additional capability for agents to adapt at the individual or population levels. These collective investigations into complex systems sought to identify universal principles of such systems, such as the basis for self-organization, emergent phenomenon, and the origins of adaptation in nature. ABMS began largely as the set of ideas, techniques, and tools for implementing computational models of complex adaptive systems. Initially, agent behaviours were modelled using exceedingly simple rules that still led to exceedingly complex emergent behaviours. In the past 10 years or so, available agent-based modelling software tools and development environments have expanded considerably in both numbers and capabilities.
2.2. Structure of an agent-based model
A typical agent-based model has three elements:
- A set of agents, their attributes and behaviours.
- A set of agent relationships and methods of interaction: An underlying topology of connectedness defines how and with whom agents interact.
- The agents’ environment: Agents interact with their environment in addition to other agents.
A model developer must identify, model, and program these elements to create an agent-based model. A computational engine for simulating agent behaviours and agent interactions is then needed to make the model run. An agent-based modelling toolkit, programming language or other implementation provides this capability. To run an agent-based model is to have agents repeatedly execute their behaviours and interactions. This process often does, but is not necessarily modelled to, operate over a timeline, as in time-stepped, activity-based, or discrete-event simulation structures.
2.3. Autonomous agents
The single most important defining characteristic of an agent is its capability to act autonomously, that is, to act on its own without external direction in response to situations it encounters. Agents are endowed with behaviours that allow them to make independent decisions. Typically, agents are active, initiating their actions to achieve their internal goals, rather than merely passive, reactively responding to other agents and the environment.
From a practical modelling standpoint, based on how and why agent-models are actually built and described in applications, we consider agents to have certain essential characteristics:
- An agent is a self-contained, modular, and uniquely identifiable individual. The modularity requirement implies that an agent has a boundary. One can easily determine whether something is part of an agent, is not part of an agent, or is a shared attribute. Agents have attributes that allow the agents to be distinguished from and recognized by other agents.
- An agent is autonomous and self-directed. An agent can function independently in its environment and in its interactions with other agents, at least over a limited range of situations that are of interest in the model. An agent has behaviours that relate information sensed by the agent to its decisions and actions. An agent's information comes through interactions with other agents and with the environment. An agent's behaviour can be specified by anything from simple rules to abstract models, such as neural networks or genetic programs that relate agent inputs to outputs through adaptive mechanisms.
- An agent has a state that varies over time. Just as a system has a state consisting of the collection of its state variables, an agent also has a state that represents the essential variables associated with its current situation. An agent's state consists of a set or subset of its attributes. The state of an agent-based model is the collective states of all the agents along with the state of the environment. An agent's behaviours are conditioned on its state. As such, the richer the set of an agent's possible states, the richer the set of behaviours that an agent can have. In an agent-based simulation, the state at any time is all the information needed to move the system from that point forward.
- An agent is social having dynamic interactions with other agents that influence its behaviour. Agents have protocols for interaction with other agents, such as for communication, movement and contention for space, the capability to respond to the environment, and others. Agents have the ability to recognize and distinguish the traits of other agents.
Agents may also have other useful characteristics:
- An agent may be adaptive, for example, by having rules or more abstract mechanisms that modify its behaviours. An agent may have the ability to learn and adapt its behaviours based on its accumulated experiences. Learning requires some form of memory. In addition to adaptation at the individual level, populations of agents may be adaptive through the process of selection, as individuals better suited to the environment proportionately increase in numbers.
- An agent may be goal-directed, having goals to achieve (not necessarily objectives to maximize) with respect to its behaviours. This allows an agent to compare the outcome of its behaviours relative to its goals and adjust its responses and behaviours in future interactions.
- Agents may be heterogeneous. Unlike particle simulation that considers relatively homogeneous particles, such as idealized gas particles, or molecular dynamics simulations that model individual molecules and their interactions, agent simulations often consider the full range of agent diversity across a population. Agent characteristics and behaviours may vary in their extent and sophistication, how much information is considered in the agent's decisions, the agent's internal models of the external world, the agent's view of the possible reactions of other agents in response to its actions, and the extent of memory of past events the agent retains and uses in making its decisions. Agents may also be endowed with different amounts of resources or accumulate different levels of resources as a result of agent interactions, further differentiating agents.
A theory of agent behaviour for the situations or contexts the agent encounters in the model is needed to model agent behaviour. One may begin with a normative model in which agents attempt to optimize profits, utility, etc, as a starting point for developing a simpler, more descriptive, but realistic, heuristic model of behaviour. One may also begin with a behavioural model if there is available behavioural theory and empirical data to support the application. For example, numerous theories and empirically based heuristics exist for modelling consumer shopping behaviour. These could be implemented and compared in an agent-based model. Cognitive science and related disciplines focus on agents and their social behaviours. Behavioural modelling frameworks such as BDI (Belief-Desire-Intent) combine modal and temporal logics as the basis for reactive planning and agent action selection. In agent-based modelling applications in which learning is important, theories of learning by individual agents or collectives of agents become important. The field of machine learning is another source of learning algorithms for recognizing patterns in data (such as data mining) through techniques such as supervised learning, unsupervised learning, and reinforcement learning.
2.4. Interacting agents
Agent-based modelling concerns itself with modelling agent relationships and interactions as much as it does modelling agent behaviours. The two primary issues of modelling agent interactions are specifying who is, or could be, connected to who, and the mechanisms of the dynamics of the interactions. Both aspects must be addressed in developing agent-based models.
One of the tenets of complex systems and agent-based modelling is that only local information is available to an agent. Agent-based systems are decentralized systems. There is no central authority that either pushes out globally available information to all agents or controls their behaviour in an effort to optimize system performance. Agents interact with other agents, but not all agents interact directly with all the other agents all the time, just as in real-world systems. Agents typically interact with a subset of other agents, termed the agent's neighbours. Local information is obtained from interactions with an agent's neighbours (not any agent or all agents) and from its localized environment (not from any part of the entire environment). Generally, an agent's set of neighbours changes rapidly as a simulation proceeds and agents move through space.
How agents are connected to each other is generally termed an agent-based model's topology or connectedness. Typical topologies include a spatial grid or network of nodes (agents) and links (relationships). A topology describes who transfers information to whom. In some applications, agents interact according to multiple topologies. For example, a recent agent-based pandemic model has agents interacting over a spatial grid to model physical contact as agents go through daily activities and possibly pass on infections. Agents also are members of social networks that model the likelihood of contact with relatives and friends.
An agent's neighbourhood is a general concept applicable to whatever agent spaces are defined in the model. For example, an agent could interact only with its neighbours located close-by in physical (or geographical) space as well as neighbour agents located close-by in its social space as specified by the agent's social network.
2.5. Agent environment
Agents interact with their environment and with other agents. The environment may simply be used to provide information on the spatial location of an agent relative to other agents or it may provide a rich set of geographic information, as in a GIS. An agent's location, included as a dynamic attribute, is sometimes needed to track agents as they move across a landscape, contend for space, acquire resources, and encounter other situations. Complex environmental models can be used to model the agents’ environment. For example, hydrology or atmospheric dispersion models can provide point location-specific data on groundwater levels or atmospheric pollutants, respectively, which are accessible by agents. The environment may thus constrain agent actions. For example, the environment in an agent-based transportation model would include the infrastructure and capacities of the nodes and links of the road network. These capacities would create congestion effects (reduced travel speeds) and limit the number of agents moving through the transportation network at any given time.
3. Agent-based modelling applications
3.1. The nature of agent-based model applications
Agent-based modelling has been used in an enormous variety of applications spanning the physical, biological, social, and management sciences. Applications range from modelling ancient civilizations that have been gone for hundreds of years to modelling how to design new markets that do not currently exist. Several agent-based modelling applications are summarized in this section, but the list is only a small sampling. Several of the papers covered here make the case that agent-based modelling, versus other modelling techniques is necessary because agent-based models can explicitly model the complexity arising from individual actions and interactions that exist in the real world.
Agent-based model structure spans a continuum, from elegant, minimalist academic models to large-scale decision support systems. Minimalist models are based on a set of idealized assumptions, designed to capture only the most salient features of a system. Decision support models tend to serve large-scale applications, are designed to answer real-world policy questions, include real data, and have passed appropriate validation tests to establish credibility.
3.2. Applications overview
Here are some examples to show the wide range of applications of ABM
- modelling molecular self-assembly
- modelling is used to model cell behaviour and interaction, the workings of the immune system, tissue growth, and disease processes
- in ecology, agent-based modelling is used to model diverse populations of individuals and their interactions
- spatial and network topologies to model people's realistic activity and contact. The focus is on understanding tipping point conditions that might lead to an epidemic and identifying possible mitigation measures. These models explicitly consider the role of people's behaviour and interactions through social networks as they affect the spread of infectious diseases
- in many economic models based on standard micro-economic theory, simplifying assumptions are made for analytical tractability. These assumptions include (1) economic agents are rational, which implies that agents have well-defined objectives and are able to optimize their behaviour, (2) economic agents are homogeneous, that is, agents have identical characteristics and rules of behaviour, (3) the system experiences primarily decreasing returns to scale from economic processes (decreasing marginal utility, decreasing marginal productivity, etc), and (4) the long-run equilibrium state of the system is the primary information of interest. Agent-based modelling allows relaxing the standard assumptions of classical economics so the transient states that are encountered along the way to equilibrium can be investigated
- archaeology and anthropology are making use of large-scale agent-based modelling by providing an experimental virtual laboratory for long-vanished civilizations.
4. Methods for agent-based modelling
4.1. Agent model design
When developing an agent-based model, it is useful to ask a series of questions, the answers to which will lead to an initial model design:
- What specific problem should be solved by the model? What specific questions should the model answer? What value-added would agent-based modelling bring to the problem that other modelling approaches cannot bring?
- What should the agents be in the model? Who are the decision makers in the system? What are the entities that have behaviours? What data on agents are simply descriptive (static attributes)? What agent attributes would be calculated endogenously by the model and updated in the agents (dynamic attributes)?
- What is the agents’ environment? How do the agents interact with the environment? Is an agent's mobility through space an important consideration?
- What agent behaviours are of interest? What decisions do the agents make? What behaviours are being acted upon? What actions are being taken by the agents?
- How do the agents interact with each other? With the environment? How expansive or focused are agent interactions?
- Where might the data come from, especially on agent behaviours, for such a model?
- How might you validate the model, especially the agent behaviours?
Answering these questions is an essential part of the agent-based model design process. There are a variety of approaches to designing and implementing agent-based models. Overall, bottom-up, highly iterative design methodologies seem to be the most effective for practical model development. Modern software (and model) development practices dictate that model design be independent of model implementation. That is, a good software (model) design should be able to be implemented in whatever computer language or coding scheme is selected.
4.2. Agent model implementation
Agent-based modelling can be done using general, all-purpose software or programming languages, or it can be done using specially designed software and toolkits that address the special requirements of agent modelling. Agent modelling can be done in the small, on the desktop, or in the large, using large-scale computing cluster, or it can be done at any scale in-between these extremes. Projects often begin small, using one of the desktop ABMS tools, and then grow in stages into the larger-scale ABMS toolkits. Often one begins developing their first agent model using the approach that one is most familiar with, or the approach that one finds easiest to learn given their background and experience.
We can distinguish implementation alternatives to building agent-based models on the basis of the software used. Spreadsheets, such as Microsoft Excel, in many ways offer the simplest approach to modelling. It is easier to develop models with spreadsheets than with many of the other tools, but the resulting models generally allow limited agent diversity, restrict agent behaviours, and have poor scalability compared to the other approaches. Some macro-level programming is also needed using the VBA language.
General computational mathematics systems such as MATLAB and Mathematica, which many people may be already familiar with, can also be used quite successfully; however, these systems provide no specific capabilities for modelling agents. General programming languages such as Python, Java, and C++, and C also can be used, but development from scratch can be prohibitively expensive given that this would require the development of many of the available services already provided by specialized agent modelling tools. Most large-scale agent-based models use specialized tools, toolkits, or development environments based on reasons having to do with usability, ease of learning, cross-platform compatibility, and the need for sophisticated capabilities to connect to databases, graphical user interfaces and GIS.
4.3. Agent modelling services
Regardless of the specific design methodology that is selected, a range of services is commonly required for implementing large-scale models that include real data and geo-spatial environments, which are becoming more prevalent. Some of the more common capabilities include project specification services; agent specification services; input data specification and storage services; model execution services; results storage and analysis services; and model packaging and distribution services.
5. Summary and conclusions
ABMS is a new approach to modelling systems comprised of autonomous, interacting agents. There are a growing number of agent-based applications in a variety of fields and disciplines. ABMS is particularly applicable when agent adaptation and emergence are important considerations. Many agent-based software and toolkits have been developed and are widely used. A combination of several synergistic factors is moving ABMS forward rapidly. These factors include the continuing development of specialized agent-based modelling methods and toolkits, the widespread application of agent-based modelling, the mounting collective experience of the agent-based modelling community, the recognition that behaviour is an important missing element in existing models, the increasing availability of micro-data to support agent-based models, and advances in computer performance. Taken together, these factors suggest that ABMS promises to have far-reaching effects into the future on how businesses use computers to support decision-making, government uses models to make and support policy, and researchers use electronic laboratories to further their research.