Agent-based simulation in forestry & farming

Agent-based simulation can be a useful tool for forestry planning and farming planning as it can help simulate and understand the complex interactions between system entities. Agent-based simulation is a method for complex system design and analysis. The method implements micro-scopic system behaviour with agents that interact with eachother and with the environment that they are in. Agents have attributes, behaviours – some of which are internal and some of which take place in the form of interactions with agents around them. This type of modelling contributes to policy analysis. It does so by studying the impact of behavioral changes on the system as a whole. It also analyzes the impact resulting from absorption of external impacts. Agent-based simulation is therefore often to address strategic subjects. This article covers agent-based simulation for plant growth modelling. Farm and forestry planning can make use of such models for forecasting and decision-making.

Exemplary applications in forestry and farming

Agent-based simulation can e.g. model the growth and development of trees in a forest and the interactions between the trees and the environment. The model can simulate how different factors, such as soil composition, climate, and competition for resources, affect the growth and survival of individual trees and the overall health of the forest. The model can also test different forest management strategies, such as thinning or clearcutting, and their impact on the forest ecosystem.

Agent-based simulation can model the interactions between different crops, livestock, and the environment in a farming system. The model can simulate how different factors, such as soil quality, climate, and pest infestations, affect the growth and yield of crops and the health and productivity of livestock. The model can furthermore test different farming practices, such as crop rotation or use of fertilizers, and their impact on the farming system.

Small plant growth simulation model in Python

The following simulation model in Python demonstrates agent-based modelling, and the concept behind. Using, in this case, only NumPy and matplotlib I implement a simple agent-based plant growth simulation model from scratch. In this simple model trees grow in grid cells on a grid map, and when passing a specified age they reproduce in their surrounding available cells. Plants die after at a specified age. Plant growth is also impacted by sunlight and already obtained plant height.

import numpy as np
import matplotlib.pyplot as plt

# global constants
SUNLIGHT_RANGE = (0.0, 1.0)

class Plant:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.height = 1
        self.lifetime = 0

    def grow(self, sunlight):
        if self.height < MAX_PLANT_HEIGHT:
            self.height += sunlight

        self.lifetime += 1

    def reproduce(self):
        if np.random.uniform(0, 1) < PLANT_REPRODUCTION_PROBABILITY:
            return Plant(self.x, self.y)
            return None

class Grid:
    def __init__(self, size):
        self.size = size
        self.plants = []

        # initialize plants
        for i in range(INITIAL_PLANTS):
            x = np.random.randint(0, self.size)
            y = np.random.randint(0, self.size)
            plant = Plant(x, y)

    def update(self):
        sunlight_map = self.get_sunlight_map()

        # grow existing plants
        for plant in self.plants:
            sunlight = sunlight_map[plant.x, plant.y]

            # check if plant has reached max lifetime or height
            if plant.lifetime >= MAX_PLANT_LIFETIME or plant.height >= MAX_PLANT_HEIGHT:
                # reproduce if possible
                new_plant = plant.reproduce()
                if new_plant is not None:

    def get_sunlight_map(self):
        # generate a random sunlight map for the grid
        return np.random.uniform(SUNLIGHT_RANGE[0], SUNLIGHT_RANGE[1], size=(self.size, self.size))

    def plot(self):
        # create a plot of the grid with the plants
        fig, ax = plt.subplots()
        ax.imshow(self.get_sunlight_map(), cmap='Greens', interpolation='nearest')

        for plant in self.plants:
            ax.plot(plant.y, plant.x, 'bo', markersize=plant.height)

# create a grid object and plot it
grid = Grid(GRID_SIZE)

# update the grid and plot it again
for i in range(10):

This is a grid-based model, and this is what it looks like after 1 iteration:

agent-based plant growth simulation

And here is what plant height (size of scalar plots) looks like after 10 iterations:

abm simulation of plant growth

In a future blog post I will show how these types of models are easily implemented with my own abm_framework library. You can read more about that library here:

Larger models will take in many more and more well thought-out attributes and behavioural models, but implement them based on the same or simular concept. For example, disease outbreak and disease spread, different plant species with differing resistancy towards disease spread. Or the impact of dry vs. wet summers could be analyzed with an agent-based simulation model similar to this one. Soil quality or overcrowding would be some more examples of mechanisms that could be implemented into such a model to understand their impact.

It is important to understand that a good model in this case is not necessarily a model with thousands of attributes, but a model and scenario definition that effectively answers a defined research question or analysis objective. E.g. does “behaviour X” have a significant impact on “KPI Y”.

Content related to agent-based simulation in forestry

The following articles will take you further in your understanding of agent-based simulation and its applications. They also include some examples that I implemented with abm_framework:

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.