There are a number of great projects that already exist that cover agent based simulation quite well, like Mesa, however they do not handle the case of a parallel agent based simulation in which the agents act independentily, but are acted upon by external events. An example of this type of model is PEARL.
This project aims to make creating Population Agent Based Simulations (PABS) easy, as easy as creating agent based simulations in Mesa. Much of the insipiration for this project, comes from the ease of using Mesa, and extends its design.
The lifecycle of creating a population based simulation follows these steps:
-
- Define the population generating functions. These are functions that produce
nagents with the desired characteristics, wherenis the population size.
- Define the population generating functions. These are functions that produce
-
- Define event functions that runs during each step in the simulation. An example would be agents aging in a longitudinal study, or contracting a disease in the case of pearl.
-
- Define an engine that runs
ksteps feeding the population into the event functions in a fixed or random order.
- Define an engine that runs
-
- Run the simulation generating output artifacts.
-
- Analyze the resulting artifacts to create reports or plots.
These steps contain the following key components:
- Population generating functions
- Population with persistent state
- Simulation engine
- Event functions for processing simulation states
- Artifacts from simulation runs
- Analysis of artifacts to generate reports and plots
- Return
nagents that form the population. This generation could be through sampling, random generation, static values, parametric or non-parametric methods, but it must return a value for a given feature or feature in the population. - The returned features may depend on the current state of the population based on other generating functions, so the order of feature generation matters.
- The population must keep state of what the expected features are and communicate when a feature is referenced outside of scope.
- The population should also maintain it's expected representation, for instance in the case of long tailed distributions, if an instance of an agent does not exist in the given simulation, it's abscence should be referencible in later analysis.
- Event functions take the population as input and return a mutated population.
- Event functions must not reference features of a population that do not exist, and this should be checked before running to save time in development.
- The engine takes a given seed population, and a list of event functions and run them over a number of steps.
- The resulting population, as well as residual artifacts from the event functions must be stored in a manner that allows for efficient storage and retrieval for analysis.
- Large pandas dataframes should have correct types for feature columns to avoid wasted space
- Ability to write results to sql during/after run
- The scope of analysis is quite large, and user specific, however this library will support some basic utility functions.
- Basic verification statistics/graphs should be available after run