Moritz Nelle

Introduction to Modeling

A Blog Post

How Simple Rules Create Complex Systems

Modeling is a powerful tool for bioscientists to understand complex systems. This introduction explains the core concepts and shows how simple rules can create complex, life-like emergent behaviors.

A Simple Simulation Webapp

Virtual Ecosystem Simulation More explanation about this Webapp, its working, mathematical backend, and...

↖️Note, that this blog article references the Webapp linked here.​

How Simple Rules Create Complex Life (An Introduction to Modeling)

An ecosystem, a cell, a population - they aren't just collections of things; they are intricate networks of interactions, feedback loops, and processes that change over time. How do you begin to understand a system where everything seems to affect everything else?

While lab experiments and field studies are the cornerstones of biology, there's another powerful tool that can help you untangle this complexity: modeling.

If you think modeling is just for mathematicians or computer scientists, think again. It's a fundamental approach to scientific inquiry that allows you to formalize your understanding, test hypotheses that are impossible to test in the real world, and discover surprising behaviors that emerge from simple rules.





So, What is a Model, Anyway?

Before we dive into a complex example, let's break down the basics, using the core ideas from systems analysis.

A model is simply a simplified or abstracted representation of a system. And a system is any limited part of reality that contains interrelated elements. A leaf, a human body, a lake - these are all systems. The first step in modeling is always to define your system and its boundaries. The research questions you ask determine where those boundaries lie. For example, if you're studying nutrient cycling in a pond, your system might be the pond itself, with the surrounding land and atmosphere being the "environment" that influences it.

There are many types of models, but we can start by categorizing them in two key ways:

  • Static vs. Dynamic Models: A static model doesn't include the dimension of time. A geographical map is a perfect example - it’s a simplified representation of the Earth's surface, but it's a snapshot. A dichotomous key for identifying tree species is another static model; it represents knowledge but doesn't change. A dynamic model, which is our focus, describes how a system changes over time. The growth of a bacterial culture, the spread of a disease through a population, or the fluctuation of predator and prey populations are all processes that require a dynamic model.
  • Descriptive vs. Explanatory Models: A descriptive model shows that relationships exist between elements but doesn't explain how they work. A statistical analysis showing a correlation between fertilizer application and yield is descriptive. It tells you what happens, but not why. An explanatory model, on the other hand, tries to explain the behavior of a system at one level (like crop yield) by simulating the underlying processes at a lower level (like nitrogen uptake, photosynthesis, and biomass allocation). This is the type of model that allows us to test our understanding of how a system truly functions.





The Building Blocks of a Dynamic Model

To build an explanatory dynamic model, we start with two fundamental assumptions:

  1. The state of a system can be quantified at any moment. This means we can take a "snapshot" and measure the key components. For a bacterial culture, we could measure the number of cells and the amount of nutrients in the medium.
  2. The changes in that system can be described with mathematical equations. This means we can define the rules that govern how the system moves from one state to the next. For instance, we can write an equation for how quickly the bacteria consume nutrients and reproduce.


This leads to a powerful framework using three main components. Let's use a simple, non-biological example: filling a bathtub.

  1. State Variables: A state variable represents a quantity that defines the condition of the system at any instant. It must be something additive - a quantity you can meaningfully add or subtract.

    • Bathtub Example: The amount of water in the tub (in liters) is a perfect state variable. At any moment, you can measure it. If you add 5 more liters, the total amount increases by 5. The water's temperature, however, is not a state variable. If you have 50 liters of 20°C water and add 10 liters of 60°C water, the new temperature is not 80°C. You can't just add temperatures; you'd have to model the underlying state variable, which is heat energy.
    • Biological Example: The amount of biomass in a forest, the number of animals in a population, or the concentration of nitrogen in the soil.

  2. Rate Variables: A rate variable indicates how fast a state variable is changing. These are the engines of the model, representing flows and processes.

    • Bathtub Example: The flow rate from the faucet (e.g., in liters per second) is an inflow rate that increases the "water" state variable. The flow rate down the drain is an outflow rate that decreases it. The net change in the water level is the inflow rate minus the outflow rate.
    • Biological Example: The growth rate of yeast (an inflow to the yeast biomass state), the mortality rate of a species (an outflow from the population state), or the rate of sugar consumption (an outflow from the sugar resource state).

  3. Driving Variables (or Parameters): These are external factors or settings that influence the rates but are not, in turn, influenced by the system itself. They are the "rules" we impose on our model.

    • Bathtub Example: How far you've turned the faucet handle is a parameter. It directly determines the inflow rate, but the amount of water in the tub doesn't magically turn the handle. The size of the drain is another parameter that determines the maximum potential outflow rate.
    • Biological Example: The average daily temperature (which affects growth rates), the amount of rainfall, or a genetically fixed mortality rate for a species.





