Skip to content

stfnmangini/BiologicalSimulation-with-SimPy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simulation of a Biological system using SimPy

This Python project uses SimPy, a discrete time simulation framework, to simulate the evolution of a population of living creatures in an environment with limited food supply.
The main idea behind the simulation is from Primer's youtube video on Natural Selection, but simpler and without any video rendering.

SimPy may not be the best tool for implementing this kind of biological simulations, but since I had to make a Python project with it, I decided to give it a try with the natural selection simulation. Probably the bes solution for this kind of simulation would be using OOP (Object Oriented Programming), and constantly looping and updating the state of the living creatures, until the end of the simulation.

All the three python files (bio_sim.py, averages.py and equilibrium.py) can be directly executed, each one adding more features and analysis. Infact, equilibrium.py imports and run averages.py, which in turn imports and execute bio_sim.py.

The fils are well documented, so it should not be hard to understand.

bio_sim.py

Useful information for the simulation

  • A Forest is the natural environment where the living creatures, called Blobs, live. The simulation is divided into days, and each day has a daylight and nighttime period. During daylight the Blobs goes searching for food, while during nighttime they go to sleep and wait for the next day to begin.

  • The Blob is the living creature populating the Forest. Each Blob goes searching for food during daylight, and rest during nighttime. The Blob has to eat a minimum amount of food each day to survive, otherwise it dies. The process of finding food takes a random time, and after the Blob found and ate the food, it rests for a while before going hunting again. If It eats more food than required to survive, it reproduces, thus creating another Blob in the simulation.

averages.py

This file executes the simulaton in bio_sim.py multiple times in order to achieve a sufficient statistics to plot relevant information and results of the simulation.

equilibrium.py

This file extrapolates relevant information when an equilibrium is reached between available food and surviving blobs, and eventually fits the data.

Presentation folder

The folder contains a presentation explaining the code, its motivations, difficulties encountered and final thoughts.

Required packages (installation with Conda)

conda install -c mutirri simpy
conda install -c conda-forge tqdm
  • Scipy: for linear fitting of data
conda conda install -c anaconda scipy
  • Numpy and Matplotlib

About

Simulation of a biological system using SimPy

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages