forked from PPSantos/network-epidemics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulation.cpp
170 lines (127 loc) · 3.63 KB
/
simulation.cpp
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include "multi_layer_net.cpp"
int main(int argc, char* argv[]) {
/**
* Simulation flags & parameters.
*/
int SEED = 57;
bool VERBOSE = false;
// Number of simulations per network.
int numSim = 250;
// Total number of steps for each simulation.
int simulationSteps = 50;
// Initially infected population size.
int gamma = 10;
// Initially aware population size
// (not counting with infected nodes).
int phi = 5;
// Infection rate: [0,1].
double beta = 0.4;
// Recovery rate: [0,1].
double delta = 0.0;
// Awareness spread rate: [0,1].
double mu = 0.0;
// Forgetness rate: [0,1].
double omega = 0.2;
// Decay in infection rate for aware nodes: [0,1]
// For (S,A) node: prob of getting infected = beta*(1-lambda).
// e.g. lambda = 0.0 -> no effect (no decay).
// e.g. lambda = 1.0 -> (S,A) don't get infected.
double lambda = 0.0;
// Whether to write nodes' states to file.
bool writeStatesToFile = false;
// Writing to files time-step.
int writeToFileStep = 1;
srand(SEED);
//srand(time(NULL));
// Namefiles of the networks to load.
vector<string> networks;
networks.push_back("graph_0");
networks.push_back("graph_1");
networks.push_back("graph_2");
networks.push_back("graph_3");
networks.push_back("graph_4");
networks.push_back("graph_5");
networks.push_back("graph_6");
networks.push_back("graph_7");
networks.push_back("graph_8");
networks.push_back("graph_9");
// Parameter values.
vector<double> param_values;
param_values.push_back(0.0);
param_values.push_back(0.1);
param_values.push_back(0.2);
param_values.push_back(0.3);
param_values.push_back(0.4);
param_values.push_back(0.5);
param_values.push_back(0.6);
param_values.push_back(0.7);
param_values.push_back(0.8);
param_values.push_back(0.9);
param_values.push_back(1.0);
string net_name;
int counter;
for (int i=0; i < param_values.size(); i++) {
cout << "Mu = " << param_values[i] << endl;
for (int net=0; net < networks.size(); net++) {
cout << "Simulating network: " << networks[net] << endl;
// Create network (second argument is the network name).
net_name = to_string(param_values[i]).substr(0,3) + "_" + networks[net];
MultiLayerNetwork MNet(networks[net], net_name);
MNet.simulateSIS(numSim,
simulationSteps,
gamma,
phi,
beta,
delta,
param_values[i],
omega,
lambda,
VERBOSE,
writeStatesToFile,
writeToFileStep);
}
}
/*string net_name;
int counter;
for (int i=0; i < param_values.size(); i++) {
cout << "Mu = " << param_values[i] << endl;
for (int net_1=0; net_1 < networks.size(); net_1++) {
for (int net_2=0; net_2 < networks.size(); net_2++) {
if (net_1 == net_2) {
continue;
}
cout << "Simulating network: " << networks[net_1] << " with " << networks[net_2] << endl;
// Create network (second argument is the network name).
net_name = to_string(param_values[i]).substr(0,3) + "_" + networks[net_1] + "_" + networks[net_2];
MultiLayerNetwork MNet(networks[net_1], networks[net_2], net_name);
MNet.simulateSIS(numSim,
simulationSteps,
gamma,
phi,
beta,
delta,
mu,
param_values[i],
lambda,
VERBOSE,
writeStatesToFile,
writeToFileStep);
}
}
}*/
// Create network (second argument is the network name).
/*MultiLayerNetwork MNet(networks[0], "Net");
MNet.simulateSIS(numSim,
simulationSteps,
gamma,
phi,
beta,
delta,
mu,
omega,
lambda,
VERBOSE,
writeStatesToFile,
writeToFileStep);*/
return 0;
}