School of Computing and Information Systems SWEN90004 Modelling Complex Software Systems Complex Systems Workshop 2 solutions
The exercises
1. Logistic map
(a) The population dies out (x ¡ú 0). Large values of x0 will collapse rapidly before fading
away.
(b) The system converges to a stable fixed point attractor (a constant population size), the exact location of which depends on r. Values of x0 below the value at this fixed point will increase; values of x0 above this value will collapse before increasing back to the fixed point.
(c) The system converges to a stable limit cycle attractor (also known as periodic orbit), with period 2; ie, the system oscillates between two values. Again, the value of x0 will determine the initial transient behaviour of the system.
A world governed with such population dynamics would display periodic boom/bust cycles in population size.
(d) The value of x¡Þ would oscillate between 4 values (a limit cycle with period 4).
For large values of r (ie, resulting in chaotic behaviour) the trajectory will depend on x0; very similar values of x0 will result in very different long term behaviours.
When r > 4, the value of xn+1 can be > 1 for some values of xn; ie, outside the range [0, 1]. Typically therefore, only values of r ¡Ü 4 are studied.
(e) You should be able to locate ¡°self-similar¡± regions of the bifurcation diagram (ie, small subsets that look like the whole diagram; eg, try zooming in to r = [3.44,3.58] and x = [0.35, 0.9].
2. Lotka-Volterra model
(a) The first plot (prey/predator vs time) shows how the size of the two populations vary over time. The second plot (predator vs prey) shows how the size of the two populations vary with respect to each other.
(b) (no solution) You should experiment with varying parameters to observe how they in- fluence system behaviour.
(c) You should experiment with varying parameters to observe how they influence system behaviour. One effect of adding intra-species competition is that it is possible to observe stable coexistence of two species at a fixed level. That is, trajectories that are per- turbed from this attractor will return to it. In the absence of intra-specific competition, perturbations from this fixed point would lead to a new cyclic attractor.
(d) See lecture Cx.03 for one approach to modelling an N-species system. A MATLAB function to implement this model is:
function dx = lotka_volterra_function_3(t, x)
% rates of change of populations
dx = [0; 0; 0];
% matrix of growth rates
r = [1.1, -0.5, 1.75];
% matrix of interaction rates
A = [0.5, 0.5, 0.1;
-0.5, -0.1, 0.1;
1.55, 0.1, 0.1];
% equations for updating each population
dx(1) = x(1) * (r(1) + A(1,1)*(1-x(1)) + A(1,2)*(1-x(2)) + A(1,3)*(1-x(3)));
dx(2) = x(2) * (r(2) + A(2,1)*(1-x(1)) + A(2,2)*(1-x(2)) + A(2,3)*(1-x(3)));
dx(3) = x(3) * (r(3) + A(3,1)*(1-x(1)) + A(3,2)*(1-x(2)) + A(3,3)*(1-x(3)));
Note that you will also need to modify the commands that solve the function, namely:
% initial population levels
x1 = 1.1; x2 = 1.1; x3 = 1;
options = odeset(¡¯RelTol¡¯, 1e-4, ¡¯NonNegative¡¯, [1 2 3]);
[t,x] = ode45(@lotka_volterra_function_3, [0 200], [x1 x2 x3], options);
Note that the system above (corresponding to ¦Á = 1.55) will produce chaotic dynamics. Try increasing the number of iterations (from 200 in the line above).
3. SIR model
(a) The expected maximum number of infected people during the first 4 months of the outbreak is approximately 2.96 million people. This will occur after approximately 1 month.
(b) There will be approximately 1.9 million susceptible people and 1.9 million infected people after approximately 0.28 months. NB: you can use the ¡°data cursor¡± in MATLAB to interact with a plot to estimate values.
(c) 1 month after the mutation (ie, at t = 1.5), there will be approximately 2.15 million infected people. This is compared to approximately 2.5 million people without the mutation. The reduced transmissibility of the mutated virus (ie, lower ¦Â) means that susceptible people will not become infected as quickly.
(d) (no solution) You should experiment with varying parameters to observe how they in- fluence system behaviour.
(e) Demography can be added by modifying the SIR function as follows:
function dx = sir_function_demog(t, x)
dx = [0; 0; 0];
gamma = 1/7;
beta = 520/365;
mu = 1/(70*365);
dx(1) = mu -beta * x(1) * x(2) -mu * x(1);
dx(2) = beta * x(1) * x(2) -gamma * x(2) -mu * x(2);
dx(3) = gamma * x(2) -mu * x(3);
The birth/death rate (¦Ì) influences the rate at which the susceptible population is replenished by the birth of new people. The faster this happens, the sooner their will be enough susceptible people to support a further outbreak. Therefore, increasing the birth rate will increase the frequency of outbreaks. It will also increase the rate at which the system reaches a equilibrium.
Note that you may need to limit the scale of the y-axis to be able to observe the oscil- lations clearly (by inserting axis([0 Inf 0 0.2]) after the plot function.
(f) Waning immunity can be added by modifying the SIR function as follows:
function dx = sirs_function(t, x)
dx = [0; 0; 0];
gamma = 1/7;
beta = 520/365;
omega = 1/(2*365);
dx(1) = omega * x(3) -beta * x(1) * x(2);
dx(2) = beta * x(1) * x(2) -gamma * x(2);
dx(3) = gamma * x(2) -omega * x(3);
Try using the following initial conditions: N=100000; I=1/N; S=1-I; R=0. Change the number of time steps to 1000 In this model, people who have been infected lose their immunity at rate ¦Ø (here, 2 years). As with demography, waning immunity allows the susceptible pool to be replenished, supporting repeated outbreaks. Again, the system eventually converges to an equilibrium.
(g) Vaccination can be added to the demographic model as follows:
function dx = sir_function_demog_vacc(t, x)
dx = [0; 0; 0];
gamma = 1/7;
beta = 520/365;
mu = 1/(70*365);
p = 0.7
dx(1) = mu * p -beta * x(1) * x(2) -mu * x(1);
dx(2) = beta * x(1) * x(2) -gamma * x(2) -mu * x(2);
dx(3) = mu * (1-p) + gamma * x(2) -mu * x(3);
Draw the compartments and flows for this model to satisfy yourself why these equations satisfy the conditions of the equation. Recalling the R0 = ¦Â/¦Ã, explore some of the different diseases and vaccination rates shown in the slides to lecture Cx.04.