0 The Last Plague Investigating the Lethality of Pandemics Using Deterministic and Stochastic Epidemic Models Co-Authors: Li Qing Wang & Uma Wu Faculty Advisor: James D. Berger SCI001 T2 Project March 9, 2016 1 Abstract This project investigates the effects of seven parameters on the spread of viral epidemics: infectivity, infectious period, mobility, incubation period, mortality, immunity and recovery period. Two algorithms were created to simulate the progression – one stochastic, and one deterministic. While the deterministic model simulates the spread through regulating the flux between compartments, the stochastic model simulates the spread by applying the parameters as a set of probabilities. The models were calibrated with current data on SARS and Ebola from WHO. Using optimization methods, we found the characteristics of viral diseases that would lead to the most lethal disease, marked by death rates of 92.26% of the world population in the deterministic model and 98.76% in the stochastic model. By investigating the effect of each parameter on the disease, we found that the key factors in regulating the spread of an epidemic are percentage immunity, mobility and recovery rate. Introduction Scientific question: what parameter values define the most deadly disease possible, and how do they each contribute to the epidemic? An epidemic is defined as a sudden spread of a disease that affects an unexpectedly high number of people in a certain population [1]. The determinant factors for the lethality examined in this study include infectivity, infectious period, mobility, incubation period, mortality, immunity and recovery period (refer to Appendix Pages for definitions). Although we are working with simulated diseases, the combination of parameters that define a “super viral disease” is important because any of these combinations may be present in a future infection. Therefore, by knowing the most dangerous aspects of an infectious disease, we can better focus our resources to counteract it. This project has four phases: 0, I, II and III. The model is developed in Phase 0, calibrated in Phase I and used to answer our scientific question in Phases II and III. The models use the susceptible-infected-removed model with a few more compartments to provide insight into the effect of each on the spread of diseases. The deterministic model is a closed model. The flux in and out of the compartments is represented as a series of differential equations. In order to optimize this program for certain desired outputs, the L-BFGS-B method was implemented [14]. The stochastic model is also closed, but it relies on a matrix system instead. To optimize this program for desired outputs, the Bayesian Optimization package Spearmint was implemented. Different sets of parameters can contribute to the same death rate; therefore, further analysis was done to find the trend in those combinations. 2 Procedure Phase 0 Principle Objective: To create the deterministic and stochastic models Deterministic Assumption 1: The parameters remain constant throughout the simulation. Justification: This means the effects of borders, quarantines, cures, and other currently implementable disease-control tactics are unavailable. The implementation of these features would impede the observations on the spread of the disease amidst all of the other elements affecting it. FIGURE 1: Flowchart of Deterministic Model. [For the complete code, refer to Appendix Pages 10-16] Stochastic -See also Assumptions 1 for the Deterministic Model- Assumption 1: The disease can only spread between adjacent individuals. Justification: While it is possible to simulate the disease spreading as a function of the total number of infected/incubating individuals regardless of their position in the simulated matrix, it defeats the point of having a stochastic process. Assumption 2: The parameter values produced by optimizing the program are scalable and will produce around the same proportions between individuals of different states regardless of population size. Justification: The spread of the disease overall have the same progression as long as the population is >9, since the disease needs to be spreading between unique individuals. This has been verified. 3 FIGURE 2: Flowchart of one individual’s possible status within Stochastic Model [For the complete code, refer to Appendix Pages 21-32] Phase I Principle Objective: Fitting and calibrating the program to real disease data Cumulative data on the number of cases, recoveries and deaths for SARS and cumulative data on the number cases and deaths for Ebola were collected from the World Health Organization (WHO) website [7, 11]. Target points were chosen for the simulations to fit. The best trend line for each category of data was found by minimizing the coefficient of determination (R2) to a value below a biological alpha of 5% with respect to the population using minimize function L-BFGS-B. For each disease, the category of data with the highest number of data points on the trend line was selected, and target points were chosen from these points. The death data and infected data for SARS and Ebola were used, respectively. The selected data points were representative of the trend of the disease, and minimized the noise in the raw data. [For the raw data used to fit the data points, refer to Appendix Pages 1-7.] Phase II Principal Objective: Finding the Parameters that result in the most deadly pandemics In both models, the functions representing the simulation were reconfigured to return the negative maximum percentage of the population that is dead over the time frame of a year. Deterministic - L-BFGS-B The percentage mortality is maximized using the L-BFGS-B gradient evaluation method. The L-BFGS-B evaluates the derivative of the gradient from a given starting point and follows the slope to find a local minimum. To counteract the possibility of multiple minima within our function, multiple parameter sets were generated (~10000) to ideally produce as many minima 4 as possible. Among these, the ones with the highest death rates were selected for analysis. Stochastic - Spearmint The Spearmint package uses Bayesian Optimization in a global black-box operation in order to find the global minimum of a function. This experiment required no more than using Spearmint to find the global minimum of the Stochastic outputs while minimizing the noise that comes from the random factors that govern its processes. Assumption: everyone was susceptible. Justification: if a significant fraction of a population is pre-immune, the disease may not become an epidemic at all. Phase III Principal Objective: investigating the effect of each parameter on percentage death independently. While keeping other parameters at the values that lead to the most deadly disease, each parameter in the deterministic program was varied independently from 0.1~1.0, in increments of 10%. The output percentage death, defined by the percentage of the world population dying from the disease, was recorded. Results Each of the following sets of parameters fit the respective disease data collected from WHO with the sum of residuals squared indicated. PHASE I RESULTS Deterministic Fitting Results (PHASE I) (FIGURE 3) EBOLA SARS SARS Infectivity 62.9133% 12.2454% 63.4744% Infection Rate 30.6023% 98.3275% 37.0586% Mobility 99% 98.211% 76.4858% Incubation Period 1.395 101.01 150.443 Incubation Rate 71.68% 99% 0.6647% Mortality 46.2063% 42.6484% 29.8424% Percent Immunity 0.1% 0.1% 0.9516% Recovery Rate 10.6243% 43.7013% 32.6739% Population 6990000000 1795595082 1407579615 Residual Sum 2.546% of Pop 0.0083558% of Pop. 0.0081459% of Pop Stochastic Fitting Results (PHASE I) (FIGURE 4) EBOLA SARS Infectivity 99% 43.14% Infectious Period 25 11 Mobility 27.6382% 40.22% Incubation Period 23 12 5 Mortality 36.72% 13.79% Percentage Immunity 50.266% 85.85% Recovery Period 28 11 Population Any Any Standard Deviation 0.022747 0.022434 FIGURE 5.2: Plots of epidemic progression as generated by Deterministic Model & SARS Data Simulated SARS (Parameter Set 2) Simulated SARS (Parameter Set 1) FIGURE 5.1: Plots of epidemic progression as generated by Deterministic Model & SARS Data 6 Simulated Ebola FIGURE 6: Plot of epidemic progression as generated by Deterministic Model & Ebola Data FIGURE 7: Plot of epidemic progression as generated by Stochastic Model & SARS Data 7 Model Disease Estimated Basic Reproductive Number R0 from Literature [3, 15] Deterministic SARS 2.25 0.24-2.47, 2.87 2.4-3.6 (Re) Deterministic SARS 1.13 Deterministic Ebola 2.88 1.50-2.67 Stochastic Ebola 1.12 Stochastic SARS 1.0 0.24-2.47, 3.87 2.4-3.6 (Re) FIGURE 9: Estimation of Basic Reproduction Number FIGURE 8: Plot of epidemic progression as generated by Stochastic Model & EBOLA Data 8 PHASE II RESULTS Deterministic Stochastic Infectivity 19.82% Infectivity 99% Infectious Period 1.124 Infectious Period 14 Infection Rate 90.53% Infection Rate 7.14% Mobility 99.00% Mobility 65.61% Incubation Period 7.731 Incubation Period 4 Incubation Rate 18.65% Incubation Rate 25% Mortality 99.00% Mortality 90.45% Percentage Immunity 1.0% Percentage Immunity 0.00% Recovery Rate 1.0% Recovery Rate 4% Recovery Period 100 Recovery Period 25 Percentage Dead 92.26% Percentage Dead 98.76% FIGURE 10: Parameters that constitute the most lethal disease in each model Average Standard Deviation Maximum Minimum Infectivity 19.82362286% 9.03404125% 37.5849% 1.5306% Infectious Period 1.123803493 0.1633870674 1.6784099416 1.010101 Infectious Rate 90.53117143% 11.04190317% 99% 59.5802% Mobility 99% 0% 99% 0.99 Incubation Period 7.7306150843 7.0662311461 38.6085479325 2.6623430216 Incubation Rate 18.64900571% 8.47061018% 37.5609% 2.5901% Mortality 99% 0% 99% 99% Percentage Immunity 1% 0% 1% 1% Recovery Rate 1% 0% 1% 1% Percentage Dead 92.25818% 8.622e-4% 92.2588% 92.2555% FIGURE 11: PHASE II Deterministic Parameter Features 9 Deterministic Model The data shows parameter values that contribute to the most deadly disease predicted by the deterministic model. (Figure 10) The disease is infectious slightly over 1 day. A diseased individual may infect 99% of the healthy people he meets. Only 19.82% of infecteds will display symptoms after infection. Other individuals do not show any symptom until 7.7 days after infection. 99% of infected individuals will die from the disease, and only 1% will gain immunity. Infected individuals, if capable of recovering from the disease, take 100 days to do so. FIGURE 12: Trend of optimized pandemic (Deterministic) 10 Stochastic Model The data shows parameter values that contribute to the most deadly disease predicted by the stochastic model. (Figure 10) The disease incubates for 4 days. There is a 99% chance that an infected population will display symptoms of the disease, and the disease is infectious over a span of two weeks. A healthy individual has a 65.61% chance of contracting the disease from an infectious individual in close proximity. Infected individuals have a 90.45% chance of dying from the disease. No one can develop immunity against this disease, but individuals can recover from the disease over a period of 25 days. FIGURE 13: Trend of optimized pandemic (Stochastic) 11 FIGURE 14.1: Incubation Period compared to Infectivity FIGURE 14.2: Percentage Death compared to Incubation Period FIGURE 14.3: Incubation Period compared to Infection Rate 12 PHASE III RESULTS Infectivity Infectious Period Mobility Incubation Period Mortality Percentage Immunity Recovery Rate ≤30% 1-2 days ≥20% 5-10 days any ≤70% ≤70% FIGURE 15: Table of criteria for a significant drop in population as a result of an epidemic Analysis Analysis of PHASE I Data Estimation of Basic Reproduction Number The basic reproduction number characterizes the ability of a disease to spread, and is calculated by dividing the infection rate by recovery rate. On the other hand, the effect reproduction number (Re) represents the observed number of secondary infections from a primary infection. Since the two are sometimes used interchangeably in literature, both values were obtained from literature as references. Two sets of parameters were selected for SARS because both provided R0 that were within the literature range. No statistical comparison was feasible between our results and the literature values due to the limitations of the model. However, it is clear that the Ro estimated by both models (Figure 9) generally adhered to what was reported from the literature. The deterministic model generally predicts a higher R0 than the stochastic model. Incubation Periods The stochastic model predicted a more reasonable incubation period for each disease compared to the deterministic one. The actual incubation periods for SARS and Ebola are up to two weeks [16] and up to 21 days [17], respectively. Both of these adhere significantly more to the stochastic results. Deterministic vs. Stochastic Comparing the shapes of the graphs of simulated SARS and Ebola produced by both models to the graphs of raw disease data, the stochastic model is clearly a better model than the deterministic one. The stochastic model is a better fit for the randomness in the nature of disease spread, unlike the deterministic. Combining this with analyses of estimated R0 and incubation period, the stochastic model seemed to have produced a lower residual for each disease (See Appendix Graphs). 13 Analysis of PHASE II Data A Holistic Analysis of PHASE II Deterministic Data This is done to deterministic only due to the various sets of optimized parameters it produced, all of which produced the desired maximal death rate. Of the 10000 parameter sets, 34 representative ones were selected for analysis. The standard deviation for each parameter was computed using 34 sets of parameters that yield a percentage death of 92.26%. Since the standard deviation of mobility, mortality, percentage immunity and recovery are zero, these parameters must be at a specific value to result in the most lethal epidemic. Therefore, any changes made to those parameters alone will result in a death rate deviating from 92.26%. The disease has high mobility (99%), high mortality (99%), low immunity (1%) and low recovery rate (1%). Infectivity can range from 1.53% to 37.58%, infection rate can range from 59.58% to 99% and incubation period can range from 2.66 ~ 38.61 days. A clear correlation between incubation period and infectivity can be observed below (Figure 14.1). When infectivity is below 20%, incubation period is less than a week. As infectivity goes beyond 20%, incubation period increases drastically and can be as high as 38 days. Therefore, as shown in Figures 14.1-3, a combination of the following qualities is most likely to happen and will lead to a 92.26% death rate: 1.53% ~26.21% infectivity, a short infectious period of 1~1.33 days, 99% mobility, within two weeks of incubation, 99% mortality, 1% immunity and1% recovery. 14 Discussion Accuracy & Precision The accuracy of either models can be defined by how replicable the results are. The deterministic model is completely accurate since the same parameters will always yield the same output. Therefore, the accuracy of deterministic model is not representative of its uncertainty, since no model can have 0 uncertainty. However, for the stochastic model, standard deviations of outputs were determined. The standard deviation of the phase II result, (0.005512%), defines the uncertainty of the model since it is purely based on the outputs of the program and does not depend on any data. This small standard deviation indicates an accurate model. The precision of either models can be defined as how well it fits to the real data in Phase I. This was obtained by fitting the simulation to the real data by minimizing the residuals. The stochastic model’s precision cannot be determined through its precision due to the restraint in runtime as a function of population (it can only fit the trend), and is therefore not representative of its uncertainty. The deterministic model does yield a wide array of residuals, however. In our fitting of the data, the lowest residual was 2.546% of Population with Ebola, while the two SARS fittings yielded 0.0083558% of population and 0.0081459% of population respectively. Since the percentages are less than 5%, the model is likely precise. Limitations Limitations of Collected Data Inconsistency in WHO data The cumulative number of SARS cases fluctuated for the last few days for which data were collected. SARS is a diagnosis of exclusion; as previous cases were further investigated, some patients were re-examined and re-diagnosed [6]. Since the fluctuation only involved a few individuals, we disregarded the occasional decrease, and recorded further data by adding the number of newly dead people to the cumulative number. Limitation of Obtainable Categories of Data While there are 7 parameters, only the aforementioned 3 had available data. Limitations of Model 1. Quarantine & Borders In April 2003, the Chinese government started implementing quarantine and restricting social interactions by methods such as closing theatres and implementing border control [4]. Quarantine would limit the mobility of the disease; however, this is not accounted for in the model. (See Assumptions) 2. Parameters change with time The parameters in both models are constant over time, while in reality they do change with 15 time. For example, the mortality of both disease increased with time. Run Time Constraints Deterministic The deterministic model does not take long to complete one function evaluation (~0.1s for Population = 7000000000) due to its nature as a linear-time computation, but its optimization took much longer due to the methodology of the L-BFGS-B method of evaluating the function multiple times until it reached a local minimum. Therefore, a global optimization would have been better for this instance. Stochastic The stochastic model takes a lot longer than the deterministic (~1s for Population = 400) to complete one function evaluation. With the Spearmint Optimization package, we were able to bypass that issue. Not only does Spearmint find the global minimum, it only takes around 5 hours to yield applicable and accurate results. However, it is still subject to the limitations of populations, since the run time increases linearly with the addition of an individual. Inferences Deterministic Phase II Summary: The most deadly disease according to the deterministic model is a disease that doesn’t show symptoms immediately (19.82% infectivity), transmits quickly from person to person (99% mobility), almost certainly and immediately kills its host upon infection (99% mortality), and is almost impossible to develop immunity from (only 1% of the population can become immune). . This disease can kill 92.26 % of the world population in one year. This set of parameters produces a greater incubating population than infectious population. There are many currently known viruses that can remain dormant in individuals (e.g Rabies, STDs) for a relatively long time before manifesting symptoms. The disease may cover its lethality by displaying nonlethal typical flu symptoms as fever, cough and diarrhea when individuals are first infected, thus creating a high incubating population. This feature of the simulated disease greatly contributes to the risk of unknowingly getting infected since the number of susceptible people becoming incubating is dependent on both the number of carriers (infecteds) and susceptibles. Stochastic Phase II Summary: The most deadly disease according to the stochastic model is one that shows symptoms almost immediately (99% infectivity), transmits at a moderate rate (65.61%) from person to person, is infectious over two weeks, and is develop immunity. This disease can kill 98.76% of the world population in one year. Instead of a high mobility, the disease becomes highly infective with a small incubation period, which means the patients would immediately show symptoms upon infection. A zero percent immunity means that even if a patient did manage to survive, they would become susceptible again with another chance of being infected and eventually succumbing to the 16 disease. This disease resembles past epidemics such as AIDS, since it mutates very quickly and suppresses the immune system. The disease would exhibit symptoms that lead to more infection and eventually death, such as skin lesions (e.g smallpox), discharging fluids (e.g diarrhea), and even irregular behavior (e.g rabies patients may bite other individuals). 17 Figure 16.1 The percentage dead seems to decrease somewhat linearly with increased recovery rate when the recovery rate is lower than 70%. A recovery rate of 70% seems to be a threshold beyond which the disease is no longer an epidemic. Figure 16.2 A disease with low mortality (10%) can have a high percentage death (~70%). The percentage death increase by ~10% in response to a 10 fold increase in mortality. This may indicate that the mortality of a disease is not the major determinant of its percentage death. Deterministic Phase III results and inferences Since the purpose of Phase III is purely making inferences, its results will be shown here along with the inferences. 18 Figure 16.3 A disease for which an infected can only spread the infection to less than 20% of the people he contacts will not cause an epidemic. The percentage death increases drastically with the increase in mobility. This suggests that mobility is a major determinant in the spread of a disease. Figure 16.4 As incubation rate increases, or as the length of incubation period decreases, the percentage death decreases. 19 Figure 16.5 The larger the fraction of the infected population that shows symptoms, the less deadly the disease becomes. This may suggest that a disease must not let the patients display symptoms immediately in order to let it spread unknowingly, and eventually kill a large percentage of the world population. Figure 16.6 The disease is the most deadly when zero percent of the population is immune to it. The death rate decreases with increased immunity. There seems to be a threshold at 70% immunity, beyond which the disease is essentially no longer an epidemic. 20 Key Inferences and Observations In agreement with what was observed in phase II, any deviation from the set of the most deadly parameters led to a decrease in percentage death. However, this phase allowed a closer investigation of the magnitude of such effect. For example, the mortality barely alters the percentage death while independent changes in mobility, recovery rate, and percentage immunity led to much greater changes. The effect of infection rate, incubation rate, and infectivity is somewhere in between. Some threshold values were observed in percentage immunity (≤70%), mobility (≥20%) and recovery rate (≤70%). These three parameters are the major contributors to the percentage death of an epidemic; however, they must reach a certain threshold level for a disease to become an epidemic. These three parameters need to be regulated in order to prevent or control the spread of epidemic most efficiently. As a summary of phase III, a chart of criteria for the most lethal epidemic predicted by the deterministic model was produced (figure 15). If an outbreak is suspected and several of its parameters fall into these values, it is likely to develop into a fairly lethal epidemic. Such disease can then be most effectively regulated by controlling percentage immunity, mobility and recovery rate. Figure 16.7 A low infection rate such as 10% can lead to a death percentage of ~87%. The increase in infection rate from 10% to 70% causes the most increase in percentage death. Beyond that, the increase in infection rate has minute effect on percentage death. 21 Conclusion Both the deterministic and stochastic models developed are able to fit realistic disease data and predict combinations of parameters that would lead to the most deadly epidemic. Both models also predict a high death rate when the chances of developing immunity are low, indicating the threat of an immune-suppressive disease is especially high. Ranges of values for each parameter that constitute the most lethal epidemic outlined can be used to assess the lethality of a real disease. With further development, future potentials of this pair of models include investigation of other viral diseases, predicting the outcome of a disease in real time, and modelling the effect of prevention and control methods on the epidemic. References [1]"Lesson 1: Introduction to Epidemiology." Centers for Disease Control and Prevention. Centers for Disease Control and Prevention, 2012. Web. 11 Mar. 2016. [2]"Learning Basic Epidemic Models with Python." Learning Basic Epidemic Models with Python. Web. 11 Mar. 2016. [3]"Estimating the Reproduction Number of Ebola Virus (EBOV) During the 2014 Outbreak in West Africa – PLOS Currents Outbreaks." PLOS Currents Outbreaks. Web. 11 Mar. 2016. [4]"SARS Reference | SARS Timeline." SARS Reference | SARS Timeline. Web. 11 Mar. 2016. [5]"The SIR Model for Spread of Disease - The Differential Equation Model." The SIR Model for Spread of Disease. Web. 11 Mar. 2016. [6] "Cumulative Number of Reported Probable Cases of SARS." WHO. Web. 13 Mar. 2016. <http://www.who.int/csr/sars/country/2003_07_09/en/>. [7]"Cumulative Number of Reported Probable Cases of Severe Acute Respiratory Syndrome (SARS)." WHO. Web. 11 Mar. 2016. [8]"WHO IRIS: Consensus Document on the Epidemiology of Severe Acute Respiratory Syndrome (SARS)." WHO IRIS: Consensus Document on the Epidemiology of Severe Acute Respiratory Syndrome (SARS). Web. 11 Mar. 2016. [9]Wallinga, J. "Different Epidemic Curves for Severe Acute Respiratory Syndrome Reveal Similar Impacts of Control Measures." American Journal of Epidemiology 160.6 (2004): 509-16. Web. [10]"Epidemic." Wikipedia. Wikimedia Foundation. Web. 11 Mar. 2016. [11]"Ebola Virus Disease." World Health Organization. Web. 11 Mar. 2016. [12]Zhang, Zhibin. "The Outbreak Pattern of SARS Cases in China as Revealed by a Mathematical Model." Ecological Modelling 204.3-4 (2007): 420-26. Web. [13]Zhou, Yicang, Zhien Ma, and F. Brauer. "A Discrete Epidemic Model for SARS Transmission and Control in China." Mathematical and Computer Modelling 40.13 (2004): 1491-506. Web. [14]"Scipy.optimize.minimize¶." Scipy.optimize.minimize — SciPy V0.17.0 Reference Guide. Web. 11 Mar. 2016. [15] Althaus, Christian L. "Estimating the Reproduction Number of Ebola Virus (EBOV) 22 During the 2014 Outbreak in West Africa." PLoS Curr PLoS Currents (2014). Web. 13 Mar. 2016. [16] "Frequently Asked Questions About SARS." Centers for Disease Control and Prevention. Centers for Disease Control and Prevention, 2012. Web. 21 Mar. 2016. <http://www.cdc.gov/sars/about/faq.html>. [17] "Ebola Virus Disease." World Health Organization. Web. 21 Mar. 2016. <http://www.who.int/mediacentre/factsheets/fs103/en/>. Special Thanks James D. Berger for mentoring this project Michael Gelbart for implementing Spearmint, suggesting fitting methods, and debugging Pam Kalas for reviewing and advising this project Omer Angel for providing insight on the data analysis Costanza Piccolo for refining our parameters Eric Cytrynbaum for refining the mechanics of the model Appendix Table of Contents SARS Raw Data: Cumulative Number of Deaths vs. Time (Fig1) ---------------------------------------------1 SARS Raw Data: Cumulative Number of Recovered Individuals vs. Time (Fig2) --------------------------1 SARS Extrapolated Data: Number of Alive & Infected Individuals vs. Time (Fig3) -----------------------2 SARS Extrapolated Data: Cumulative Number of Deaths vs. Time Fitted (Fig4) --------------------------2 SARS Extrapolated Data: Currently Infectious Individuals vs. Time Fitted (Fig5) -------------------------3 EBOLA Raw Data: Cumulative Number of Infectious Individuals vs. Time (Fig6) -------------------------3 EBOLA Raw Data: Cumulative Number of Deaths vs. Time (Fig7) -------------------------------------------4 EBOLA Raw Data: Cumulative Number of Deaths vs. Time Fitted (Fig7) -----------------------------------4 EBOLA Extrapolated Data: Cumulative Number of Infectious vs. Time Fitted (Fig8) --------------------5 EBOLA Parameter Sets--------------------------------------------------------------------------------------------------6 SARS Parameter Sets----------------------------------------------------------------------------------------------------7 PHASE II Parameter Sets (Deterministic) --------------------------------------------------------------------------8 DeterministicEPIMOD PHASE I Model-----------------------------------------------------------------------------10 DeterministicEPIMOD PHASE II Model----------------------------------------------------------------------------17 StochasticEPIMOD PHASE I Model---------------------------------------------------------------------------------21 StochasticEPIMOD PHASE II Model--------------------------------------------------------------------------------33 PHASE III Data Table---------------------------------------------------------------------------------------------------39 Definitions of Parameters--------------------------------------------------------------------------------------------40 Phase I Target Points---------------------------------------------------------------------------------------------------41 Appendix Fig1 Appendix Fig2 SARS Raw Data SARS Raw Data 1 Appendix Fig3 Appendix Fig4 SARS Extrapolated Data 2 Appendix Fig5 Appendix Fig6 3 Appendix Fig7 Appendix Fig7 Cumulative Deaths vs. Time 4 Appendix Fig8 Cumulative Infectious vs. Time 5 Ebola Parameter Sets Infectivity Infection Rate Mobility Incubation Rate Mortality Percentage Immunity Recovery Rate Population ResidualSum Average 0.99 0.001 0.9887100417 0.989113625 0.8238342917 0.0010002083 0.0010002083 3470330353.29167 0.000287125 Standard Deviation 0 0 0.0044474239 0.0030006973 0.0039407441 1.02062072615966E-06 1.02062072615966E-06 2126288880.69625 5.50345741132434E-06 Maximum Population 6866802093 Minimum Population 729407782 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2218138142 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2584033055 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 1901057942 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 3827085168 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 5857301234 0.000285 0.99 0.001 0.99 0.982891 0.82749 0.001 0.001 6114060146 0.00029 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 930036007 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 729407782 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 801051285 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 6193655290 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2750261610 0.000285 0.99 0.001 0.977391 0.99 0.81404 0.001 0.001 3354761252 0.000299 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 6205577078 0.000285 CHOSEN 0.99 0.001 0.971673 0.989046 0.809716 0.001005 0.001005 1040879429 0.000307 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 1737874180 0.000285 0.99 0.001 0.99 0.97679 0.830056 0.001 0.001 6085799484 0.000295 0.99 0.001 0.989994 0.99 0.824532 0.001 0.001 6866802093 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 4768289329 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2566033336 0.000285 6 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 3319300965 0.000285 0.99 0.001 0.989983 0.99 0.824523 0.001 0.001 1374802524 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 1356416950 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 6781393146 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 3923911052 0.000285 SARS Parameter Sets Infectivity Infection Rate Mobility Incubation Period Incubation Rate Mortality Percentage Immunity Recovery Period Recovery Rate Population Residual Sum Estimated Basic Reproduction Number Standard Deviation 0.3224714094 0.2345012131 0.097017819 0.2934826039 0.0495100597 0.0636622241 0.0496357966 2350778466.15791 1.7285763331 0.486726 0.253035 0.866356 1.1178792489 0.894551 0.215118 0.029584 16.0815657012 0.062183 4930935930 0.456655 4.0691989772 Chosen Parameter set#1 0.851473 0.187879 0.868682 10.0161259628 0.099839 0.233785 0.024091 5.8622832421 0.170582 1959432004 0.492016 1.1013999132 0.644418 0.26588 0.944756 1.489913287 0.67118 0.245621 0.02129 7.9605158414 0.12562 114133266 0.370468 2.1165419519 0.200633 0.124275 0.796056 1.4747587663 0.678077 0.249025 0.07947 21.1671570391 0.047243 781370871 0.276411 2.630548441 0.942965 0.970427 0.973074 1.0972913363 0.911335 0.265489 0.118805 6.096631611 0.164025 4384338355 0.980407 5.9163359244 0.08657 0.255206 0.706624 1.0120136136 0.988129 0.283516 0.021446 20.461195343 0.048873 5630901875 0.317624 5.2218198187 0.033523 0.142002 0.853813 1.7794385871 0.561975 0.322865 0.211555 7.2050781391 0.138791 1453683352 0.739969 1.0231355059 0.245728 0.430487 0.826955 1.3681443994 0.730917 0.325093 0.117911 7.381544662 0.135473 3293913925 0.625295 3.1776590169 0.533429 0.364678 0.873111 1.2384805825 0.807441 0.338197 0.001 8.5397825771 0.117099 1607023420 0.233318 3.1142708307 0.533066 0.387292 0.907111 1.589327349 0.629197 0.339495 0.148519 15.5265037419 0.064406 5784967215 0.348509 6.0132906872 Chosen Parameter set#2 0.840515 0.539667 0.801637 13.8900463928 0.071994 0.347849 0.098526 5.1692943913 0.19345 6631318516 0.819369 2.7896975963 0.095789 0.538563 0.62483 1.2243318821 0.816772 0.349846 0.055587 9.1958250954 0.108745 73865743 0.724964 4.9525311509 7 PHASE II PARAMETER SETS Infectivity Infectious Period Infection Rate Mobility Incubation Period Incubation Rate Mortality Percentage Immunity Recovery Rate Percentage Dead Max 0.375849 1.6784099416 0.99 0.99 38.6085479325 0.375609 0.99 0.01 0.01 0.922588 Min 0.015306 1.0101010101 0.595802 0.99 2.6623430216 0.025901 0.99 0.01 0.01 0.922555 Average 0.1982362286 1.123803493 0.9053117143 0.99 7.7306120843 0.1864900571 0.99 0.01 0.01 0.9225818 Standard Deviation 0.0903404125 0.163870674 0.1104190317 0 7.0662311461 0.0847061018 0 0 0 8.62213294205885E-06 0.260417 1.2797854056 0.781381 0.99 10.059147789 0.099412 0.99 0.01 0.01 0.922573 0.104144 1.0101010101 0.99 0.99 3.3601360183 0.297607 0.99 0.01 0.01 0.922588 0.189311 1.1429681741 0.874915 0.99 5.2823132306 0.189311 0.99 0.01 0.01 0.92258 0.262111 1.1204130291 0.892528 0.99 8.3298625573 0.12005 0.99 0.01 0.01 0.922582 0.141358 1.0555983659 0.94733 0.99 3.9715162852 0.251793 0.99 0.01 0.01 0.922585 0.243455 1.3201633834 0.757482 0.99 8.9630632165 0.111569 0.99 0.01 0.01 0.922571 0.076546 1.0101010101 0.99 0.99 3.0750023831 0.325203 0.99 0.01 0.01 0.922588 0.28003 1.3154761826 0.760181 0.99 13.23872061 0.075536 0.99 0.01 0.01 0.922571 0.158479 1.2698122456 0.787518 0.99 4.9362970861 0.202581 0.99 0.01 0.01 0.922573 0.139883 1.0952806547 0.913008 0.99 4.0586392194 0.246388 0.99 0.01 0.01 0.922583 0.303098 1.0101010101 0.99 0.99 10.1366419333 0.098652 0.99 0.01 0.01 0.922588 0.210875 1.0101010101 0.99 0.99 5.2390307793 0.190875 0.99 0.01 0.01 0.922588 0.358884 1.0185975541 0.981742 0.99 24.2824534991 0.041182 0.99 0.01 0.01 0.922588 0.199946 1.0101010101 0.99 0.99 4.9553031654 0.201804 0.99 0.01 0.01 0.922588 8 0.015306 1.6784099416 0.595802 0.99 3.2547951269 0.307239 0.99 0.01 0.01 0.922555 0.197484 1.0425093617 0.959224 0.99 5.0488730915 0.198064 0.99 0.01 0.01 0.922586 0.200874 1.0101010101 0.99 0.99 4.978245069 0.200874 0.99 0.01 0.01 0.922588 0.1805 1.2800475154 0.781221 0.99 5.5774625892 0.179293 0.99 0.01 0.01 0.922573 0.24139 1.0132061287 0.986966 0.99 6.2602119708 0.159739 0.99 0.01 0.01 0.922588 0.183169 1.0124039735 0.987748 0.99 4.5845692568 0.218123 0.99 0.01 0.01 0.922588 0.343787 1.0307875629 0.970132 0.99 18.5325895587 0.053959 0.99 0.01 0.01 0.922587 0.154238 1.2546358796 0.797044 0.99 4.7907175058 0.208737 0.99 0.01 0.01 0.922574 0.091475 1.5073748314 0.663405 0.99 4.0880233181 0.244617 0.99 0.01 0.01 0.922562 0.200875 1.0101010101 0.99 0.99 4.9782202862 0.200875 0.99 0.01 0.01 0.922588 0.32745 1.0101010101 0.99 0.99 13.458769061 0.074301 0.99 0.01 0.01 0.922588 0.375849 1.0101010101 0.99 0.99 38.6085479325 0.025901 0.99 0.01 0.01 0.922588 0.204574 1.0683144349 0.936054 0.99 5.3677153393 0.186299 0.99 0.01 0.01 0.922585 0.211214 1.0777011772 0.927901 0.99 5.6163052574 0.178053 0.99 0.01 0.01 0.922584 0.133185 1.3427378694 0.744747 0.99 4.5602338488 0.219287 0.99 0.01 0.01 0.92257 0.234127 1.0205143801 0.979898 0.99 6.0392308436 0.165584 0.99 0.01 0.01 0.922587 0.306 1.0101010101 0.99 0.99 10.4435370171 0.095753 0.99 0.01 0.01 0.922588 0.041942 1.2324423186 0.811397 0.99 3.0871724896 0.323921 0.99 0.01 0.01 0.922575 0.026141 1.0101010101 0.99 0.99 2.6623430216 0.375609 0.99 0.01 0.01 0.922588 0.181518 1.0322111822 0.968794 0.99 4.6306586649 0.215952 0.99 0.01 0.01 0.922587 0.158633 1.0106195907 0.989492 0.99 4.1150739273 0.243009 0.99 0.01 0.01 0.922588 9 """ 1 DETERMINISTIC EPIDEMIC MODEL PHASE I 2 Uma Wu & LiQing Wang 3 4 ~Ver.7 Updates~ 5 -began implementation of fitting model 6 ------------------------------------------------------------------------------- 7 8 BLOCK DIAGRAM 9 10 ######## ############# 11 #IMMUNE#<--- #SUSCEPTIBLE# 12 ######## --|------RecP------>############# 13 ^ | -Imn---------------- |Mob ^RecP 14 Imn| | | v | 15 ############<------------I---############ 16 #INFECTIOUS#<--------IncP----#INCUBATING# 17 ############-----InfP------> ############ 18 |Mor 19 v 20 ###### 21 #DEAD# 22 ###### 23 24 #####PARAMETERS##### 25 I = Infectivity (percentage of people that move from INCUBATING to INFECTIOUS without IncP 26 [OVERRIDE]) 27 InfP = Length of Infectious Period (rate of individuals moving from INFECTIOUS to INCUBATING) 28 Mob = Mobility (rate of individuals moving from SUSCEPTIBLE to INCUBATING) 29 IncP = Length of Incubation Period (rate of individuals moving from INCUBATING to 30 INFECTIOUS) 31 Mor = Morbidity (percentage of infectious individuals that move from INFECTIOUS to DEAD) 32 Imn = Immunity (percentage of recovered individuals that move from INFECTIOUS to IMMUNE) 33 RecP = Length of Recovery Period (rate of individuals moving from INFECTIOUS and 34 INCUBATING to SUSCEPTIBLE) 35 36 #Note: Incubating refers to both the disease being dormant and the disease displaying 37 nonconsequential symptoms. 38 Pop = Population (Total number of people in each compartment. Remains constant throughout 39 simulation) 40 41 #####INITIAL VALUES##### 42 Pop = Population 43 T = Time of Simulation in Days 44 10 IMMUNE = Pop*PImmune 45 SUSCEPTIBLE = Pop - Pop*PImmune 46 INCUBATING = 1 47 INFECTIOUS = 0 48 DEAD = 0 49 50 #####DIFFERENTIAL EQUATIONS FROM BLOCK##### 51 IMMUNE = IMMUNE + INFECTIOUS*Imn + INCUBATING*Imn 52 SUSCEPTIBLE = SUSCEPTIBLE + INFECTIOUS*RecP + INCUBATING*RecP - 53 SUSCEPTIBLE*(INCUBATING/Population)Mob 54 INCUBATING = INCUBATING + SUSCEPTIBLE*Mob + INFECTIOUS*InfP - INCUBATING*Imn - 55 INCUBATING*I - INCUBATING*IncP -INCUBATING*RecP 56 INFECTIOUS = INFECTIOUS + INCUBATING*I + INCUBATING*IncP - INFECTIOUS*Imn - 57 INFECTIOUS*InfP - INFECTIOUS*Mor 58 DEAD = DEAD + INFECTIOUS*Mor 59 60 """ 61 import numpy as np 62 import random 63 from scipy.optimize import minimize 64 import matplotlib.pyplot as plt 65 66 ################FITTING################## 67 68 SusFit = False 69 IncFit = False 70 InfFit = False 71 ImmFit = False 72 DeaFit = False 73 74 if SusFit: 75 SUSCEPTIBLEquery = [] 76 with open("SUSCEPTIBLEfit.csv", "r") as SUSCEPTIBLEfit: 77 for line in SUSCEPTIBLEfit: 78 SUSCEPTIBLEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 79 preset = SUSCEPTIBLEquery 80 status = "SusFit" 81 82 if IncFit: 83 INCUBATINGquery = [] 84 with open("INCUBATINGfit.csv", "r") as INCUBATINGfit: 85 for line in INCUBATINGfit: 86 INCUBATINGquery.append(tuple([int(x) for x in line[:-1].split(",")])) 87 preset = INCUBATINGquery 88 11 status = "IncFit" 89 90 if InfFit: 91 INFECTIOUSquery = [] 92 with open("INFECTIOUSfit.csv", "r") as INFECTIOUSfit: 93 for line in INFECTIOUSfit: 94 INFECTIOUSquery.append(tuple([int(x) for x in line[:-1].split(",")])) 95 preset = INFECTIOUSquery 96 status = "InfFit" 97 98 if ImmFit: 99 IMMUNEquery = [] 100 with open("IMMUNEfit.csv", "r") as IMMUNEfit: 101 for line in IMMUNEfit: 102 IMMUNEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 103 preset = IMMUNEquery 104 status = "ImmFit" 105 106 if DeaFit: 107 DEADquery = [] 108 with open("DEADfit.csv", "r") as DEADfit: 109 for line in DEADfit: 110 DEADquery.append(tuple([int(x) for x in line[:-1].split(",")])) 111 preset = DEADquery 112 status = "DeaFit" 113 114 """ 115 INPUTS: 116 time: the current time value 117 y: the current value of the function 118 query: the list of points (t, value) to fit against 119 OUTPUTS: 120 dy: the deviation from the query 121 """ 122 fit = False 123 if fit: 124 def Fit(time, y, query = preset): 125 for i in query: 126 if time == i[0]: 127 dy = y - i[1] #Calculates the residuals 128 return dy 129 else: 130 return "NONE" 131 else: 132 12 status = "SusFit" 133 134 ###############SIMULATION################# 135 136 def DeterministicEPIMOD1(Parameters, T = 365, Plot = True, Print = True, fit = fit, status = status, 137 dt = 0.1): 138 IMMUNE = np.zeros(int((T+1)/dt)) 139 SUSCEPTIBLE = np.zeros(int((T+1)/dt)) 140 INCUBATING = np.zeros(int((T+1)/dt)) 141 INFECTIOUS = np.zeros(int((T+1)/dt)) 142 DEAD = np.zeros(int((T+1)/dt)) 143 144 #PARAMETER VALUES (INITIAL VALUES) 145 I = Parameters[0] 146 InfP = Parameters[1] 147 Mob = Parameters[2] 148 IncP = Parameters[3] 149 Mor = Parameters[4] 150 Imn = Parameters[5] 151 RecP = Parameters[6] 152 153 Pop = Parameters[7] 154 155 #INITIAL VALUES 156 IMMUNE[0] = 0 #1213 #Pop*PImmune 157 INCUBATING[0] = 1 #1516 158 INFECTIOUS[0] = 0 #286 159 DEAD[0] = 0 160 SUSCEPTIBLE[0] = Pop - IMMUNE[0] - INCUBATING[0] - INFECTIOUS[0] - DEAD[0] 161 162 #FITTING 163 residuals = [] 164 n = 0 165 166 for t in range(1, int(float(T)/dt+1)): 167 SUSCEPTIBLEin = INFECTIOUS[t-1]*RecP*dt + INCUBATING[t-1]*RecP*dt 168 SUSCEPTIBLEout = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt 169 SUSCEPTIBLE[t] = SUSCEPTIBLE[t-1] + SUSCEPTIBLEin - SUSCEPTIBLEout 170 171 INCUBATINGin = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt + 172 INFECTIOUS[t-1]*InfP*dt 173 INCUBATINGout = INCUBATING[t-1]*Imn*dt + INCUBATING[t-1]*I*dt + 174 INCUBATING[t-1]*IncP*dt + INCUBATING[t-1]*RecP*dt 175 INCUBATING[t] = INCUBATING[t-1] + INCUBATINGin - INCUBATINGout 176 13 177 INFECTIOUSin = INCUBATING[t-1]*I*dt + INCUBATING[t-1]*IncP*dt 178 INFECTIOUSout = INFECTIOUS[t-1]*Imn*dt + INFECTIOUS[t-1]*InfP*dt + 179 INFECTIOUS[t-1]*Mor*dt + INFECTIOUS[t-1]*RecP*dt 180 INFECTIOUS[t] = INFECTIOUS[t-1] + INFECTIOUSin - INFECTIOUSout 181 182 DEADin = INFECTIOUS[t-1]*Mor*dt 183 DEADout = 0 184 DEAD[t] = DEAD[t-1] + DEADin - DEADout 185 186 IMMUNEin = INFECTIOUS[t-1]*Imn*dt + INCUBATING[t-1]*Imn*dt 187 IMMUNEout = 0 188 IMMUNE[t] = IMMUNE[t-1] + IMMUNEin - IMMUNEout 189 190 if fit == True: 191 if status == "SusFit": 192 y = SUSCEPTIBLE[t] 193 elif status == "IncFit": 194 y = INCUBATING[t] 195 elif status == "InfFit": 196 y = sum(INFECTIOUS) 197 elif status == "ImmFit": 198 y = IMMUNE[t] 199 elif status == "DeaFit": 200 y = DEAD[t] 201 else: 202 print "ERROR: I DON'T KNOW WHAT IT IS BUT SOMETHING IS NOT RIGHT." 203 204 diffs = Fit(int(t*dt), y) 205 206 if diffs != "NONE": 207 residuals.append(diffs**2) 208 # plt.plot(t, preset[n][1], "*r") 209 # plt.plot(t, y, ".b") 210 # print preset[n][1] 211 # n += 1 212 213 if Print == True: 214 Survivors = IMMUNE[t] + SUSCEPTIBLE[t] + INCUBATING[t] + INFECTIOUS[t] 215 print "TOTAL POPULATION = %i" %Pop 216 print "REMAINING POPULATION = %f" %Survivors 217 print "IMMUNE = %.0f" %round(IMMUNE[t]) 218 print "SUSCEPTIBLE = %.0f" %round(SUSCEPTIBLE[t]) 219 print "INCUBATING = %.0f" %round(INCUBATING[t]) 220 14 print "INFECTIOUS = %.0f" %round(INFECTIOUS[t]) 221 print "DEAD = %.0f" %round(DEAD[t]) 222 223 if Plot == True: 224 plt.plot(IMMUNE, label="IMMUNE") 225 plt.plot(SUSCEPTIBLE, label="SUSCEPTIBLE") 226 plt.plot(INCUBATING, label="INCUBATING") 227 plt.plot(INFECTIOUS, label="INFECTIOUS") 228 plt.plot(DEAD, label="DEAD") 229 230 plt.legend(loc="best") 231 plt.title("PHASEIIpandemic") 232 plt.ylabel("Number of Individuals") 233 plt.xlabel("Time/%f (in days)" %dt) 234 235 #plt.show() 236 plt.savefig("PHASEIIpandemicDET.pdf") 237 238 if fit == True: 239 return abs(sum(residuals)) 240 else: 241 return -np.log(DEAD[t]) 242 #return abs(7452-(IMMUNE[-1])) + abs(831 - DEAD[-1]) 243 244 ###############EXECUTING SIMULATION#################### 245 246 #Parameters = [0.8515,0.1879,0.8687,0.09984,0.2338,0.02409,0.1706,1959432004] 247 Parameters = [0.1982, 0.9053, 0.99, 0.1865, 0.99, 0.01, 0.01, 7000000000] 248 print np.exp(-DeterministicEPIMOD1(Parameters)) 249 250 # print minimize(DeterministicEPIMOD1, [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 5000], method = 'L-251 BFGS-B', bounds = ((0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1), (100, 252 7000000001))) 253 254 # if status == "SusFit": 255 # data = open('DeterministicPHASEI_EBOLAsus.csv', 'w') 256 # elif status == "IncFit": 257 # data = open('DeterministicPHASEI_EBOLAinc.csv', 'w') 258 # elif status == "InfFit": 259 # data = open('DeterministicPHASEI_EBOLAinf.csv', 'w') 260 # elif status == "ImmFit": 261 # data = open('DeterministicPHASEI_EBOLAimm.csv', 'w') 262 # elif status == "DeaFit": 263 # data = open('DeterministicPHASEI_EBOLAdea.csv', 'w') 264 15 # else: 265 # print "ERROR: I DON'T KNOW WHAT IT IS BUT SOMETHING IS NOT RIGHT." 266 267 # data.write("Infectivity, InfectionRate, Mobility, IncubationRate, Mortality, 268 PercentageImmunity, RecoveryRate, Population, ResidualSum") 269 270 # i = 0 271 # trials = 10000 272 # for n in range(trials): 273 # print "\n" 274 # print n 275 # guess = np.random.rand(8) 276 # guess[7] = random.randint(100, 7000000001) 277 # Combination = minimize(DeterministicEPIMOD1, guess, method = 'L-BFGS-B', bounds 278 = ((0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 279 0.99), (100, 7000000001))) 280 # if Combination.fun <= 1: 281 # i += 1 282 # print "%i candidates found!" %i 283 # I = Combination.x[0] 284 # InfP = Combination.x[1] 285 # Mob = Combination.x[2] 286 # IncP = Combination.x[3] 287 # Mor = Combination.x[4] 288 # Imn = Combination.x[5] 289 # RecP = Combination.x[6] 290 # Population = Combination.x[7] 291 # Residual = Combination.fun 292 # data.write("\n" + "%f, %f, %f, %f, %f, %f, %f, %f, %f" %(I, InfP, Mob, IncP, Mor, Imn, 293 RecP, Population, Residual**2)) 294 295 16 """ 1 DETERMINISTIC EPIDEMIC MODEL 2 Uma Wu & LiQing Wang 3 4 Discussed With: Michael Gelbart 5 6 ~Ver.8 Updates~ 7 -Began implementation of Spearmint 8 -Removed normalization 9 ------------------------------------------------------------------------------- 10 11 BLOCK DIAGRAM 12 13 ######## ############# 14 #IMMUNE#<--- #SUSCEPTIBLE# 15 ######## --|------RecP------>############# 16 ^ | -Imn---------------- |Mob ^RecP 17 Imn| | | v | 18 ############<------------I---############ 19 #INFECTIOUS#<--------IncP----#INCUBATING# 20 ############-----InfP------> ############ 21 |Mor 22 v 23 ###### 24 #DEAD# 25 ###### 26 27 #####PARAMETERS##### 28 PImmune = Pre-Immunity (percentage of population immune to disease at initial time) 29 I = Infectivity (percentage of people that move from INCUBATING to INFECTIOUS without IncP 30 [OVERRIDE]) 31 InfP = Length of Infectious Period (rate of individuals moving from INFECTIOUS to INCUBATING) 32 Mob = Mobility (rate of individuals moving from SUSCEPTIBLE to INCUBATING) 33 IncP = Length of Incubation Period (rate of individuals moving from INCUBATING to 34 INFECTIOUS) 35 Mor = Morbidity (percentage of infectious individuals that move from INFECTIOUS to DEAD) 36 Imn = Immunity (percentage of recovered individuals that move from INFECTIOUS to IMMUNE) 37 RecP = Length of Recovery Period (rate of individuals moving from INFECTIOUS and 38 INCUBATING to SUSCEPTIBLE) 39 #Note: Incubating refers to both the disease being dormant and the disease displaying 40 nonconsequential symptoms. 41 42 #####INITIAL VALUES##### 43 Pop = Population 44 17 T = Time of Simulation in Days 45 IMMUNE = Pop*PImmune 46 SUSCEPTIBLE = Pop - Pop*PImmune 47 INCUBATING = 0 48 INFECTIOUS = 1 49 DEAD = 0 50 51 #####DIFFERENTIAL EQUATIONS FROM BLOCK##### 52 IMMUNE = IMMUNE + INFECTIOUS*Imn + INCUBATING*Imn 53 SUSCEPTIBLE = SUSCEPTIBLE + INFECTIOUS*RecP - SUSCEPTIBLE*Mob 54 INCUBATING = INCUBATING + SUSCEPTIBLE*Mob + INFECTIOUS*InfP - INCUBATING*Imn - 55 INCUBATING*I - INCUBATING*IncP 56 INFECTIOUS = INFECTIOUS + INCUBATING*I + INCUBATING*IncP - INFECTIOUS*Imn - 57 INFECTIOUS*InfP - INFECTIOUS*Mor 58 DEAD = DEAD + INFECTIOUS*Mor 59 60 """ 61 62 import numpy as np 63 from scipy.optimize import minimize 64 import scipy.optimize 65 66 def main(job_id, params): 67 Parameters = [params["I"], params["InfP"], params["Mob"], params["IncP"], 68 params["Mor"], params["Imn"], params["RecP"]] 69 return -StochasticEPIMOD(Parameters) 70 71 def DeterministicEPIMOD(Parameters, T = 365, Pop = 7000000000): 72 dt = 0.1 73 IMMUNE = np.zeros(int((T+1)/dt)) 74 SUSCEPTIBLE = np.zeros(int((T+1)/dt)) 75 INCUBATING = np.zeros(int((T+1)/dt)) 76 INFECTIOUS = np.zeros(int((T+1)/dt)) 77 DEAD = np.zeros(int((T+1)/dt)) 78 79 #PARAMETER VALUES (INITIAL VALUES) 80 I = Parameters[0] #0.1 #0.011 is the rate of infection from data 81 InfP = Parameters[1] #0.12 #max 0.12 82 Mob = Parameters[2] #11.0/30.0 #THIS SHOULD DEPEND ON THE NUMBER OF INFECTED 83 INDIVIDUALS SOMEHOW AHHH 84 IncP = Parameters[3] #7.0/15.0 85 Mor = Parameters[4] #0.07 #0.096 is the death rate from data 86 Imn = Parameters[5] #0.397 #1.0 - Mor 87 RecP = Parameters[6] #0.468 is the recovery rate from data 88 18 89 #INITIAL VALUES 90 IMMUNE[0] = 0 #1213 #Pop*PImmune 91 INCUBATING[0] = 1 #1516 92 INFECTIOUS[0] = 0 #286 93 DEAD[0] = 0 94 SUSCEPTIBLE[0] = Pop - IMMUNE[0] - INCUBATING[0] - INFECTIOUS[0] - DEAD[0] 95 96 97 for t in range(1, int(float(T)/dt+1)): 98 SUSCEPTIBLEin = INFECTIOUS[t-1]*RecP*dt + INCUBATING[t-1]*RecP*dt 99 SUSCEPTIBLEout = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt 100 SUSCEPTIBLE[t] = SUSCEPTIBLE[t-1] + SUSCEPTIBLEin - SUSCEPTIBLEout 101 102 INCUBATINGin = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt + 103 INFECTIOUS[t-1]*InfP*dt 104 INCUBATINGout = INCUBATING[t-1]*Imn*dt + INCUBATING[t-1]*I*dt + 105 INCUBATING[t-1]*IncP*dt + INCUBATING[t-1]*RecP*dt 106 INCUBATING[t] = INCUBATING[t-1] + INCUBATINGin - INCUBATINGout 107 108 INFECTIOUSin = INCUBATING[t-1]*I*dt + INCUBATING[t-1]*IncP*dt 109 INFECTIOUSout = INFECTIOUS[t-1]*Imn*dt + INFECTIOUS[t-1]*InfP*dt + 110 INFECTIOUS[t-1]*Mor*dt + INFECTIOUS[t-1]*RecP*dt 111 INFECTIOUS[t] = INFECTIOUS[t-1] + INFECTIOUSin - INFECTIOUSout 112 113 DEADin = INFECTIOUS[t-1]*Mor*dt 114 DEADout = 0 115 DEAD[t] = DEAD[t-1] + DEADin - DEADout 116 117 IMMUNEin = INFECTIOUS[t-1]*Imn*dt + INCUBATING[t-1]*Imn*dt 118 IMMUNEout = 0 119 IMMUNE[t] = IMMUNE[t-1] + IMMUNEin - IMMUNEout 120 121 return -np.log(DEAD[t]) 122 123 def Normalize(Parameters): 124 return np.sum(Parameters) - 1 125 126 ###############EXECUTING SIMULATION#################### 127 128 #print minimize(DeterministicEPIMOD, [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], method = 'L-BFGS-B', 129 bounds = ((0.01, 1),)*7) 130 #print scipy.optimize.fmin_slsqp(DeterministicEPIMOD, [0.3, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1], 131 bounds = ((0.01, 1),)*7, f_eqcons = Normalize) 132 19 #returns the seven best parameters if not printed 133 134 data = open('DeterministicPHASEII2.csv', 'w') 135 data.write("Infectivity, InfectionRate, Mobility, IncubationRate, Mortality, 136 PercentageImmunity, RecoveryRate, PercentageDead") 137 138 trials = 50000 139 for n in range(trials): 140 print n 141 guess = np.random.rand(7) 142 Combination = minimize(DeterministicEPIMOD, guess, method = 'L-BFGS-B', bounds = 143 ((0.01, 0.99),)*7) 144 I = Combination.x[0] 145 InfP = Combination.x[1] 146 Mob = Combination.x[2] 147 IncP = Combination.x[3] 148 Mor = Combination.x[4] 149 Imn = Combination.x[5] 150 RecP = Combination.x[6] 151 Dead = np.exp(-DeterministicEPIMOD(Combination.x))/7000000000.0 152 data.write("\n" + "%f, %f, %f, %f, %f, %f, %f, %f" %(I, InfP, Mob, IncP, Mor, Imn, RecP, Dead)) 153 154 # TESTING PURPOSES ONLY 155 # guess = np.random.rand(7) 156 # print scipy.optimize.fmin_slsqp(DeterministicEPIMOD, guess, bounds = ((0.01, 1),)*7, 157 f_eqcons = Normalize) 158 20 """ 1 STOCHASTIC EPIDEMIC MODEL 2 Uma Wu & LiQing Wang 3 4 Discussed With: Noah Bayless, Michael Gelbart 5 ------------------------------------------------------------------------------- 6 #####PATIENT INFORMATION##### 7 xLoc = range(0, x_Dim) 8 yLoc = range(0, y_Dim) 9 Status = IMMUNE, SUSCEPTIBLE, INFECTIOUS, INCUBATING, or DEAD 10 tExist = time elapsed since start of simulation 11 tInc = time incubating 12 tInf = time infectious 13 tRec = time recovering 14 15 #####PARAMETERS##### 16 PImmune = Pre-Immunity (Probable Percentage of Population that is Pre-Immune to Disease, 17 float) 18 I = Infectivity (Percentage Probability of Displaying Symptoms When Infected, float) 19 InfP = Length of Infectious Period (Time Range in which the Disease is Infectious, array) 20 Mob = Mobility (Percentage Probability of Contracting the Disease from an Adjacent Diseased 21 Individual, float) 22 IncP = Length of Incubation Period (Time Range in which the Disease does not produce 23 Symptoms (In an Infective Individual), array) 24 Mor = Morbidity (Percentage Probability of Infective Individuals Dying from the Disease, float) 25 Imn = Immunity (Percentage Probability of Individuals of Gaining Immunity After Recovery, 26 float) 27 RecP = Length of Recovery Period (Time Range in which the Disease is Present in an Individual, 28 array) 29 """ 30 31 ########################DEFINING PATIENT 32 CLASS################################# 33 34 import random 35 import matplotlib.pyplot as plt 36 import numpy as np 37 38 class Dossier(): #Creates an object (like list or array) that has its own modules 39 def __init__(self, x, y, PImmune, IncP, InfP, RecP): #Automatically run as soon as object is 40 created 41 #x and y - int 42 #PImmune - float 43 #IncP, InfP and RecP - lists 44 21 self.xLoc = x #Stores the inputted x location in the object 45 self.yLoc = y #Same as above 46 47 vaccination = random.random() 48 if vaccination <= PImmune: #If the "roll" is below the PImmune probability 49 self.Status = "IMMUNE" #The Individual becomes immune 50 else: self.Status = "SUSCEPTIBLE" #If not, the individual becomes susceptible 51 52 self.IncLen = random.choice(IncP) #Picks a incubation rate out of the IncP list 53 self.InfLen = random.choice(InfP) #Same as above for infectious rate 54 self.RecLen = random.choice(RecP) #Same as above for recovery rate 55 self.IncState = False #Sets incubation state as false 56 self.InfState = False #Same as above for infectious rate 57 self.RecState = False #Same as above for recovery rate 58 59 60 def Incubation(self, I, Imn): 61 self.IncLen -= 1 #When the function is called, it first decreases the incubation period 62 by 1 63 if self.IncLen >= 0: #While the incubation period is more than 0, the IncState is set to 64 True 65 self.IncState = True 66 else: self.IncState = False #Otherwise, the IncState is False. In other words, the 67 patient stops incubating. 68 69 if self.IncState == False: #Once the patient finishes incubating.. 70 luck = random.random() 71 if luck <= I: #If their "roll" is less than Infectivity... 72 self.Status = "INFECTIOUS" #They become Infectious 73 else: 74 antibody = random.random() #If their "roll" is more than Infectivity... 75 if antibody <= Imn: #If their "roll" is smaller than the Immunity 76 self.Status = "IMMUNE" #They become Immune. 77 else: self.Status = "SUSCEPTIBLE" #Otherwise, they become susceptible. 78 79 80 def Infection(self, Mor): #Same concepts as incubation. 81 self.InfLen -= 1 82 if self.InfLen >= 0: 83 self.InfState = True 84 else: self.InfState = False 85 86 if self.InfState == False: 87 hopesndreams = random.random() 88 22 if hopesndreams <= Mor: 89 self.Status = "DEAD" 90 else: self.Status = "INCUBATING" 91 92 93 def Recovery(self, Imn): #Activated when patient goes into incubation or infection 94 self.RecLen -= 1 95 if self.RecLen >= 0: 96 self.RecState = True 97 else: self.RecState = False 98 99 if self.RecState == False: 100 antibody = random.random() 101 if antibody <= Imn: 102 self.Status = "IMMUNE" 103 else: self.Status = "SUSCEPTIBLE" 104 105 def Copy(self): 106 new_pat = Dossier(self.xLoc, self.yLoc, 0, range(2,7), range(2,7), range(2,7)) 107 #^These input values doesn't matter cuz we're gonna update it anyway 108 new_pat.Status = self.Status 109 new_pat.IncLen = self.IncLen 110 new_pat.InfLen = self.InfLen 111 new_pat.RecLen = self.RecLen 112 new_pat.IncState = self.IncState 113 new_pat.InfState = self.InfState 114 new_pat.RecState = self.RecState 115 return new_pat 116 117 ############################DEFINING 118 FUNCTIONS################################# 119 120 def Spread(Mob, NBR): 121 if NBR.Status == "INFECTIOUS": 122 contagion = random.random() 123 if contagion <= Mob: #If the "roll" is lower than mobility, then the patient is infected 124 by the virus 125 return True 126 else: 127 return False 128 return False 129 130 def Plot(Patient, Population): 131 for P in range(1, Population+1): 132 23 x = Patient[P].xLoc 133 y = Patient[P].yLoc 134 135 if Patient[P].Status == 'SUSCEPTIBLE': 136 colour = "white" 137 elif Patient[P].Status == 'IMMUNE': 138 colour = "blue" 139 elif Patient[P].Status == 'INFECTIOUS': 140 colour = "red" 141 elif Patient[P].Status == 'INCUBATING': 142 colour = "yellow" 143 elif Patient[P].Status == 'DEAD': 144 colour = "black" 145 146 if colour == "white": 147 plt.plot(x, y, "wo") 148 elif colour == "blue": 149 plt.plot(x, y, "bo") 150 elif colour == "red": 151 plt.plot(x, y, "ro") 152 elif colour == "yellow": 153 plt.plot(x, y, "yo") 154 elif colour == "black": 155 plt.plot(x, y, "ko") 156 plt.show() 157 158 def DeepCopy(Old): #Takes in dict, returns deep copy 159 New = dict() 160 for i in range(1, len(Old)+1): 161 New[i] = Old[i].Copy() 162 return New 163 164 ########################FITTING 165 FUNCTIONS###################################### 166 if __name__ == "__main__": 167 SusFit = False 168 IncFit = False 169 InfFit = False 170 ImmFit = False 171 DeaFit = False 172 173 if SusFit: 174 SUSCEPTIBLEquery = [] 175 with open("SUSCEPTIBLEfit.csv", "r") as SUSCEPTIBLEfit: 176 24 for line in SUSCEPTIBLEfit: 177 SUSCEPTIBLEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 178 preset = SUSCEPTIBLEquery 179 status = "SusFit" 180 181 if IncFit: 182 INCUBATINGquery = [] 183 with open("INCUBATINGfit.csv", "r") as INCUBATINGfit: 184 for line in INCUBATINGfit: 185 INCUBATINGquery.append(tuple([int(x) for x in line[:-1].split(",")])) 186 preset = INCUBATINGquery 187 status = "IncFit" 188 189 if InfFit: 190 INFECTIOUSquery = [] 191 with open("INFECTIOUSfit.csv", "r") as INFECTIOUSfit: 192 for line in INFECTIOUSfit: 193 INFECTIOUSquery.append(tuple([int(x) for x in line[:-1].split(",")])) 194 preset = INFECTIOUSquery 195 status = "InfFit" 196 197 if ImmFit: 198 IMMUNEquery = [] 199 with open("IMMUNEfit.csv", "r") as IMMUNEfit: 200 for line in IMMUNEfit: 201 IMMUNEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 202 preset = IMMUNEquery 203 status = "ImmFit" 204 205 if DeaFit: 206 DEADquery = [] 207 with open("DEADfit.csv", "r") as DEADfit: 208 for line in DEADfit: 209 DEADquery.append(tuple([int(x) for x in line[:-1].split(",")])) 210 preset = DEADquery 211 status = "DeaFit" 212 213 """ 214 INPUTS: 215 time: the current time value 216 y: the current value of the function 217 query: the list of points (t, value) to fit against 218 OUTPUTS: 219 dy: the deviation from the query 220 25 """ 221 222 fit = False 223 if fit == True: 224 def Fit(time, y, query = preset): 225 for i in query: 226 if time == i[0]: 227 dy = y - i[1] 228 else: 229 dy = "NONE" 230 return dy 231 else: 232 fit = False 233 234 235 ###########################INITIALIZE 236 SIMULATION############################### 237 def main(job_id, params): 238 Parameters = [params["I"], params["InfP"], params["Mob"], params["IncP"], 239 params["Mor"], params["Imn"], params["RecP"]] 240 return StochasticEPIMOD(Parameters) 241 242 243 def StochasticEPIMOD(Parameters, xDimension = 20, yDimension = 20, tElapsed = 365, flux = 244 True, move_range = 0.5, Plot = True, Print = True, fit = fit): 245 #INITIAL VALUES 246 Population = xDimension*yDimension 247 248 #PARAMETERS 249 PImmune = 0.0 250 I = Parameters[0] #Percentage 251 InfP = range(int(Parameters[1])-3, int(Parameters[1])+4) 252 Mob = Parameters[2] #Percentage 253 IncP = range(int(Parameters[3])-3, int(Parameters[3])+4) 254 Mor = Parameters[4] #Percentage 255 Imn = Parameters[5] #Percentage 256 RecP = range(int(Parameters[6])-3, int(Parameters[6])+4) 257 258 #PATIENTS 259 Patient = dict() 260 ID = 0 261 Pos2Pat = np.zeros((yDimension, xDimension)) 262 for x in range(xDimension): 263 for y in range(yDimension): 264 26 ID += 1 265 Patient[ID] = Dossier(x, y, PImmune, IncP, InfP, RecP) 266 Pos2Pat[y,x] = ID 267 268 #GENERATING PATIENT ZERO 269 x = xDimension/2 270 y = yDimension/2 271 for P in range(1, ID+1): 272 if Patient[P].xLoc == x and Patient[P].yLoc == y: 273 Patient[P].Status = "INFECTIOUS" 274 275 Record = DeepCopy(Patient) 276 277 SUSCEPTIBLEtrend = [] 278 INCUBATINGtrend = [] 279 INFECTIOUStrend = [] 280 IMMUNEtrend = [] 281 DEADtrend = [] 282 283 residuals = [] 284 285 ###########################SIMULATION 286 BEGINS################################### 287 for t in range(tElapsed): 288 # Plot(Patient, Population) 289 for P in range(1,ID+1): 290 #STATUS PRIORITY: DEAD = IMMUNE > INFECTIOUS = INCUBATING > 291 SUSCEPTIBLE 292 if Record[P].Status == "SUSCEPTIBLE": 293 n = 8 294 x = Patient[P].xLoc 295 y = Patient[P].yLoc 296 while Patient[P].Status != "INFECTIOUS" and Patient[P].Status != 297 "INCUBATING" and n > 0: 298 if n == 8: 299 infection = Spread(Mob, Record[Pos2Pat[y,(x+1)%xDimension]]) 300 #Right 301 if infection == True: 302 infection = random.random() 303 if infection <= I: 304 Patient[P].Status = "INFECTIOUS" 305 else: Patient[P].Status = "INCUBATING" 306 elif n == 7: 307 infection = Spread(Mob, Record[Pos2Pat[y,(x-1)%xDimension]]) 308 27 #Left 309 if infection == True: 310 infection = random.random() 311 if infection <= I: 312 Patient[P].Status = "INFECTIOUS" 313 else: Patient[P].Status = "INCUBATING" 314 elif n == 6: 315 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,x]]) 316 #Above 317 if infection == True: 318 infection = random.random() 319 if infection <= I: 320 Patient[P].Status = "INFECTIOUS" 321 else: Patient[P].Status = "INCUBATING" 322 elif n == 5: 323 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,x]]) 324 #Below 325 if infection == True: 326 infection = random.random() 327 if infection <= I: 328 Patient[P].Status = "INFECTIOUS" 329 else: Patient[P].Status = "INCUBATING" 330 elif n == 4: 331 infection = Spread(Mob, 332 Record[Pos2Pat[(y+1)%yDimension,(x+1)%xDimension]]) #Upper Right 333 if infection == True: 334 infection = random.random() 335 if infection <= I: 336 Patient[P].Status = "INFECTIOUS" 337 else: Patient[P].Status = "INCUBATING" 338 elif n == 3: 339 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,(x-340 1)%xDimension]]) #Lower Left 341 if infection == True: 342 infection = random.random() 343 if infection <= I: 344 Patient[P].Status = "INFECTIOUS" 345 else: Patient[P].Status = "INCUBATING" 346 elif n == 2: 347 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,(x-348 1)%xDimension]]) #Upper Left 349 if infection == True: 350 infection = random.random() 351 if infection <= I: 352 28 Patient[P].Status = "INFECTIOUS" 353 else: Patient[P].Status = "INCUBATING" 354 elif n == 1: 355 infection = Spread(Mob, Record[Pos2Pat[(y-356 1)%yDimension,(x+1)%xDimension]]) #Lower Right 357 if infection == True: 358 infection = random.random() 359 if infection <= I: 360 Patient[P].Status = "INFECTIOUS" 361 else: Patient[P].Status = "INCUBATING" 362 n -= 1 363 364 elif Record[P].Status == "INFECTIOUS": 365 Patient[P].Recovery(Imn) 366 if Patient[P].RecState == True: #If the patient is still infectious... 367 Patient[P].Infection(Mor) 368 369 elif Record[P].Status == "INCUBATING": 370 Patient[P].Recovery(Imn) 371 if Patient[P].RecState == True: #If the patient is still incubating... 372 Patient[P].Incubation(I,Imn) 373 374 elif Record[P].Status == "IMMUNE": #Removed from population 375 pass 376 elif Record[P].Status == "DEAD": #Removed from population 377 pass 378 379 380 #UPDATE MOVING 381 if flux == True: 382 for x in range(xDimension): 383 for y in range(yDimension): 384 if Patient[Pos2Pat[y,x]].Status != "DEAD": 385 move = random.random() 386 if move <= move_range: 387 swap = random.randint(1, 4) 388 if swap == 1: #switch with above 389 oriID = Pos2Pat[y, x] 390 newID = Pos2Pat[(y+1)%yDimension, x] 391 Patient[oriID].yLoc = (y+1)%yDimension 392 Patient[newID].yLoc = y 393 Pos2Pat[y,x] = newID 394 Pos2Pat[(y+1)%yDimension, x] = oriID 395 396 29 elif swap == 2: #switch with below 397 oriID = Pos2Pat[y, x] 398 newID = Pos2Pat[(y-1)%yDimension, x] 399 Patient[oriID].yLoc = (y-1)%yDimension 400 Patient[newID].yLoc = y 401 Pos2Pat[y,x] = newID 402 Pos2Pat[(y-1)%yDimension, x] = oriID 403 404 elif swap == 3: #switch with left 405 oriID = Pos2Pat[y, x] 406 newID = Pos2Pat[y, (x-1)%yDimension] 407 Patient[oriID].xLoc = (x-1)%xDimension 408 Patient[newID].xLoc = x 409 Pos2Pat[y,x] = newID 410 Pos2Pat[y, (x-1)%yDimension] = oriID 411 412 elif swap == 4: #switch with right 413 oriID = Pos2Pat[y, x] 414 newID = Pos2Pat[y, (x+1)%yDimension] 415 Patient[oriID].xLoc = (x+1)%xDimension 416 Patient[newID].xLoc = x 417 Pos2Pat[y,x] = newID 418 Pos2Pat[y, (x+1)%yDimension] = oriID 419 SUSCEPTIBLE = 0 420 INFECTIOUS = 0 421 INCUBATING = 0 422 IMMUNE = 0 423 DEAD = 0 424 425 for P in range(1, ID+1): 426 if Patient[P].Status == "SUSCEPTIBLE": 427 SUSCEPTIBLE += 1 428 elif Patient[P].Status == "INFECTIOUS": 429 INFECTIOUS += 1 430 elif Patient[P].Status == "INCUBATING": 431 INCUBATING += 1 432 elif Patient[P].Status == "IMMUNE": 433 IMMUNE += 1 434 elif Patient[P].Status == "DEAD": 435 DEAD += 1 436 437 SUSCEPTIBLEtrend.append(SUSCEPTIBLE) 438 INCUBATINGtrend.append(INCUBATING) 439 INFECTIOUStrend.append(INFECTIOUS) 440 30 IMMUNEtrend.append(IMMUNE) 441 DEADtrend.append(DEAD) 442 443 if fit == True: 444 if status == "SusFit": 445 y = SUSCEPTIBLE 446 elif status == "IncFit": 447 y = INCUBATING 448 elif status == "InfFit": 449 y = INFECTIOUS 450 elif status == "ImmFit": 451 y = IMMUNE 452 elif status == "DeaFit": 453 y = DEAD 454 455 diffs = Fit(t, y) 456 if diffs != "NONE": 457 residuals.append(diffs**2) 458 459 Record = DeepCopy(Patient) 460 461 if Plot: 462 plt.plot(SUSCEPTIBLEtrend, "0.5", label = "SUSCEPTIBLE") 463 plt.plot(INCUBATINGtrend, "y", label = "INCUBATING") 464 plt.plot(INFECTIOUStrend, "r", label = "INFECTIOUS") 465 plt.plot(IMMUNEtrend, "b", label = "IMMUNE") 466 plt.plot(DEADtrend, "k", label = "DEAD") 467 468 plt.legend(loc="best") 469 plt.title("ebolaSTOinfSIM") 470 plt.ylabel("Number of Individuals") 471 plt.xlabel("Time (in days)") 472 # plt.show() 473 plt.savefig("ebolaSTOinfSIM2.pdf") 474 475 if Print: 476 print "SUSCEPTIBLE = %i" %SUSCEPTIBLE 477 print "INFECTIOUS = %i" %INFECTIOUS 478 print "INCUBATING = %i" %INCUBATING 479 print "IMMUNE = %i" %IMMUNE 480 print "DEAD = %i" %DEAD 481 print "Percent Dead = %f" %(float(DEAD)/float(Population)) 482 483 return abs(sum(residuals)) 484 31 # PercentDead = float(DEAD)/float(Population) 485 # return PercentDead 486 487 if __name__ == "__main__": 488 StochasticEPIMOD([0.6834, 14, 0.0163, 19, 0.9512, 0.8861, 22]) 489 32 """ 1 STOCHASTIC EPIDEMIC MODEL 2 Uma Wu & LiQing Wang 3 4 Discussed With: Noah Bayless, Michael Gelbart 5 ------------------------------------------------------------------------------- 6 #####PATIENT INFORMATION##### 7 xLoc = range(0, x_Dim) 8 yLoc = range(0, y_Dim) 9 Status = IMMUNE, SUSCEPTIBLE, INFECTIOUS, INCUBATING, or DEAD 10 tExist = time elapsed since start of simulation 11 tInc = time incubating 12 tInf = time infectious 13 tRec = time recovering 14 15 16 #####PARAMETERS##### 17 PImmune = Pre-Immunity (PERCENTAGE PROBABILITY of Population that is Pre-Immune to 18 Disease, float) 19 I = Infectivity (PERCENTAGE PROBABILITY of Displaying Symptoms When Infected, float) 20 InfP = Length of Infectious Period (TIME RANGE in which the Disease is Infectious, array) 21 Mob = Mobility (PERCENTAGE PROBABILITY of Contracting the Disease from an Adjacent 22 Diseased Individual, float) 23 IncP = Length of Incubation Period (TIME RANGE in which the Disease does not produce 24 Symptoms (In an Infective Individual), array) 25 Mor = Morbidity (PERCENTAGE PROBABILITY of Infective Individuals Dying from the Disease, 26 float) 27 Imn = Immunity (PERCENTAGE PROBABILITY of Individuals of Gaining Immunity After Recovery, 28 float) 29 RecP = Length of Recovery Period (TIME RANGE in which the Disease is Present in an Individual, 30 array) 31 """ 32 33 from StochasticEPIMOD1 import Dossier 34 from StochasticEPIMOD1 import Spread 35 from StochasticEPIMOD1 import Plot 36 from StochasticEPIMOD1 import DeepCopy 37 38 import random 39 import matplotlib.pyplot as plt 40 import numpy as np 41 from scipy.optimize import minimize 42 43 44 33 def main(job_id, params): 45 Parameters = [params["I"], params["InfP"], params["Mob"], params["IncP"], 46 params["Mor"], params["Imn"], params["RecP"]] 47 return -StochasticEPIMOD(Parameters) 48 49 def StochasticEPIMOD(Parameters, xDimension = 20, yDimension = 20, tElapsed = 365, flux = 50 True, move_range = 0.5, Plot = False, Print = False): 51 #INITIAL VALUES 52 Population = xDimension*yDimension 53 54 #PARAMETERS 55 PImmune = 0.0 56 I = Parameters[0] #Percentage 57 InfP = range(int(Parameters[1])-3, int(Parameters[1])+4) 58 Mob = Parameters[2] #Percentage 59 IncP = range(int(Parameters[3])-3, int(Parameters[3])+4) 60 Mor = Parameters[4] #Percentage 61 Imn = Parameters[5] #Percentage 62 RecP = range(int(Parameters[6])-3, int(Parameters[6])+4) 63 64 #PATIENTS 65 Patient = dict() 66 ID = 0 67 Pos2Pat = np.zeros((yDimension, xDimension)) 68 for x in range(xDimension): 69 for y in range(yDimension): 70 ID += 1 71 Patient[ID] = Dossier(x, y, PImmune, IncP, InfP, RecP) 72 Pos2Pat[y,x] = ID 73 74 #GENERATING PATIENT ZERO 75 x = xDimension/2 76 y = yDimension/2 77 for P in range(1, ID+1): 78 if Patient[P].xLoc == x and Patient[P].yLoc == y: 79 Patient[P].Status = "INFECTIOUS" 80 81 Record = DeepCopy(Patient) 82 83 ###########################SIMULATION 84 BEGINS################################### 85 for t in range(tElapsed): 86 for P in range(1,ID+1): 87 #STATUS PRIORITY: DEAD = IMMUNE > INFECTIOUS = INCUBATING > 88 34 SUSCEPTIBLE 89 if Record[P].Status == "SUSCEPTIBLE": 90 n = 8 91 x = Patient[P].xLoc 92 y = Patient[P].yLoc 93 while Patient[P].Status != "INFECTIOUS" and Patient[P].Status != 94 "INCUBATING" and n > 0: 95 if n == 8: 96 infection = Spread(Mob, Record[Pos2Pat[y,(x+1)%xDimension]]) 97 #Right 98 if infection == True: 99 infection = random.random() 100 if infection <= I: 101 Patient[P].Status = "INFECTIOUS" 102 else: Patient[P].Status = "INCUBATING" 103 elif n == 7: 104 infection = Spread(Mob, Record[Pos2Pat[y,(x-1)%xDimension]]) 105 #Left 106 if infection == True: 107 infection = random.random() 108 if infection <= I: 109 Patient[P].Status = "INFECTIOUS" 110 else: Patient[P].Status = "INCUBATING" 111 elif n == 6: 112 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,x]]) 113 #Above 114 if infection == True: 115 infection = random.random() 116 if infection <= I: 117 Patient[P].Status = "INFECTIOUS" 118 else: Patient[P].Status = "INCUBATING" 119 elif n == 5: 120 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,x]]) 121 #Below 122 if infection == True: 123 infection = random.random() 124 if infection <= I: 125 Patient[P].Status = "INFECTIOUS" 126 else: Patient[P].Status = "INCUBATING" 127 elif n == 4: 128 infection = Spread(Mob, 129 Record[Pos2Pat[(y+1)%yDimension,(x+1)%xDimension]]) #Upper Right 130 if infection == True: 131 infection = random.random() 132 35 if infection <= I: 133 Patient[P].Status = "INFECTIOUS" 134 else: Patient[P].Status = "INCUBATING" 135 elif n == 3: 136 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,(x-137 1)%xDimension]]) #Lower Left 138 if infection == True: 139 infection = random.random() 140 if infection <= I: 141 Patient[P].Status = "INFECTIOUS" 142 else: Patient[P].Status = "INCUBATING" 143 elif n == 2: 144 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,(x-145 1)%xDimension]]) #Upper Left 146 if infection == True: 147 infection = random.random() 148 if infection <= I: 149 Patient[P].Status = "INFECTIOUS" 150 else: Patient[P].Status = "INCUBATING" 151 elif n == 1: 152 infection = Spread(Mob, Record[Pos2Pat[(y-153 1)%yDimension,(x+1)%xDimension]]) #Lower Right 154 if infection == True: 155 infection = random.random() 156 if infection <= I: 157 Patient[P].Status = "INFECTIOUS" 158 else: Patient[P].Status = "INCUBATING" 159 n -= 1 160 161 elif Record[P].Status == "INFECTIOUS": 162 Patient[P].Recovery(Imn) 163 if Patient[P].RecState == True: #If the patient is still infectious... 164 Patient[P].Infection(Mor) 165 166 elif Record[P].Status == "INCUBATING": 167 Patient[P].Recovery(Imn) 168 if Patient[P].RecState == True: #If the patient is still incubating... 169 Patient[P].Incubation(I,Imn) 170 171 elif Record[P].Status == "IMMUNE": #Removed from population 172 pass 173 elif Record[P].Status == "DEAD": #Removed from population 174 pass 175 176 36 177 #UPDATE MOVING 178 if flux == True: 179 for x in range(xDimension): 180 for y in range(yDimension): 181 if Patient[Pos2Pat[y,x]].Status != "DEAD": 182 move = random.random() 183 if move <= move_range: 184 swap = random.randint(1, 4) 185 if swap == 1: #switch with above 186 oriID = Pos2Pat[y, x] 187 newID = Pos2Pat[(y+1)%yDimension, x] 188 Patient[oriID].yLoc = (y+1)%yDimension 189 Patient[newID].yLoc = y 190 Pos2Pat[y,x] = newID 191 Pos2Pat[(y+1)%yDimension, x] = oriID 192 193 elif swap == 2: #switch with below 194 oriID = Pos2Pat[y, x] 195 newID = Pos2Pat[(y-1)%yDimension, x] 196 Patient[oriID].yLoc = (y-1)%yDimension 197 Patient[newID].yLoc = y 198 Pos2Pat[y,x] = newID 199 Pos2Pat[(y-1)%yDimension, x] = oriID 200 201 elif swap == 3: #switch with left 202 oriID = Pos2Pat[y, x] 203 newID = Pos2Pat[y, (x-1)%yDimension] 204 Patient[oriID].xLoc = (x-1)%xDimension 205 Patient[newID].xLoc = x 206 Pos2Pat[y,x] = newID 207 Pos2Pat[y, (x-1)%yDimension] = oriID 208 209 elif swap == 4: #switch with right 210 oriID = Pos2Pat[y, x] 211 newID = Pos2Pat[y, (x+1)%yDimension] 212 Patient[oriID].xLoc = (x+1)%xDimension 213 Patient[newID].xLoc = x 214 Pos2Pat[y,x] = newID 215 Pos2Pat[y, (x+1)%yDimension] = oriID 216 SUSCEPTIBLE = 0 217 INFECTIOUS = 0 218 INCUBATING = 0 219 IMMUNE = 0 220 37 DEAD = 0 221 222 for P in range(1, ID+1): 223 if Patient[P].Status == "SUSCEPTIBLE": 224 SUSCEPTIBLE += 1 225 elif Patient[P].Status == "INFECTIOUS": 226 INFECTIOUS += 1 227 elif Patient[P].Status == "INCUBATING": 228 INCUBATING += 1 229 elif Patient[P].Status == "IMMUNE": 230 IMMUNE += 1 231 elif Patient[P].Status == "DEAD": 232 DEAD += 1 233 234 Record = DeepCopy(Patient) 235 236 PercentDead = float(DEAD)/float(Population) 237 return PercentDead 238 239 def Average(Parameters, tests = 1000): 240 total = 0.0 241 results = np.zeros(tests) 242 for n in range(tests): 243 results[n] = float(StochasticEPIMOD(Parameters)) 244 print n 245 print np.mean(results) 246 print np.std(results) 247 print results 248 return np.mean(results), np.std(results), results 249 250 data = open("StochasticEPIMOD1SARSresultsDEAD.txt", "w") 251 252 Combination = [0.2860000, 9, 0.256050, 5, 0.34989, 0.462340, 17] 253 average, stdev, results = Average(Combination) 254 255 data.write("Average: %f" %average) 256 data.write("Standard Deviation: %f" %stdev) 257 for i in range(len(results)-1): 258 data.write("%f" %results[i]) 259 260 261 38 0.1 0.91525 0.1 0.87414 0.1 0 0.1 0.91696 0.1 0.72152 0.1 0.57796 0.1 0.81512 0.2 0.92258 0.2 0.89061 0.2 0 0.2 0.92245 0.2 0.82444 0.2 0.37337 0.2 0.69716 0.3 0.91566 0.3 0.90209 0.3 0.4279 0.3 0.91401 0.3 0.86564 0.3 0.24622 0.3 0.57964 0.4 0.8965 0.4 0.91003 0.4 0.68413 0.4 0.89352 0.4 0.88763 0.4 0.15879 0.4 0.46093 0.5 0.86648 0.5 0.91542 0.5 0.79698 0.5 0.86229 0.5 0.90095 0.5 0.09498 0.5 0.33827 0.6 0.82672 0.6 0.91895 0.6 0.85485 0.6 0.82146 0.6 0.9095 0.6 0.0466 0.6 0.20618 0.7 0.7782 0.7 0.9211 0.7 0.88673 0.7 0.77197 0.7 0.91513 0.7 0.00002 0.7 0.00002 0.8 0.72177 0.8 0.92223 0.8 0.90518 0.8 0.71465 0.8 0.91884 0.8 0 0.8 0 0.9 0.65814 0.9 0.92258 0.9 0.91627 0.9 0.65022 0.9 0.92123 0.9 0 0.9 0 1 0.58794 1 0.92235 1 0.92314 1 0.57929 1 0.9227 1 0 1 0 Infectivity Percentage Death Infection Rate Percentage Death Mobility Percentage Death Incubation Rate Percentage Death Mortality Percentage Death Percentage Immunity Percentage Death Recovery Rate Percentage Death 39 PARAMETERS STOCHASTIC DETERMINISTIC Initially Susceptible Population/ Total Population (Pop) N/A: There was not enough computational power to simulate population as a parameter. (PHASE I only) Total number of people in each compartment. Remains constant throughout simulation Infectivity (I) Percentage Probability of Population that Displays Symptoms When Infected Percentage of Population that Displays Symptoms When Infected Length of Infectious Period (InfP) (+/-3) Possible Time Range in which the Disease is Infectious Time in which the Disease is Infectious Mobility (Mob) Percentage Probability of Contracting the Disease from an Adjacent Diseased Individual Number of Healthy Individuals that a Diseased Individual may Infect Length of Incubation Period (IncP) (+/-3) Possible Time Range in which the Disease does not produce Symptoms (In an Infective Individual) Time in which the Disease does not produce Symptoms (In an Infective Individual) Length of Recovery Period (RecP) (+/-3) Possible Time Range in which the Disease is Present in an Individual Time in which the Disease is Present in an Individual Mortality (Mor) Percentage Probability of Infective Individuals Dying from the Disease Percentage of Infective Individuals Dying from the Disease Immunity (Imn) Percentage Probability of Individuals of Gaining Immunity After Recovery Percentage of Individuals that Gain Immunity Upon Recovery 40 SARS Data points for Fitting 153 78 158 98 159 103 165 144 166 154 186 461 187 478 188 495 189 506 202 666 204 689 210 750 211 754 216 772 221 784 228 799 229 799 231 804 238 809 239 810 242 811 243 812 244 812 249 812 252 812 41 Ebola Data Points for Fitting 7 24 279 12713 312 13697 347 14487 382 15151 413 15854 446 16236 479 16470 510 16763 42 0 The Last Plague Investigating the Lethality of Pandemics Using Deterministic and Stochastic Epidemic Models Co-Authors: Li Qing Wang & Uma Wu Faculty Advisor: James D. Berger SCI001 T2 Project March 9, 2016 1 Abstract This project investigates the effects of seven parameters on the spread of viral epidemics: infectivity, infectious period, mobility, incubation period, mortality, immunity and recovery period. Two algorithms were created to simulate the progression – one stochastic, and one deterministic. While the deterministic model simulates the spread through regulating the flux between compartments, the stochastic model simulates the spread by applying the parameters as a set of probabilities. The models were calibrated with current data on SARS and Ebola from WHO. Using optimization methods, we found the characteristics of viral diseases that would lead to the most lethal disease, marked by death rates of 92.26% of the world population in the deterministic model and 98.76% in the stochastic model. By investigating the effect of each parameter on the disease, we found that the key factors in regulating the spread of an epidemic are percentage immunity, mobility and recovery rate. Introduction Scientific question: what parameter values define the most deadly disease possible, and how do they each contribute to the epidemic? An epidemic is defined as a sudden spread of a disease that affects an unexpectedly high number of people in a certain population [1]. The determinant factors for the lethality examined in this study include infectivity, infectious period, mobility, incubation period, mortality, immunity and recovery period (refer to Appendix Pages for definitions). Although we are working with simulated diseases, the combination of parameters that define a “super viral disease” is important because any of these combinations may be present in a future infection. Therefore, by knowing the most dangerous aspects of an infectious disease, we can better focus our resources to counteract it. This project has four phases: 0, I, II and III. The model is developed in Phase 0, calibrated in Phase I and used to answer our scientific question in Phases II and III. The models use the susceptible-infected-removed model with a few more compartments to provide insight into the effect of each on the spread of diseases. The deterministic model is a closed model. The flux in and out of the compartments is represented as a series of differential equations. In order to optimize this program for certain desired outputs, the L-BFGS-B method was implemented [14]. The stochastic model is also closed, but it relies on a matrix system instead. To optimize this program for desired outputs, the Bayesian Optimization package Spearmint was implemented. Different sets of parameters can contribute to the same death rate; therefore, further analysis was done to find the trend in those combinations. 2 Procedure Phase 0 Principle Objective: To create the deterministic and stochastic models Deterministic Assumption 1: The parameters remain constant throughout the simulation. Justification: This means the effects of borders, quarantines, cures, and other currently implementable disease-control tactics are unavailable. The implementation of these features would impede the observations on the spread of the disease amidst all of the other elements affecting it. FIGURE 1: Flowchart of Deterministic Model. [For the complete code, refer to Appendix Pages 10-16] Stochastic -See also Assumptions 1 for the Deterministic Model- Assumption 1: The disease can only spread between adjacent individuals. Justification: While it is possible to simulate the disease spreading as a function of the total number of infected/incubating individuals regardless of their position in the simulated matrix, it defeats the point of having a stochastic process. Assumption 2: The parameter values produced by optimizing the program are scalable and will produce around the same proportions between individuals of different states regardless of population size. Justification: The spread of the disease overall have the same progression as long as the population is >9, since the disease needs to be spreading between unique individuals. This has been verified. 3 FIGURE 2: Flowchart of one individual’s possible status within Stochastic Model [For the complete code, refer to Appendix Pages 21-32] Phase I Principle Objective: Fitting and calibrating the program to real disease data Cumulative data on the number of cases, recoveries and deaths for SARS and cumulative data on the number cases and deaths for Ebola were collected from the World Health Organization (WHO) website [7, 11]. Target points were chosen for the simulations to fit. The best trend line for each category of data was found by minimizing the coefficient of determination (R2) to a value below a biological alpha of 5% with respect to the population using minimize function L-BFGS-B. For each disease, the category of data with the highest number of data points on the trend line was selected, and target points were chosen from these points. The death data and infected data for SARS and Ebola were used, respectively. The selected data points were representative of the trend of the disease, and minimized the noise in the raw data. [For the raw data used to fit the data points, refer to Appendix Pages 1-7.] Phase II Principal Objective: Finding the Parameters that result in the most deadly pandemics In both models, the functions representing the simulation were reconfigured to return the negative maximum percentage of the population that is dead over the time frame of a year. Deterministic - L-BFGS-B The percentage mortality is maximized using the L-BFGS-B gradient evaluation method. The L-BFGS-B evaluates the derivative of the gradient from a given starting point and follows the slope to find a local minimum. To counteract the possibility of multiple minima within our function, multiple parameter sets were generated (~10000) to ideally produce as many minima 4 as possible. Among these, the ones with the highest death rates were selected for analysis. Stochastic - Spearmint The Spearmint package uses Bayesian Optimization in a global black-box operation in order to find the global minimum of a function. This experiment required no more than using Spearmint to find the global minimum of the Stochastic outputs while minimizing the noise that comes from the random factors that govern its processes. Assumption: everyone was susceptible. Justification: if a significant fraction of a population is pre-immune, the disease may not become an epidemic at all. Phase III Principal Objective: investigating the effect of each parameter on percentage death independently. While keeping other parameters at the values that lead to the most deadly disease, each parameter in the deterministic program was varied independently from 0.1~1.0, in increments of 10%. The output percentage death, defined by the percentage of the world population dying from the disease, was recorded. Results Each of the following sets of parameters fit the respective disease data collected from WHO with the sum of residuals squared indicated. PHASE I RESULTS Deterministic Fitting Results (PHASE I) (FIGURE 3) EBOLA SARS SARS Infectivity 62.9133% 12.2454% 63.4744% Infection Rate 30.6023% 98.3275% 37.0586% Mobility 99% 98.211% 76.4858% Incubation Period 1.395 101.01 150.443 Incubation Rate 71.68% 99% 0.6647% Mortality 46.2063% 42.6484% 29.8424% Percent Immunity 0.1% 0.1% 0.9516% Recovery Rate 10.6243% 43.7013% 32.6739% Population 6990000000 1795595082 1407579615 Residual Sum 2.546% of Pop 0.0083558% of Pop. 0.0081459% of Pop Stochastic Fitting Results (PHASE I) (FIGURE 4) EBOLA SARS Infectivity 99% 43.14% Infectious Period 25 11 Mobility 27.6382% 40.22% Incubation Period 23 12 5 Mortality 36.72% 13.79% Percentage Immunity 50.266% 85.85% Recovery Period 28 11 Population Any Any Standard Deviation 0.022747 0.022434 FIGURE 5.2: Plots of epidemic progression as generated by Deterministic Model & SARS Data Simulated SARS (Parameter Set 2) Simulated SARS (Parameter Set 1) FIGURE 5.1: Plots of epidemic progression as generated by Deterministic Model & SARS Data 6 Simulated Ebola FIGURE 6: Plot of epidemic progression as generated by Deterministic Model & Ebola Data FIGURE 7: Plot of epidemic progression as generated by Stochastic Model & SARS Data 7 Model Disease Estimated Basic Reproductive Number R0 from Literature [3, 15] Deterministic SARS 2.25 0.24-2.47, 2.87 2.4-3.6 (Re) Deterministic SARS 1.13 Deterministic Ebola 2.88 1.50-2.67 Stochastic Ebola 1.12 Stochastic SARS 1.0 0.24-2.47, 3.87 2.4-3.6 (Re) FIGURE 9: Estimation of Basic Reproduction Number FIGURE 8: Plot of epidemic progression as generated by Stochastic Model & EBOLA Data 8 PHASE II RESULTS Deterministic Stochastic Infectivity 19.82% Infectivity 99% Infectious Period 1.124 Infectious Period 14 Infection Rate 90.53% Infection Rate 7.14% Mobility 99.00% Mobility 65.61% Incubation Period 7.731 Incubation Period 4 Incubation Rate 18.65% Incubation Rate 25% Mortality 99.00% Mortality 90.45% Percentage Immunity 1.0% Percentage Immunity 0.00% Recovery Rate 1.0% Recovery Rate 4% Recovery Period 100 Recovery Period 25 Percentage Dead 92.26% Percentage Dead 98.76% FIGURE 10: Parameters that constitute the most lethal disease in each model Average Standard Deviation Maximum Minimum Infectivity 19.82362286% 9.03404125% 37.5849% 1.5306% Infectious Period 1.123803493 0.1633870674 1.6784099416 1.010101 Infectious Rate 90.53117143% 11.04190317% 99% 59.5802% Mobility 99% 0% 99% 0.99 Incubation Period 7.7306150843 7.0662311461 38.6085479325 2.6623430216 Incubation Rate 18.64900571% 8.47061018% 37.5609% 2.5901% Mortality 99% 0% 99% 99% Percentage Immunity 1% 0% 1% 1% Recovery Rate 1% 0% 1% 1% Percentage Dead 92.25818% 8.622e-4% 92.2588% 92.2555% FIGURE 11: PHASE II Deterministic Parameter Features 9 Deterministic Model The data shows parameter values that contribute to the most deadly disease predicted by the deterministic model. (Figure 10) The disease is infectious slightly over 1 day. A diseased individual may infect 99% of the healthy people he meets. Only 19.82% of infecteds will display symptoms after infection. Other individuals do not show any symptom until 7.7 days after infection. 99% of infected individuals will die from the disease, and only 1% will gain immunity. Infected individuals, if capable of recovering from the disease, take 100 days to do so. FIGURE 12: Trend of optimized pandemic (Deterministic) 10 Stochastic Model The data shows parameter values that contribute to the most deadly disease predicted by the stochastic model. (Figure 10) The disease incubates for 4 days. There is a 99% chance that an infected population will display symptoms of the disease, and the disease is infectious over a span of two weeks. A healthy individual has a 65.61% chance of contracting the disease from an infectious individual in close proximity. Infected individuals have a 90.45% chance of dying from the disease. No one can develop immunity against this disease, but individuals can recover from the disease over a period of 25 days. FIGURE 13: Trend of optimized pandemic (Stochastic) 11 FIGURE 14.1: Incubation Period compared to Infectivity FIGURE 14.2: Percentage Death compared to Incubation Period FIGURE 14.3: Incubation Period compared to Infection Rate 12 PHASE III RESULTS Infectivity Infectious Period Mobility Incubation Period Mortality Percentage Immunity Recovery Rate ≤30% 1-2 days ≥20% 5-10 days any ≤70% ≤70% FIGURE 15: Table of criteria for a significant drop in population as a result of an epidemic Analysis Analysis of PHASE I Data Estimation of Basic Reproduction Number The basic reproduction number characterizes the ability of a disease to spread, and is calculated by dividing the infection rate by recovery rate. On the other hand, the effect reproduction number (Re) represents the observed number of secondary infections from a primary infection. Since the two are sometimes used interchangeably in literature, both values were obtained from literature as references. Two sets of parameters were selected for SARS because both provided R0 that were within the literature range. No statistical comparison was feasible between our results and the literature values due to the limitations of the model. However, it is clear that the Ro estimated by both models (Figure 9) generally adhered to what was reported from the literature. The deterministic model generally predicts a higher R0 than the stochastic model. Incubation Periods The stochastic model predicted a more reasonable incubation period for each disease compared to the deterministic one. The actual incubation periods for SARS and Ebola are up to two weeks [16] and up to 21 days [17], respectively. Both of these adhere significantly more to the stochastic results. Deterministic vs. Stochastic Comparing the shapes of the graphs of simulated SARS and Ebola produced by both models to the graphs of raw disease data, the stochastic model is clearly a better model than the deterministic one. The stochastic model is a better fit for the randomness in the nature of disease spread, unlike the deterministic. Combining this with analyses of estimated R0 and incubation period, the stochastic model seemed to have produced a lower residual for each disease (See Appendix Graphs). 13 Analysis of PHASE II Data A Holistic Analysis of PHASE II Deterministic Data This is done to deterministic only due to the various sets of optimized parameters it produced, all of which produced the desired maximal death rate. Of the 10000 parameter sets, 34 representative ones were selected for analysis. The standard deviation for each parameter was computed using 34 sets of parameters that yield a percentage death of 92.26%. Since the standard deviation of mobility, mortality, percentage immunity and recovery are zero, these parameters must be at a specific value to result in the most lethal epidemic. Therefore, any changes made to those parameters alone will result in a death rate deviating from 92.26%. The disease has high mobility (99%), high mortality (99%), low immunity (1%) and low recovery rate (1%). Infectivity can range from 1.53% to 37.58%, infection rate can range from 59.58% to 99% and incubation period can range from 2.66 ~ 38.61 days. A clear correlation between incubation period and infectivity can be observed below (Figure 14.1). When infectivity is below 20%, incubation period is less than a week. As infectivity goes beyond 20%, incubation period increases drastically and can be as high as 38 days. Therefore, as shown in Figures 14.1-3, a combination of the following qualities is most likely to happen and will lead to a 92.26% death rate: 1.53% ~26.21% infectivity, a short infectious period of 1~1.33 days, 99% mobility, within two weeks of incubation, 99% mortality, 1% immunity and1% recovery. 14 Discussion Accuracy & Precision The accuracy of either models can be defined by how replicable the results are. The deterministic model is completely accurate since the same parameters will always yield the same output. Therefore, the accuracy of deterministic model is not representative of its uncertainty, since no model can have 0 uncertainty. However, for the stochastic model, standard deviations of outputs were determined. The standard deviation of the phase II result, (0.005512%), defines the uncertainty of the model since it is purely based on the outputs of the program and does not depend on any data. This small standard deviation indicates an accurate model. The precision of either models can be defined as how well it fits to the real data in Phase I. This was obtained by fitting the simulation to the real data by minimizing the residuals. The stochastic model’s precision cannot be determined through its precision due to the restraint in runtime as a function of population (it can only fit the trend), and is therefore not representative of its uncertainty. The deterministic model does yield a wide array of residuals, however. In our fitting of the data, the lowest residual was 2.546% of Population with Ebola, while the two SARS fittings yielded 0.0083558% of population and 0.0081459% of population respectively. Since the percentages are less than 5%, the model is likely precise. Limitations Limitations of Collected Data Inconsistency in WHO data The cumulative number of SARS cases fluctuated for the last few days for which data were collected. SARS is a diagnosis of exclusion; as previous cases were further investigated, some patients were re-examined and re-diagnosed [6]. Since the fluctuation only involved a few individuals, we disregarded the occasional decrease, and recorded further data by adding the number of newly dead people to the cumulative number. Limitation of Obtainable Categories of Data While there are 7 parameters, only the aforementioned 3 had available data. Limitations of Model 1. Quarantine & Borders In April 2003, the Chinese government started implementing quarantine and restricting social interactions by methods such as closing theatres and implementing border control [4]. Quarantine would limit the mobility of the disease; however, this is not accounted for in the model. (See Assumptions) 2. Parameters change with time The parameters in both models are constant over time, while in reality they do change with 15 time. For example, the mortality of both disease increased with time. Run Time Constraints Deterministic The deterministic model does not take long to complete one function evaluation (~0.1s for Population = 7000000000) due to its nature as a linear-time computation, but its optimization took much longer due to the methodology of the L-BFGS-B method of evaluating the function multiple times until it reached a local minimum. Therefore, a global optimization would have been better for this instance. Stochastic The stochastic model takes a lot longer than the deterministic (~1s for Population = 400) to complete one function evaluation. With the Spearmint Optimization package, we were able to bypass that issue. Not only does Spearmint find the global minimum, it only takes around 5 hours to yield applicable and accurate results. However, it is still subject to the limitations of populations, since the run time increases linearly with the addition of an individual. Inferences Deterministic Phase II Summary: The most deadly disease according to the deterministic model is a disease that doesn’t show symptoms immediately (19.82% infectivity), transmits quickly from person to person (99% mobility), almost certainly and immediately kills its host upon infection (99% mortality), and is almost impossible to develop immunity from (only 1% of the population can become immune). . This disease can kill 92.26 % of the world population in one year. This set of parameters produces a greater incubating population than infectious population. There are many currently known viruses that can remain dormant in individuals (e.g Rabies, STDs) for a relatively long time before manifesting symptoms. The disease may cover its lethality by displaying nonlethal typical flu symptoms as fever, cough and diarrhea when individuals are first infected, thus creating a high incubating population. This feature of the simulated disease greatly contributes to the risk of unknowingly getting infected since the number of susceptible people becoming incubating is dependent on both the number of carriers (infecteds) and susceptibles. Stochastic Phase II Summary: The most deadly disease according to the stochastic model is one that shows symptoms almost immediately (99% infectivity), transmits at a moderate rate (65.61%) from person to person, is infectious over two weeks, and is develop immunity. This disease can kill 98.76% of the world population in one year. Instead of a high mobility, the disease becomes highly infective with a small incubation period, which means the patients would immediately show symptoms upon infection. A zero percent immunity means that even if a patient did manage to survive, they would become susceptible again with another chance of being infected and eventually succumbing to the 16 disease. This disease resembles past epidemics such as AIDS, since it mutates very quickly and suppresses the immune system. The disease would exhibit symptoms that lead to more infection and eventually death, such as skin lesions (e.g smallpox), discharging fluids (e.g diarrhea), and even irregular behavior (e.g rabies patients may bite other individuals). 17 Figure 16.1 The percentage dead seems to decrease somewhat linearly with increased recovery rate when the recovery rate is lower than 70%. A recovery rate of 70% seems to be a threshold beyond which the disease is no longer an epidemic. Figure 16.2 A disease with low mortality (10%) can have a high percentage death (~70%). The percentage death increase by ~10% in response to a 10 fold increase in mortality. This may indicate that the mortality of a disease is not the major determinant of its percentage death. Deterministic Phase III results and inferences Since the purpose of Phase III is purely making inferences, its results will be shown here along with the inferences. 18 Figure 16.3 A disease for which an infected can only spread the infection to less than 20% of the people he contacts will not cause an epidemic. The percentage death increases drastically with the increase in mobility. This suggests that mobility is a major determinant in the spread of a disease. Figure 16.4 As incubation rate increases, or as the length of incubation period decreases, the percentage death decreases. 19 Figure 16.5 The larger the fraction of the infected population that shows symptoms, the less deadly the disease becomes. This may suggest that a disease must not let the patients display symptoms immediately in order to let it spread unknowingly, and eventually kill a large percentage of the world population. Figure 16.6 The disease is the most deadly when zero percent of the population is immune to it. The death rate decreases with increased immunity. There seems to be a threshold at 70% immunity, beyond which the disease is essentially no longer an epidemic. 20 Key Inferences and Observations In agreement with what was observed in phase II, any deviation from the set of the most deadly parameters led to a decrease in percentage death. However, this phase allowed a closer investigation of the magnitude of such effect. For example, the mortality barely alters the percentage death while independent changes in mobility, recovery rate, and percentage immunity led to much greater changes. The effect of infection rate, incubation rate, and infectivity is somewhere in between. Some threshold values were observed in percentage immunity (≤70%), mobility (≥20%) and recovery rate (≤70%). These three parameters are the major contributors to the percentage death of an epidemic; however, they must reach a certain threshold level for a disease to become an epidemic. These three parameters need to be regulated in order to prevent or control the spread of epidemic most efficiently. As a summary of phase III, a chart of criteria for the most lethal epidemic predicted by the deterministic model was produced (figure 15). If an outbreak is suspected and several of its parameters fall into these values, it is likely to develop into a fairly lethal epidemic. Such disease can then be most effectively regulated by controlling percentage immunity, mobility and recovery rate. Figure 16.7 A low infection rate such as 10% can lead to a death percentage of ~87%. The increase in infection rate from 10% to 70% causes the most increase in percentage death. Beyond that, the increase in infection rate has minute effect on percentage death. 21 Conclusion Both the deterministic and stochastic models developed are able to fit realistic disease data and predict combinations of parameters that would lead to the most deadly epidemic. Both models also predict a high death rate when the chances of developing immunity are low, indicating the threat of an immune-suppressive disease is especially high. Ranges of values for each parameter that constitute the most lethal epidemic outlined can be used to assess the lethality of a real disease. With further development, future potentials of this pair of models include investigation of other viral diseases, predicting the outcome of a disease in real time, and modelling the effect of prevention and control methods on the epidemic. References [1]"Lesson 1: Introduction to Epidemiology." Centers for Disease Control and Prevention. Centers for Disease Control and Prevention, 2012. Web. 11 Mar. 2016. [2]"Learning Basic Epidemic Models with Python." Learning Basic Epidemic Models with Python. Web. 11 Mar. 2016. [3]"Estimating the Reproduction Number of Ebola Virus (EBOV) During the 2014 Outbreak in West Africa – PLOS Currents Outbreaks." PLOS Currents Outbreaks. Web. 11 Mar. 2016. [4]"SARS Reference | SARS Timeline." SARS Reference | SARS Timeline. Web. 11 Mar. 2016. [5]"The SIR Model for Spread of Disease - The Differential Equation Model." The SIR Model for Spread of Disease. Web. 11 Mar. 2016. [6] "Cumulative Number of Reported Probable Cases of SARS." WHO. Web. 13 Mar. 2016. <http://www.who.int/csr/sars/country/2003_07_09/en/>. [7]"Cumulative Number of Reported Probable Cases of Severe Acute Respiratory Syndrome (SARS)." WHO. Web. 11 Mar. 2016. [8]"WHO IRIS: Consensus Document on the Epidemiology of Severe Acute Respiratory Syndrome (SARS)." WHO IRIS: Consensus Document on the Epidemiology of Severe Acute Respiratory Syndrome (SARS). Web. 11 Mar. 2016. [9]Wallinga, J. "Different Epidemic Curves for Severe Acute Respiratory Syndrome Reveal Similar Impacts of Control Measures." American Journal of Epidemiology 160.6 (2004): 509-16. Web. [10]"Epidemic." Wikipedia. Wikimedia Foundation. Web. 11 Mar. 2016. [11]"Ebola Virus Disease." World Health Organization. Web. 11 Mar. 2016. [12]Zhang, Zhibin. "The Outbreak Pattern of SARS Cases in China as Revealed by a Mathematical Model." Ecological Modelling 204.3-4 (2007): 420-26. Web. [13]Zhou, Yicang, Zhien Ma, and F. Brauer. "A Discrete Epidemic Model for SARS Transmission and Control in China." Mathematical and Computer Modelling 40.13 (2004): 1491-506. Web. [14]"Scipy.optimize.minimize¶." Scipy.optimize.minimize — SciPy V0.17.0 Reference Guide. Web. 11 Mar. 2016. [15] Althaus, Christian L. "Estimating the Reproduction Number of Ebola Virus (EBOV) 22 During the 2014 Outbreak in West Africa." PLoS Curr PLoS Currents (2014). Web. 13 Mar. 2016. [16] "Frequently Asked Questions About SARS." Centers for Disease Control and Prevention. Centers for Disease Control and Prevention, 2012. Web. 21 Mar. 2016. <http://www.cdc.gov/sars/about/faq.html>. [17] "Ebola Virus Disease." World Health Organization. Web. 21 Mar. 2016. <http://www.who.int/mediacentre/factsheets/fs103/en/>. Special Thanks James D. Berger for mentoring this project Michael Gelbart for implementing Spearmint, suggesting fitting methods, and debugging Pam Kalas for reviewing and advising this project Omer Angel for providing insight on the data analysis Costanza Piccolo for refining our parameters Eric Cytrynbaum for refining the mechanics of the model Appendix Table of Contents SARS Raw Data: Cumulative Number of Deaths vs. Time (Fig1) ---------------------------------------------1 SARS Raw Data: Cumulative Number of Recovered Individuals vs. Time (Fig2) --------------------------1 SARS Extrapolated Data: Number of Alive & Infected Individuals vs. Time (Fig3) -----------------------2 SARS Extrapolated Data: Cumulative Number of Deaths vs. Time Fitted (Fig4) --------------------------2 SARS Extrapolated Data: Currently Infectious Individuals vs. Time Fitted (Fig5) -------------------------3 EBOLA Raw Data: Cumulative Number of Infectious Individuals vs. Time (Fig6) -------------------------3 EBOLA Raw Data: Cumulative Number of Deaths vs. Time (Fig7) -------------------------------------------4 EBOLA Raw Data: Cumulative Number of Deaths vs. Time Fitted (Fig7) -----------------------------------4 EBOLA Extrapolated Data: Cumulative Number of Infectious vs. Time Fitted (Fig8) --------------------5 EBOLA Parameter Sets--------------------------------------------------------------------------------------------------6 SARS Parameter Sets----------------------------------------------------------------------------------------------------7 PHASE II Parameter Sets (Deterministic) --------------------------------------------------------------------------8 DeterministicEPIMOD PHASE I Model-----------------------------------------------------------------------------10 DeterministicEPIMOD PHASE II Model----------------------------------------------------------------------------17 StochasticEPIMOD PHASE I Model---------------------------------------------------------------------------------21 StochasticEPIMOD PHASE II Model--------------------------------------------------------------------------------33 PHASE III Data Table---------------------------------------------------------------------------------------------------39 Definitions of Parameters--------------------------------------------------------------------------------------------40 Phase I Target Points---------------------------------------------------------------------------------------------------41 Appendix Fig1 Appendix Fig2 SARS Raw Data SARS Raw Data 1 Appendix Fig3 Appendix Fig4 SARS Extrapolated Data 2 Appendix Fig5 Appendix Fig6 3 Appendix Fig7 Appendix Fig7 Cumulative Deaths vs. Time 4 Appendix Fig8 Cumulative Infectious vs. Time 5 Ebola Parameter Sets Infectivity Infection Rate Mobility Incubation Rate Mortality Percentage Immunity Recovery Rate Population ResidualSum Average 0.99 0.001 0.9887100417 0.989113625 0.8238342917 0.0010002083 0.0010002083 3470330353.29167 0.000287125 Standard Deviation 0 0 0.0044474239 0.0030006973 0.0039407441 1.02062072615966E-06 1.02062072615966E-06 2126288880.69625 5.50345741132434E-06 Maximum Population 6866802093 Minimum Population 729407782 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2218138142 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2584033055 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 1901057942 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 3827085168 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 5857301234 0.000285 0.99 0.001 0.99 0.982891 0.82749 0.001 0.001 6114060146 0.00029 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 930036007 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 729407782 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 801051285 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 6193655290 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2750261610 0.000285 0.99 0.001 0.977391 0.99 0.81404 0.001 0.001 3354761252 0.000299 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 6205577078 0.000285 CHOSEN 0.99 0.001 0.971673 0.989046 0.809716 0.001005 0.001005 1040879429 0.000307 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 1737874180 0.000285 0.99 0.001 0.99 0.97679 0.830056 0.001 0.001 6085799484 0.000295 0.99 0.001 0.989994 0.99 0.824532 0.001 0.001 6866802093 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 4768289329 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2566033336 0.000285 6 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 3319300965 0.000285 0.99 0.001 0.989983 0.99 0.824523 0.001 0.001 1374802524 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 1356416950 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 6781393146 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 3923911052 0.000285 SARS Parameter Sets Infectivity Infection Rate Mobility Incubation Period Incubation Rate Mortality Percentage Immunity Recovery Period Recovery Rate Population Residual Sum Estimated Basic Reproduction Number Standard Deviation 0.3224714094 0.2345012131 0.097017819 0.2934826039 0.0495100597 0.0636622241 0.0496357966 2350778466.15791 1.7285763331 0.486726 0.253035 0.866356 1.1178792489 0.894551 0.215118 0.029584 16.0815657012 0.062183 4930935930 0.456655 4.0691989772 Chosen Parameter set#1 0.851473 0.187879 0.868682 10.0161259628 0.099839 0.233785 0.024091 5.8622832421 0.170582 1959432004 0.492016 1.1013999132 0.644418 0.26588 0.944756 1.489913287 0.67118 0.245621 0.02129 7.9605158414 0.12562 114133266 0.370468 2.1165419519 0.200633 0.124275 0.796056 1.4747587663 0.678077 0.249025 0.07947 21.1671570391 0.047243 781370871 0.276411 2.630548441 0.942965 0.970427 0.973074 1.0972913363 0.911335 0.265489 0.118805 6.096631611 0.164025 4384338355 0.980407 5.9163359244 0.08657 0.255206 0.706624 1.0120136136 0.988129 0.283516 0.021446 20.461195343 0.048873 5630901875 0.317624 5.2218198187 0.033523 0.142002 0.853813 1.7794385871 0.561975 0.322865 0.211555 7.2050781391 0.138791 1453683352 0.739969 1.0231355059 0.245728 0.430487 0.826955 1.3681443994 0.730917 0.325093 0.117911 7.381544662 0.135473 3293913925 0.625295 3.1776590169 0.533429 0.364678 0.873111 1.2384805825 0.807441 0.338197 0.001 8.5397825771 0.117099 1607023420 0.233318 3.1142708307 0.533066 0.387292 0.907111 1.589327349 0.629197 0.339495 0.148519 15.5265037419 0.064406 5784967215 0.348509 6.0132906872 Chosen Parameter set#2 0.840515 0.539667 0.801637 13.8900463928 0.071994 0.347849 0.098526 5.1692943913 0.19345 6631318516 0.819369 2.7896975963 0.095789 0.538563 0.62483 1.2243318821 0.816772 0.349846 0.055587 9.1958250954 0.108745 73865743 0.724964 4.9525311509 7 PHASE II PARAMETER SETS Infectivity Infectious Period Infection Rate Mobility Incubation Period Incubation Rate Mortality Percentage Immunity Recovery Rate Percentage Dead Max 0.375849 1.6784099416 0.99 0.99 38.6085479325 0.375609 0.99 0.01 0.01 0.922588 Min 0.015306 1.0101010101 0.595802 0.99 2.6623430216 0.025901 0.99 0.01 0.01 0.922555 Average 0.1982362286 1.123803493 0.9053117143 0.99 7.7306120843 0.1864900571 0.99 0.01 0.01 0.9225818 Standard Deviation 0.0903404125 0.163870674 0.1104190317 0 7.0662311461 0.0847061018 0 0 0 8.62213294205885E-06 0.260417 1.2797854056 0.781381 0.99 10.059147789 0.099412 0.99 0.01 0.01 0.922573 0.104144 1.0101010101 0.99 0.99 3.3601360183 0.297607 0.99 0.01 0.01 0.922588 0.189311 1.1429681741 0.874915 0.99 5.2823132306 0.189311 0.99 0.01 0.01 0.92258 0.262111 1.1204130291 0.892528 0.99 8.3298625573 0.12005 0.99 0.01 0.01 0.922582 0.141358 1.0555983659 0.94733 0.99 3.9715162852 0.251793 0.99 0.01 0.01 0.922585 0.243455 1.3201633834 0.757482 0.99 8.9630632165 0.111569 0.99 0.01 0.01 0.922571 0.076546 1.0101010101 0.99 0.99 3.0750023831 0.325203 0.99 0.01 0.01 0.922588 0.28003 1.3154761826 0.760181 0.99 13.23872061 0.075536 0.99 0.01 0.01 0.922571 0.158479 1.2698122456 0.787518 0.99 4.9362970861 0.202581 0.99 0.01 0.01 0.922573 0.139883 1.0952806547 0.913008 0.99 4.0586392194 0.246388 0.99 0.01 0.01 0.922583 0.303098 1.0101010101 0.99 0.99 10.1366419333 0.098652 0.99 0.01 0.01 0.922588 0.210875 1.0101010101 0.99 0.99 5.2390307793 0.190875 0.99 0.01 0.01 0.922588 0.358884 1.0185975541 0.981742 0.99 24.2824534991 0.041182 0.99 0.01 0.01 0.922588 0.199946 1.0101010101 0.99 0.99 4.9553031654 0.201804 0.99 0.01 0.01 0.922588 8 0.015306 1.6784099416 0.595802 0.99 3.2547951269 0.307239 0.99 0.01 0.01 0.922555 0.197484 1.0425093617 0.959224 0.99 5.0488730915 0.198064 0.99 0.01 0.01 0.922586 0.200874 1.0101010101 0.99 0.99 4.978245069 0.200874 0.99 0.01 0.01 0.922588 0.1805 1.2800475154 0.781221 0.99 5.5774625892 0.179293 0.99 0.01 0.01 0.922573 0.24139 1.0132061287 0.986966 0.99 6.2602119708 0.159739 0.99 0.01 0.01 0.922588 0.183169 1.0124039735 0.987748 0.99 4.5845692568 0.218123 0.99 0.01 0.01 0.922588 0.343787 1.0307875629 0.970132 0.99 18.5325895587 0.053959 0.99 0.01 0.01 0.922587 0.154238 1.2546358796 0.797044 0.99 4.7907175058 0.208737 0.99 0.01 0.01 0.922574 0.091475 1.5073748314 0.663405 0.99 4.0880233181 0.244617 0.99 0.01 0.01 0.922562 0.200875 1.0101010101 0.99 0.99 4.9782202862 0.200875 0.99 0.01 0.01 0.922588 0.32745 1.0101010101 0.99 0.99 13.458769061 0.074301 0.99 0.01 0.01 0.922588 0.375849 1.0101010101 0.99 0.99 38.6085479325 0.025901 0.99 0.01 0.01 0.922588 0.204574 1.0683144349 0.936054 0.99 5.3677153393 0.186299 0.99 0.01 0.01 0.922585 0.211214 1.0777011772 0.927901 0.99 5.6163052574 0.178053 0.99 0.01 0.01 0.922584 0.133185 1.3427378694 0.744747 0.99 4.5602338488 0.219287 0.99 0.01 0.01 0.92257 0.234127 1.0205143801 0.979898 0.99 6.0392308436 0.165584 0.99 0.01 0.01 0.922587 0.306 1.0101010101 0.99 0.99 10.4435370171 0.095753 0.99 0.01 0.01 0.922588 0.041942 1.2324423186 0.811397 0.99 3.0871724896 0.323921 0.99 0.01 0.01 0.922575 0.026141 1.0101010101 0.99 0.99 2.6623430216 0.375609 0.99 0.01 0.01 0.922588 0.181518 1.0322111822 0.968794 0.99 4.6306586649 0.215952 0.99 0.01 0.01 0.922587 0.158633 1.0106195907 0.989492 0.99 4.1150739273 0.243009 0.99 0.01 0.01 0.922588 9 """ 1 DETERMINISTIC EPIDEMIC MODEL PHASE I 2 Uma Wu & LiQing Wang 3 4 ~Ver.7 Updates~ 5 -began implementation of fitting model 6 ------------------------------------------------------------------------------- 7 8 BLOCK DIAGRAM 9 10 ######## ############# 11 #IMMUNE#<--- #SUSCEPTIBLE# 12 ######## --|------RecP------>############# 13 ^ | -Imn---------------- |Mob ^RecP 14 Imn| | | v | 15 ############<------------I---############ 16 #INFECTIOUS#<--------IncP----#INCUBATING# 17 ############-----InfP------> ############ 18 |Mor 19 v 20 ###### 21 #DEAD# 22 ###### 23 24 #####PARAMETERS##### 25 I = Infectivity (percentage of people that move from INCUBATING to INFECTIOUS without IncP 26 [OVERRIDE]) 27 InfP = Length of Infectious Period (rate of individuals moving from INFECTIOUS to INCUBATING) 28 Mob = Mobility (rate of individuals moving from SUSCEPTIBLE to INCUBATING) 29 IncP = Length of Incubation Period (rate of individuals moving from INCUBATING to 30 INFECTIOUS) 31 Mor = Morbidity (percentage of infectious individuals that move from INFECTIOUS to DEAD) 32 Imn = Immunity (percentage of recovered individuals that move from INFECTIOUS to IMMUNE) 33 RecP = Length of Recovery Period (rate of individuals moving from INFECTIOUS and 34 INCUBATING to SUSCEPTIBLE) 35 36 #Note: Incubating refers to both the disease being dormant and the disease displaying 37 nonconsequential symptoms. 38 Pop = Population (Total number of people in each compartment. Remains constant throughout 39 simulation) 40 41 #####INITIAL VALUES##### 42 Pop = Population 43 T = Time of Simulation in Days 44 10 IMMUNE = Pop*PImmune 45 SUSCEPTIBLE = Pop - Pop*PImmune 46 INCUBATING = 1 47 INFECTIOUS = 0 48 DEAD = 0 49 50 #####DIFFERENTIAL EQUATIONS FROM BLOCK##### 51 IMMUNE = IMMUNE + INFECTIOUS*Imn + INCUBATING*Imn 52 SUSCEPTIBLE = SUSCEPTIBLE + INFECTIOUS*RecP + INCUBATING*RecP - 53 SUSCEPTIBLE*(INCUBATING/Population)Mob 54 INCUBATING = INCUBATING + SUSCEPTIBLE*Mob + INFECTIOUS*InfP - INCUBATING*Imn - 55 INCUBATING*I - INCUBATING*IncP -INCUBATING*RecP 56 INFECTIOUS = INFECTIOUS + INCUBATING*I + INCUBATING*IncP - INFECTIOUS*Imn - 57 INFECTIOUS*InfP - INFECTIOUS*Mor 58 DEAD = DEAD + INFECTIOUS*Mor 59 60 """ 61 import numpy as np 62 import random 63 from scipy.optimize import minimize 64 import matplotlib.pyplot as plt 65 66 ################FITTING################## 67 68 SusFit = False 69 IncFit = False 70 InfFit = False 71 ImmFit = False 72 DeaFit = False 73 74 if SusFit: 75 SUSCEPTIBLEquery = [] 76 with open("SUSCEPTIBLEfit.csv", "r") as SUSCEPTIBLEfit: 77 for line in SUSCEPTIBLEfit: 78 SUSCEPTIBLEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 79 preset = SUSCEPTIBLEquery 80 status = "SusFit" 81 82 if IncFit: 83 INCUBATINGquery = [] 84 with open("INCUBATINGfit.csv", "r") as INCUBATINGfit: 85 for line in INCUBATINGfit: 86 INCUBATINGquery.append(tuple([int(x) for x in line[:-1].split(",")])) 87 preset = INCUBATINGquery 88 11 status = "IncFit" 89 90 if InfFit: 91 INFECTIOUSquery = [] 92 with open("INFECTIOUSfit.csv", "r") as INFECTIOUSfit: 93 for line in INFECTIOUSfit: 94 INFECTIOUSquery.append(tuple([int(x) for x in line[:-1].split(",")])) 95 preset = INFECTIOUSquery 96 status = "InfFit" 97 98 if ImmFit: 99 IMMUNEquery = [] 100 with open("IMMUNEfit.csv", "r") as IMMUNEfit: 101 for line in IMMUNEfit: 102 IMMUNEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 103 preset = IMMUNEquery 104 status = "ImmFit" 105 106 if DeaFit: 107 DEADquery = [] 108 with open("DEADfit.csv", "r") as DEADfit: 109 for line in DEADfit: 110 DEADquery.append(tuple([int(x) for x in line[:-1].split(",")])) 111 preset = DEADquery 112 status = "DeaFit" 113 114 """ 115 INPUTS: 116 time: the current time value 117 y: the current value of the function 118 query: the list of points (t, value) to fit against 119 OUTPUTS: 120 dy: the deviation from the query 121 """ 122 fit = False 123 if fit: 124 def Fit(time, y, query = preset): 125 for i in query: 126 if time == i[0]: 127 dy = y - i[1] #Calculates the residuals 128 return dy 129 else: 130 return "NONE" 131 else: 132 12 status = "SusFit" 133 134 ###############SIMULATION################# 135 136 def DeterministicEPIMOD1(Parameters, T = 365, Plot = True, Print = True, fit = fit, status = status, 137 dt = 0.1): 138 IMMUNE = np.zeros(int((T+1)/dt)) 139 SUSCEPTIBLE = np.zeros(int((T+1)/dt)) 140 INCUBATING = np.zeros(int((T+1)/dt)) 141 INFECTIOUS = np.zeros(int((T+1)/dt)) 142 DEAD = np.zeros(int((T+1)/dt)) 143 144 #PARAMETER VALUES (INITIAL VALUES) 145 I = Parameters[0] 146 InfP = Parameters[1] 147 Mob = Parameters[2] 148 IncP = Parameters[3] 149 Mor = Parameters[4] 150 Imn = Parameters[5] 151 RecP = Parameters[6] 152 153 Pop = Parameters[7] 154 155 #INITIAL VALUES 156 IMMUNE[0] = 0 #1213 #Pop*PImmune 157 INCUBATING[0] = 1 #1516 158 INFECTIOUS[0] = 0 #286 159 DEAD[0] = 0 160 SUSCEPTIBLE[0] = Pop - IMMUNE[0] - INCUBATING[0] - INFECTIOUS[0] - DEAD[0] 161 162 #FITTING 163 residuals = [] 164 n = 0 165 166 for t in range(1, int(float(T)/dt+1)): 167 SUSCEPTIBLEin = INFECTIOUS[t-1]*RecP*dt + INCUBATING[t-1]*RecP*dt 168 SUSCEPTIBLEout = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt 169 SUSCEPTIBLE[t] = SUSCEPTIBLE[t-1] + SUSCEPTIBLEin - SUSCEPTIBLEout 170 171 INCUBATINGin = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt + 172 INFECTIOUS[t-1]*InfP*dt 173 INCUBATINGout = INCUBATING[t-1]*Imn*dt + INCUBATING[t-1]*I*dt + 174 INCUBATING[t-1]*IncP*dt + INCUBATING[t-1]*RecP*dt 175 INCUBATING[t] = INCUBATING[t-1] + INCUBATINGin - INCUBATINGout 176 13 177 INFECTIOUSin = INCUBATING[t-1]*I*dt + INCUBATING[t-1]*IncP*dt 178 INFECTIOUSout = INFECTIOUS[t-1]*Imn*dt + INFECTIOUS[t-1]*InfP*dt + 179 INFECTIOUS[t-1]*Mor*dt + INFECTIOUS[t-1]*RecP*dt 180 INFECTIOUS[t] = INFECTIOUS[t-1] + INFECTIOUSin - INFECTIOUSout 181 182 DEADin = INFECTIOUS[t-1]*Mor*dt 183 DEADout = 0 184 DEAD[t] = DEAD[t-1] + DEADin - DEADout 185 186 IMMUNEin = INFECTIOUS[t-1]*Imn*dt + INCUBATING[t-1]*Imn*dt 187 IMMUNEout = 0 188 IMMUNE[t] = IMMUNE[t-1] + IMMUNEin - IMMUNEout 189 190 if fit == True: 191 if status == "SusFit": 192 y = SUSCEPTIBLE[t] 193 elif status == "IncFit": 194 y = INCUBATING[t] 195 elif status == "InfFit": 196 y = sum(INFECTIOUS) 197 elif status == "ImmFit": 198 y = IMMUNE[t] 199 elif status == "DeaFit": 200 y = DEAD[t] 201 else: 202 print "ERROR: I DON'T KNOW WHAT IT IS BUT SOMETHING IS NOT RIGHT." 203 204 diffs = Fit(int(t*dt), y) 205 206 if diffs != "NONE": 207 residuals.append(diffs**2) 208 # plt.plot(t, preset[n][1], "*r") 209 # plt.plot(t, y, ".b") 210 # print preset[n][1] 211 # n += 1 212 213 if Print == True: 214 Survivors = IMMUNE[t] + SUSCEPTIBLE[t] + INCUBATING[t] + INFECTIOUS[t] 215 print "TOTAL POPULATION = %i" %Pop 216 print "REMAINING POPULATION = %f" %Survivors 217 print "IMMUNE = %.0f" %round(IMMUNE[t]) 218 print "SUSCEPTIBLE = %.0f" %round(SUSCEPTIBLE[t]) 219 print "INCUBATING = %.0f" %round(INCUBATING[t]) 220 14 print "INFECTIOUS = %.0f" %round(INFECTIOUS[t]) 221 print "DEAD = %.0f" %round(DEAD[t]) 222 223 if Plot == True: 224 plt.plot(IMMUNE, label="IMMUNE") 225 plt.plot(SUSCEPTIBLE, label="SUSCEPTIBLE") 226 plt.plot(INCUBATING, label="INCUBATING") 227 plt.plot(INFECTIOUS, label="INFECTIOUS") 228 plt.plot(DEAD, label="DEAD") 229 230 plt.legend(loc="best") 231 plt.title("PHASEIIpandemic") 232 plt.ylabel("Number of Individuals") 233 plt.xlabel("Time/%f (in days)" %dt) 234 235 #plt.show() 236 plt.savefig("PHASEIIpandemicDET.pdf") 237 238 if fit == True: 239 return abs(sum(residuals)) 240 else: 241 return -np.log(DEAD[t]) 242 #return abs(7452-(IMMUNE[-1])) + abs(831 - DEAD[-1]) 243 244 ###############EXECUTING SIMULATION#################### 245 246 #Parameters = [0.8515,0.1879,0.8687,0.09984,0.2338,0.02409,0.1706,1959432004] 247 Parameters = [0.1982, 0.9053, 0.99, 0.1865, 0.99, 0.01, 0.01, 7000000000] 248 print np.exp(-DeterministicEPIMOD1(Parameters)) 249 250 # print minimize(DeterministicEPIMOD1, [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 5000], method = 'L-251 BFGS-B', bounds = ((0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1), (100, 252 7000000001))) 253 254 # if status == "SusFit": 255 # data = open('DeterministicPHASEI_EBOLAsus.csv', 'w') 256 # elif status == "IncFit": 257 # data = open('DeterministicPHASEI_EBOLAinc.csv', 'w') 258 # elif status == "InfFit": 259 # data = open('DeterministicPHASEI_EBOLAinf.csv', 'w') 260 # elif status == "ImmFit": 261 # data = open('DeterministicPHASEI_EBOLAimm.csv', 'w') 262 # elif status == "DeaFit": 263 # data = open('DeterministicPHASEI_EBOLAdea.csv', 'w') 264 15 # else: 265 # print "ERROR: I DON'T KNOW WHAT IT IS BUT SOMETHING IS NOT RIGHT." 266 267 # data.write("Infectivity, InfectionRate, Mobility, IncubationRate, Mortality, 268 PercentageImmunity, RecoveryRate, Population, ResidualSum") 269 270 # i = 0 271 # trials = 10000 272 # for n in range(trials): 273 # print "\n" 274 # print n 275 # guess = np.random.rand(8) 276 # guess[7] = random.randint(100, 7000000001) 277 # Combination = minimize(DeterministicEPIMOD1, guess, method = 'L-BFGS-B', bounds 278 = ((0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 279 0.99), (100, 7000000001))) 280 # if Combination.fun <= 1: 281 # i += 1 282 # print "%i candidates found!" %i 283 # I = Combination.x[0] 284 # InfP = Combination.x[1] 285 # Mob = Combination.x[2] 286 # IncP = Combination.x[3] 287 # Mor = Combination.x[4] 288 # Imn = Combination.x[5] 289 # RecP = Combination.x[6] 290 # Population = Combination.x[7] 291 # Residual = Combination.fun 292 # data.write("\n" + "%f, %f, %f, %f, %f, %f, %f, %f, %f" %(I, InfP, Mob, IncP, Mor, Imn, 293 RecP, Population, Residual**2)) 294 295 16 """ 1 DETERMINISTIC EPIDEMIC MODEL 2 Uma Wu & LiQing Wang 3 4 Discussed With: Michael Gelbart 5 6 ~Ver.8 Updates~ 7 -Began implementation of Spearmint 8 -Removed normalization 9 ------------------------------------------------------------------------------- 10 11 BLOCK DIAGRAM 12 13 ######## ############# 14 #IMMUNE#<--- #SUSCEPTIBLE# 15 ######## --|------RecP------>############# 16 ^ | -Imn---------------- |Mob ^RecP 17 Imn| | | v | 18 ############<------------I---############ 19 #INFECTIOUS#<--------IncP----#INCUBATING# 20 ############-----InfP------> ############ 21 |Mor 22 v 23 ###### 24 #DEAD# 25 ###### 26 27 #####PARAMETERS##### 28 PImmune = Pre-Immunity (percentage of population immune to disease at initial time) 29 I = Infectivity (percentage of people that move from INCUBATING to INFECTIOUS without IncP 30 [OVERRIDE]) 31 InfP = Length of Infectious Period (rate of individuals moving from INFECTIOUS to INCUBATING) 32 Mob = Mobility (rate of individuals moving from SUSCEPTIBLE to INCUBATING) 33 IncP = Length of Incubation Period (rate of individuals moving from INCUBATING to 34 INFECTIOUS) 35 Mor = Morbidity (percentage of infectious individuals that move from INFECTIOUS to DEAD) 36 Imn = Immunity (percentage of recovered individuals that move from INFECTIOUS to IMMUNE) 37 RecP = Length of Recovery Period (rate of individuals moving from INFECTIOUS and 38 INCUBATING to SUSCEPTIBLE) 39 #Note: Incubating refers to both the disease being dormant and the disease displaying 40 nonconsequential symptoms. 41 42 #####INITIAL VALUES##### 43 Pop = Population 44 17 T = Time of Simulation in Days 45 IMMUNE = Pop*PImmune 46 SUSCEPTIBLE = Pop - Pop*PImmune 47 INCUBATING = 0 48 INFECTIOUS = 1 49 DEAD = 0 50 51 #####DIFFERENTIAL EQUATIONS FROM BLOCK##### 52 IMMUNE = IMMUNE + INFECTIOUS*Imn + INCUBATING*Imn 53 SUSCEPTIBLE = SUSCEPTIBLE + INFECTIOUS*RecP - SUSCEPTIBLE*Mob 54 INCUBATING = INCUBATING + SUSCEPTIBLE*Mob + INFECTIOUS*InfP - INCUBATING*Imn - 55 INCUBATING*I - INCUBATING*IncP 56 INFECTIOUS = INFECTIOUS + INCUBATING*I + INCUBATING*IncP - INFECTIOUS*Imn - 57 INFECTIOUS*InfP - INFECTIOUS*Mor 58 DEAD = DEAD + INFECTIOUS*Mor 59 60 """ 61 62 import numpy as np 63 from scipy.optimize import minimize 64 import scipy.optimize 65 66 def main(job_id, params): 67 Parameters = [params["I"], params["InfP"], params["Mob"], params["IncP"], 68 params["Mor"], params["Imn"], params["RecP"]] 69 return -StochasticEPIMOD(Parameters) 70 71 def DeterministicEPIMOD(Parameters, T = 365, Pop = 7000000000): 72 dt = 0.1 73 IMMUNE = np.zeros(int((T+1)/dt)) 74 SUSCEPTIBLE = np.zeros(int((T+1)/dt)) 75 INCUBATING = np.zeros(int((T+1)/dt)) 76 INFECTIOUS = np.zeros(int((T+1)/dt)) 77 DEAD = np.zeros(int((T+1)/dt)) 78 79 #PARAMETER VALUES (INITIAL VALUES) 80 I = Parameters[0] #0.1 #0.011 is the rate of infection from data 81 InfP = Parameters[1] #0.12 #max 0.12 82 Mob = Parameters[2] #11.0/30.0 #THIS SHOULD DEPEND ON THE NUMBER OF INFECTED 83 INDIVIDUALS SOMEHOW AHHH 84 IncP = Parameters[3] #7.0/15.0 85 Mor = Parameters[4] #0.07 #0.096 is the death rate from data 86 Imn = Parameters[5] #0.397 #1.0 - Mor 87 RecP = Parameters[6] #0.468 is the recovery rate from data 88 18 89 #INITIAL VALUES 90 IMMUNE[0] = 0 #1213 #Pop*PImmune 91 INCUBATING[0] = 1 #1516 92 INFECTIOUS[0] = 0 #286 93 DEAD[0] = 0 94 SUSCEPTIBLE[0] = Pop - IMMUNE[0] - INCUBATING[0] - INFECTIOUS[0] - DEAD[0] 95 96 97 for t in range(1, int(float(T)/dt+1)): 98 SUSCEPTIBLEin = INFECTIOUS[t-1]*RecP*dt + INCUBATING[t-1]*RecP*dt 99 SUSCEPTIBLEout = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt 100 SUSCEPTIBLE[t] = SUSCEPTIBLE[t-1] + SUSCEPTIBLEin - SUSCEPTIBLEout 101 102 INCUBATINGin = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt + 103 INFECTIOUS[t-1]*InfP*dt 104 INCUBATINGout = INCUBATING[t-1]*Imn*dt + INCUBATING[t-1]*I*dt + 105 INCUBATING[t-1]*IncP*dt + INCUBATING[t-1]*RecP*dt 106 INCUBATING[t] = INCUBATING[t-1] + INCUBATINGin - INCUBATINGout 107 108 INFECTIOUSin = INCUBATING[t-1]*I*dt + INCUBATING[t-1]*IncP*dt 109 INFECTIOUSout = INFECTIOUS[t-1]*Imn*dt + INFECTIOUS[t-1]*InfP*dt + 110 INFECTIOUS[t-1]*Mor*dt + INFECTIOUS[t-1]*RecP*dt 111 INFECTIOUS[t] = INFECTIOUS[t-1] + INFECTIOUSin - INFECTIOUSout 112 113 DEADin = INFECTIOUS[t-1]*Mor*dt 114 DEADout = 0 115 DEAD[t] = DEAD[t-1] + DEADin - DEADout 116 117 IMMUNEin = INFECTIOUS[t-1]*Imn*dt + INCUBATING[t-1]*Imn*dt 118 IMMUNEout = 0 119 IMMUNE[t] = IMMUNE[t-1] + IMMUNEin - IMMUNEout 120 121 return -np.log(DEAD[t]) 122 123 def Normalize(Parameters): 124 return np.sum(Parameters) - 1 125 126 ###############EXECUTING SIMULATION#################### 127 128 #print minimize(DeterministicEPIMOD, [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], method = 'L-BFGS-B', 129 bounds = ((0.01, 1),)*7) 130 #print scipy.optimize.fmin_slsqp(DeterministicEPIMOD, [0.3, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1], 131 bounds = ((0.01, 1),)*7, f_eqcons = Normalize) 132 19 #returns the seven best parameters if not printed 133 134 data = open('DeterministicPHASEII2.csv', 'w') 135 data.write("Infectivity, InfectionRate, Mobility, IncubationRate, Mortality, 136 PercentageImmunity, RecoveryRate, PercentageDead") 137 138 trials = 50000 139 for n in range(trials): 140 print n 141 guess = np.random.rand(7) 142 Combination = minimize(DeterministicEPIMOD, guess, method = 'L-BFGS-B', bounds = 143 ((0.01, 0.99),)*7) 144 I = Combination.x[0] 145 InfP = Combination.x[1] 146 Mob = Combination.x[2] 147 IncP = Combination.x[3] 148 Mor = Combination.x[4] 149 Imn = Combination.x[5] 150 RecP = Combination.x[6] 151 Dead = np.exp(-DeterministicEPIMOD(Combination.x))/7000000000.0 152 data.write("\n" + "%f, %f, %f, %f, %f, %f, %f, %f" %(I, InfP, Mob, IncP, Mor, Imn, RecP, Dead)) 153 154 # TESTING PURPOSES ONLY 155 # guess = np.random.rand(7) 156 # print scipy.optimize.fmin_slsqp(DeterministicEPIMOD, guess, bounds = ((0.01, 1),)*7, 157 f_eqcons = Normalize) 158 20 """ 1 STOCHASTIC EPIDEMIC MODEL 2 Uma Wu & LiQing Wang 3 4 Discussed With: Noah Bayless, Michael Gelbart 5 ------------------------------------------------------------------------------- 6 #####PATIENT INFORMATION##### 7 xLoc = range(0, x_Dim) 8 yLoc = range(0, y_Dim) 9 Status = IMMUNE, SUSCEPTIBLE, INFECTIOUS, INCUBATING, or DEAD 10 tExist = time elapsed since start of simulation 11 tInc = time incubating 12 tInf = time infectious 13 tRec = time recovering 14 15 #####PARAMETERS##### 16 PImmune = Pre-Immunity (Probable Percentage of Population that is Pre-Immune to Disease, 17 float) 18 I = Infectivity (Percentage Probability of Displaying Symptoms When Infected, float) 19 InfP = Length of Infectious Period (Time Range in which the Disease is Infectious, array) 20 Mob = Mobility (Percentage Probability of Contracting the Disease from an Adjacent Diseased 21 Individual, float) 22 IncP = Length of Incubation Period (Time Range in which the Disease does not produce 23 Symptoms (In an Infective Individual), array) 24 Mor = Morbidity (Percentage Probability of Infective Individuals Dying from the Disease, float) 25 Imn = Immunity (Percentage Probability of Individuals of Gaining Immunity After Recovery, 26 float) 27 RecP = Length of Recovery Period (Time Range in which the Disease is Present in an Individual, 28 array) 29 """ 30 31 ########################DEFINING PATIENT 32 CLASS################################# 33 34 import random 35 import matplotlib.pyplot as plt 36 import numpy as np 37 38 class Dossier(): #Creates an object (like list or array) that has its own modules 39 def __init__(self, x, y, PImmune, IncP, InfP, RecP): #Automatically run as soon as object is 40 created 41 #x and y - int 42 #PImmune - float 43 #IncP, InfP and RecP - lists 44 21 self.xLoc = x #Stores the inputted x location in the object 45 self.yLoc = y #Same as above 46 47 vaccination = random.random() 48 if vaccination <= PImmune: #If the "roll" is below the PImmune probability 49 self.Status = "IMMUNE" #The Individual becomes immune 50 else: self.Status = "SUSCEPTIBLE" #If not, the individual becomes susceptible 51 52 self.IncLen = random.choice(IncP) #Picks a incubation rate out of the IncP list 53 self.InfLen = random.choice(InfP) #Same as above for infectious rate 54 self.RecLen = random.choice(RecP) #Same as above for recovery rate 55 self.IncState = False #Sets incubation state as false 56 self.InfState = False #Same as above for infectious rate 57 self.RecState = False #Same as above for recovery rate 58 59 60 def Incubation(self, I, Imn): 61 self.IncLen -= 1 #When the function is called, it first decreases the incubation period 62 by 1 63 if self.IncLen >= 0: #While the incubation period is more than 0, the IncState is set to 64 True 65 self.IncState = True 66 else: self.IncState = False #Otherwise, the IncState is False. In other words, the 67 patient stops incubating. 68 69 if self.IncState == False: #Once the patient finishes incubating.. 70 luck = random.random() 71 if luck <= I: #If their "roll" is less than Infectivity... 72 self.Status = "INFECTIOUS" #They become Infectious 73 else: 74 antibody = random.random() #If their "roll" is more than Infectivity... 75 if antibody <= Imn: #If their "roll" is smaller than the Immunity 76 self.Status = "IMMUNE" #They become Immune. 77 else: self.Status = "SUSCEPTIBLE" #Otherwise, they become susceptible. 78 79 80 def Infection(self, Mor): #Same concepts as incubation. 81 self.InfLen -= 1 82 if self.InfLen >= 0: 83 self.InfState = True 84 else: self.InfState = False 85 86 if self.InfState == False: 87 hopesndreams = random.random() 88 22 if hopesndreams <= Mor: 89 self.Status = "DEAD" 90 else: self.Status = "INCUBATING" 91 92 93 def Recovery(self, Imn): #Activated when patient goes into incubation or infection 94 self.RecLen -= 1 95 if self.RecLen >= 0: 96 self.RecState = True 97 else: self.RecState = False 98 99 if self.RecState == False: 100 antibody = random.random() 101 if antibody <= Imn: 102 self.Status = "IMMUNE" 103 else: self.Status = "SUSCEPTIBLE" 104 105 def Copy(self): 106 new_pat = Dossier(self.xLoc, self.yLoc, 0, range(2,7), range(2,7), range(2,7)) 107 #^These input values doesn't matter cuz we're gonna update it anyway 108 new_pat.Status = self.Status 109 new_pat.IncLen = self.IncLen 110 new_pat.InfLen = self.InfLen 111 new_pat.RecLen = self.RecLen 112 new_pat.IncState = self.IncState 113 new_pat.InfState = self.InfState 114 new_pat.RecState = self.RecState 115 return new_pat 116 117 ############################DEFINING 118 FUNCTIONS################################# 119 120 def Spread(Mob, NBR): 121 if NBR.Status == "INFECTIOUS": 122 contagion = random.random() 123 if contagion <= Mob: #If the "roll" is lower than mobility, then the patient is infected 124 by the virus 125 return True 126 else: 127 return False 128 return False 129 130 def Plot(Patient, Population): 131 for P in range(1, Population+1): 132 23 x = Patient[P].xLoc 133 y = Patient[P].yLoc 134 135 if Patient[P].Status == 'SUSCEPTIBLE': 136 colour = "white" 137 elif Patient[P].Status == 'IMMUNE': 138 colour = "blue" 139 elif Patient[P].Status == 'INFECTIOUS': 140 colour = "red" 141 elif Patient[P].Status == 'INCUBATING': 142 colour = "yellow" 143 elif Patient[P].Status == 'DEAD': 144 colour = "black" 145 146 if colour == "white": 147 plt.plot(x, y, "wo") 148 elif colour == "blue": 149 plt.plot(x, y, "bo") 150 elif colour == "red": 151 plt.plot(x, y, "ro") 152 elif colour == "yellow": 153 plt.plot(x, y, "yo") 154 elif colour == "black": 155 plt.plot(x, y, "ko") 156 plt.show() 157 158 def DeepCopy(Old): #Takes in dict, returns deep copy 159 New = dict() 160 for i in range(1, len(Old)+1): 161 New[i] = Old[i].Copy() 162 return New 163 164 ########################FITTING 165 FUNCTIONS###################################### 166 if __name__ == "__main__": 167 SusFit = False 168 IncFit = False 169 InfFit = False 170 ImmFit = False 171 DeaFit = False 172 173 if SusFit: 174 SUSCEPTIBLEquery = [] 175 with open("SUSCEPTIBLEfit.csv", "r") as SUSCEPTIBLEfit: 176 24 for line in SUSCEPTIBLEfit: 177 SUSCEPTIBLEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 178 preset = SUSCEPTIBLEquery 179 status = "SusFit" 180 181 if IncFit: 182 INCUBATINGquery = [] 183 with open("INCUBATINGfit.csv", "r") as INCUBATINGfit: 184 for line in INCUBATINGfit: 185 INCUBATINGquery.append(tuple([int(x) for x in line[:-1].split(",")])) 186 preset = INCUBATINGquery 187 status = "IncFit" 188 189 if InfFit: 190 INFECTIOUSquery = [] 191 with open("INFECTIOUSfit.csv", "r") as INFECTIOUSfit: 192 for line in INFECTIOUSfit: 193 INFECTIOUSquery.append(tuple([int(x) for x in line[:-1].split(",")])) 194 preset = INFECTIOUSquery 195 status = "InfFit" 196 197 if ImmFit: 198 IMMUNEquery = [] 199 with open("IMMUNEfit.csv", "r") as IMMUNEfit: 200 for line in IMMUNEfit: 201 IMMUNEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 202 preset = IMMUNEquery 203 status = "ImmFit" 204 205 if DeaFit: 206 DEADquery = [] 207 with open("DEADfit.csv", "r") as DEADfit: 208 for line in DEADfit: 209 DEADquery.append(tuple([int(x) for x in line[:-1].split(",")])) 210 preset = DEADquery 211 status = "DeaFit" 212 213 """ 214 INPUTS: 215 time: the current time value 216 y: the current value of the function 217 query: the list of points (t, value) to fit against 218 OUTPUTS: 219 dy: the deviation from the query 220 25 """ 221 222 fit = False 223 if fit == True: 224 def Fit(time, y, query = preset): 225 for i in query: 226 if time == i[0]: 227 dy = y - i[1] 228 else: 229 dy = "NONE" 230 return dy 231 else: 232 fit = False 233 234 235 ###########################INITIALIZE 236 SIMULATION############################### 237 def main(job_id, params): 238 Parameters = [params["I"], params["InfP"], params["Mob"], params["IncP"], 239 params["Mor"], params["Imn"], params["RecP"]] 240 return StochasticEPIMOD(Parameters) 241 242 243 def StochasticEPIMOD(Parameters, xDimension = 20, yDimension = 20, tElapsed = 365, flux = 244 True, move_range = 0.5, Plot = True, Print = True, fit = fit): 245 #INITIAL VALUES 246 Population = xDimension*yDimension 247 248 #PARAMETERS 249 PImmune = 0.0 250 I = Parameters[0] #Percentage 251 InfP = range(int(Parameters[1])-3, int(Parameters[1])+4) 252 Mob = Parameters[2] #Percentage 253 IncP = range(int(Parameters[3])-3, int(Parameters[3])+4) 254 Mor = Parameters[4] #Percentage 255 Imn = Parameters[5] #Percentage 256 RecP = range(int(Parameters[6])-3, int(Parameters[6])+4) 257 258 #PATIENTS 259 Patient = dict() 260 ID = 0 261 Pos2Pat = np.zeros((yDimension, xDimension)) 262 for x in range(xDimension): 263 for y in range(yDimension): 264 26 ID += 1 265 Patient[ID] = Dossier(x, y, PImmune, IncP, InfP, RecP) 266 Pos2Pat[y,x] = ID 267 268 #GENERATING PATIENT ZERO 269 x = xDimension/2 270 y = yDimension/2 271 for P in range(1, ID+1): 272 if Patient[P].xLoc == x and Patient[P].yLoc == y: 273 Patient[P].Status = "INFECTIOUS" 274 275 Record = DeepCopy(Patient) 276 277 SUSCEPTIBLEtrend = [] 278 INCUBATINGtrend = [] 279 INFECTIOUStrend = [] 280 IMMUNEtrend = [] 281 DEADtrend = [] 282 283 residuals = [] 284 285 ###########################SIMULATION 286 BEGINS################################### 287 for t in range(tElapsed): 288 # Plot(Patient, Population) 289 for P in range(1,ID+1): 290 #STATUS PRIORITY: DEAD = IMMUNE > INFECTIOUS = INCUBATING > 291 SUSCEPTIBLE 292 if Record[P].Status == "SUSCEPTIBLE": 293 n = 8 294 x = Patient[P].xLoc 295 y = Patient[P].yLoc 296 while Patient[P].Status != "INFECTIOUS" and Patient[P].Status != 297 "INCUBATING" and n > 0: 298 if n == 8: 299 infection = Spread(Mob, Record[Pos2Pat[y,(x+1)%xDimension]]) 300 #Right 301 if infection == True: 302 infection = random.random() 303 if infection <= I: 304 Patient[P].Status = "INFECTIOUS" 305 else: Patient[P].Status = "INCUBATING" 306 elif n == 7: 307 infection = Spread(Mob, Record[Pos2Pat[y,(x-1)%xDimension]]) 308 27 #Left 309 if infection == True: 310 infection = random.random() 311 if infection <= I: 312 Patient[P].Status = "INFECTIOUS" 313 else: Patient[P].Status = "INCUBATING" 314 elif n == 6: 315 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,x]]) 316 #Above 317 if infection == True: 318 infection = random.random() 319 if infection <= I: 320 Patient[P].Status = "INFECTIOUS" 321 else: Patient[P].Status = "INCUBATING" 322 elif n == 5: 323 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,x]]) 324 #Below 325 if infection == True: 326 infection = random.random() 327 if infection <= I: 328 Patient[P].Status = "INFECTIOUS" 329 else: Patient[P].Status = "INCUBATING" 330 elif n == 4: 331 infection = Spread(Mob, 332 Record[Pos2Pat[(y+1)%yDimension,(x+1)%xDimension]]) #Upper Right 333 if infection == True: 334 infection = random.random() 335 if infection <= I: 336 Patient[P].Status = "INFECTIOUS" 337 else: Patient[P].Status = "INCUBATING" 338 elif n == 3: 339 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,(x-340 1)%xDimension]]) #Lower Left 341 if infection == True: 342 infection = random.random() 343 if infection <= I: 344 Patient[P].Status = "INFECTIOUS" 345 else: Patient[P].Status = "INCUBATING" 346 elif n == 2: 347 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,(x-348 1)%xDimension]]) #Upper Left 349 if infection == True: 350 infection = random.random() 351 if infection <= I: 352 28 Patient[P].Status = "INFECTIOUS" 353 else: Patient[P].Status = "INCUBATING" 354 elif n == 1: 355 infection = Spread(Mob, Record[Pos2Pat[(y-356 1)%yDimension,(x+1)%xDimension]]) #Lower Right 357 if infection == True: 358 infection = random.random() 359 if infection <= I: 360 Patient[P].Status = "INFECTIOUS" 361 else: Patient[P].Status = "INCUBATING" 362 n -= 1 363 364 elif Record[P].Status == "INFECTIOUS": 365 Patient[P].Recovery(Imn) 366 if Patient[P].RecState == True: #If the patient is still infectious... 367 Patient[P].Infection(Mor) 368 369 elif Record[P].Status == "INCUBATING": 370 Patient[P].Recovery(Imn) 371 if Patient[P].RecState == True: #If the patient is still incubating... 372 Patient[P].Incubation(I,Imn) 373 374 elif Record[P].Status == "IMMUNE": #Removed from population 375 pass 376 elif Record[P].Status == "DEAD": #Removed from population 377 pass 378 379 380 #UPDATE MOVING 381 if flux == True: 382 for x in range(xDimension): 383 for y in range(yDimension): 384 if Patient[Pos2Pat[y,x]].Status != "DEAD": 385 move = random.random() 386 if move <= move_range: 387 swap = random.randint(1, 4) 388 if swap == 1: #switch with above 389 oriID = Pos2Pat[y, x] 390 newID = Pos2Pat[(y+1)%yDimension, x] 391 Patient[oriID].yLoc = (y+1)%yDimension 392 Patient[newID].yLoc = y 393 Pos2Pat[y,x] = newID 394 Pos2Pat[(y+1)%yDimension, x] = oriID 395 396 29 elif swap == 2: #switch with below 397 oriID = Pos2Pat[y, x] 398 newID = Pos2Pat[(y-1)%yDimension, x] 399 Patient[oriID].yLoc = (y-1)%yDimension 400 Patient[newID].yLoc = y 401 Pos2Pat[y,x] = newID 402 Pos2Pat[(y-1)%yDimension, x] = oriID 403 404 elif swap == 3: #switch with left 405 oriID = Pos2Pat[y, x] 406 newID = Pos2Pat[y, (x-1)%yDimension] 407 Patient[oriID].xLoc = (x-1)%xDimension 408 Patient[newID].xLoc = x 409 Pos2Pat[y,x] = newID 410 Pos2Pat[y, (x-1)%yDimension] = oriID 411 412 elif swap == 4: #switch with right 413 oriID = Pos2Pat[y, x] 414 newID = Pos2Pat[y, (x+1)%yDimension] 415 Patient[oriID].xLoc = (x+1)%xDimension 416 Patient[newID].xLoc = x 417 Pos2Pat[y,x] = newID 418 Pos2Pat[y, (x+1)%yDimension] = oriID 419 SUSCEPTIBLE = 0 420 INFECTIOUS = 0 421 INCUBATING = 0 422 IMMUNE = 0 423 DEAD = 0 424 425 for P in range(1, ID+1): 426 if Patient[P].Status == "SUSCEPTIBLE": 427 SUSCEPTIBLE += 1 428 elif Patient[P].Status == "INFECTIOUS": 429 INFECTIOUS += 1 430 elif Patient[P].Status == "INCUBATING": 431 INCUBATING += 1 432 elif Patient[P].Status == "IMMUNE": 433 IMMUNE += 1 434 elif Patient[P].Status == "DEAD": 435 DEAD += 1 436 437 SUSCEPTIBLEtrend.append(SUSCEPTIBLE) 438 INCUBATINGtrend.append(INCUBATING) 439 INFECTIOUStrend.append(INFECTIOUS) 440 30 IMMUNEtrend.append(IMMUNE) 441 DEADtrend.append(DEAD) 442 443 if fit == True: 444 if status == "SusFit": 445 y = SUSCEPTIBLE 446 elif status == "IncFit": 447 y = INCUBATING 448 elif status == "InfFit": 449 y = INFECTIOUS 450 elif status == "ImmFit": 451 y = IMMUNE 452 elif status == "DeaFit": 453 y = DEAD 454 455 diffs = Fit(t, y) 456 if diffs != "NONE": 457 residuals.append(diffs**2) 458 459 Record = DeepCopy(Patient) 460 461 if Plot: 462 plt.plot(SUSCEPTIBLEtrend, "0.5", label = "SUSCEPTIBLE") 463 plt.plot(INCUBATINGtrend, "y", label = "INCUBATING") 464 plt.plot(INFECTIOUStrend, "r", label = "INFECTIOUS") 465 plt.plot(IMMUNEtrend, "b", label = "IMMUNE") 466 plt.plot(DEADtrend, "k", label = "DEAD") 467 468 plt.legend(loc="best") 469 plt.title("ebolaSTOinfSIM") 470 plt.ylabel("Number of Individuals") 471 plt.xlabel("Time (in days)") 472 # plt.show() 473 plt.savefig("ebolaSTOinfSIM2.pdf") 474 475 if Print: 476 print "SUSCEPTIBLE = %i" %SUSCEPTIBLE 477 print "INFECTIOUS = %i" %INFECTIOUS 478 print "INCUBATING = %i" %INCUBATING 479 print "IMMUNE = %i" %IMMUNE 480 print "DEAD = %i" %DEAD 481 print "Percent Dead = %f" %(float(DEAD)/float(Population)) 482 483 return abs(sum(residuals)) 484 31 # PercentDead = float(DEAD)/float(Population) 485 # return PercentDead 486 487 if __name__ == "__main__": 488 StochasticEPIMOD([0.6834, 14, 0.0163, 19, 0.9512, 0.8861, 22]) 489 32 """ 1 STOCHASTIC EPIDEMIC MODEL 2 Uma Wu & LiQing Wang 3 4 Discussed With: Noah Bayless, Michael Gelbart 5 ------------------------------------------------------------------------------- 6 #####PATIENT INFORMATION##### 7 xLoc = range(0, x_Dim) 8 yLoc = range(0, y_Dim) 9 Status = IMMUNE, SUSCEPTIBLE, INFECTIOUS, INCUBATING, or DEAD 10 tExist = time elapsed since start of simulation 11 tInc = time incubating 12 tInf = time infectious 13 tRec = time recovering 14 15 16 #####PARAMETERS##### 17 PImmune = Pre-Immunity (PERCENTAGE PROBABILITY of Population that is Pre-Immune to 18 Disease, float) 19 I = Infectivity (PERCENTAGE PROBABILITY of Displaying Symptoms When Infected, float) 20 InfP = Length of Infectious Period (TIME RANGE in which the Disease is Infectious, array) 21 Mob = Mobility (PERCENTAGE PROBABILITY of Contracting the Disease from an Adjacent 22 Diseased Individual, float) 23 IncP = Length of Incubation Period (TIME RANGE in which the Disease does not produce 24 Symptoms (In an Infective Individual), array) 25 Mor = Morbidity (PERCENTAGE PROBABILITY of Infective Individuals Dying from the Disease, 26 float) 27 Imn = Immunity (PERCENTAGE PROBABILITY of Individuals of Gaining Immunity After Recovery, 28 float) 29 RecP = Length of Recovery Period (TIME RANGE in which the Disease is Present in an Individual, 30 array) 31 """ 32 33 from StochasticEPIMOD1 import Dossier 34 from StochasticEPIMOD1 import Spread 35 from StochasticEPIMOD1 import Plot 36 from StochasticEPIMOD1 import DeepCopy 37 38 import random 39 import matplotlib.pyplot as plt 40 import numpy as np 41 from scipy.optimize import minimize 42 43 44 33 def main(job_id, params): 45 Parameters = [params["I"], params["InfP"], params["Mob"], params["IncP"], 46 params["Mor"], params["Imn"], params["RecP"]] 47 return -StochasticEPIMOD(Parameters) 48 49 def StochasticEPIMOD(Parameters, xDimension = 20, yDimension = 20, tElapsed = 365, flux = 50 True, move_range = 0.5, Plot = False, Print = False): 51 #INITIAL VALUES 52 Population = xDimension*yDimension 53 54 #PARAMETERS 55 PImmune = 0.0 56 I = Parameters[0] #Percentage 57 InfP = range(int(Parameters[1])-3, int(Parameters[1])+4) 58 Mob = Parameters[2] #Percentage 59 IncP = range(int(Parameters[3])-3, int(Parameters[3])+4) 60 Mor = Parameters[4] #Percentage 61 Imn = Parameters[5] #Percentage 62 RecP = range(int(Parameters[6])-3, int(Parameters[6])+4) 63 64 #PATIENTS 65 Patient = dict() 66 ID = 0 67 Pos2Pat = np.zeros((yDimension, xDimension)) 68 for x in range(xDimension): 69 for y in range(yDimension): 70 ID += 1 71 Patient[ID] = Dossier(x, y, PImmune, IncP, InfP, RecP) 72 Pos2Pat[y,x] = ID 73 74 #GENERATING PATIENT ZERO 75 x = xDimension/2 76 y = yDimension/2 77 for P in range(1, ID+1): 78 if Patient[P].xLoc == x and Patient[P].yLoc == y: 79 Patient[P].Status = "INFECTIOUS" 80 81 Record = DeepCopy(Patient) 82 83 ###########################SIMULATION 84 BEGINS################################### 85 for t in range(tElapsed): 86 for P in range(1,ID+1): 87 #STATUS PRIORITY: DEAD = IMMUNE > INFECTIOUS = INCUBATING > 88 34 SUSCEPTIBLE 89 if Record[P].Status == "SUSCEPTIBLE": 90 n = 8 91 x = Patient[P].xLoc 92 y = Patient[P].yLoc 93 while Patient[P].Status != "INFECTIOUS" and Patient[P].Status != 94 "INCUBATING" and n > 0: 95 if n == 8: 96 infection = Spread(Mob, Record[Pos2Pat[y,(x+1)%xDimension]]) 97 #Right 98 if infection == True: 99 infection = random.random() 100 if infection <= I: 101 Patient[P].Status = "INFECTIOUS" 102 else: Patient[P].Status = "INCUBATING" 103 elif n == 7: 104 infection = Spread(Mob, Record[Pos2Pat[y,(x-1)%xDimension]]) 105 #Left 106 if infection == True: 107 infection = random.random() 108 if infection <= I: 109 Patient[P].Status = "INFECTIOUS" 110 else: Patient[P].Status = "INCUBATING" 111 elif n == 6: 112 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,x]]) 113 #Above 114 if infection == True: 115 infection = random.random() 116 if infection <= I: 117 Patient[P].Status = "INFECTIOUS" 118 else: Patient[P].Status = "INCUBATING" 119 elif n == 5: 120 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,x]]) 121 #Below 122 if infection == True: 123 infection = random.random() 124 if infection <= I: 125 Patient[P].Status = "INFECTIOUS" 126 else: Patient[P].Status = "INCUBATING" 127 elif n == 4: 128 infection = Spread(Mob, 129 Record[Pos2Pat[(y+1)%yDimension,(x+1)%xDimension]]) #Upper Right 130 if infection == True: 131 infection = random.random() 132 35 if infection <= I: 133 Patient[P].Status = "INFECTIOUS" 134 else: Patient[P].Status = "INCUBATING" 135 elif n == 3: 136 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,(x-137 1)%xDimension]]) #Lower Left 138 if infection == True: 139 infection = random.random() 140 if infection <= I: 141 Patient[P].Status = "INFECTIOUS" 142 else: Patient[P].Status = "INCUBATING" 143 elif n == 2: 144 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,(x-145 1)%xDimension]]) #Upper Left 146 if infection == True: 147 infection = random.random() 148 if infection <= I: 149 Patient[P].Status = "INFECTIOUS" 150 else: Patient[P].Status = "INCUBATING" 151 elif n == 1: 152 infection = Spread(Mob, Record[Pos2Pat[(y-153 1)%yDimension,(x+1)%xDimension]]) #Lower Right 154 if infection == True: 155 infection = random.random() 156 if infection <= I: 157 Patient[P].Status = "INFECTIOUS" 158 else: Patient[P].Status = "INCUBATING" 159 n -= 1 160 161 elif Record[P].Status == "INFECTIOUS": 162 Patient[P].Recovery(Imn) 163 if Patient[P].RecState == True: #If the patient is still infectious... 164 Patient[P].Infection(Mor) 165 166 elif Record[P].Status == "INCUBATING": 167 Patient[P].Recovery(Imn) 168 if Patient[P].RecState == True: #If the patient is still incubating... 169 Patient[P].Incubation(I,Imn) 170 171 elif Record[P].Status == "IMMUNE": #Removed from population 172 pass 173 elif Record[P].Status == "DEAD": #Removed from population 174 pass 175 176 36 177 #UPDATE MOVING 178 if flux == True: 179 for x in range(xDimension): 180 for y in range(yDimension): 181 if Patient[Pos2Pat[y,x]].Status != "DEAD": 182 move = random.random() 183 if move <= move_range: 184 swap = random.randint(1, 4) 185 if swap == 1: #switch with above 186 oriID = Pos2Pat[y, x] 187 newID = Pos2Pat[(y+1)%yDimension, x] 188 Patient[oriID].yLoc = (y+1)%yDimension 189 Patient[newID].yLoc = y 190 Pos2Pat[y,x] = newID 191 Pos2Pat[(y+1)%yDimension, x] = oriID 192 193 elif swap == 2: #switch with below 194 oriID = Pos2Pat[y, x] 195 newID = Pos2Pat[(y-1)%yDimension, x] 196 Patient[oriID].yLoc = (y-1)%yDimension 197 Patient[newID].yLoc = y 198 Pos2Pat[y,x] = newID 199 Pos2Pat[(y-1)%yDimension, x] = oriID 200 201 elif swap == 3: #switch with left 202 oriID = Pos2Pat[y, x] 203 newID = Pos2Pat[y, (x-1)%yDimension] 204 Patient[oriID].xLoc = (x-1)%xDimension 205 Patient[newID].xLoc = x 206 Pos2Pat[y,x] = newID 207 Pos2Pat[y, (x-1)%yDimension] = oriID 208 209 elif swap == 4: #switch with right 210 oriID = Pos2Pat[y, x] 211 newID = Pos2Pat[y, (x+1)%yDimension] 212 Patient[oriID].xLoc = (x+1)%xDimension 213 Patient[newID].xLoc = x 214 Pos2Pat[y,x] = newID 215 Pos2Pat[y, (x+1)%yDimension] = oriID 216 SUSCEPTIBLE = 0 217 INFECTIOUS = 0 218 INCUBATING = 0 219 IMMUNE = 0 220 37 DEAD = 0 221 222 for P in range(1, ID+1): 223 if Patient[P].Status == "SUSCEPTIBLE": 224 SUSCEPTIBLE += 1 225 elif Patient[P].Status == "INFECTIOUS": 226 INFECTIOUS += 1 227 elif Patient[P].Status == "INCUBATING": 228 INCUBATING += 1 229 elif Patient[P].Status == "IMMUNE": 230 IMMUNE += 1 231 elif Patient[P].Status == "DEAD": 232 DEAD += 1 233 234 Record = DeepCopy(Patient) 235 236 PercentDead = float(DEAD)/float(Population) 237 return PercentDead 238 239 def Average(Parameters, tests = 1000): 240 total = 0.0 241 results = np.zeros(tests) 242 for n in range(tests): 243 results[n] = float(StochasticEPIMOD(Parameters)) 244 print n 245 print np.mean(results) 246 print np.std(results) 247 print results 248 return np.mean(results), np.std(results), results 249 250 data = open("StochasticEPIMOD1SARSresultsDEAD.txt", "w") 251 252 Combination = [0.2860000, 9, 0.256050, 5, 0.34989, 0.462340, 17] 253 average, stdev, results = Average(Combination) 254 255 data.write("Average: %f" %average) 256 data.write("Standard Deviation: %f" %stdev) 257 for i in range(len(results)-1): 258 data.write("%f" %results[i]) 259 260 261 38 0.1 0.91525 0.1 0.87414 0.1 0 0.1 0.91696 0.1 0.72152 0.1 0.57796 0.1 0.81512 0.2 0.92258 0.2 0.89061 0.2 0 0.2 0.92245 0.2 0.82444 0.2 0.37337 0.2 0.69716 0.3 0.91566 0.3 0.90209 0.3 0.4279 0.3 0.91401 0.3 0.86564 0.3 0.24622 0.3 0.57964 0.4 0.8965 0.4 0.91003 0.4 0.68413 0.4 0.89352 0.4 0.88763 0.4 0.15879 0.4 0.46093 0.5 0.86648 0.5 0.91542 0.5 0.79698 0.5 0.86229 0.5 0.90095 0.5 0.09498 0.5 0.33827 0.6 0.82672 0.6 0.91895 0.6 0.85485 0.6 0.82146 0.6 0.9095 0.6 0.0466 0.6 0.20618 0.7 0.7782 0.7 0.9211 0.7 0.88673 0.7 0.77197 0.7 0.91513 0.7 0.00002 0.7 0.00002 0.8 0.72177 0.8 0.92223 0.8 0.90518 0.8 0.71465 0.8 0.91884 0.8 0 0.8 0 0.9 0.65814 0.9 0.92258 0.9 0.91627 0.9 0.65022 0.9 0.92123 0.9 0 0.9 0 1 0.58794 1 0.92235 1 0.92314 1 0.57929 1 0.9227 1 0 1 0 Infectivity Percentage Death Infection Rate Percentage Death Mobility Percentage Death Incubation Rate Percentage Death Mortality Percentage Death Percentage Immunity Percentage Death Recovery Rate Percentage Death 39 PARAMETERS STOCHASTIC DETERMINISTIC Initially Susceptible Population/ Total Population (Pop) N/A: There was not enough computational power to simulate population as a parameter. (PHASE I only) Total number of people in each compartment. Remains constant throughout simulation Infectivity (I) Percentage Probability of Population that Displays Symptoms When Infected Percentage of Population that Displays Symptoms When Infected Length of Infectious Period (InfP) (+/-3) Possible Time Range in which the Disease is Infectious Time in which the Disease is Infectious Mobility (Mob) Percentage Probability of Contracting the Disease from an Adjacent Diseased Individual Number of Healthy Individuals that a Diseased Individual may Infect Length of Incubation Period (IncP) (+/-3) Possible Time Range in which the Disease does not produce Symptoms (In an Infective Individual) Time in which the Disease does not produce Symptoms (In an Infective Individual) Length of Recovery Period (RecP) (+/-3) Possible Time Range in which the Disease is Present in an Individual Time in which the Disease is Present in an Individual Mortality (Mor) Percentage Probability of Infective Individuals Dying from the Disease Percentage of Infective Individuals Dying from the Disease Immunity (Imn) Percentage Probability of Individuals of Gaining Immunity After Recovery Percentage of Individuals that Gain Immunity Upon Recovery 40 SARS Data points for Fitting 153 78 158 98 159 103 165 144 166 154 186 461 187 478 188 495 189 506 202 666 204 689 210 750 211 754 216 772 221 784 228 799 229 799 231 804 238 809 239 810 242 811 243 812 244 812 249 812 252 812 41 Ebola Data Points for Fitting 7 24 279 12713 312 13697 347 14487 382 15151 413 15854 446 16236 479 16470 510 16763 42 0 The Last Plague Investigating the Lethality of Pandemics Using Deterministic and Stochastic Epidemic Models Co-Authors: Li Qing Wang & GuanYue (Uma) Wu Faculty Advisor: James D. Berger SCI001 T2 Project March 9, 2016 1 Abstract This project investigates the effects of seven parameters on the spread of viral epidemics: infectivity, infectious period, mobility, incubation period, mortality, immunity and recovery period. Two algorithms were created to simulate the progression – one stochastic, and one deterministic. While the deterministic model simulates the spread through regulating the flux between compartments, the stochastic model simulates the spread by applying the parameters as a set of probabilities. The models were calibrated with current data on SARS and Ebola from WHO. Using optimization methods, we found the characteristics of viral diseases that would lead to the most lethal disease, marked by death rates of 92.26% of the world population in the deterministic model and 98.76% in the stochastic model. By investigating the effect of each parameter on the disease, we found that the key factors in regulating the spread of an epidemic are percentage immunity, mobility and recovery rate. Introduction Scientific question: what parameter values define the most deadly disease possible, and how do they each contribute to the epidemic? An epidemic is defined as a sudden spread of a disease that affects an unexpectedly high number of people in a certain population [1]. The determinant factors for the lethality examined in this study include infectivity, infectious period, mobility, incubation period, mortality, immunity and recovery period (refer to Appendix Pages for definitions). Although we are working with simulated diseases, the combination of parameters that define a “super viral disease” is important because any of these combinations may be present in a future infection. Therefore, by knowing the most dangerous aspects of an infectious disease, we can better focus our resources to counteract it. This project has four phases: 0, I, II and III. The model is developed in Phase 0, calibrated in Phase I and used to answer our scientific question in Phases II and III. The models use the susceptible-infected-removed model with a few more compartments to provide insight into the effect of each on the spread of diseases. The deterministic model is a closed model. The flux in and out of the compartments is represented as a series of differential equations. In order to optimize this program for certain desired outputs, the L-BFGS-B method was implemented [14]. The stochastic model is also closed, but it relies on a matrix system instead. To optimize this program for desired outputs, the Bayesian Optimization package Spearmint was implemented. Different sets of parameters can contribute to the same death rate; therefore, further analysis was done to find the trend in those combinations. 2 Procedure Phase 0 Principle Objective: To create the deterministic and stochastic models Deterministic Assumption 1: The parameters remain constant throughout the simulation. Justification: This means the effects of borders, quarantines, cures, and other currently implementable disease-control tactics are unavailable. The implementation of these features would impede the observations on the spread of the disease amidst all of the other elements affecting it. FIGURE 1: Flowchart of Deterministic Model. [For the complete code, refer to Appendix Pages 10-16] Stochastic -See also Assumptions 1 for the Deterministic Model- Assumption 1: The disease can only spread between adjacent individuals. Justification: While it is possible to simulate the disease spreading as a function of the total number of infected/incubating individuals regardless of their position in the simulated matrix, it defeats the point of having a stochastic process. Assumption 2: The parameter values produced by optimizing the program are scalable and will produce around the same proportions between individuals of different states regardless of population size. Justification: The spread of the disease overall have the same progression as long as the population is >9, since the disease needs to be spreading between unique individuals. This has been verified. 3 FIGURE 2: Flowchart of one individual’s possible status within Stochastic Model [For the complete code, refer to Appendix Pages 21-32] Phase I Principle Objective: Fitting and calibrating the program to real disease data Cumulative data on the number of cases, recoveries and deaths for SARS and cumulative data on the number cases and deaths for Ebola were collected from the World Health Organization (WHO) website [7, 11]. Target points were chosen for the simulations to fit. The best trend line for each category of data was found by minimizing the coefficient of determination (R2) to a value below a biological alpha of 5% with respect to the population using minimize function L-BFGS-B. For each disease, the category of data with the highest number of data points on the trend line was selected, and target points were chosen from these points. The death data and infected data for SARS and Ebola were used, respectively. The selected data points were representative of the trend of the disease, and minimized the noise in the raw data. [For the raw data used to fit the data points, refer to Appendix Pages 1-7.] Phase II Principal Objective: Finding the Parameters that result in the most deadly pandemics In both models, the functions representing the simulation were reconfigured to return the negative maximum percentage of the population that is dead over the time frame of a year. Deterministic - L-BFGS-B The percentage mortality is maximized using the L-BFGS-B gradient evaluation method. The L-BFGS-B evaluates the derivative of the gradient from a given starting point and follows the slope to find a local minimum. To counteract the possibility of multiple minima within our function, multiple parameter sets were generated (~10000) to ideally produce as many minima 4 as possible. Among these, the ones with the highest death rates were selected for analysis. Stochastic - Spearmint The Spearmint package uses Bayesian Optimization in a global black-box operation in order to find the global minimum of a function. This experiment required no more than using Spearmint to find the global minimum of the Stochastic outputs while minimizing the noise that comes from the random factors that govern its processes. Assumption: everyone was susceptible. Justification: if a significant fraction of a population is pre-immune, the disease may not become an epidemic at all. Phase III Principal Objective: investigating the effect of each parameter on percentage death independently. While keeping other parameters at the values that lead to the most deadly disease, each parameter in the deterministic program was varied independently from 0.1~1.0, in increments of 10%. The output percentage death, defined by the percentage of the world population dying from the disease, was recorded. Results Each of the following sets of parameters fit the respective disease data collected from WHO with the sum of residuals squared indicated. PHASE I RESULTS Deterministic Fitting Results (PHASE I) (FIGURE 3) EBOLA SARS SARS Infectivity 62.9133% 12.2454% 63.4744% Infection Rate 30.6023% 98.3275% 37.0586% Mobility 99% 98.211% 76.4858% Incubation Period 1.395 101.01 150.443 Incubation Rate 71.68% 99% 0.6647% Mortality 46.2063% 42.6484% 29.8424% Percent Immunity 0.1% 0.1% 0.9516% Recovery Rate 10.6243% 43.7013% 32.6739% Population 6990000000 1795595082 1407579615 Residual Sum 2.546% of Pop 0.0083558% of Pop. 0.0081459% of Pop Stochastic Fitting Results (PHASE I) (FIGURE 4) EBOLA SARS Infectivity 99% 43.14% Infectious Period 25 11 Mobility 27.6382% 40.22% Incubation Period 23 12 5 Mortality 36.72% 13.79% Percentage Immunity 50.266% 85.85% Recovery Period 28 11 Population Any Any Standard Deviation 0.022747 0.022434 FIGURE 5.2: Plots of epidemic progression as generated by Deterministic Model & SARS Data Simulated SARS (Parameter Set 2) Simulated SARS (Parameter Set 1) FIGURE 5.1: Plots of epidemic progression as generated by Deterministic Model & SARS Data 6 Simulated Ebola FIGURE 6: Plot of epidemic progression as generated by Deterministic Model & Ebola Data FIGURE 7: Plot of epidemic progression as generated by Stochastic Model & SARS Data 7 Model Disease Estimated Basic Reproductive Number R0 from Literature [3, 15] Deterministic SARS 2.25 0.24-2.47, 2.87 2.4-3.6 (Re) Deterministic SARS 1.13 Deterministic Ebola 2.88 1.50-2.67 Stochastic Ebola 1.12 Stochastic SARS 1.0 0.24-2.47, 3.87 2.4-3.6 (Re) FIGURE 9: Estimation of Basic Reproduction Number FIGURE 8: Plot of epidemic progression as generated by Stochastic Model & EBOLA Data 8 PHASE II RESULTS Deterministic Stochastic Infectivity 19.82% Infectivity 99% Infectious Period 1.124 Infectious Period 14 Infection Rate 90.53% Infection Rate 7.14% Mobility 99.00% Mobility 65.61% Incubation Period 7.731 Incubation Period 4 Incubation Rate 18.65% Incubation Rate 25% Mortality 99.00% Mortality 90.45% Percentage Immunity 1.0% Percentage Immunity 0.00% Recovery Rate 1.0% Recovery Rate 4% Recovery Period 100 Recovery Period 25 Percentage Dead 92.26% Percentage Dead 98.76% FIGURE 10: Parameters that constitute the most lethal disease in each model Average Standard Deviation Maximum Minimum Infectivity 19.82362286% 9.03404125% 37.5849% 1.5306% Infectious Period 1.123803493 0.1633870674 1.6784099416 1.010101 Infectious Rate 90.53117143% 11.04190317% 99% 59.5802% Mobility 99% 0% 99% 0.99 Incubation Period 7.7306150843 7.0662311461 38.6085479325 2.6623430216 Incubation Rate 18.64900571% 8.47061018% 37.5609% 2.5901% Mortality 99% 0% 99% 99% Percentage Immunity 1% 0% 1% 1% Recovery Rate 1% 0% 1% 1% Percentage Dead 92.25818% 8.622e-4% 92.2588% 92.2555% FIGURE 11: PHASE II Deterministic Parameter Features 9 Deterministic Model The data shows parameter values that contribute to the most deadly disease predicted by the deterministic model. (Figure 10) The disease is infectious slightly over 1 day. A diseased individual may infect 99% of the healthy people he meets. Only 19.82% of infecteds will display symptoms after infection. Other individuals do not show any symptom until 7.7 days after infection. 99% of infected individuals will die from the disease, and only 1% will gain immunity. Infected individuals, if capable of recovering from the disease, take 100 days to do so. FIGURE 12: Trend of optimized pandemic (Deterministic) 10 Stochastic Model The data shows parameter values that contribute to the most deadly disease predicted by the stochastic model. (Figure 10) The disease incubates for 4 days. There is a 99% chance that an infected population will display symptoms of the disease, and the disease is infectious over a span of two weeks. A healthy individual has a 65.61% chance of contracting the disease from an infectious individual in close proximity. Infected individuals have a 90.45% chance of dying from the disease. No one can develop immunity against this disease, but individuals can recover from the disease over a period of 25 days. FIGURE 13: Trend of optimized pandemic (Stochastic) 11 FIGURE 14.1: Incubation Period compared to Infectivity FIGURE 14.2: Percentage Death compared to Incubation Period FIGURE 14.3: Incubation Period compared to Infection Rate 12 PHASE III RESULTS Infectivity Infectious Period Mobility Incubation Period Mortality Percentage Immunity Recovery Rate ≤30% 1-2 days ≥20% 5-10 days any ≤70% ≤70% FIGURE 15: Table of criteria for a significant drop in population as a result of an epidemic Analysis Analysis of PHASE I Data Estimation of Basic Reproduction Number The basic reproduction number characterizes the ability of a disease to spread, and is calculated by dividing the infection rate by recovery rate. On the other hand, the effect reproduction number (Re) represents the observed number of secondary infections from a primary infection. Since the two are sometimes used interchangeably in literature, both values were obtained from literature as references. Two sets of parameters were selected for SARS because both provided R0 that were within the literature range. No statistical comparison was feasible between our results and the literature values due to the limitations of the model. However, it is clear that the Ro estimated by both models (Figure 9) generally adhered to what was reported from the literature. The deterministic model generally predicts a higher R0 than the stochastic model. Incubation Periods The stochastic model predicted a more reasonable incubation period for each disease compared to the deterministic one. The actual incubation periods for SARS and Ebola are up to two weeks [16] and up to 21 days [17], respectively. Both of these adhere significantly more to the stochastic results. Deterministic vs. Stochastic Comparing the shapes of the graphs of simulated SARS and Ebola produced by both models to the graphs of raw disease data, the stochastic model is clearly a better model than the deterministic one. The stochastic model is a better fit for the randomness in the nature of disease spread, unlike the deterministic. Combining this with analyses of estimated R0 and incubation period, the stochastic model seemed to have produced a lower residual for each disease (See Appendix Graphs). 13 Analysis of PHASE II Data A Holistic Analysis of PHASE II Deterministic Data This is done to deterministic only due to the various sets of optimized parameters it produced, all of which produced the desired maximal death rate. Of the 10000 parameter sets, 34 representative ones were selected for analysis. The standard deviation for each parameter was computed using 34 sets of parameters that yield a percentage death of 92.26%. Since the standard deviation of mobility, mortality, percentage immunity and recovery are zero, these parameters must be at a specific value to result in the most lethal epidemic. Therefore, any changes made to those parameters alone will result in a death rate deviating from 92.26%. The disease has high mobility (99%), high mortality (99%), low immunity (1%) and low recovery rate (1%). Infectivity can range from 1.53% to 37.58%, infection rate can range from 59.58% to 99% and incubation period can range from 2.66 ~ 38.61 days. A clear correlation between incubation period and infectivity can be observed below (Figure 14.1). When infectivity is below 20%, incubation period is less than a week. As infectivity goes beyond 20%, incubation period increases drastically and can be as high as 38 days. Therefore, as shown in Figures 14.1-3, a combination of the following qualities is most likely to happen and will lead to a 92.26% death rate: 1.53% ~26.21% infectivity, a short infectious period of 1~1.33 days, 99% mobility, within two weeks of incubation, 99% mortality, 1% immunity and1% recovery. 14 Discussion Accuracy & Precision The accuracy of either models can be defined by how replicable the results are. The deterministic model is completely accurate since the same parameters will always yield the same output. Therefore, the accuracy of deterministic model is not representative of its uncertainty, since no model can have 0 uncertainty. However, for the stochastic model, standard deviations of outputs were determined. The standard deviation of the phase II result, (0.005512%), defines the uncertainty of the model since it is purely based on the outputs of the program and does not depend on any data. This small standard deviation indicates an accurate model. The precision of either models can be defined as how well it fits to the real data in Phase I. This was obtained by fitting the simulation to the real data by minimizing the residuals. The stochastic model’s precision cannot be determined through its precision due to the restraint in runtime as a function of population (it can only fit the trend), and is therefore not representative of its uncertainty. The deterministic model does yield a wide array of residuals, however. In our fitting of the data, the lowest residual was 2.546% of Population with Ebola, while the two SARS fittings yielded 0.0083558% of population and 0.0081459% of population respectively. Since the percentages are less than 5%, the model is likely precise. Limitations Limitations of Collected Data Inconsistency in WHO data The cumulative number of SARS cases fluctuated for the last few days for which data were collected. SARS is a diagnosis of exclusion; as previous cases were further investigated, some patients were re-examined and re-diagnosed [6]. Since the fluctuation only involved a few individuals, we disregarded the occasional decrease, and recorded further data by adding the number of newly dead people to the cumulative number. Limitation of Obtainable Categories of Data While there are 7 parameters, only the aforementioned 3 had available data. Limitations of Model 1. Quarantine & Borders In April 2003, the Chinese government started implementing quarantine and restricting social interactions by methods such as closing theatres and implementing border control [4]. Quarantine would limit the mobility of the disease; however, this is not accounted for in the model. (See Assumptions) 2. Parameters change with time The parameters in both models are constant over time, while in reality they do change with 15 time. For example, the mortality of both disease increased with time. Run Time Constraints Deterministic The deterministic model does not take long to complete one function evaluation (~0.1s for Population = 7000000000) due to its nature as a linear-time computation, but its optimization took much longer due to the methodology of the L-BFGS-B method of evaluating the function multiple times until it reached a local minimum. Therefore, a global optimization would have been better for this instance. Stochastic The stochastic model takes a lot longer than the deterministic (~1s for Population = 400) to complete one function evaluation. With the Spearmint Optimization package, we were able to bypass that issue. Not only does Spearmint find the global minimum, it only takes around 5 hours to yield applicable and accurate results. However, it is still subject to the limitations of populations, since the run time increases linearly with the addition of an individual. Inferences Deterministic Phase II Summary: The most deadly disease according to the deterministic model is a disease that doesn’t show symptoms immediately (19.82% infectivity), transmits quickly from person to person (99% mobility), almost certainly and immediately kills its host upon infection (99% mortality), and is almost impossible to develop immunity from (only 1% of the population can become immune). . This disease can kill 92.26 % of the world population in one year. This set of parameters produces a greater incubating population than infectious population. There are many currently known viruses that can remain dormant in individuals (e.g Rabies, STDs) for a relatively long time before manifesting symptoms. The disease may cover its lethality by displaying nonlethal typical flu symptoms as fever, cough and diarrhea when individuals are first infected, thus creating a high incubating population. This feature of the simulated disease greatly contributes to the risk of unknowingly getting infected since the number of susceptible people becoming incubating is dependent on both the number of carriers (infecteds) and susceptibles. Stochastic Phase II Summary: The most deadly disease according to the stochastic model is one that shows symptoms almost immediately (99% infectivity), transmits at a moderate rate (65.61%) from person to person, is infectious over two weeks, and is develop immunity. This disease can kill 98.76% of the world population in one year. Instead of a high mobility, the disease becomes highly infective with a small incubation period, which means the patients would immediately show symptoms upon infection. A zero percent immunity means that even if a patient did manage to survive, they would become susceptible again with another chance of being infected and eventually succumbing to the 16 disease. This disease resembles past epidemics such as AIDS, since it mutates very quickly and suppresses the immune system. The disease would exhibit symptoms that lead to more infection and eventually death, such as skin lesions (e.g smallpox), discharging fluids (e.g diarrhea), and even irregular behavior (e.g rabies patients may bite other individuals). 17 Figure 16.1 The percentage dead seems to decrease somewhat linearly with increased recovery rate when the recovery rate is lower than 70%. A recovery rate of 70% seems to be a threshold beyond which the disease is no longer an epidemic. Figure 16.2 A disease with low mortality (10%) can have a high percentage death (~70%). The percentage death increase by ~10% in response to a 10 fold increase in mortality. This may indicate that the mortality of a disease is not the major determinant of its percentage death. Deterministic Phase III results and inferences Since the purpose of Phase III is purely making inferences, its results will be shown here along with the inferences. 18 Figure 16.3 A disease for which an infected can only spread the infection to less than 20% of the people he contacts will not cause an epidemic. The percentage death increases drastically with the increase in mobility. This suggests that mobility is a major determinant in the spread of a disease. Figure 16.4 As incubation rate increases, or as the length of incubation period decreases, the percentage death decreases. 19 Figure 16.5 The larger the fraction of the infected population that shows symptoms, the less deadly the disease becomes. This may suggest that a disease must not let the patients display symptoms immediately in order to let it spread unknowingly, and eventually kill a large percentage of the world population. Figure 16.6 The disease is the most deadly when zero percent of the population is immune to it. The death rate decreases with increased immunity. There seems to be a threshold at 70% immunity, beyond which the disease is essentially no longer an epidemic. 20 Key Inferences and Observations In agreement with what was observed in phase II, any deviation from the set of the most deadly parameters led to a decrease in percentage death. However, this phase allowed a closer investigation of the magnitude of such effect. For example, the mortality barely alters the percentage death while independent changes in mobility, recovery rate, and percentage immunity led to much greater changes. The effect of infection rate, incubation rate, and infectivity is somewhere in between. Some threshold values were observed in percentage immunity (≤70%), mobility (≥20%) and recovery rate (≤70%). These three parameters are the major contributors to the percentage death of an epidemic; however, they must reach a certain threshold level for a disease to become an epidemic. These three parameters need to be regulated in order to prevent or control the spread of epidemic most efficiently. As a summary of phase III, a chart of criteria for the most lethal epidemic predicted by the deterministic model was produced (figure 15). If an outbreak is suspected and several of its parameters fall into these values, it is likely to develop into a fairly lethal epidemic. Such disease can then be most effectively regulated by controlling percentage immunity, mobility and recovery rate. Figure 16.7 A low infection rate such as 10% can lead to a death percentage of ~87%. The increase in infection rate from 10% to 70% causes the most increase in percentage death. Beyond that, the increase in infection rate has minute effect on percentage death. 21 Conclusion Both the deterministic and stochastic models developed are able to fit realistic disease data and predict combinations of parameters that would lead to the most deadly epidemic. Both models also predict a high death rate when the chances of developing immunity are low, indicating the threat of an immune-suppressive disease is especially high. Ranges of values for each parameter that constitute the most lethal epidemic outlined can be used to assess the lethality of a real disease. With further development, future potentials of this pair of models include investigation of other viral diseases, predicting the outcome of a disease in real time, and modelling the effect of prevention and control methods on the epidemic. References [1]"Lesson 1: Introduction to Epidemiology." Centers for Disease Control and Prevention. Centers for Disease Control and Prevention, 2012. Web. 11 Mar. 2016. [2]"Learning Basic Epidemic Models with Python." Learning Basic Epidemic Models with Python. Web. 11 Mar. 2016. [3]"Estimating the Reproduction Number of Ebola Virus (EBOV) During the 2014 Outbreak in West Africa – PLOS Currents Outbreaks." PLOS Currents Outbreaks. Web. 11 Mar. 2016. [4]"SARS Reference | SARS Timeline." SARS Reference | SARS Timeline. Web. 11 Mar. 2016. [5]"The SIR Model for Spread of Disease - The Differential Equation Model." The SIR Model for Spread of Disease. Web. 11 Mar. 2016. [6] "Cumulative Number of Reported Probable Cases of SARS." WHO. Web. 13 Mar. 2016. <http://www.who.int/csr/sars/country/2003_07_09/en/>. [7]"Cumulative Number of Reported Probable Cases of Severe Acute Respiratory Syndrome (SARS)." WHO. Web. 11 Mar. 2016. [8]"WHO IRIS: Consensus Document on the Epidemiology of Severe Acute Respiratory Syndrome (SARS)." WHO IRIS: Consensus Document on the Epidemiology of Severe Acute Respiratory Syndrome (SARS). Web. 11 Mar. 2016. [9]Wallinga, J. "Different Epidemic Curves for Severe Acute Respiratory Syndrome Reveal Similar Impacts of Control Measures." American Journal of Epidemiology 160.6 (2004): 509-16. Web. [10]"Epidemic." Wikipedia. Wikimedia Foundation. Web. 11 Mar. 2016. [11]"Ebola Virus Disease." World Health Organization. Web. 11 Mar. 2016. [12]Zhang, Zhibin. "The Outbreak Pattern of SARS Cases in China as Revealed by a Mathematical Model." Ecological Modelling 204.3-4 (2007): 420-26. Web. [13]Zhou, Yicang, Zhien Ma, and F. Brauer. "A Discrete Epidemic Model for SARS Transmission and Control in China." Mathematical and Computer Modelling 40.13 (2004): 1491-506. Web. [14]"Scipy.optimize.minimize¶." Scipy.optimize.minimize — SciPy V0.17.0 Reference Guide. Web. 11 Mar. 2016. [15] Althaus, Christian L. "Estimating the Reproduction Number of Ebola Virus (EBOV) 22 During the 2014 Outbreak in West Africa." PLoS Curr PLoS Currents (2014). Web. 13 Mar. 2016. [16] "Frequently Asked Questions About SARS." Centers for Disease Control and Prevention. Centers for Disease Control and Prevention, 2012. Web. 21 Mar. 2016. <http://www.cdc.gov/sars/about/faq.html>. [17] "Ebola Virus Disease." World Health Organization. Web. 21 Mar. 2016. <http://www.who.int/mediacentre/factsheets/fs103/en/>. Special Thanks James D. Berger for mentoring this project Michael Gelbart for implementing Spearmint, suggesting fitting methods, and debugging Pam Kalas for reviewing and advising this project Omer Angel for providing insight on the data analysis Costanza Piccolo for refining our parameters Eric Cytrynbaum for refining the mechanics of the model Appendix Table of Contents SARS Raw Data: Cumulative Number of Deaths vs. Time (Fig1) ---------------------------------------------1 SARS Raw Data: Cumulative Number of Recovered Individuals vs. Time (Fig2) --------------------------1 SARS Extrapolated Data: Number of Alive & Infected Individuals vs. Time (Fig3) -----------------------2 SARS Extrapolated Data: Cumulative Number of Deaths vs. Time Fitted (Fig4) --------------------------2 SARS Extrapolated Data: Currently Infectious Individuals vs. Time Fitted (Fig5) -------------------------3 EBOLA Raw Data: Cumulative Number of Infectious Individuals vs. Time (Fig6) -------------------------3 EBOLA Raw Data: Cumulative Number of Deaths vs. Time (Fig7) -------------------------------------------4 EBOLA Raw Data: Cumulative Number of Deaths vs. Time Fitted (Fig7) -----------------------------------4 EBOLA Extrapolated Data: Cumulative Number of Infectious vs. Time Fitted (Fig8) --------------------5 EBOLA Parameter Sets--------------------------------------------------------------------------------------------------6 SARS Parameter Sets----------------------------------------------------------------------------------------------------7 PHASE II Parameter Sets (Deterministic) --------------------------------------------------------------------------8 DeterministicEPIMOD PHASE I Model-----------------------------------------------------------------------------10 DeterministicEPIMOD PHASE II Model----------------------------------------------------------------------------17 StochasticEPIMOD PHASE I Model---------------------------------------------------------------------------------21 StochasticEPIMOD PHASE II Model--------------------------------------------------------------------------------33 PHASE III Data Table---------------------------------------------------------------------------------------------------39 Definitions of Parameters--------------------------------------------------------------------------------------------40 Phase I Target Points---------------------------------------------------------------------------------------------------41 Appendix Fig1 Appendix Fig2 SARS Raw Data SARS Raw Data 1 Appendix Fig3 Appendix Fig4 SARS Extrapolated Data 2 Appendix Fig5 Appendix Fig6 3 Appendix Fig7 Appendix Fig7 Cumulative Deaths vs. Time 4 Appendix Fig8 Cumulative Infectious vs. Time 5 Ebola Parameter Sets Infectivity Infection Rate Mobility Incubation Rate Mortality Percentage Immunity Recovery Rate Population ResidualSum Average 0.99 0.001 0.9887100417 0.989113625 0.8238342917 0.0010002083 0.0010002083 3470330353.29167 0.000287125 Standard Deviation 0 0 0.0044474239 0.0030006973 0.0039407441 1.02062072615966E-06 1.02062072615966E-06 2126288880.69625 5.50345741132434E-06 Maximum Population 6866802093 Minimum Population 729407782 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2218138142 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2584033055 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 1901057942 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 3827085168 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 5857301234 0.000285 0.99 0.001 0.99 0.982891 0.82749 0.001 0.001 6114060146 0.00029 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 930036007 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 729407782 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 801051285 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 6193655290 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2750261610 0.000285 0.99 0.001 0.977391 0.99 0.81404 0.001 0.001 3354761252 0.000299 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 6205577078 0.000285 CHOSEN 0.99 0.001 0.971673 0.989046 0.809716 0.001005 0.001005 1040879429 0.000307 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 1737874180 0.000285 0.99 0.001 0.99 0.97679 0.830056 0.001 0.001 6085799484 0.000295 0.99 0.001 0.989994 0.99 0.824532 0.001 0.001 6866802093 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 4768289329 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 2566033336 0.000285 6 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 3319300965 0.000285 0.99 0.001 0.989983 0.99 0.824523 0.001 0.001 1374802524 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 1356416950 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 6781393146 0.000285 0.99 0.001 0.99 0.99 0.824537 0.001 0.001 3923911052 0.000285 SARS Parameter Sets Infectivity Infection Rate Mobility Incubation Period Incubation Rate Mortality Percentage Immunity Recovery Period Recovery Rate Population Residual Sum Estimated Basic Reproduction Number Standard Deviation 0.3224714094 0.2345012131 0.097017819 0.2934826039 0.0495100597 0.0636622241 0.0496357966 2350778466.15791 1.7285763331 0.486726 0.253035 0.866356 1.1178792489 0.894551 0.215118 0.029584 16.0815657012 0.062183 4930935930 0.456655 4.0691989772 Chosen Parameter set#1 0.851473 0.187879 0.868682 10.0161259628 0.099839 0.233785 0.024091 5.8622832421 0.170582 1959432004 0.492016 1.1013999132 0.644418 0.26588 0.944756 1.489913287 0.67118 0.245621 0.02129 7.9605158414 0.12562 114133266 0.370468 2.1165419519 0.200633 0.124275 0.796056 1.4747587663 0.678077 0.249025 0.07947 21.1671570391 0.047243 781370871 0.276411 2.630548441 0.942965 0.970427 0.973074 1.0972913363 0.911335 0.265489 0.118805 6.096631611 0.164025 4384338355 0.980407 5.9163359244 0.08657 0.255206 0.706624 1.0120136136 0.988129 0.283516 0.021446 20.461195343 0.048873 5630901875 0.317624 5.2218198187 0.033523 0.142002 0.853813 1.7794385871 0.561975 0.322865 0.211555 7.2050781391 0.138791 1453683352 0.739969 1.0231355059 0.245728 0.430487 0.826955 1.3681443994 0.730917 0.325093 0.117911 7.381544662 0.135473 3293913925 0.625295 3.1776590169 0.533429 0.364678 0.873111 1.2384805825 0.807441 0.338197 0.001 8.5397825771 0.117099 1607023420 0.233318 3.1142708307 0.533066 0.387292 0.907111 1.589327349 0.629197 0.339495 0.148519 15.5265037419 0.064406 5784967215 0.348509 6.0132906872 Chosen Parameter set#2 0.840515 0.539667 0.801637 13.8900463928 0.071994 0.347849 0.098526 5.1692943913 0.19345 6631318516 0.819369 2.7896975963 0.095789 0.538563 0.62483 1.2243318821 0.816772 0.349846 0.055587 9.1958250954 0.108745 73865743 0.724964 4.9525311509 7 PHASE II PARAMETER SETS Infectivity Infectious Period Infection Rate Mobility Incubation Period Incubation Rate Mortality Percentage Immunity Recovery Rate Percentage Dead Max 0.375849 1.6784099416 0.99 0.99 38.6085479325 0.375609 0.99 0.01 0.01 0.922588 Min 0.015306 1.0101010101 0.595802 0.99 2.6623430216 0.025901 0.99 0.01 0.01 0.922555 Average 0.1982362286 1.123803493 0.9053117143 0.99 7.7306120843 0.1864900571 0.99 0.01 0.01 0.9225818 Standard Deviation 0.0903404125 0.163870674 0.1104190317 0 7.0662311461 0.0847061018 0 0 0 8.62213294205885E-06 0.260417 1.2797854056 0.781381 0.99 10.059147789 0.099412 0.99 0.01 0.01 0.922573 0.104144 1.0101010101 0.99 0.99 3.3601360183 0.297607 0.99 0.01 0.01 0.922588 0.189311 1.1429681741 0.874915 0.99 5.2823132306 0.189311 0.99 0.01 0.01 0.92258 0.262111 1.1204130291 0.892528 0.99 8.3298625573 0.12005 0.99 0.01 0.01 0.922582 0.141358 1.0555983659 0.94733 0.99 3.9715162852 0.251793 0.99 0.01 0.01 0.922585 0.243455 1.3201633834 0.757482 0.99 8.9630632165 0.111569 0.99 0.01 0.01 0.922571 0.076546 1.0101010101 0.99 0.99 3.0750023831 0.325203 0.99 0.01 0.01 0.922588 0.28003 1.3154761826 0.760181 0.99 13.23872061 0.075536 0.99 0.01 0.01 0.922571 0.158479 1.2698122456 0.787518 0.99 4.9362970861 0.202581 0.99 0.01 0.01 0.922573 0.139883 1.0952806547 0.913008 0.99 4.0586392194 0.246388 0.99 0.01 0.01 0.922583 0.303098 1.0101010101 0.99 0.99 10.1366419333 0.098652 0.99 0.01 0.01 0.922588 0.210875 1.0101010101 0.99 0.99 5.2390307793 0.190875 0.99 0.01 0.01 0.922588 0.358884 1.0185975541 0.981742 0.99 24.2824534991 0.041182 0.99 0.01 0.01 0.922588 0.199946 1.0101010101 0.99 0.99 4.9553031654 0.201804 0.99 0.01 0.01 0.922588 8 0.015306 1.6784099416 0.595802 0.99 3.2547951269 0.307239 0.99 0.01 0.01 0.922555 0.197484 1.0425093617 0.959224 0.99 5.0488730915 0.198064 0.99 0.01 0.01 0.922586 0.200874 1.0101010101 0.99 0.99 4.978245069 0.200874 0.99 0.01 0.01 0.922588 0.1805 1.2800475154 0.781221 0.99 5.5774625892 0.179293 0.99 0.01 0.01 0.922573 0.24139 1.0132061287 0.986966 0.99 6.2602119708 0.159739 0.99 0.01 0.01 0.922588 0.183169 1.0124039735 0.987748 0.99 4.5845692568 0.218123 0.99 0.01 0.01 0.922588 0.343787 1.0307875629 0.970132 0.99 18.5325895587 0.053959 0.99 0.01 0.01 0.922587 0.154238 1.2546358796 0.797044 0.99 4.7907175058 0.208737 0.99 0.01 0.01 0.922574 0.091475 1.5073748314 0.663405 0.99 4.0880233181 0.244617 0.99 0.01 0.01 0.922562 0.200875 1.0101010101 0.99 0.99 4.9782202862 0.200875 0.99 0.01 0.01 0.922588 0.32745 1.0101010101 0.99 0.99 13.458769061 0.074301 0.99 0.01 0.01 0.922588 0.375849 1.0101010101 0.99 0.99 38.6085479325 0.025901 0.99 0.01 0.01 0.922588 0.204574 1.0683144349 0.936054 0.99 5.3677153393 0.186299 0.99 0.01 0.01 0.922585 0.211214 1.0777011772 0.927901 0.99 5.6163052574 0.178053 0.99 0.01 0.01 0.922584 0.133185 1.3427378694 0.744747 0.99 4.5602338488 0.219287 0.99 0.01 0.01 0.92257 0.234127 1.0205143801 0.979898 0.99 6.0392308436 0.165584 0.99 0.01 0.01 0.922587 0.306 1.0101010101 0.99 0.99 10.4435370171 0.095753 0.99 0.01 0.01 0.922588 0.041942 1.2324423186 0.811397 0.99 3.0871724896 0.323921 0.99 0.01 0.01 0.922575 0.026141 1.0101010101 0.99 0.99 2.6623430216 0.375609 0.99 0.01 0.01 0.922588 0.181518 1.0322111822 0.968794 0.99 4.6306586649 0.215952 0.99 0.01 0.01 0.922587 0.158633 1.0106195907 0.989492 0.99 4.1150739273 0.243009 0.99 0.01 0.01 0.922588 9 """ 1 DETERMINISTIC EPIDEMIC MODEL PHASE I 2 Uma Wu & LiQing Wang 3 4 ~Ver.7 Updates~ 5 -began implementation of fitting model 6 ------------------------------------------------------------------------------- 7 8 BLOCK DIAGRAM 9 10 ######## ############# 11 #IMMUNE#<--- #SUSCEPTIBLE# 12 ######## --|------RecP------>############# 13 ^ | -Imn---------------- |Mob ^RecP 14 Imn| | | v | 15 ############<------------I---############ 16 #INFECTIOUS#<--------IncP----#INCUBATING# 17 ############-----InfP------> ############ 18 |Mor 19 v 20 ###### 21 #DEAD# 22 ###### 23 24 #####PARAMETERS##### 25 I = Infectivity (percentage of people that move from INCUBATING to INFECTIOUS without IncP 26 [OVERRIDE]) 27 InfP = Length of Infectious Period (rate of individuals moving from INFECTIOUS to INCUBATING) 28 Mob = Mobility (rate of individuals moving from SUSCEPTIBLE to INCUBATING) 29 IncP = Length of Incubation Period (rate of individuals moving from INCUBATING to 30 INFECTIOUS) 31 Mor = Morbidity (percentage of infectious individuals that move from INFECTIOUS to DEAD) 32 Imn = Immunity (percentage of recovered individuals that move from INFECTIOUS to IMMUNE) 33 RecP = Length of Recovery Period (rate of individuals moving from INFECTIOUS and 34 INCUBATING to SUSCEPTIBLE) 35 36 #Note: Incubating refers to both the disease being dormant and the disease displaying 37 nonconsequential symptoms. 38 Pop = Population (Total number of people in each compartment. Remains constant throughout 39 simulation) 40 41 #####INITIAL VALUES##### 42 Pop = Population 43 T = Time of Simulation in Days 44 10 IMMUNE = Pop*PImmune 45 SUSCEPTIBLE = Pop - Pop*PImmune 46 INCUBATING = 1 47 INFECTIOUS = 0 48 DEAD = 0 49 50 #####DIFFERENTIAL EQUATIONS FROM BLOCK##### 51 IMMUNE = IMMUNE + INFECTIOUS*Imn + INCUBATING*Imn 52 SUSCEPTIBLE = SUSCEPTIBLE + INFECTIOUS*RecP + INCUBATING*RecP - 53 SUSCEPTIBLE*(INCUBATING/Population)Mob 54 INCUBATING = INCUBATING + SUSCEPTIBLE*Mob + INFECTIOUS*InfP - INCUBATING*Imn - 55 INCUBATING*I - INCUBATING*IncP -INCUBATING*RecP 56 INFECTIOUS = INFECTIOUS + INCUBATING*I + INCUBATING*IncP - INFECTIOUS*Imn - 57 INFECTIOUS*InfP - INFECTIOUS*Mor 58 DEAD = DEAD + INFECTIOUS*Mor 59 60 """ 61 import numpy as np 62 import random 63 from scipy.optimize import minimize 64 import matplotlib.pyplot as plt 65 66 ################FITTING################## 67 68 SusFit = False 69 IncFit = False 70 InfFit = False 71 ImmFit = False 72 DeaFit = False 73 74 if SusFit: 75 SUSCEPTIBLEquery = [] 76 with open("SUSCEPTIBLEfit.csv", "r") as SUSCEPTIBLEfit: 77 for line in SUSCEPTIBLEfit: 78 SUSCEPTIBLEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 79 preset = SUSCEPTIBLEquery 80 status = "SusFit" 81 82 if IncFit: 83 INCUBATINGquery = [] 84 with open("INCUBATINGfit.csv", "r") as INCUBATINGfit: 85 for line in INCUBATINGfit: 86 INCUBATINGquery.append(tuple([int(x) for x in line[:-1].split(",")])) 87 preset = INCUBATINGquery 88 11 status = "IncFit" 89 90 if InfFit: 91 INFECTIOUSquery = [] 92 with open("INFECTIOUSfit.csv", "r") as INFECTIOUSfit: 93 for line in INFECTIOUSfit: 94 INFECTIOUSquery.append(tuple([int(x) for x in line[:-1].split(",")])) 95 preset = INFECTIOUSquery 96 status = "InfFit" 97 98 if ImmFit: 99 IMMUNEquery = [] 100 with open("IMMUNEfit.csv", "r") as IMMUNEfit: 101 for line in IMMUNEfit: 102 IMMUNEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 103 preset = IMMUNEquery 104 status = "ImmFit" 105 106 if DeaFit: 107 DEADquery = [] 108 with open("DEADfit.csv", "r") as DEADfit: 109 for line in DEADfit: 110 DEADquery.append(tuple([int(x) for x in line[:-1].split(",")])) 111 preset = DEADquery 112 status = "DeaFit" 113 114 """ 115 INPUTS: 116 time: the current time value 117 y: the current value of the function 118 query: the list of points (t, value) to fit against 119 OUTPUTS: 120 dy: the deviation from the query 121 """ 122 fit = False 123 if fit: 124 def Fit(time, y, query = preset): 125 for i in query: 126 if time == i[0]: 127 dy = y - i[1] #Calculates the residuals 128 return dy 129 else: 130 return "NONE" 131 else: 132 12 status = "SusFit" 133 134 ###############SIMULATION################# 135 136 def DeterministicEPIMOD1(Parameters, T = 365, Plot = True, Print = True, fit = fit, status = status, 137 dt = 0.1): 138 IMMUNE = np.zeros(int((T+1)/dt)) 139 SUSCEPTIBLE = np.zeros(int((T+1)/dt)) 140 INCUBATING = np.zeros(int((T+1)/dt)) 141 INFECTIOUS = np.zeros(int((T+1)/dt)) 142 DEAD = np.zeros(int((T+1)/dt)) 143 144 #PARAMETER VALUES (INITIAL VALUES) 145 I = Parameters[0] 146 InfP = Parameters[1] 147 Mob = Parameters[2] 148 IncP = Parameters[3] 149 Mor = Parameters[4] 150 Imn = Parameters[5] 151 RecP = Parameters[6] 152 153 Pop = Parameters[7] 154 155 #INITIAL VALUES 156 IMMUNE[0] = 0 #1213 #Pop*PImmune 157 INCUBATING[0] = 1 #1516 158 INFECTIOUS[0] = 0 #286 159 DEAD[0] = 0 160 SUSCEPTIBLE[0] = Pop - IMMUNE[0] - INCUBATING[0] - INFECTIOUS[0] - DEAD[0] 161 162 #FITTING 163 residuals = [] 164 n = 0 165 166 for t in range(1, int(float(T)/dt+1)): 167 SUSCEPTIBLEin = INFECTIOUS[t-1]*RecP*dt + INCUBATING[t-1]*RecP*dt 168 SUSCEPTIBLEout = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt 169 SUSCEPTIBLE[t] = SUSCEPTIBLE[t-1] + SUSCEPTIBLEin - SUSCEPTIBLEout 170 171 INCUBATINGin = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt + 172 INFECTIOUS[t-1]*InfP*dt 173 INCUBATINGout = INCUBATING[t-1]*Imn*dt + INCUBATING[t-1]*I*dt + 174 INCUBATING[t-1]*IncP*dt + INCUBATING[t-1]*RecP*dt 175 INCUBATING[t] = INCUBATING[t-1] + INCUBATINGin - INCUBATINGout 176 13 177 INFECTIOUSin = INCUBATING[t-1]*I*dt + INCUBATING[t-1]*IncP*dt 178 INFECTIOUSout = INFECTIOUS[t-1]*Imn*dt + INFECTIOUS[t-1]*InfP*dt + 179 INFECTIOUS[t-1]*Mor*dt + INFECTIOUS[t-1]*RecP*dt 180 INFECTIOUS[t] = INFECTIOUS[t-1] + INFECTIOUSin - INFECTIOUSout 181 182 DEADin = INFECTIOUS[t-1]*Mor*dt 183 DEADout = 0 184 DEAD[t] = DEAD[t-1] + DEADin - DEADout 185 186 IMMUNEin = INFECTIOUS[t-1]*Imn*dt + INCUBATING[t-1]*Imn*dt 187 IMMUNEout = 0 188 IMMUNE[t] = IMMUNE[t-1] + IMMUNEin - IMMUNEout 189 190 if fit == True: 191 if status == "SusFit": 192 y = SUSCEPTIBLE[t] 193 elif status == "IncFit": 194 y = INCUBATING[t] 195 elif status == "InfFit": 196 y = sum(INFECTIOUS) 197 elif status == "ImmFit": 198 y = IMMUNE[t] 199 elif status == "DeaFit": 200 y = DEAD[t] 201 else: 202 print "ERROR: I DON'T KNOW WHAT IT IS BUT SOMETHING IS NOT RIGHT." 203 204 diffs = Fit(int(t*dt), y) 205 206 if diffs != "NONE": 207 residuals.append(diffs**2) 208 # plt.plot(t, preset[n][1], "*r") 209 # plt.plot(t, y, ".b") 210 # print preset[n][1] 211 # n += 1 212 213 if Print == True: 214 Survivors = IMMUNE[t] + SUSCEPTIBLE[t] + INCUBATING[t] + INFECTIOUS[t] 215 print "TOTAL POPULATION = %i" %Pop 216 print "REMAINING POPULATION = %f" %Survivors 217 print "IMMUNE = %.0f" %round(IMMUNE[t]) 218 print "SUSCEPTIBLE = %.0f" %round(SUSCEPTIBLE[t]) 219 print "INCUBATING = %.0f" %round(INCUBATING[t]) 220 14 print "INFECTIOUS = %.0f" %round(INFECTIOUS[t]) 221 print "DEAD = %.0f" %round(DEAD[t]) 222 223 if Plot == True: 224 plt.plot(IMMUNE, label="IMMUNE") 225 plt.plot(SUSCEPTIBLE, label="SUSCEPTIBLE") 226 plt.plot(INCUBATING, label="INCUBATING") 227 plt.plot(INFECTIOUS, label="INFECTIOUS") 228 plt.plot(DEAD, label="DEAD") 229 230 plt.legend(loc="best") 231 plt.title("PHASEIIpandemic") 232 plt.ylabel("Number of Individuals") 233 plt.xlabel("Time/%f (in days)" %dt) 234 235 #plt.show() 236 plt.savefig("PHASEIIpandemicDET.pdf") 237 238 if fit == True: 239 return abs(sum(residuals)) 240 else: 241 return -np.log(DEAD[t]) 242 #return abs(7452-(IMMUNE[-1])) + abs(831 - DEAD[-1]) 243 244 ###############EXECUTING SIMULATION#################### 245 246 #Parameters = [0.8515,0.1879,0.8687,0.09984,0.2338,0.02409,0.1706,1959432004] 247 Parameters = [0.1982, 0.9053, 0.99, 0.1865, 0.99, 0.01, 0.01, 7000000000] 248 print np.exp(-DeterministicEPIMOD1(Parameters)) 249 250 # print minimize(DeterministicEPIMOD1, [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 5000], method = 'L-251 BFGS-B', bounds = ((0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1),(0.01, 1), (100, 252 7000000001))) 253 254 # if status == "SusFit": 255 # data = open('DeterministicPHASEI_EBOLAsus.csv', 'w') 256 # elif status == "IncFit": 257 # data = open('DeterministicPHASEI_EBOLAinc.csv', 'w') 258 # elif status == "InfFit": 259 # data = open('DeterministicPHASEI_EBOLAinf.csv', 'w') 260 # elif status == "ImmFit": 261 # data = open('DeterministicPHASEI_EBOLAimm.csv', 'w') 262 # elif status == "DeaFit": 263 # data = open('DeterministicPHASEI_EBOLAdea.csv', 'w') 264 15 # else: 265 # print "ERROR: I DON'T KNOW WHAT IT IS BUT SOMETHING IS NOT RIGHT." 266 267 # data.write("Infectivity, InfectionRate, Mobility, IncubationRate, Mortality, 268 PercentageImmunity, RecoveryRate, Population, ResidualSum") 269 270 # i = 0 271 # trials = 10000 272 # for n in range(trials): 273 # print "\n" 274 # print n 275 # guess = np.random.rand(8) 276 # guess[7] = random.randint(100, 7000000001) 277 # Combination = minimize(DeterministicEPIMOD1, guess, method = 'L-BFGS-B', bounds 278 = ((0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 0.99),(0.001, 279 0.99), (100, 7000000001))) 280 # if Combination.fun <= 1: 281 # i += 1 282 # print "%i candidates found!" %i 283 # I = Combination.x[0] 284 # InfP = Combination.x[1] 285 # Mob = Combination.x[2] 286 # IncP = Combination.x[3] 287 # Mor = Combination.x[4] 288 # Imn = Combination.x[5] 289 # RecP = Combination.x[6] 290 # Population = Combination.x[7] 291 # Residual = Combination.fun 292 # data.write("\n" + "%f, %f, %f, %f, %f, %f, %f, %f, %f" %(I, InfP, Mob, IncP, Mor, Imn, 293 RecP, Population, Residual**2)) 294 295 16 """ 1 DETERMINISTIC EPIDEMIC MODEL 2 Uma Wu & LiQing Wang 3 4 Discussed With: Michael Gelbart 5 6 ~Ver.8 Updates~ 7 -Began implementation of Spearmint 8 -Removed normalization 9 ------------------------------------------------------------------------------- 10 11 BLOCK DIAGRAM 12 13 ######## ############# 14 #IMMUNE#<--- #SUSCEPTIBLE# 15 ######## --|------RecP------>############# 16 ^ | -Imn---------------- |Mob ^RecP 17 Imn| | | v | 18 ############<------------I---############ 19 #INFECTIOUS#<--------IncP----#INCUBATING# 20 ############-----InfP------> ############ 21 |Mor 22 v 23 ###### 24 #DEAD# 25 ###### 26 27 #####PARAMETERS##### 28 PImmune = Pre-Immunity (percentage of population immune to disease at initial time) 29 I = Infectivity (percentage of people that move from INCUBATING to INFECTIOUS without IncP 30 [OVERRIDE]) 31 InfP = Length of Infectious Period (rate of individuals moving from INFECTIOUS to INCUBATING) 32 Mob = Mobility (rate of individuals moving from SUSCEPTIBLE to INCUBATING) 33 IncP = Length of Incubation Period (rate of individuals moving from INCUBATING to 34 INFECTIOUS) 35 Mor = Morbidity (percentage of infectious individuals that move from INFECTIOUS to DEAD) 36 Imn = Immunity (percentage of recovered individuals that move from INFECTIOUS to IMMUNE) 37 RecP = Length of Recovery Period (rate of individuals moving from INFECTIOUS and 38 INCUBATING to SUSCEPTIBLE) 39 #Note: Incubating refers to both the disease being dormant and the disease displaying 40 nonconsequential symptoms. 41 42 #####INITIAL VALUES##### 43 Pop = Population 44 17 T = Time of Simulation in Days 45 IMMUNE = Pop*PImmune 46 SUSCEPTIBLE = Pop - Pop*PImmune 47 INCUBATING = 0 48 INFECTIOUS = 1 49 DEAD = 0 50 51 #####DIFFERENTIAL EQUATIONS FROM BLOCK##### 52 IMMUNE = IMMUNE + INFECTIOUS*Imn + INCUBATING*Imn 53 SUSCEPTIBLE = SUSCEPTIBLE + INFECTIOUS*RecP - SUSCEPTIBLE*Mob 54 INCUBATING = INCUBATING + SUSCEPTIBLE*Mob + INFECTIOUS*InfP - INCUBATING*Imn - 55 INCUBATING*I - INCUBATING*IncP 56 INFECTIOUS = INFECTIOUS + INCUBATING*I + INCUBATING*IncP - INFECTIOUS*Imn - 57 INFECTIOUS*InfP - INFECTIOUS*Mor 58 DEAD = DEAD + INFECTIOUS*Mor 59 60 """ 61 62 import numpy as np 63 from scipy.optimize import minimize 64 import scipy.optimize 65 66 def main(job_id, params): 67 Parameters = [params["I"], params["InfP"], params["Mob"], params["IncP"], 68 params["Mor"], params["Imn"], params["RecP"]] 69 return -StochasticEPIMOD(Parameters) 70 71 def DeterministicEPIMOD(Parameters, T = 365, Pop = 7000000000): 72 dt = 0.1 73 IMMUNE = np.zeros(int((T+1)/dt)) 74 SUSCEPTIBLE = np.zeros(int((T+1)/dt)) 75 INCUBATING = np.zeros(int((T+1)/dt)) 76 INFECTIOUS = np.zeros(int((T+1)/dt)) 77 DEAD = np.zeros(int((T+1)/dt)) 78 79 #PARAMETER VALUES (INITIAL VALUES) 80 I = Parameters[0] #0.1 #0.011 is the rate of infection from data 81 InfP = Parameters[1] #0.12 #max 0.12 82 Mob = Parameters[2] #11.0/30.0 #THIS SHOULD DEPEND ON THE NUMBER OF INFECTED 83 INDIVIDUALS SOMEHOW AHHH 84 IncP = Parameters[3] #7.0/15.0 85 Mor = Parameters[4] #0.07 #0.096 is the death rate from data 86 Imn = Parameters[5] #0.397 #1.0 - Mor 87 RecP = Parameters[6] #0.468 is the recovery rate from data 88 18 89 #INITIAL VALUES 90 IMMUNE[0] = 0 #1213 #Pop*PImmune 91 INCUBATING[0] = 1 #1516 92 INFECTIOUS[0] = 0 #286 93 DEAD[0] = 0 94 SUSCEPTIBLE[0] = Pop - IMMUNE[0] - INCUBATING[0] - INFECTIOUS[0] - DEAD[0] 95 96 97 for t in range(1, int(float(T)/dt+1)): 98 SUSCEPTIBLEin = INFECTIOUS[t-1]*RecP*dt + INCUBATING[t-1]*RecP*dt 99 SUSCEPTIBLEout = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt 100 SUSCEPTIBLE[t] = SUSCEPTIBLE[t-1] + SUSCEPTIBLEin - SUSCEPTIBLEout 101 102 INCUBATINGin = SUSCEPTIBLE[t-1]*(INCUBATING[t-1]/float(Pop))*Mob*dt + 103 INFECTIOUS[t-1]*InfP*dt 104 INCUBATINGout = INCUBATING[t-1]*Imn*dt + INCUBATING[t-1]*I*dt + 105 INCUBATING[t-1]*IncP*dt + INCUBATING[t-1]*RecP*dt 106 INCUBATING[t] = INCUBATING[t-1] + INCUBATINGin - INCUBATINGout 107 108 INFECTIOUSin = INCUBATING[t-1]*I*dt + INCUBATING[t-1]*IncP*dt 109 INFECTIOUSout = INFECTIOUS[t-1]*Imn*dt + INFECTIOUS[t-1]*InfP*dt + 110 INFECTIOUS[t-1]*Mor*dt + INFECTIOUS[t-1]*RecP*dt 111 INFECTIOUS[t] = INFECTIOUS[t-1] + INFECTIOUSin - INFECTIOUSout 112 113 DEADin = INFECTIOUS[t-1]*Mor*dt 114 DEADout = 0 115 DEAD[t] = DEAD[t-1] + DEADin - DEADout 116 117 IMMUNEin = INFECTIOUS[t-1]*Imn*dt + INCUBATING[t-1]*Imn*dt 118 IMMUNEout = 0 119 IMMUNE[t] = IMMUNE[t-1] + IMMUNEin - IMMUNEout 120 121 return -np.log(DEAD[t]) 122 123 def Normalize(Parameters): 124 return np.sum(Parameters) - 1 125 126 ###############EXECUTING SIMULATION#################### 127 128 #print minimize(DeterministicEPIMOD, [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], method = 'L-BFGS-B', 129 bounds = ((0.01, 1),)*7) 130 #print scipy.optimize.fmin_slsqp(DeterministicEPIMOD, [0.3, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1], 131 bounds = ((0.01, 1),)*7, f_eqcons = Normalize) 132 19 #returns the seven best parameters if not printed 133 134 data = open('DeterministicPHASEII2.csv', 'w') 135 data.write("Infectivity, InfectionRate, Mobility, IncubationRate, Mortality, 136 PercentageImmunity, RecoveryRate, PercentageDead") 137 138 trials = 50000 139 for n in range(trials): 140 print n 141 guess = np.random.rand(7) 142 Combination = minimize(DeterministicEPIMOD, guess, method = 'L-BFGS-B', bounds = 143 ((0.01, 0.99),)*7) 144 I = Combination.x[0] 145 InfP = Combination.x[1] 146 Mob = Combination.x[2] 147 IncP = Combination.x[3] 148 Mor = Combination.x[4] 149 Imn = Combination.x[5] 150 RecP = Combination.x[6] 151 Dead = np.exp(-DeterministicEPIMOD(Combination.x))/7000000000.0 152 data.write("\n" + "%f, %f, %f, %f, %f, %f, %f, %f" %(I, InfP, Mob, IncP, Mor, Imn, RecP, Dead)) 153 154 # TESTING PURPOSES ONLY 155 # guess = np.random.rand(7) 156 # print scipy.optimize.fmin_slsqp(DeterministicEPIMOD, guess, bounds = ((0.01, 1),)*7, 157 f_eqcons = Normalize) 158 20 """ 1 STOCHASTIC EPIDEMIC MODEL 2 Uma Wu & LiQing Wang 3 4 Discussed With: Noah Bayless, Michael Gelbart 5 ------------------------------------------------------------------------------- 6 #####PATIENT INFORMATION##### 7 xLoc = range(0, x_Dim) 8 yLoc = range(0, y_Dim) 9 Status = IMMUNE, SUSCEPTIBLE, INFECTIOUS, INCUBATING, or DEAD 10 tExist = time elapsed since start of simulation 11 tInc = time incubating 12 tInf = time infectious 13 tRec = time recovering 14 15 #####PARAMETERS##### 16 PImmune = Pre-Immunity (Probable Percentage of Population that is Pre-Immune to Disease, 17 float) 18 I = Infectivity (Percentage Probability of Displaying Symptoms When Infected, float) 19 InfP = Length of Infectious Period (Time Range in which the Disease is Infectious, array) 20 Mob = Mobility (Percentage Probability of Contracting the Disease from an Adjacent Diseased 21 Individual, float) 22 IncP = Length of Incubation Period (Time Range in which the Disease does not produce 23 Symptoms (In an Infective Individual), array) 24 Mor = Morbidity (Percentage Probability of Infective Individuals Dying from the Disease, float) 25 Imn = Immunity (Percentage Probability of Individuals of Gaining Immunity After Recovery, 26 float) 27 RecP = Length of Recovery Period (Time Range in which the Disease is Present in an Individual, 28 array) 29 """ 30 31 ########################DEFINING PATIENT 32 CLASS################################# 33 34 import random 35 import matplotlib.pyplot as plt 36 import numpy as np 37 38 class Dossier(): #Creates an object (like list or array) that has its own modules 39 def __init__(self, x, y, PImmune, IncP, InfP, RecP): #Automatically run as soon as object is 40 created 41 #x and y - int 42 #PImmune - float 43 #IncP, InfP and RecP - lists 44 21 self.xLoc = x #Stores the inputted x location in the object 45 self.yLoc = y #Same as above 46 47 vaccination = random.random() 48 if vaccination <= PImmune: #If the "roll" is below the PImmune probability 49 self.Status = "IMMUNE" #The Individual becomes immune 50 else: self.Status = "SUSCEPTIBLE" #If not, the individual becomes susceptible 51 52 self.IncLen = random.choice(IncP) #Picks a incubation rate out of the IncP list 53 self.InfLen = random.choice(InfP) #Same as above for infectious rate 54 self.RecLen = random.choice(RecP) #Same as above for recovery rate 55 self.IncState = False #Sets incubation state as false 56 self.InfState = False #Same as above for infectious rate 57 self.RecState = False #Same as above for recovery rate 58 59 60 def Incubation(self, I, Imn): 61 self.IncLen -= 1 #When the function is called, it first decreases the incubation period 62 by 1 63 if self.IncLen >= 0: #While the incubation period is more than 0, the IncState is set to 64 True 65 self.IncState = True 66 else: self.IncState = False #Otherwise, the IncState is False. In other words, the 67 patient stops incubating. 68 69 if self.IncState == False: #Once the patient finishes incubating.. 70 luck = random.random() 71 if luck <= I: #If their "roll" is less than Infectivity... 72 self.Status = "INFECTIOUS" #They become Infectious 73 else: 74 antibody = random.random() #If their "roll" is more than Infectivity... 75 if antibody <= Imn: #If their "roll" is smaller than the Immunity 76 self.Status = "IMMUNE" #They become Immune. 77 else: self.Status = "SUSCEPTIBLE" #Otherwise, they become susceptible. 78 79 80 def Infection(self, Mor): #Same concepts as incubation. 81 self.InfLen -= 1 82 if self.InfLen >= 0: 83 self.InfState = True 84 else: self.InfState = False 85 86 if self.InfState == False: 87 hopesndreams = random.random() 88 22 if hopesndreams <= Mor: 89 self.Status = "DEAD" 90 else: self.Status = "INCUBATING" 91 92 93 def Recovery(self, Imn): #Activated when patient goes into incubation or infection 94 self.RecLen -= 1 95 if self.RecLen >= 0: 96 self.RecState = True 97 else: self.RecState = False 98 99 if self.RecState == False: 100 antibody = random.random() 101 if antibody <= Imn: 102 self.Status = "IMMUNE" 103 else: self.Status = "SUSCEPTIBLE" 104 105 def Copy(self): 106 new_pat = Dossier(self.xLoc, self.yLoc, 0, range(2,7), range(2,7), range(2,7)) 107 #^These input values doesn't matter cuz we're gonna update it anyway 108 new_pat.Status = self.Status 109 new_pat.IncLen = self.IncLen 110 new_pat.InfLen = self.InfLen 111 new_pat.RecLen = self.RecLen 112 new_pat.IncState = self.IncState 113 new_pat.InfState = self.InfState 114 new_pat.RecState = self.RecState 115 return new_pat 116 117 ############################DEFINING 118 FUNCTIONS################################# 119 120 def Spread(Mob, NBR): 121 if NBR.Status == "INFECTIOUS": 122 contagion = random.random() 123 if contagion <= Mob: #If the "roll" is lower than mobility, then the patient is infected 124 by the virus 125 return True 126 else: 127 return False 128 return False 129 130 def Plot(Patient, Population): 131 for P in range(1, Population+1): 132 23 x = Patient[P].xLoc 133 y = Patient[P].yLoc 134 135 if Patient[P].Status == 'SUSCEPTIBLE': 136 colour = "white" 137 elif Patient[P].Status == 'IMMUNE': 138 colour = "blue" 139 elif Patient[P].Status == 'INFECTIOUS': 140 colour = "red" 141 elif Patient[P].Status == 'INCUBATING': 142 colour = "yellow" 143 elif Patient[P].Status == 'DEAD': 144 colour = "black" 145 146 if colour == "white": 147 plt.plot(x, y, "wo") 148 elif colour == "blue": 149 plt.plot(x, y, "bo") 150 elif colour == "red": 151 plt.plot(x, y, "ro") 152 elif colour == "yellow": 153 plt.plot(x, y, "yo") 154 elif colour == "black": 155 plt.plot(x, y, "ko") 156 plt.show() 157 158 def DeepCopy(Old): #Takes in dict, returns deep copy 159 New = dict() 160 for i in range(1, len(Old)+1): 161 New[i] = Old[i].Copy() 162 return New 163 164 ########################FITTING 165 FUNCTIONS###################################### 166 if __name__ == "__main__": 167 SusFit = False 168 IncFit = False 169 InfFit = False 170 ImmFit = False 171 DeaFit = False 172 173 if SusFit: 174 SUSCEPTIBLEquery = [] 175 with open("SUSCEPTIBLEfit.csv", "r") as SUSCEPTIBLEfit: 176 24 for line in SUSCEPTIBLEfit: 177 SUSCEPTIBLEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 178 preset = SUSCEPTIBLEquery 179 status = "SusFit" 180 181 if IncFit: 182 INCUBATINGquery = [] 183 with open("INCUBATINGfit.csv", "r") as INCUBATINGfit: 184 for line in INCUBATINGfit: 185 INCUBATINGquery.append(tuple([int(x) for x in line[:-1].split(",")])) 186 preset = INCUBATINGquery 187 status = "IncFit" 188 189 if InfFit: 190 INFECTIOUSquery = [] 191 with open("INFECTIOUSfit.csv", "r") as INFECTIOUSfit: 192 for line in INFECTIOUSfit: 193 INFECTIOUSquery.append(tuple([int(x) for x in line[:-1].split(",")])) 194 preset = INFECTIOUSquery 195 status = "InfFit" 196 197 if ImmFit: 198 IMMUNEquery = [] 199 with open("IMMUNEfit.csv", "r") as IMMUNEfit: 200 for line in IMMUNEfit: 201 IMMUNEquery.append(tuple([int(x) for x in line[:-1].split(",")])) 202 preset = IMMUNEquery 203 status = "ImmFit" 204 205 if DeaFit: 206 DEADquery = [] 207 with open("DEADfit.csv", "r") as DEADfit: 208 for line in DEADfit: 209 DEADquery.append(tuple([int(x) for x in line[:-1].split(",")])) 210 preset = DEADquery 211 status = "DeaFit" 212 213 """ 214 INPUTS: 215 time: the current time value 216 y: the current value of the function 217 query: the list of points (t, value) to fit against 218 OUTPUTS: 219 dy: the deviation from the query 220 25 """ 221 222 fit = False 223 if fit == True: 224 def Fit(time, y, query = preset): 225 for i in query: 226 if time == i[0]: 227 dy = y - i[1] 228 else: 229 dy = "NONE" 230 return dy 231 else: 232 fit = False 233 234 235 ###########################INITIALIZE 236 SIMULATION############################### 237 def main(job_id, params): 238 Parameters = [params["I"], params["InfP"], params["Mob"], params["IncP"], 239 params["Mor"], params["Imn"], params["RecP"]] 240 return StochasticEPIMOD(Parameters) 241 242 243 def StochasticEPIMOD(Parameters, xDimension = 20, yDimension = 20, tElapsed = 365, flux = 244 True, move_range = 0.5, Plot = True, Print = True, fit = fit): 245 #INITIAL VALUES 246 Population = xDimension*yDimension 247 248 #PARAMETERS 249 PImmune = 0.0 250 I = Parameters[0] #Percentage 251 InfP = range(int(Parameters[1])-3, int(Parameters[1])+4) 252 Mob = Parameters[2] #Percentage 253 IncP = range(int(Parameters[3])-3, int(Parameters[3])+4) 254 Mor = Parameters[4] #Percentage 255 Imn = Parameters[5] #Percentage 256 RecP = range(int(Parameters[6])-3, int(Parameters[6])+4) 257 258 #PATIENTS 259 Patient = dict() 260 ID = 0 261 Pos2Pat = np.zeros((yDimension, xDimension)) 262 for x in range(xDimension): 263 for y in range(yDimension): 264 26 ID += 1 265 Patient[ID] = Dossier(x, y, PImmune, IncP, InfP, RecP) 266 Pos2Pat[y,x] = ID 267 268 #GENERATING PATIENT ZERO 269 x = xDimension/2 270 y = yDimension/2 271 for P in range(1, ID+1): 272 if Patient[P].xLoc == x and Patient[P].yLoc == y: 273 Patient[P].Status = "INFECTIOUS" 274 275 Record = DeepCopy(Patient) 276 277 SUSCEPTIBLEtrend = [] 278 INCUBATINGtrend = [] 279 INFECTIOUStrend = [] 280 IMMUNEtrend = [] 281 DEADtrend = [] 282 283 residuals = [] 284 285 ###########################SIMULATION 286 BEGINS################################### 287 for t in range(tElapsed): 288 # Plot(Patient, Population) 289 for P in range(1,ID+1): 290 #STATUS PRIORITY: DEAD = IMMUNE > INFECTIOUS = INCUBATING > 291 SUSCEPTIBLE 292 if Record[P].Status == "SUSCEPTIBLE": 293 n = 8 294 x = Patient[P].xLoc 295 y = Patient[P].yLoc 296 while Patient[P].Status != "INFECTIOUS" and Patient[P].Status != 297 "INCUBATING" and n > 0: 298 if n == 8: 299 infection = Spread(Mob, Record[Pos2Pat[y,(x+1)%xDimension]]) 300 #Right 301 if infection == True: 302 infection = random.random() 303 if infection <= I: 304 Patient[P].Status = "INFECTIOUS" 305 else: Patient[P].Status = "INCUBATING" 306 elif n == 7: 307 infection = Spread(Mob, Record[Pos2Pat[y,(x-1)%xDimension]]) 308 27 #Left 309 if infection == True: 310 infection = random.random() 311 if infection <= I: 312 Patient[P].Status = "INFECTIOUS" 313 else: Patient[P].Status = "INCUBATING" 314 elif n == 6: 315 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,x]]) 316 #Above 317 if infection == True: 318 infection = random.random() 319 if infection <= I: 320 Patient[P].Status = "INFECTIOUS" 321 else: Patient[P].Status = "INCUBATING" 322 elif n == 5: 323 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,x]]) 324 #Below 325 if infection == True: 326 infection = random.random() 327 if infection <= I: 328 Patient[P].Status = "INFECTIOUS" 329 else: Patient[P].Status = "INCUBATING" 330 elif n == 4: 331 infection = Spread(Mob, 332 Record[Pos2Pat[(y+1)%yDimension,(x+1)%xDimension]]) #Upper Right 333 if infection == True: 334 infection = random.random() 335 if infection <= I: 336 Patient[P].Status = "INFECTIOUS" 337 else: Patient[P].Status = "INCUBATING" 338 elif n == 3: 339 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,(x-340 1)%xDimension]]) #Lower Left 341 if infection == True: 342 infection = random.random() 343 if infection <= I: 344 Patient[P].Status = "INFECTIOUS" 345 else: Patient[P].Status = "INCUBATING" 346 elif n == 2: 347 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,(x-348 1)%xDimension]]) #Upper Left 349 if infection == True: 350 infection = random.random() 351 if infection <= I: 352 28 Patient[P].Status = "INFECTIOUS" 353 else: Patient[P].Status = "INCUBATING" 354 elif n == 1: 355 infection = Spread(Mob, Record[Pos2Pat[(y-356 1)%yDimension,(x+1)%xDimension]]) #Lower Right 357 if infection == True: 358 infection = random.random() 359 if infection <= I: 360 Patient[P].Status = "INFECTIOUS" 361 else: Patient[P].Status = "INCUBATING" 362 n -= 1 363 364 elif Record[P].Status == "INFECTIOUS": 365 Patient[P].Recovery(Imn) 366 if Patient[P].RecState == True: #If the patient is still infectious... 367 Patient[P].Infection(Mor) 368 369 elif Record[P].Status == "INCUBATING": 370 Patient[P].Recovery(Imn) 371 if Patient[P].RecState == True: #If the patient is still incubating... 372 Patient[P].Incubation(I,Imn) 373 374 elif Record[P].Status == "IMMUNE": #Removed from population 375 pass 376 elif Record[P].Status == "DEAD": #Removed from population 377 pass 378 379 380 #UPDATE MOVING 381 if flux == True: 382 for x in range(xDimension): 383 for y in range(yDimension): 384 if Patient[Pos2Pat[y,x]].Status != "DEAD": 385 move = random.random() 386 if move <= move_range: 387 swap = random.randint(1, 4) 388 if swap == 1: #switch with above 389 oriID = Pos2Pat[y, x] 390 newID = Pos2Pat[(y+1)%yDimension, x] 391 Patient[oriID].yLoc = (y+1)%yDimension 392 Patient[newID].yLoc = y 393 Pos2Pat[y,x] = newID 394 Pos2Pat[(y+1)%yDimension, x] = oriID 395 396 29 elif swap == 2: #switch with below 397 oriID = Pos2Pat[y, x] 398 newID = Pos2Pat[(y-1)%yDimension, x] 399 Patient[oriID].yLoc = (y-1)%yDimension 400 Patient[newID].yLoc = y 401 Pos2Pat[y,x] = newID 402 Pos2Pat[(y-1)%yDimension, x] = oriID 403 404 elif swap == 3: #switch with left 405 oriID = Pos2Pat[y, x] 406 newID = Pos2Pat[y, (x-1)%yDimension] 407 Patient[oriID].xLoc = (x-1)%xDimension 408 Patient[newID].xLoc = x 409 Pos2Pat[y,x] = newID 410 Pos2Pat[y, (x-1)%yDimension] = oriID 411 412 elif swap == 4: #switch with right 413 oriID = Pos2Pat[y, x] 414 newID = Pos2Pat[y, (x+1)%yDimension] 415 Patient[oriID].xLoc = (x+1)%xDimension 416 Patient[newID].xLoc = x 417 Pos2Pat[y,x] = newID 418 Pos2Pat[y, (x+1)%yDimension] = oriID 419 SUSCEPTIBLE = 0 420 INFECTIOUS = 0 421 INCUBATING = 0 422 IMMUNE = 0 423 DEAD = 0 424 425 for P in range(1, ID+1): 426 if Patient[P].Status == "SUSCEPTIBLE": 427 SUSCEPTIBLE += 1 428 elif Patient[P].Status == "INFECTIOUS": 429 INFECTIOUS += 1 430 elif Patient[P].Status == "INCUBATING": 431 INCUBATING += 1 432 elif Patient[P].Status == "IMMUNE": 433 IMMUNE += 1 434 elif Patient[P].Status == "DEAD": 435 DEAD += 1 436 437 SUSCEPTIBLEtrend.append(SUSCEPTIBLE) 438 INCUBATINGtrend.append(INCUBATING) 439 INFECTIOUStrend.append(INFECTIOUS) 440 30 IMMUNEtrend.append(IMMUNE) 441 DEADtrend.append(DEAD) 442 443 if fit == True: 444 if status == "SusFit": 445 y = SUSCEPTIBLE 446 elif status == "IncFit": 447 y = INCUBATING 448 elif status == "InfFit": 449 y = INFECTIOUS 450 elif status == "ImmFit": 451 y = IMMUNE 452 elif status == "DeaFit": 453 y = DEAD 454 455 diffs = Fit(t, y) 456 if diffs != "NONE": 457 residuals.append(diffs**2) 458 459 Record = DeepCopy(Patient) 460 461 if Plot: 462 plt.plot(SUSCEPTIBLEtrend, "0.5", label = "SUSCEPTIBLE") 463 plt.plot(INCUBATINGtrend, "y", label = "INCUBATING") 464 plt.plot(INFECTIOUStrend, "r", label = "INFECTIOUS") 465 plt.plot(IMMUNEtrend, "b", label = "IMMUNE") 466 plt.plot(DEADtrend, "k", label = "DEAD") 467 468 plt.legend(loc="best") 469 plt.title("ebolaSTOinfSIM") 470 plt.ylabel("Number of Individuals") 471 plt.xlabel("Time (in days)") 472 # plt.show() 473 plt.savefig("ebolaSTOinfSIM2.pdf") 474 475 if Print: 476 print "SUSCEPTIBLE = %i" %SUSCEPTIBLE 477 print "INFECTIOUS = %i" %INFECTIOUS 478 print "INCUBATING = %i" %INCUBATING 479 print "IMMUNE = %i" %IMMUNE 480 print "DEAD = %i" %DEAD 481 print "Percent Dead = %f" %(float(DEAD)/float(Population)) 482 483 return abs(sum(residuals)) 484 31 # PercentDead = float(DEAD)/float(Population) 485 # return PercentDead 486 487 if __name__ == "__main__": 488 StochasticEPIMOD([0.6834, 14, 0.0163, 19, 0.9512, 0.8861, 22]) 489 32 """ 1 STOCHASTIC EPIDEMIC MODEL 2 Uma Wu & LiQing Wang 3 4 Discussed With: Noah Bayless, Michael Gelbart 5 ------------------------------------------------------------------------------- 6 #####PATIENT INFORMATION##### 7 xLoc = range(0, x_Dim) 8 yLoc = range(0, y_Dim) 9 Status = IMMUNE, SUSCEPTIBLE, INFECTIOUS, INCUBATING, or DEAD 10 tExist = time elapsed since start of simulation 11 tInc = time incubating 12 tInf = time infectious 13 tRec = time recovering 14 15 16 #####PARAMETERS##### 17 PImmune = Pre-Immunity (PERCENTAGE PROBABILITY of Population that is Pre-Immune to 18 Disease, float) 19 I = Infectivity (PERCENTAGE PROBABILITY of Displaying Symptoms When Infected, float) 20 InfP = Length of Infectious Period (TIME RANGE in which the Disease is Infectious, array) 21 Mob = Mobility (PERCENTAGE PROBABILITY of Contracting the Disease from an Adjacent 22 Diseased Individual, float) 23 IncP = Length of Incubation Period (TIME RANGE in which the Disease does not produce 24 Symptoms (In an Infective Individual), array) 25 Mor = Morbidity (PERCENTAGE PROBABILITY of Infective Individuals Dying from the Disease, 26 float) 27 Imn = Immunity (PERCENTAGE PROBABILITY of Individuals of Gaining Immunity After Recovery, 28 float) 29 RecP = Length of Recovery Period (TIME RANGE in which the Disease is Present in an Individual, 30 array) 31 """ 32 33 from StochasticEPIMOD1 import Dossier 34 from StochasticEPIMOD1 import Spread 35 from StochasticEPIMOD1 import Plot 36 from StochasticEPIMOD1 import DeepCopy 37 38 import random 39 import matplotlib.pyplot as plt 40 import numpy as np 41 from scipy.optimize import minimize 42 43 44 33 def main(job_id, params): 45 Parameters = [params["I"], params["InfP"], params["Mob"], params["IncP"], 46 params["Mor"], params["Imn"], params["RecP"]] 47 return -StochasticEPIMOD(Parameters) 48 49 def StochasticEPIMOD(Parameters, xDimension = 20, yDimension = 20, tElapsed = 365, flux = 50 True, move_range = 0.5, Plot = False, Print = False): 51 #INITIAL VALUES 52 Population = xDimension*yDimension 53 54 #PARAMETERS 55 PImmune = 0.0 56 I = Parameters[0] #Percentage 57 InfP = range(int(Parameters[1])-3, int(Parameters[1])+4) 58 Mob = Parameters[2] #Percentage 59 IncP = range(int(Parameters[3])-3, int(Parameters[3])+4) 60 Mor = Parameters[4] #Percentage 61 Imn = Parameters[5] #Percentage 62 RecP = range(int(Parameters[6])-3, int(Parameters[6])+4) 63 64 #PATIENTS 65 Patient = dict() 66 ID = 0 67 Pos2Pat = np.zeros((yDimension, xDimension)) 68 for x in range(xDimension): 69 for y in range(yDimension): 70 ID += 1 71 Patient[ID] = Dossier(x, y, PImmune, IncP, InfP, RecP) 72 Pos2Pat[y,x] = ID 73 74 #GENERATING PATIENT ZERO 75 x = xDimension/2 76 y = yDimension/2 77 for P in range(1, ID+1): 78 if Patient[P].xLoc == x and Patient[P].yLoc == y: 79 Patient[P].Status = "INFECTIOUS" 80 81 Record = DeepCopy(Patient) 82 83 ###########################SIMULATION 84 BEGINS################################### 85 for t in range(tElapsed): 86 for P in range(1,ID+1): 87 #STATUS PRIORITY: DEAD = IMMUNE > INFECTIOUS = INCUBATING > 88 34 SUSCEPTIBLE 89 if Record[P].Status == "SUSCEPTIBLE": 90 n = 8 91 x = Patient[P].xLoc 92 y = Patient[P].yLoc 93 while Patient[P].Status != "INFECTIOUS" and Patient[P].Status != 94 "INCUBATING" and n > 0: 95 if n == 8: 96 infection = Spread(Mob, Record[Pos2Pat[y,(x+1)%xDimension]]) 97 #Right 98 if infection == True: 99 infection = random.random() 100 if infection <= I: 101 Patient[P].Status = "INFECTIOUS" 102 else: Patient[P].Status = "INCUBATING" 103 elif n == 7: 104 infection = Spread(Mob, Record[Pos2Pat[y,(x-1)%xDimension]]) 105 #Left 106 if infection == True: 107 infection = random.random() 108 if infection <= I: 109 Patient[P].Status = "INFECTIOUS" 110 else: Patient[P].Status = "INCUBATING" 111 elif n == 6: 112 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,x]]) 113 #Above 114 if infection == True: 115 infection = random.random() 116 if infection <= I: 117 Patient[P].Status = "INFECTIOUS" 118 else: Patient[P].Status = "INCUBATING" 119 elif n == 5: 120 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,x]]) 121 #Below 122 if infection == True: 123 infection = random.random() 124 if infection <= I: 125 Patient[P].Status = "INFECTIOUS" 126 else: Patient[P].Status = "INCUBATING" 127 elif n == 4: 128 infection = Spread(Mob, 129 Record[Pos2Pat[(y+1)%yDimension,(x+1)%xDimension]]) #Upper Right 130 if infection == True: 131 infection = random.random() 132 35 if infection <= I: 133 Patient[P].Status = "INFECTIOUS" 134 else: Patient[P].Status = "INCUBATING" 135 elif n == 3: 136 infection = Spread(Mob, Record[Pos2Pat[(y-1)%yDimension,(x-137 1)%xDimension]]) #Lower Left 138 if infection == True: 139 infection = random.random() 140 if infection <= I: 141 Patient[P].Status = "INFECTIOUS" 142 else: Patient[P].Status = "INCUBATING" 143 elif n == 2: 144 infection = Spread(Mob, Record[Pos2Pat[(y+1)%yDimension,(x-145 1)%xDimension]]) #Upper Left 146 if infection == True: 147 infection = random.random() 148 if infection <= I: 149 Patient[P].Status = "INFECTIOUS" 150 else: Patient[P].Status = "INCUBATING" 151 elif n == 1: 152 infection = Spread(Mob, Record[Pos2Pat[(y-153 1)%yDimension,(x+1)%xDimension]]) #Lower Right 154 if infection == True: 155 infection = random.random() 156 if infection <= I: 157 Patient[P].Status = "INFECTIOUS" 158 else: Patient[P].Status = "INCUBATING" 159 n -= 1 160 161 elif Record[P].Status == "INFECTIOUS": 162 Patient[P].Recovery(Imn) 163 if Patient[P].RecState == True: #If the patient is still infectious... 164 Patient[P].Infection(Mor) 165 166 elif Record[P].Status == "INCUBATING": 167 Patient[P].Recovery(Imn) 168 if Patient[P].RecState == True: #If the patient is still incubating... 169 Patient[P].Incubation(I,Imn) 170 171 elif Record[P].Status == "IMMUNE": #Removed from population 172 pass 173 elif Record[P].Status == "DEAD": #Removed from population 174 pass 175 176 36 177 #UPDATE MOVING 178 if flux == True: 179 for x in range(xDimension): 180 for y in range(yDimension): 181 if Patient[Pos2Pat[y,x]].Status != "DEAD": 182 move = random.random() 183 if move <= move_range: 184 swap = random.randint(1, 4) 185 if swap == 1: #switch with above 186 oriID = Pos2Pat[y, x] 187 newID = Pos2Pat[(y+1)%yDimension, x] 188 Patient[oriID].yLoc = (y+1)%yDimension 189 Patient[newID].yLoc = y 190 Pos2Pat[y,x] = newID 191 Pos2Pat[(y+1)%yDimension, x] = oriID 192 193 elif swap == 2: #switch with below 194 oriID = Pos2Pat[y, x] 195 newID = Pos2Pat[(y-1)%yDimension, x] 196 Patient[oriID].yLoc = (y-1)%yDimension 197 Patient[newID].yLoc = y 198 Pos2Pat[y,x] = newID 199 Pos2Pat[(y-1)%yDimension, x] = oriID 200 201 elif swap == 3: #switch with left 202 oriID = Pos2Pat[y, x] 203 newID = Pos2Pat[y, (x-1)%yDimension] 204 Patient[oriID].xLoc = (x-1)%xDimension 205 Patient[newID].xLoc = x 206 Pos2Pat[y,x] = newID 207 Pos2Pat[y, (x-1)%yDimension] = oriID 208 209 elif swap == 4: #switch with right 210 oriID = Pos2Pat[y, x] 211 newID = Pos2Pat[y, (x+1)%yDimension] 212 Patient[oriID].xLoc = (x+1)%xDimension 213 Patient[newID].xLoc = x 214 Pos2Pat[y,x] = newID 215 Pos2Pat[y, (x+1)%yDimension] = oriID 216 SUSCEPTIBLE = 0 217 INFECTIOUS = 0 218 INCUBATING = 0 219 IMMUNE = 0 220 37 DEAD = 0 221 222 for P in range(1, ID+1): 223 if Patient[P].Status == "SUSCEPTIBLE": 224 SUSCEPTIBLE += 1 225 elif Patient[P].Status == "INFECTIOUS": 226 INFECTIOUS += 1 227 elif Patient[P].Status == "INCUBATING": 228 INCUBATING += 1 229 elif Patient[P].Status == "IMMUNE": 230 IMMUNE += 1 231 elif Patient[P].Status == "DEAD": 232 DEAD += 1 233 234 Record = DeepCopy(Patient) 235 236 PercentDead = float(DEAD)/float(Population) 237 return PercentDead 238 239 def Average(Parameters, tests = 1000): 240 total = 0.0 241 results = np.zeros(tests) 242 for n in range(tests): 243 results[n] = float(StochasticEPIMOD(Parameters)) 244 print n 245 print np.mean(results) 246 print np.std(results) 247 print results 248 return np.mean(results), np.std(results), results 249 250 data = open("StochasticEPIMOD1SARSresultsDEAD.txt", "w") 251 252 Combination = [0.2860000, 9, 0.256050, 5, 0.34989, 0.462340, 17] 253 average, stdev, results = Average(Combination) 254 255 data.write("Average: %f" %average) 256 data.write("Standard Deviation: %f" %stdev) 257 for i in range(len(results)-1): 258 data.write("%f" %results[i]) 259 260 261 38 0.1 0.91525 0.1 0.87414 0.1 0 0.1 0.91696 0.1 0.72152 0.1 0.57796 0.1 0.81512 0.2 0.92258 0.2 0.89061 0.2 0 0.2 0.92245 0.2 0.82444 0.2 0.37337 0.2 0.69716 0.3 0.91566 0.3 0.90209 0.3 0.4279 0.3 0.91401 0.3 0.86564 0.3 0.24622 0.3 0.57964 0.4 0.8965 0.4 0.91003 0.4 0.68413 0.4 0.89352 0.4 0.88763 0.4 0.15879 0.4 0.46093 0.5 0.86648 0.5 0.91542 0.5 0.79698 0.5 0.86229 0.5 0.90095 0.5 0.09498 0.5 0.33827 0.6 0.82672 0.6 0.91895 0.6 0.85485 0.6 0.82146 0.6 0.9095 0.6 0.0466 0.6 0.20618 0.7 0.7782 0.7 0.9211 0.7 0.88673 0.7 0.77197 0.7 0.91513 0.7 0.00002 0.7 0.00002 0.8 0.72177 0.8 0.92223 0.8 0.90518 0.8 0.71465 0.8 0.91884 0.8 0 0.8 0 0.9 0.65814 0.9 0.92258 0.9 0.91627 0.9 0.65022 0.9 0.92123 0.9 0 0.9 0 1 0.58794 1 0.92235 1 0.92314 1 0.57929 1 0.9227 1 0 1 0 Infectivity Percentage Death Infection Rate Percentage Death Mobility Percentage Death Incubation Rate Percentage Death Mortality Percentage Death Percentage Immunity Percentage Death Recovery Rate Percentage Death 39 PARAMETERS STOCHASTIC DETERMINISTIC Initially Susceptible Population/ Total Population (Pop) N/A: There was not enough computational power to simulate population as a parameter. (PHASE I only) Total number of people in each compartment. Remains constant throughout simulation Infectivity (I) Percentage Probability of Population that Displays Symptoms When Infected Percentage of Population that Displays Symptoms When Infected Length of Infectious Period (InfP) (+/-3) Possible Time Range in which the Disease is Infectious Time in which the Disease is Infectious Mobility (Mob) Percentage Probability of Contracting the Disease from an Adjacent Diseased Individual Number of Healthy Individuals that a Diseased Individual may Infect Length of Incubation Period (IncP) (+/-3) Possible Time Range in which the Disease does not produce Symptoms (In an Infective Individual) Time in which the Disease does not produce Symptoms (In an Infective Individual) Length of Recovery Period (RecP) (+/-3) Possible Time Range in which the Disease is Present in an Individual Time in which the Disease is Present in an Individual Mortality (Mor) Percentage Probability of Infective Individuals Dying from the Disease Percentage of Infective Individuals Dying from the Disease Immunity (Imn) Percentage Probability of Individuals of Gaining Immunity After Recovery Percentage of Individuals that Gain Immunity Upon Recovery 40 SARS Data points for Fitting 153 78 158 98 159 103 165 144 166 154 186 461 187 478 188 495 189 506 202 666 204 689 210 750 211 754 216 772 221 784 228 799 229 799 231 804 238 809 239 810 242 811 243 812 244 812 249 812 252 812 41 Ebola Data Points for Fitting 7 24 279 12713 312 13697 347 14487 382 15151 413 15854 446 16236 479 16470 510 16763 42
- Library Home /
- Search Collections /
- Open Collections /
- Browse Collections /
- UBC Undergraduate Research /
- The Last Plague : Investigating the Lethality of Pandemics...
Open Collections
UBC Undergraduate Research
The Last Plague : Investigating the Lethality of Pandemics Using Deterministic and Stochastic Epidemic… Wang, Li Qing; Wu, GuanYue (Uma) Mar 9, 2016
Page Metadata
Item Metadata
Title | The Last Plague : Investigating the Lethality of Pandemics Using Deterministic and Stochastic Epidemic Models |
Creator |
Wang, Li Qing Wu, GuanYue (Uma) |
Date Issued | 2016-03-09 |
Description | This project investigates the effects of seven parameters on the spread of viral epidemics: infectivity, infectious period, mobility, incubation period, mortality, immunity and recovery period. Two algorithms were created to simulate the progression – one stochastic, and one deterministic. While the deterministic model simulates the spread through regulating the flux between compartments, the stochastic model simulates the spread by applying the parameters as a set of probabilities. The models were calibrated with current data on SARS and Ebola from WHO. Using optimization methods, we found the characteristics of viral diseases that would lead to the most lethal disease, marked by death rates of 92.26% of the world population in the deterministic model and 98.76% in the stochastic model. By investigating the effect of each parameter on the disease, we found that the key factors in regulating the spread of an epidemic are percentage immunity, mobility and recovery rate. |
Genre |
Article |
Type |
Text |
Language | eng |
Series | University of British Columbia. Science One Research Projects University of British Columbia. SCIE 001 |
Date Available | 2016-10-12 |
Provider | Vancouver : University of British Columbia Library |
Rights | Attribution-NonCommercial-NoDerivatives 4.0 International |
DOI | 10.14288/1.0319001 |
URI | http://hdl.handle.net/2429/59352 |
Affiliation |
Science, Faculty of |
Peer Review Status | Unreviewed |
Scholarly Level | Undergraduate |
Rights URI | http://creativecommons.org/licenses/by-nc-nd/4.0/ |
AggregatedSourceRepository | DSpace |
Download
- Media
- 51869-Wang_L_et_al_Science_One_2015.pdf [ 1.52MB ]
- 51869-Wang_L_et_al_Science_One_2015_rev_9_Oct_2016.pdf [ 1.52MB ]
- Metadata
- JSON: 51869-1.0319001.json
- JSON-LD: 51869-1.0319001-ld.json
- RDF/XML (Pretty): 51869-1.0319001-rdf.xml
- RDF/JSON: 51869-1.0319001-rdf.json
- Turtle: 51869-1.0319001-turtle.txt
- N-Triples: 51869-1.0319001-rdf-ntriples.txt
- Original Record: 51869-1.0319001-source.json
- Full Text
- 51869-1.0319001-fulltext.txt
- Citation
- 51869-1.0319001.ris
Full Text
Cite
Citation Scheme:
Usage Statistics
Share
Embed
Customize your widget with the following options, then copy and paste the code below into the HTML
of your page to embed this item in your website.
<div id="ubcOpenCollectionsWidgetDisplay">
<script id="ubcOpenCollectionsWidget"
src="{[{embed.src}]}"
data-item="{[{embed.item}]}"
data-collection="{[{embed.collection}]}"
data-metadata="{[{embed.showMetadata}]}"
data-width="{[{embed.width}]}"
async >
</script>
</div>
Our image viewer uses the IIIF 2.0 standard.
To load this item in other compatible viewers, use this url:
http://iiif.library.ubc.ca/presentation/dsp.51869.1-0319001/manifest