Skip to main content

After all, how does COVID-19 continue to spread? - A simulation (How it was built)

This "project" started with my curiosity about the covid-19 spread around the world. In my own country, and after everyone knows all health authorities' rules, the virus is now attacking harder than never before. Why the virus still continues to spread? This is one of my big questions. So I did this simulation-like project to study the influences of people behaviours in the overall number of infected people. As an example, evaluating the influence of 50% of the people within an area not wearing a mask, or not respecting the social distance as we should.
Stop The Spread. Image created by Hazem Asif. Submitted for United Nations Global Call Out To Creatives 

To build the simulation I used the python programming language and the Object-oriented programming paradigm. I did not use any python library to build the simulation environment itself. It is just two classes to represent the Agents and the Simulation.

Classes

  • Simulation
    • The class that stores the list of agents in the simulation and "performs tasks" such as updating the health status, the quarantine zone, and move the agents on each day of simulation.
  • Agent
    • The class representing the agent where we defined each agent's characteristics such as age, position in the environment, health status, name, number of days with the virus,  and so on.

The simulation is based on random agent behaviours to simulate the free will of real persons. So, the functions to move the agents use a randomly generated number in the x-axis and y-axis. I also added a parameter to limit the agent's movement ray to test cases where the agents' moves are limited, and a social distancing value that forces the agents to choose a position, when they need to move, with a distance to another agent greater than the social distance value. 

As you must already found out, the simulation has two dimensions to represent the agent's position (x-axis and y-axis). The environment's size is also configurable to evaluate the free space impact in the virus spread.

With regard to the agents, we have two different ways of creating them: 

  1. We can create n agents based on probabilities of being Healthy, Sick, Asymptomatic, or the agent's immune system response to the virus being moderately infected, etc. 
  2. The other possible way is by specifying the number of agents of each type of health status and immune system response
Please note that only in the first case the age of each agent is used as the factor to indicate the immune system response. The second approach, defined as static begging in the simulation, do not take into account the age of the agent. Here, the immune system response type is randomly distributed by the agents, according to the specified numbers for each type.

The age influence

In the random beginning approach, I use probabilities based on real data from my country when it comes to death data by age range. The data was retrieved from the response of one service from this site. After that, I stored the data to have it in a file (I chose not to call the service and avoid that implementation since it takes time). Then I handle the data so I can have, for instance, the percentage of people that die grouped by age range. You can find that logic at the end of constants.py file. In other cases, I simply defined probability values that I think are valid. Almost all values can be changed in the configuration file (config.yaml) if you want to test the Simulation. The file also includes the variables' meaning in the simulation context through code comments. 

Using the Simulation

After having your own configurations, you can run the simulation in a trivial graphic mode. This simulation mode shows an image in a black background and the agents represented by pixels with different colours, also configurable in the config.yaml file. In each simulation day, the image is updated. I chose this approach as it is quite simple and quick to develop, and my focus was not in the graphical part. You can also run a parallel small script to show you, in real-time, the current simulation's cumulative values. To run the simulation you should read the README.md file at the root of the project.
Simulation graphical mode

Simulation Test Cases and Outputs

For readability, I had split the post into 3 so you can find the key points you want to know. The simulation results can be found here.

Code

You can find the simulation's code at Github.

Comments

Popular posts from this blog

How does COVID-19 continue to spread? - A simulation 2.0 (How it was built)

 Unfortunately, the days we are living right now are still bad, or even worse than ever. Millions of people are being killed by this "new virus", as they called it once. COVID-19 is here and will be among us for too long. Some of us thought, incorrectly, 2021 will be the year, we will have vaccines, that's it! No more problems related to COVID-19! Let's start living as before!  No, no, no! If you still think this way, please stop it right now. By not respecting the known procedures to avoid the COVID-19 infection you will keep the virus spreading chain. Consequently, the virus will kill more people, being them related to you or not. Many apparently  healthy humans are having severe "side effects" by getting infected with this virus. Stop thinking the virus provokes just flu and help to stop the spread!  Millions of healthcare professionals are giving their lives to help in this war. You are neglecting them and all the people around you! Keep yourself safe

Artificial Intelligence History

As you know, AI today is a widely used tool in every kind of systems. However, how did it start? We had only one inventor or more people had invested in AI? AI is a recent discovery? When it became so powerful and why? Today's post will put you up to date to the Artificial Intelligence History. Alan Turing Well, everything started alongside the Second World War. Sadly, some of the human's biggest discoveries occurred during wars.  In 1943,  Warren McCulloch and Walter Pitts presented an initial mathematical and computer model of the biological neuron [2].  There was 1950 when John Von Neumann and Alan Turing created the technology behind AI.  Turing created the called Bombe machine to decipher messages exchanged between the German forces. That system was the pillar of today's machine learning [1]. Turing was a huge impact in the Artificial Intelligence field, and still today some of his statements are updated and used.  Turing questioned the possible intelligence of a ma

How does COVID-19 continue to spread? - A simulation 2.0 (Results)

This post shows some of the results we can find by using the simulation. As in the first version I made some tests, now I focused the new tests on the travelling and vaccination processes. These two processes were added in the last simulation version and represent some critical behaviour and processes in the virus spread. Photo by Sharon McCutcheon on Unsplash Vaccination process impact Using the standard static configuration values we can find the following results: The vaccination process does not have a considerable impact if we close our borders. By not receiving new agents with the infection, the simulation reaches the number of 0 infected agents on the 38th day using a vaccination percentage of 0.1 If we increase the vaccination percentage to 0.9 the 0 infected agents threshold is reached on the 39th day. Thus, we can infer that if we control the flow of agents in a city/simulation, the vaccination process does not have a considerable impact as it takes some time until the people