# Import modules
import matplotlib.pyplot as plt
72 Predator-Prey model
The Lotka-Volterra model, also known as the predator-prey model, is a pair of first-order, non-linear, differential equations frequently used to describe the dynamics of biological systems in which two species interact, one as a predator and the other as prey. The model illustrates how the population sizes of both species fluctuate over time, with the predator population depending on the prey for food and the prey population being controlled by predation.
In agriculture, this model can be used to simulate the interaction between a crop-damaging pest (prey) and its biological control agents such as parasitoids or predatory insects (predators). Another application could be in integrated pest management (IPM) programs, where the model helps in devising strategies that maintain pest populations below economic threshold levels by enhancing the population of beneficial predators.
Equations
\frac{dx}{dt} = ax - \beta xy
\frac{dy}{dt} = \delta x y - \gamma y
x is the number of prey (for example, rabbits)
y is the number of some predator (for example, foxes)
t represents time
\frac{dx}{dt} instantaneous growth rate of prey
\frac{dy}{dt} instantaneous growth rate of predator
\alpha natural prey birth rate in the absence of predation
\beta prey death rate due to predation
\delta predator birth rate (or efficiency of turning prey flesh into predators, or how many caught prey result into a new predator)
\gamma natural predator death rate in the absence of food (prey)
If we discretize the equations (meaning that we deal with a finite amount of time instead of an instant), so that dt becomes \Delta t, then the right hand side of the equations represent change (increment or decrement) of the prey and predator in the specified finite amount of time (e.g. 1 day). So, that:
dx = (ax - \beta xy) \; \Delta t
represents the change of prey. In order to find the total number of prey at time t we simply need to add this change to the existing quantity of prey:
x_t = x_{t-1} + (ax_{t-1} - \beta x_{t-1}y_{t-1}) \; \Delta t
# Initial predator and prey count
= [10]
predator = [100]
prey
# Prey and predator parameters
= 0.005 # births per day
prey_birth_rate = 0.00015 # deaths per day
prey_death_rate = 0.00015 # births per day. If value is too high predators will quickly dominate prey
predator_birth_rate = 0.01 # deaths per day. When there is no food, predators should die quickly, to let the prey recover
predator_death_rate
# Time parameters
= 1 # 1 day
delta_time = 3650 # in days total_time
# Run model over defined period
for t in range(1, total_time):
= max(prey[t-1] + delta_time * (prey_birth_rate * prey[t-1] - prey_death_rate * prey[t-1] * predator[t-1]), 0)
updated_prey = max(predator[t-1] + delta_time * (predator_birth_rate * predator[t-1] * prey[t-1] - predator_death_rate * predator[t-1]), 0)
updated_predator
prey.append(updated_prey)
predator.append(updated_predator)
# Create figure
= range(total_time)
time_points
=(5,4))
plt.figure(figsize
plt.plot(time_points, predator)
plt.plot(time_points, prey) 'Days')
plt.xlabel('Prey or Predator count')
plt.ylabel('Predator','Prey'])
plt.legend(["legend.edgecolor"] = 'w'
plt.rcParams[ plt.show()
References
Lotka, A.J., 1926. Elements of physical biology. Science Progress in the Twentieth Century (1919-1933), 21(82), pp.341-343.
Volterra, V., 1927. Variazioni e fluttuazioni del numero d’individui in specie animali conviventi (p. 142). C. Ferrari.
You can also learn more at https://www.wikiwand.com/en/Lotka%E2%80%93Volterra_equations