# Preface

# 1. What is this book about?

The objective of this book is to help you learn to **implement and analyze evolutionary models of social interactions in finite populations**. This goal may not be perfectly clear to you right now (and that is absolutely fine), so let us examine the main terms in the bold sentence above, one by one.

- By “
**social interactions**” we mean interactions between individuals where the outcome for each individual depends not only on her own actions, but also on the actions of others. A simple example is the decision to drive on the left or on the right of a two-way road. Driving on your left is a good idea if everyone else also drives on their left, but not so good if everyone drives on their right. The interaction between a penalty kicker and the goal keeper is another example. A more complex example would be the decision to start a new collaboration with a partner or not and, if so, how much effort to put into the partnership. We will see in this book that*game theory*is a great framework to formalize and analyze this type of social interactions. - By “
**evolutionary model**” we mean a model where the individuals involved in the interaction may change their actions in time, according to some decision rule. An example of a decision rule could be: “Look at what other individuals are doing, identify who is doing best, and copy what she is doing (i.e., her action)”. If individuals update their actions in time, the distribution of actions in the population changes or*evolves*. Evolutionary models at their core are just*dynamic*models, i.e. models where there is some change in time. We will see in this book that*evolutionary game theory*is a great framework to formalize and analyze this type of dynamic models of social interactions. - By “
**finite populations**” we mean that there is a finite number of individuals in our models. You may be wondering: what else could it be? Well, the point is that many models in evolutionary game theory assume that the population is infinite. Normally, this assumption is made for mathematical tractability, i.e., for analytical convenience. Here we will not impose that assumption. Our object of study will always be a model of a population which, in principle, could exist in the real world. - By “
**learn to implement evolutionary models**“, we mean that we are going to learn how to code our evolutionary models in a programming language, using a computer. It is perfectly fine if you have never programmed before; actually, if that is the case, we believe that you are going to enjoy this book immensely. If, on the other hand, you have some programming experience, chances are that you will sail through many chapters of this book faster than you think. In this book we are going to use an agent-based (aka individual-based) approach, i.e. we are going to implement how individuals make their own decisions, how they*individually*change their actions in time, and we are going to see how they*individually*enjoy or suffer the consequences of their*individual*decisions. We will also be able to see how the distribution of actions in the population changes in time, according to the different assumptions that we wish to implement in our models. - And finally, by “
**learn to analyze evolutionary models**” we mean that we will do our very best to understand the dynamics of our models, i.e. we are going to find out*why*we observe what we observe, and try to derive conclusions about the logical implications of the assumptions we implement in our models.

The following paragraphs explain why the two skills we are going to learn with this book –i.e. model implementation and analysis– are key for scientific modeling.

## Model implementation

To use a scientific model rigorously, it is important to be fully aware of all the assumptions embedded in it, and also of the various alternative assumptions that could have been chosen. If we don’t understand all the details of a model, we run the risk of over-extrapolating its scope and of drawing unsound conclusions. A great way to understand a model in depth is to *implement* it in computer code following an agent-based approach. We believe this is true regardless of whether the model is currently expressed in natural language (and may even exist only in your mind) or, alternatively, it is written down in mathematical language (e.g. using equations).

Coding a model expressed in natural language is very useful because it ensures that the model is both consistent and completely specified. A computer implementation of a model is necessarily *consistent* because the language used to code it (i.e. the programming language) is formal, so it does not allow ambiguities to infiltrate; symbols and instructions used in programming languages have always the same meaning regardless of context. A computer implementation of a model must also be *completely specified* before it can be run, since computers do not make assumptions by themselves. Thus, to execute a model in a computer, there cannot be any loose ends in the description of the model. This contrasts with models expressed in natural language, where it is easy to leave aspects of the model partially unspecified –often unintentionally–, since our brains are particularly good at using context to unconsciously fill the details. If we use natural language to describe a model, the audience may understand something slightly different from what we mean to communicate, and results may be driven by assumptions that we have not made explicit. By contrast, computers need all assumptions to be spelt out, and this requirement makes the process of scientific modeling more sound and rigorous.

If a model is written in the language of mathematics, the problems outlined in the paragraph above are no longer an issue. Thus, is it really worth implementing a mathematical model in computer code following an agent-based approach? We believe that, in many cases, it certainly is. The reason is that many mathematical models contain assumptions that are desirable for analytical tractability, but which also weaken the link between the model and the real world. These assumptions made for analytical convenience tend to elevate the mathematical model to a higher level of abstraction and aggregation. By contrast, the agent-based approach has the advantage of forcing the programmer to implement the microfoundations of a model explicitly, considering each individual agent as a separate entity. This requirement helps the modeler be aware of all the assumptions that are made in the mathematical model, and it also allows for an assessment of their significance.

## Model analysis

Once the model is implemented, the way to fully understand it is to *analyze* it. In this book, we will see several techniques that are useful to analyze finite-population evolutionary models, including Markov chain analyses, Monte Carlo simulations, mean dynamics, stochastic stability analyses, diffusion approximations and the pair approximation. For each of these techniques, we give a brief introduction, illustrate its usefulness with concrete examples, and provide references for the interested reader to learn more about it.

# 2. How to use this book

This book has been written and formatted following a hands-on approach. To make the most of it, we encourage you to have NetLogo open, and to code the models as you read the book. We are hopeful and confident that if you go through the whole text, implement the proposed models, and try to do some of the exercises included at the end of most sections, you will master the art of implementing and analyzing agent-based evolutionary dynamics.

Nonetheless, we also have in mind two other types of less committed readers:

- If you are interested in learning to analyze finite-population evolutionary models, and in their relation with other models in Evolutionary Game Theory, but
**you do not wish to program**, then you should skip all the sections preceded by the label^{ CODE }. - If you want to become proficient in coding agent-based models, but
**you are not interested in learning how to analyze these models**, please do reconsider your preference. If your preference persists after careful reflection, you may want to skip the section titled “Analysis of these models”, which you will find at the end of most chapters.

Our hope is that, regardless of the discipline you are coming from, your background and your preferences, this book will help you learn new and exciting ways of understanding evolutionary systems.