aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTa180m2020-04-28 21:39:05 -0500
committerGitHub2020-04-28 21:39:05 -0500
commit2f85db6f4380f323e769d6111b6976d9346654ef (patch)
tree3ab3be1d227088b092894752da393c8a03b878e0
parent824bb98d05c8c2e97862dfcaa48ea5ca9426544e (diff)
Add files via upload
-rw-r--r--SARS in Hong Kong.xlsxbin0 -> 8246 bytes
-rw-r--r--sir_model.cpp48
2 files changed, 48 insertions, 0 deletions
diff --git a/SARS in Hong Kong.xlsx b/SARS in Hong Kong.xlsx
new file mode 100644
index 0000000..f53cee9
--- /dev/null
+++ b/SARS in Hong Kong.xlsx
Binary files differ
diff --git a/sir_model.cpp b/sir_model.cpp
new file mode 100644
index 0000000..f054c36
--- /dev/null
+++ b/sir_model.cpp
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <iomanip>
+using namespace std;
+
+// Iterations for Euler's method
+const int DAYS = 200, ITER = 10000;
+
+// Population size
+const int POP = 2000;
+
+// Model parameters
+// Beta = infection rate
+// Gamma = removal rate
+const double beta = 0.42, gamma = 0.25;
+
+// Compartments
+double S[DAYS + 1], I[DAYS + 1], R[DAYS + 1];
+
+int main() {
+ // Initial conditions
+ S[0] = 1 - 1.0 / POP, I[0] = 1.0 / POP, R[0] = 0;
+
+ // Run simulation
+ for (int i = 0; i < DAYS; ++i) {
+ double S_[ITER + 1], I_[ITER + 1], R_[ITER + 1];
+
+ S_[0] = S[i], I_[0] = I[i], R_[0] = R[i];
+
+ // Euler's method
+ for (int j = 0; j < ITER; ++j) {
+ S_[j+1] = S_[j] + (-beta * S_[j] * I_[j]) / ITER;
+ I_[j+1] = I_[j] + (beta * S_[j] * I_[j] - gamma * I_[j]) / ITER;
+ R_[j+1] = R_[j] + (gamma * I_[j]) / ITER;
+ }
+
+ S[i + 1] = S_[ITER], I[i + 1] = I_[ITER], R[i + 1] = R_[ITER];
+ }
+
+ // Print results
+ cout << "| DAY | SUSCEPTIBLE | INFECTIOUS | RECOVERED |\n";
+ cout << "-------------------------------------------------\n";
+ for (int i = 0; i < DAYS; ++i) {
+ cout << "| " << setw(3) << i << " | "; // Day
+ cout << setw(11) << (int)(POP * S[i] + .5) << " | "; // Suspectible
+ cout << setw(11) << (int)(POP * I[i] + .5) << " | "; // Infectious
+ cout << setw(11) << (int)(POP * R[i] + .5) << " |\n"; // Recovered
+ }
+} \ No newline at end of file