Covid 19 - Contacts

Jump to: navigation, search

Problem definition

The global Covid 19 pandemic is impacting everyone's lives. To contain the pandemic, mass events have been banned in Germany since 2020 and masks must be worn daily on public transport and in stores. These measures are increasingly criticized and disregarded by some parts of the population.

This simulation is used to illustrate the impact of bans on mass gatherings on infection rates and the extent to which wearing masks protects all members of society. It shows in several steps how successful a measure and combined measures are.


NetLogo is used for the simulation. This allows the representation of autonomous agents. Thus, pandemic behavior can be well represented in a situation where people/agents move differently in the daily routine. Hence, reality can be suitably represented in an abstracted model to show the specifics of a pandemic spread.


The model shows the abstracted version of a village. The houses of the inhabitants and points of interest (office, shops...) are randomly distributed through the village. The model simulates the daily routine of the inhabitants. The day is determined by a fixed number of ticks. At the start of a day the inhabitants are in their permanently assigned houses. At 8 a.m. all residents leave their houses and go to one of the different points of interest. In the afternoon, residents return to their homes.

In this village, the spread of Covid 19 is simulated. Residents can become infected by being close enough to infected residents for a sufficient amount of time. If the contact is long and close enough for an infection, the person turns orange. If an infection has occurred, the chain of infection is represented by a link The person now infected also become contagious after an incubation period, turns red, and can infect other persons at home, on routes, or at one of the points of interest. Infection lasts between 7 and 10 days, after which time the person may die from the infection (triangle) or become immune and turn purple.


The world consists of a 64x64 patches standard Netlogo world. One day is set as 240 ticks.

Static Elements of the World

At the beginning of each run the world is filled with its static elements, namely the points of interest and houses, each of which takes a random position. Houses are permanently assigned to agents. The number of houses is a quarter of the number of people to be generated, which is set at the start. A group of agents assigned to a house is called a family. One family lives per house.

Points of interest (pois) are stores, offices, schools etc. Which will be repeatedly visited by groups of people.

Dynamic Elements of the world

In the following, a given number of inhabitants is generated. When generated each person is assigned a random home (one-of houses) and a random point of interest (one-of pois). All people follow the same day structure: at 8 am (80 ticks) each person decides with a given probability (home-prob) if he stays at home at this day. If he decides to leave the house he goes to his assigned point of interest with a given probability (1-pois-var-prob) or goes to a random point of interest. After eight hours (80 ticks) each person heads back home where he stays till the next morning.

infection mechanism

Covid 19 Infection Mechanism

At the start a fixed number of infected and contagious people is given. The infection is indicated by setting the color of the person to red. In each tick is for each healthy person checked if there are any contagious persons within a certain radius. If infected persons remain within this radius for a sufficient time, the healthy person can become infected with a certain probability (inf-prob) per tick. If a person is infected he enters the incubation period indicated by changing its color to orange. After infection, a directed link is drawn from a randomly selected infected person present within the radius to the infected person. The incubation period length is derived from the log-normal distribution for each person. At the end of the incubation period the person becomes contagious for a given amount of time, derived from a moral distribution. After which the person recovers and becomes dies or becomes immune with a given probability. Death is indicated by a triangle. Immunity is indicated by a purple color.


It is differentiated between three types of parameters. The world parameters which describe the given situation in the village (number of people, number of pois, ...). Secondly, the behavioral parameters which determine the actions of the people and can be influenced by the anti-pandemic measures. And finally, infection mechanic parameters which describe how long a person is contagious. The parameters of the first two groups can be adjusted using sliders. The last group of infection mechanic parameters is derived from scientific findings about the Covid 19 pandemic.

World Parameters

persons - initial number of inhabitants of the village

infected-int - initial number of infected and already contagious people

cnt-pois - initial number of points of interest

Behavioral Parameters

inf-prob - the probability of infection per tick for healthy people surrounded by contagious people after a given time and can be influenced by ant-pandemic measures as wearing masks, banning mass events and reducing contacts

home-prob - the probability of a person of staying home and not leaving in the morning to any point of interest

pois-var-prob - the probability of a person to go to random point of interest instead of the one initially assigned (simulates shopping, meeting other people, staying at other points of the village, ...)

mass-event - switch to allow or ban mass events (on/off), whether mass events will take place is determined every day at 8 o'clock. The probability of this is one third. If a mass event takes place, a random point of interest is chosen as the mass event point. Then people who do not stay at home go to the mass event point of interest with a probability of 50%.

masks - switch to force people to wear masks or not (on/off)

Infection Mechanic Parameters

time-to-contagious - incubation time in days (in which the person is not contagious); drawn for each person from a log normal distribution with mean 5.8 and sigma of -1.98 [6]

time-contagious - contagious time of an infected person after the time-to-contagious in days; drawn from a normal distribution with mean 8.5 and standard deviation 0.75 [4]

