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
I complex systems
I building a mathematical model I assumptions
I states
I update rules
I population growth models I exponential
I logistic
I behaviour of dynamic systems I fixed points
I limit cycles I chaos
2 / 28
Objectives
I interpret mathematical equations describing a model
I understand how these equations can be solved numerically
and/or analytically to give the model’s dynamic behaviour
I describe the dynamic behaviour of the model, and how this depends on:
I model parameters I 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
I the rabbit population is sustainable (they have ample food)
I the rabbit population grows at a rate proportional to its size if
there are no red foxes
I the red foxes eat only rabbits
I the red fox population declines at a rate proportional to its size
if there are no rabbits to eat
I the environment is static and has no e ect on the rates of
population growth and decay
7 / 28
Model formulation Prey (rabbits):
dR =–R≠—RF dt
Predators (red foxes): 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 di erential 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 di erence 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 1tn + t , yn + t f (tn, yn)2 tn+1 = tn + t 2 2
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:
I R = 0, F = 0
R(– ≠ —F) = 0 F(”R ≠ “) = 0
IR=“,F=– ”—
Interpretation:
I equilibrium 1: both populations are extinct
I 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:
I 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
I 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
I There is no notion of carrying capacity for the prey species I The logistic equation captured intraspecific competition
I The base Lotka-Volterra model captues interspecific
competition
I 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 =r1x111≠1×1≠–12×222 dt K1
dx2 =r2x211≠1×2≠–21×122 dt K2
where –ij is the e ect that species j has on species i. This can then be generalised to an n-species model:
dxi =rixi11≠qNj=1–ijxj2 dt 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:
dxi =xi1ri +ÿN Aij(1≠xj)2 dt j=1
This version pulls the carrying capacities Ki and interaction terms –ij inside the interaction matrix A
For three species, growth rates r1 = 1.1; r2 = ≠0.5; r3 = – + 0.2, and the interaction matrix:
Qc0.5 0.5 0.1Rd A = a≠0.5 ≠0.1 0.1b
– 0.1 0.1
can produce chaotic behaviour for values of – Ø 1.5.
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
I Dynamic systems can exhibit di erent types of long-term behaviour, including fixed points and limit cycles
I Fixed points and limit cycles can be:
I stable and attracting (often referred to as attractors) I unstable and repelling
I A single dynamic system can exhibit multiple stable and unstable fixed points
I In a system with more than one stable fixed point, the long-term behaviour will depend on the initial conditions
I 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:
I wages = predators I employment = prey
The system operates as follows:
I at high levels of employment, employees can bargain for higher wages, which reduces profits
I as profits shrink, fewer workers will be employed, which increases profits
I 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