-
Notifications
You must be signed in to change notification settings - Fork 1
/
ADN_2Variants.m
93 lines (71 loc) · 3.09 KB
/
ADN_2Variants.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Developed by Daniel Burbano Lombana
%%% for questions contact me at [email protected]
%
%
% Desciption: This code generates the two-dimensional plots of an ADN
% with two concurrent strains
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = ADN_2Variants(Parameters)
N = Parameters.N;
dt = Parameters.dt;
T = Parameters.T;
a = Parameters.a;
ni1 = Parameters.Ni1;
ni2 = Parameters.Ni2;
IniStrain = Parameters.IniStrain;
coin = rand(N,T);
%% Initial state of infected
Nini1 = round((ni1)/100*N);
X = zeros(N,1);
Xid1 = round(1 + (N-1)*rand(Nini1,1));
X(Xid1) = 2;
Nini2 = round((ni2)/100*N);
Xid2 = round(1 + (N-1)*rand(Nini2,1));
%%
for n=1:T
if n==IniStrain
X(Xid2) = 2.5;
end
%% counting states
Xsu = X(X==0); % Suceptible nodes
Ns(n,1) = length(Xsu); % number of suceptible nodes
Xexp1 = X(X==1); % Exposed to 1
Ne(n,1) = length(Xexp1); % number of Exposed to 1
Xexp2 = X(X==1.5); % Exposed to 2
Ne(n,2) = length(Xexp2); % number of Exposed to 2
Xinf1 = X(X==2); % Infected of 1
Ni(n,1) = length(Xinf1); % number of Infected of I1
Xinf2 = X(X==2.5); % Infected of 2
Ni(n,2) = length(Xinf2); % number of Infected of I2
Xrec1 = X(X==3); % Recovered from 1
Nrec(n,1) = length(Xrec1); % number of Recovered from 1
Xrec2 = X(X==3.5); % Recovered from 2
Nrec(n,2) = length(Xrec2); % number of Recovered from 2
Xexp12 = X(X==4); % Exposed to strain 2 given they had strain 1 already
NreExp(n,1) = length(Xexp12);
Xexp21 = X(X==4.5); % Exposed to strain 1 given they had strain 2 already
NreExp(n,2) = length(Xexp21);
Xinf12 = X(X==5); % Exposed to strain 2 given they had strain 1 already
NreInf(n,1) = length(Xinf12);
Xinf21 = X(X==5.5); % Exposed to strain 1 given they had strain 2 already
NreInf(n,2) = length(Xinf21);
XRecovered = X(X==6); % Exposed to strain 2 given they had strain 1 already
NreRec(n,1) = length(XRecovered);
Xn = X; % auxiliary variable
XX(:,n) = X;
Acti = coin(:,n) <= a.*dt;
Xn = Node_Dynamics(Acti,X,Xn,Parameters);
X = Xn;
end
out.Ns = Ns; % Number of suceptible nodes
out.Ne = Ne; % Number of exposed nodes
out.Ni = Ni; % Number of infected nodes
out.Nrec = Nrec; % Number of recovered
out.NreExp = NreExp; % number of nodes that are reexposed
out.NreInf = NreInf; % number of nodes that are reinfected
out.NreRec = NreRec; % number of nodes that are re-recovered
out.X = XX; % Curent State
end