death-rate - percentage of people who die after the contagious time of 0.05 [2]

Preset Values

Values are set at the beginning that an R0 value between 3-5 is achieved. The R0 value is given in research for the infectivity of a virus in case no measures are taken [3]. It should be mentioned that the R value is a value that depends on the contact behavior and population density [5].

Inf-prob is set to 0.01

people - 500

infected-int - 10

cnt-pois - 30 --> in this case 500 people / 30 are 16-17 people per point of interest

home-prob - 0.1

pois-va-prob 0.1


The results were monitored using monitors and plots.


Day - number of passed days

Reproduction number (R) - average of people infected by one infected and contagious person

Not infected - number of not infected people in the village


Statistics - shows a graph of the percentage of (infected, immune, contagious, deceased) people over time

R - shows a graph of the R value over time - the average of all individual R values of the infected people

Mass Events Tracker - shows number of mass events over time


All simulations were performed for 100 days (100*240 ticks). In the initial situation, the parameters are chosen so that the R0 value is reached at the beginning of 3-5. With time, the R value decreases more and more due to now immune persons, because they cannot infect themselves anymore and do not infect other persons. After 100 days, all persons have become infected. Herd immunity is thus achieved

simulation results when mass events are not prohibited and people do not wear masks

In the next simulation, the pandemic behavior was shown after Mass Events were banned (first measure taken by the German government). All other parameters remain unchanged. The result shows that the R value is not as high as in the previous simulation. Also the slope of the curves is less steep at the beginning.

simulation results when mass events are prohibited and people do not wear masks

In the following simulation it is shown how the infection behavior changes when masks are used. The infection rate of is reduced to 15% when FFP 2 masks are worn correctly [1,7]. This assumption is implemented with the slider mask turned on. It becomes clear that after 100 days less people were infected. 14 people did not get infected over the whole time, additionally the curves are flatter.

simulation results when mask events are not prohibited and people wear masks

Now the two pandemic-restricting measures are combined. Both effects reinforce each other. This synergy leads to an even stronger decrease in the incidence of infection. The curves flatten further. After 100 days, 46 people have not become infected.

simulation results when mask events are prohibited and people wear masks

The last simulations show the effect of a lockdown and the pandemic-restricting measures. The staying home probability is increased and the var-pois is decreased. This means that the number of different people met is reduced. The pandemic cannot spread quickly in this way. The spread increases only very slowly. The R value also remains constantly low. After 100 days, 349 people have not been infected.

simulation lockdown


The simulation clearly shows how effective the measures taken can be if all members of a society stick to them. Especially the lockdown simulation shows impressively how important it is to restrict contacts (by staying at home).

The simulation also shows by assuming an infection only through a sufficiently long and close encounter with an infected person and drawing the infection path through a link, how infections arise. Additionally, it becomes clear how these infections are passed on in households. If the members of the household go to different points such as the office, school and kindergarten the next day, the chain of infection becomes longer and longer and more people become infected. The typical exponential growth of a pandemic begins.

Keeping distance is not always possible, but the simulation shows that when fewer people are moving, it is easier to keep distance on routes and at points of interest.

In addition, the simulation shows that taking action early allows the virus to be contained after a short period of time. This result is particularly interesting with regard to tightening containment measures. It shows that early action leads to rapid containment (e.g. first lockdown in Czech Republic) and that individual measures are not always sufficient.

The measures, especially all combined slow down the exponential growth significantly. An effectiveness is, with the made assumptions about the infectivity and the effect of masks, confirmed by the simulation. However, it must be pointed out that the knowledge about Covid 19 is still developing and that even higher infectiousness can result from mutations of the virus. In these cases, it is particularly important to follow the rules and measures for containment.


Chu, D. K.; et al. (2020). Physical distancing, face masks, and eye protection to prevent person-to-person transmission of SARS-CoV-2 and COVID-19: A systematic review and meta-analysis. 395, 15. from [1]

Coronavirus (COVID-19) cases and deaths Germany 2021 | Statista. (n.d.). Retrieved January 20, 2021, from [2]

Estimate of the Basic Reproduction Number for COVID-19: A Systematic Review and Meta-analysis. (2020). Retrieved January 20, 2021, from [3]

Evidence summary for COVID-19 viral load over course of infection from Health Infomation and Quality Authority, Ireland (2020) Retrieved January 20, 2021, from [4]

RKI - Coronavirus SARS-CoV-2—Epidemiologischer Steckbrief zu SARS-CoV-2 und COVID-19. (2021). Retrieved January 20, 2021, from [5]

The Incubation Period of Coronavirus Disease 2019 (COVID-19) From Publicly Reported Confirmed Cases: Estimation and Application | Annals of Internal Medicine. (2020). Retrieved January 20, 2021, from [6]

Social distancing and masks reduce risk of getting Covid-19, major review finds—CNN. (2020). Retrieved January 20, 2021, from [7]

NetLogo File