Emergence: How Simple Rules Create Complex Systems

This is one of my favorit parts and the reason, why I programmed the simulator you can find here. With these three building blocks, we can describe almost any dynamic system. But here is where the magic happens: Even when the rules for each component are simple, the interactions between them can lead to incredibly complex, surprising, and life-like behavior. This is a concept called emergence.

The classic predator-prey population cycle is a perfect example. The "rules" are simple:

  • More prey leads to more predators (higher predator birth rate).
  • More predators leads to less prey (higher prey death rate).
  • Less prey leads to less predators (higher predator death rate).
  • Less predators leads to more prey (lower prey death rate).

When you let these simple, interconnected rules run over time, you don't get a straight line. You get a dynamic, oscillating pattern of boom and bust that looks remarkably like what we observe in nature. The complexity isn't programmed in; it emerges from the interactions. This is the core power of modeling: it allows us to see how the local, simple rules we understand can give rise to the complex, large-scale patterns we observe.

Now, let's see this in action!





Meet the Virtual Ecosystem: A Model in Action

Here (and also above and below) is a link to a Virtual Ecosystem Simulator I have programmed. It’s a web application that models a basic ecosystem containing three types of organisms:

  • Plants (the producers)
  • Herbivores (who eat plants)
  • Predators (who eat herbivores)

Go ahead and play with it. Click "Start Sim." What you are seeing is a dynamic, explanatory model at work. Can you identify the building blocks?

  • State Variables: The population counts shown in the cards at the top ("Plants," "Herbivores," "Predators"). These are snapshots of the system's state.
  • Rate Variables: The unseen processes driving the changes: birth rates, death rates (from predation and starvation), and energy consumption rates.
  • Parameters: Every single slider and input box! Initial Plants, Plant Growth Rate, Herbivore Speed - these are the rules you, the modeler, are setting for this virtual world.





A Look Under the Hood: The Model's Mathematics

The logic of the simulation translates our conceptual understanding into quantitative rules. While the overall behavior is complex, the underlying formulas for each interaction are straightforward. Here is a concise mathematical overview of the simulation’s main formulas and its step-by-step update process.

Key Formulas

  1. Distance Between Two Entities d(e1, e2) = sqrt((x1 - x2)^2 + (y1 - y2)^2) This is used to check whether a herbivore or predator is close enough to eat its target.


  2. Movement and Energy Cost

    • Each animal (herbivore/predator) moves toward its target or wanders randomly.
    • Energy is reduced by moveCost * speed every step. For a herbivore with energy Eh: Eh <- Eh - (herbivoreMoveCost * herbivoreSpeed)
    • A similar formula applies to predators.

  3. Eating and Energy Gain

    • A herbivore that reaches a plant gains energy: Eh <- min(E_max, Eh + herbivoreEnergyPerPlant)
    • A predator that reaches a herbivore gains energy: Ep <- min(E_max, Ep + predatorEnergyPerHerbivore)
    • In both cases, the consumed entity is removed from the simulation.

  4. Reproduction Threshold

    • A herbivore reproduces if its energy (Eh) meets the threshold. It then pays a cost: If Eh >= herbivoreReproductionEnergy -> Eh <- Eh - herbivoreReproductionCost
    • A new herbivore is then spawned, with a small chance of a mutation in its speed. A similar rule applies to predators.

  5. Plant Growth

    • Each step, with probability plantGrowthRate, a new plant is added to a random location, as long as the total number of plants is below the maxPlants limit.





