This Python code integrates the Lotka-Volterra equations for Predator-Prey systems.
The Lotka-Volterra equations are perhaps the simplest expression of predator-prey competition. If we have R prey and P predators, and we now the birth rates b and death rates d of each, then the simplest expression of the Lotka-Volterra System is
A typical solution to this system gives R and P being periodic and out of phase. Prey grow exponentially, then predators feed on the overpopulated prey and grow exponentially until local prey are exhausted. The predators die off, and then prey are able to return, and the cycle repeats.
If we assume that there is a finite carrying capacity K for the prey, then the prey evolution equation becomes
In this case, the system's oscillations are damped, and eventually an equilibrium prey/predator population is reached.
The code is written in Python 2.7, and was developed using numpy 1.8.0, matplotlib 1.3.0. The main code is stored in the module lotka_volterra.py
, which is accessed by either:
solve_system.py
(which integrates the equations assuming exponential growth), orsolve_system_logistic.py
(which integrates the equations assuming logistic growth towards a finite carrying capacity)
Users need simply edit these scripts to specify the correct initial conditions, and execute them using e.g.
python solve_system.py
To integrate the system, and to create figures of the system's time evolution.