In today's society, the coronavirus plagues the globe. As much as direct mitigation of the such a pandemic is crucial, what's more important is both the prevention and control over another pandemic similar to the novel coronavirus. CoronaSim aims to provide a streamlined means to simulate a pathogen with sophisticated, yet adaptive, technology.
What it does
CoronaSim essentially simulates a modern city with the use of hidden nodes and agents. Several features have been added so the user can customize what type of environment and factors the simulation is conducted on. This allows the user to see the effects of demographic factors as well as preventative measures on infection rates, such as quarantining a building. The user can also analyze the simulation in real-time with a graph to gain a better understanding of the correlation between infected and recovered.
How I built it
In terms of the "science" behind it, CoronaSim is inspired by the Susceptible-Infected-Recovered (SIR) model. For the sake of technicality, the people being simulated are referred to as "agents". At initialization, each agent is assigned the "Susceptible" state, with the exception of the indicated number of "Infected" agents. As time passes, infected agents spread the pathogen to rest of the simulated population and other agents get infected as well. After contact with infected agents, they switch into a "Recovered" or a "Dead" state based on probabilistic values. Each agent's state function and data is stored server-less for seamless computing and processing as well as limiting lag on clients.
The probabilistic values are defined on a deterministic Markov chain. A Markov chain is a model utilized describe possible event sequences that can occur in the future. In CoronaSim, the Markov chain determines whether the agent is to be infected or dead based on contact. Additionally, all agent pathfinding is facilitated by a similar Markov chain between varying building nodes, which are acting as schools, supermarkets, and hospitals.
In regard to the simulation, the simulation’s clock operates as a function of ticks. Each tick, every agent is subject to a transition model optimized with the weights of the coronavirus. For example, susceptible agents can only transition to infected after contact meanwhile infected agents can transition to recovered or dead. Additionally, the model is compiled based on the assumption that recovered agents have developed some extent of immunity to the pathogen.
Also, to better the user experience as well as improving public awareness/education, I did some analysis and compiled data on the Demographic Transition Model (DTM), a means to evaluate demographic conditions in varying regions of the world. I applied the DTM to CoronaSim and created pre-determined logarithmic weights for the major regions of the world, based on factors such as climate, population density, and technological/medical development. This allows for the health application of CoronaSim to be more applicable as well as providing characteristic details for researchers and analysts.
Challenges I ran into
Storing each individuals agents state and contact tracing proved to take up a lot of memory and processing power. Therefore, the code monitoring agent state had to be optimized for minimalistic operation while still providing precious real-time feedback. Real-time monitoring was also a struggle in terms of the way I had to think about approaching the solution itself.
Accomplishments that I'm proud of
I had a hard time with real-time data analysis and plotting but, by managing data in individualistic agents, I was able to create a wireframe in which the agent's state was reported directly to the module plotting the data points/line on the graph. Although seemingly small, I think it definitely makes a difference to the overall user experience.
What I learned
I learned how to: create multi-step functions for simulation, use the Demographical Transition Model, create a React frontend, maintain a responsive and intuitive UI navigation, create a Markov chain, and collecting data in real-time, all while supporting various frontends/backends to make a cohesive application.
What's next for CoronaSim
At this point, I had compiled world data from the Demographic Transition Model and applied the contrasts to different regions of the world to generate weights. Ideally, the DTM data would be collected through an API to provide relevant statistics to exponentially increase the precision of CoronaSim simulations. This way, CoronaSim not only acts as a stand-alone simulation, but a full-fledged technology for everyone to use in any way possible.