Exploring Evolution through ABM

So, what is Agent-based modelling?

Agent-based models (ABMs) are simulations that consist of many agents, all acting based on a predefined set of rules, and are simulated in discrete steps. Each agent acts independently based on its environment including the other agents around it. This allows us to analyse the effect of individual agent behaviour on the model as a whole.

Alright. How to go about making an ABM then?

For scientific and numerical applications, I prefer to use Julia. In the words of Wikipedia:

So what does my model do?

My model consist of bacteria acting as agents, on a two-dimensional grid. The bacteria eat food in the grid cells to survive, and reproduce through binary fission, with a random variation in their parameters.

  • age : How old the bacterium is.
  • energy : The current amount of energy a bacterium has.
  • sensory_radius : How far away the bacterium can spot food.
  • reproduction_threshold : How much energy a bacterium needs to reproduce through binary fission.
  • speed : How fast the bacterium can move, measured as the maximum number of steps it can take in any direction. The amount a bacterium eats in one iteration is also proportional to this parameter.
  • food_target : The location of the food source that a bacterium is moving toward.
  • If a bacterium grows too old (as determined by a global cap on lifetime), or runs out of energy, it dies.
  • If it has energy above its reproduction_threshold, it reproduces through binary fission. In this process, each child inherits the parent’s sensory_radius, reproduction_threshold and speed with some genetic variation. Additionally, the energy of the parent is distributed between the two children, after removing a fixed cost of reproduction.
  • If the bacterium is currently on a cell with some food, it will eat some food and gain energy. The amount of food it eats is proportional to its speed.
  • The bacterium will look for food. If it sees food, it will move toward it. Otherwise, it will move around randomly.
  • Each iteration, if not eating, the bacterium loses some energy proportional to its sensory radius and distance moved that iteration

What happens when the model runs?

For the food concentrations, I used a 100 x 100 image, where each pixel corresponds to a grid tile, and the RGB value of a pixel determines the amount of food in the tile. This heatmap shows how the food is distributed:

Heatmap showing distribution of food on a 100 x 100 grid
The topmost plot is variation of population during the simulation. Below that, plots show the variation of sensory radius, reproduction threshold and speed of the bacteria with time. The line is the average value for each parameter, and around it is the standard deviation band.

My thoughts

This model was fun to make, and even more fun to explore. I expected the population and parameters to stabilise to “ideal” values, and the oscillatory behaviour was a surprise. However, what fun is a simulation if it does what you expect it to? Analysing the graphs for this proved much more of a challenge than if they simply converged.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store