Data storage
[Agent practical 1 of 9]
What is an Agent-Based Model?
For over 3000 years, we've had to aggregate individual things in order to understand their mass behaviour. Mathematics, and more specifically statistics, developed because we're unable to cope with hundreds of objects or people as individuals in our heads. However, the rise of high-powered computers and large disk space means we can now start to build models that don't aggregate, but that keep individuals as individuals: so called "individual level models".
This has several advantages, for example, we can keep track of individual entities' history for the purposes of analysis or adapting how they act. One significant advantage is we can give individual objects "agency" -- we can give them individual behaviour and the ability to interact with each other and their environment. This allows us to build an Agent-Based Model (ABM), i.e. one in which our individuals have agency.
The rise of Object-Orientated Programming, where code can be segregated into specific 'objects' to do jobs, has simultaneously created a platform for ABMs, with types of individual being represented as classes, and individuals being built as objects from those classes.
ABMs are generally iterative models. They run by allowing the agents to do their thing for a time step repeatedly (for example, representing someone doing a day's activities) until some number of time steps (iterations) have run, or some stopping condition has been reached. System-level patterns emerge from the complex interactions of the multiple, relatively simple, behaviours of the agents in the model.
The key code elements of a basic ABM are:
A Model
class, which deals with interacting with the user and
sets up the model, including running the model iterations and checking the
stopping conditions.
An Agent
class, which is used to build agents can include
the agent's behaviour and any records of their state. The behaviours can
be rule based, mathematical, or statistical. Agents will often have behaviours
based around what is happening in a limited neighbourhood around them. The class will often contain
an array of all the agent objects so agents can communicate with each other.
An Environment
class which represents the "world" that agents may interact with.
This may contain data as well as constraint the space and topology the agents can exist within.
It could be anything from a network to an abstract information-brokering class, but often
in social and environmental science it contains a 'raster' grid of data.
In building an ABM, then, we cover broader coding concepts of use across science, including:
- structuring classes and code;
- utilising rules and maths;
- getting code to interact with other code;
- interacting with users;
- reading and writing data.
So, let's move on to look at what we're going to build.