SWEN90004
Modelling Complex Software Systems
Lecture Cx.03
ODE Models I: Predator-Prey
Artem Polyvyanyy, Nic Geard
artem.polyvyanyy@unimelb.edu.au;
nicholas.geard@unimelb.edu.au
Semester 1, 2021
1 / 28
Recap
complex systems
building a mathematical model assumptions
states
update rules
population growth models exponential
logistic
behaviour of dynamic systems fixed points
limit cycles chaos
2 / 28
Objectives
interpret mathematical equations describing a model
understand how these equations can be solved numerically
and/or analytically to give the model’s dynamic behaviour
describe the dynamic behaviour of the model, and how this depends on:
model parameters initial condition
3 / 28
Outline
The Lotka-Volterra model
An aside: solving ODEs
Behaviour of the Lotka-Volterra model Extensions to the Lotka-Volterra model Summary
4 / 28
Motivation
Lynxes and hares
Figure90 years of hare and lynx populations in the Hudson Bay, Canada
5 / 28
History
Predator-prey relationships
FigureRed fox
The Lotka-Volterra model
FigureRabbit
Independently formulated in 1925–26 by Alfred Lotka, a US mathematician and chemist, and Vito Volterra, an Italian mathematician and physicist. Both were inspired by the logistic equation of Verhulst.
6 / 28
Assumptions
Predators: red foxes — Prey: rabbits
the rabbit population is sustainable (they have ample food)
the rabbit population grows at a rate proportional to its size if
there are no red foxes
the red foxes eat only rabbits
the red fox population declines at a rate proportional to its size
if there are no rabbits to eat
the environment is static and has no effect on the rates of
population growth and decay
7 / 28
Model formulation Prey (rabbits):
Predators (red foxes):
dR =αR−βRF dt
dF =δRF−γF dt
Parameters:
Parameter Meaning
α growth rate of the rabbit population
β rate at which foxes predate upon (eat) rabbits
δ growth rate of the fox population
γ decay rate of the fox population due to death and migration
8 / 28
Outline
The Lotka-Volterra model
An aside: solving ODEs
Behaviour of the Lotka-Volterra model Extensions to the Lotka-Volterra model Summary
9 / 28
An aside: solving ODEs using Euler method
Given a set of differential equations and an initial condition, how can we calculate the future states of the system?
In the system
y ′ (t ) = f (t , y (t ))
where f defines the relationshp between variables y and their deriva- tives, the Euler forward difference approach computes the sequence of approximations:
yn+1 =yn +∆t.f(tn,yn) tn+1 = tn + ∆t
as a time-stepped simulation of the underlying behaviour
10 / 28
An aside: using the mid-point to improve accuracy
Rather that basing our estimate of the next point on the slope at the start of the interval, we can improve accuracy by using the slope at the mid-point:
yn+1 = yn + ∆t.f tn + ∆t , yn + ∆t f (tn, yn) 22
tn+1 = tn + ∆t
This approach will diverge from the ‘true’ situation more slowly, but requires more calculations per iteration
11 / 28
An aside: solving ODEs using the Runge-Kutta method
The Euler method is often not accurate enough. Accuracy can be increased by making use of more points in the period between tn and tn+1
The Runge-Kutta family of approaches take this approach, with the most commonly used being RK4, which computes:
yn+1 =yn +(∆t).(k1 +2k2 +2k3 +k4) 6
where the kn values are intermediate estimates of slope: k1 =f(tn,yn)
k2 = f (tn + ∆t , yn + ∆t k1) 22
k3 = f (tn + ∆t , yn + ∆t k2) 22
k4 =f(tn +∆t,yn +∆t.k3)
12 / 28
An aside: solving ODEs using Matlab Matlab function for the Lotka-Volterra model:
function dx = lotka_volterra_function(t, x)
dx = [0; 0];
alpha
beta
delta
gamma
= 0.75;
= 0.2;
= 0.04;
= 0.5;
dx(1) = alpha * x(1) – beta * x(1) * x(2);
dx(2) = delta * x(1) * x(2) – gamma * x(2);
return
Matlab test script:
rabbits = 5;
foxes = 2;
[t, x] = ode45(@lotka_volterra_function, [0 200],
[rabbits foxes], options);
13 / 28
Outline
The Lotka-Volterra model An aside: solving ODEs
Behaviour of the Lotka-Volterra model
Extensions to the Lotka-Volterra model Summary
14 / 28
Numerical solution of the Lotka-Volterra model
FigureRed fox (predator) and rabbit (prey) population levels over time
15 / 28
Numerical solution of the Lotka-Volterra model
FigureThe phase plane
16 / 28
Analysing the Lotka-Volterra model
What is the long term behaviour of the system?
equilibria: points at which the system variables (the population levelsR andF)donotchange;ie,where dR =0and dF =0
Two equilibria:
R = 0, F = 0 R = γδ , F = αβ
R(α − βF) = 0 F(δR − γ) = 0
Interpretation:
equilibrium 1: both populations are extinct
equilibrium 2: both populations sustained at non-zero levels
indefinitely
dt dt
17 / 28
Analysing the Lotka-Volterra model
How does system behaviour depend on its initial condition?
Stability analysis reveals that:
the first equilibrium (both populations going extinct) is
unstable; it can only arise if the prey level is set to zero, at which point the predators also die out
the second equilibrium is stable; specifically, it is neutrally stable, and surrounded by infinitely many periodic orbits
How realistic is this?
18 / 28
Another limitation
FigureAnother Lotka-Volterra phase plane
What is wrong with this picture?
19 / 28
Outline
The Lotka-Volterra model An aside: solving ODEs
Behaviour of the Lotka-Volterra model
Extensions to the Lotka-Volterra model
Summary
20 / 28
Lotka-Volterra model with competition
There is no notion of carrying capacity for the prey species
The logistic equation captured intraspecific competition
The base Lotka-Volterra model captues interspecific
competition
We can combine these ideas by adding an additional term to
the Lotka-Volterra model to account for competition among members of the same species:
dR = αR − βRF − aR2 dt
dF =δRF−γF−bF2 dt
21 / 28
Lotka-Volterra model with competition
FigureTime series FigurePhase plane
Other model refinements have been proposed that increase the ability to capture observed phenomena
22 / 28
Lotka-Volterra model with multiple species
The two-species competitive model can also be written as:
dx1 =rx1−x1−α12×2 dt11 K1
dx2 =rx1−x2−α21×1 dt22 K2
where αij is the effect that species j has on species i. This can then be generalised to an n-species model:
dxi Nj=1 αijxj dt =rixi 1− Ki
where xi represents the i-th species and αij is a matrix of interaction terms.
23 / 28
Lotka-Volterra model with multiple species
Another representation of the multi-species model is:
dxiN
Aij(1−xj)
This version pulls the carrying capacities Ki and interaction terms
dt=xi ri+ αij inside the interaction matrix A
j=1
For three species, growth rates r1 = 1.1; r2 = −0.5; r3 = α + 0.2, and the interaction matrix:
0.5 A = −0.5
α
can produce chaotic behaviour for values of α ≥ 1.5.
0.5 0.1 −0.1 0.1
0.1 0.1
24 / 28
Lynxes and hares
Figure90 years of hare and lynx populations in the Hudson Bay, Canada
25 / 28
Outline
The Lotka-Volterra model An aside: solving ODEs
Behaviour of the Lotka-Volterra model Extensions to the Lotka-Volterra model Summary
26 / 28
Recap on dynamic behaviours
Dynamic systems can exhibit different types of long-term behaviour, including fixed points and limit cycles
Fixed points and limit cycles can be:
stable and attracting (often referred to as attractors) unstable and repelling
A single dynamic system can exhibit multiple stable and unstable fixed points
In a system with more than one stable fixed point, the long-term behaviour will depend on the initial conditions
The set of initial conditions that approach an attractor are known as a basin of attraction
27 / 28
Broader applicability of Lotka-Volterra model
In the 1960s, Richard Goodwin, a mathematician and economist, proposed a model analogous to the Lotka-Volterra model for the relationship between wages and employment in an economy:
wages = predators employment = prey
The system operates as follows:
at high levels of employment, employees can bargain for higher wages, which reduces profits
as profits shrink, fewer workers will be employed, which increases profits
once profit levels are higher, more workers will be employed and employment will increase, leading to cyclic behaviour.
Complex systems often exhibit underlying patterns of behaviour across multiple domains
28 / 28