Numerical Integration (Discrete Steps)

So how do we get from the rules above to the moving dots and dynamic charts (or more broadly, to a simulation over time i.e., a dynamic simulation)? For many complex systems, especially those with many interacting agents or feedback loops, it's impossible to write a single equation that solves for the entire system's behavior over time. We can't just "plug in" a future time and get the answer. This is where numerical simulation comes in. Instead of solving for the whole timeline at once, we chop time into tiny, discrete steps. At each step, we calculate the changes for every component based on our simple rules and update its state. By stringing together thousands of these simple updates, we approximate the continuous, dynamic behavior of the entire system.

The Virtual Ecosystem Simulator uses numerical integration as well. In simple terms it work as follows:

  1. Increment stepCounter by 1.
  2. Possibly add a new plant based on plantGrowthRate.
  3. For each entity in the simulation:
    • Move it and reduce its energy by the cost of movement.
    • If it encounters a valid target (plant or herbivore), consume it and gain energy.
    • If its energy is above its reproduction threshold, reproduce and pay the energy cost.
  4. Remove any entities that have been consumed or whose energy has fallen to zero.
  5. Check if any of the simulation's end conditions have been met (e.g., no plants or animals are left).
  6. Repeat this loop until an end condition is met or the user stops the simulation.

From the simple, step-by-step calculations described above, several complex and life-like patterns can emerge, including:
  • Population Cycles: You'll observe classic predator-prey oscillations, where a boom in herbivores is followed by a boom in predators. This leads to a herbivore crash and, subsequently, a predator crash from starvation, restarting the cycle. This feedback loop, first described by the Lotka-Volterra equations, emerges directly from the simple rules of hunting and reproducing.
  • Spatial Patterns: Watch for grazing fronts where herbivores create "deserts," or the formation of predator clusters around the last pockets of prey. These large-scale structures are the unintended consequence of individual agents locally depleting resources and seeking food, creating a dynamic map of risk and refuge.
  • Packs Hunting: Notice how predators often move and hunt in what appear to be packs. This pattern is a direct result of offspring being "born" close to their parents, which naturally creates kin groups that travel together. When this "pack" detects prey, the simple "move to nearest target" rule causes them all to converge, resulting in a cooperative-looking hunt. You can also witness the formation of new families when an individual separates from the group; if it's successful enough to reproduce on its own, it establishes a new pack elsewhere.

Why Should a Bioscientist Care About Modeling?

This all leads back to one crucial point: modeling is a powerful method of scientific inquiry.

  1. Test the Impossible: You can't run a thousand real-world ecosystems with slightly different starting conditions to see which is most stable. But with a model, you can. The "Batch Simulation" feature in my web-app does exactly that. It's a powerful way to perform experiments that would be impractical in the real world, a process known as parameter optimization.
  2. Gain Deeper Insights: Building a model forces you to be explicit about your assumptions. Does herbivore reproduction depend more on speed or the nutritional value of plants? You can test that. Sometimes, models reveal surprising, non-linear behaviors - like the classic population cycles - that emerge from simple rules.
  3. Predict the Future: Well-tested models can be used for prediction. Ecologists use them to forecast the spread of invasive species, the impact of climate change on vegetation patterns, or the effectiveness of conservation strategies for natural enemies in agriculture.





Your Turn to Be the Modeler

Modeling is not about replacing lab work; it's about extending the reach of our minds, just as a microscope extends the reach of our eyes. It’s a tool for thinking.
So, go back to the Virtual Ecosystem Simulator. But this time, look at it like a modeler.

  • Identify the state variables (the counters).
  • Think about the rates (birth, death, eating) that are changing those states.
  • Play with the parameters (the sliders) and predict what will happen before you run the simulation.

The journey into modeling is a journey of discovery. It's a way to ask 'what if,' to test the boundaries of your understanding, and to watch the elegant dance of complexity emerge from the simplest of rules.

Other Posts from all Categories

Introduction to Modeling

Modeling is a powerful tool for bioscientists to understand complex systems. This introduction...

A Simple Simulation Webapp

Virtual Ecosystem Simulation More explanation about this Webapp, its working, mathematical backend, and...