Getting things readyWhile the software computes the spread of an epidemic, it won't visualize them for you on screen, so one of the first things you may want to do is pick a plot tool (such as for instance gnuplot) to get graphical output. Also, epidemic is programmed by a config file, so you're going to need a text editor.
Layout of the config fileThe config file is divided into various blocks. Each block is initiated by a keyword. Inside each block, pairs of key/value pass variables. Create the following file as example01.cfg:
First we set up the simulation framework - here we select a time interval of 1000 days. The second block characterizes the disease - each simulated person will be infected for seven days and on each day the probability to transmit the disease to another person is 0.23. That means that we may reasonably expect to infect seven times that number, i.e. 1.61 people - during a one week cycle after which one person recovers. For a one week cycle, the magic probability beyond which the disease does not spread is about 0.15 - then statistically one new person is infected by the time one recovers. As it stands however, we can expect to see fast growth of the numbers.
The third block defines the population as a square grid of 1000 cells length, which means we simulate a million people. They are all the same social class - which we define in the following: Each of the million class members has a mobility of 100, i.e. can, during a day, visit any of the cells which are in x and y direction up to 100 cells adjacent. In other words, each person can cover one tenth of the grid length. The probability to make such a visit is one, and since we only have one social class, the fraction of the total population taken by the class has to be unity.
The rules of the game are: Every grid cell houses a person. Every person, once infected, becomes contagious for the recovery time (we pretend that to be days in the following, but it strictly doesn't matter). After that time, the person becomes immune (or dies, or self-quarantines, but is no longer spreading the disease - in the simulation no one ever dies, but you can multiply the numbers with a mortality rate of your choice). During each day of the recovery time, the person visits one grid cell within the mobility range and infects the inhabitant there with the transmission probability. Unless - and that is important - that person is already sick or immune. The simulation keeps count of all currently sick, immune and the total number of affected people (which is the sum of sick and immune).
Exponential growth and basic reproduction numberWe've set up the situation such that the length of one cycle is a week. After the week, we expect a growth by a factor of 1.61, so after n weeks, we would see a growth by 1.61 to the power of n. These 1.61 are called the basic reproduction number R0.
If we start with 10 seeded infections in the population, we should hit the million between the 24th and the 25th cycle, i.e. after about 170 days.
Starting the simulationRun the tool from a commandline via
You'll see a count of days and cumulated number of infections, and at the end there will be several data files produces. If you plot the file epidemic.dat (below the gnuplot software was used) that was created, you should see the growth curve:
For comparison, we also show an exponential growth fit to the first onset. If you're alert, you can spot that the simulation actually grows faster than we estimated - R0 found in the fit is rather around 3.3! .
Where is this difference from? Well, in the model you can 'get lucky' and infect a person from day one - by the end of the week, that person might also have infected someone, so the exponential rewards early infection events very strongly while not penalizing late ones - so simply averaging the effect per day underestimates what is happening. (Well, what we could have estimated instead is to take 1.23 to the 7th power - that would have been the upper bracket) In reality, the probability is enough to triple the numbers every week, i.e. reach the million after just nine cycles or about 65 days.
It is also very obvious that the curve doesn't actually to a million but levels off before. At some point, it becomes improbable to find enough healthy people to sustain the growth, and some just get lucky and their cell is never visited. Up to this point, you probably got the impression that exponential growth is very impressive - in just about two months, we can go from 'a handful of people brought the disease' to 'pretty much everyone got sick'. But - is it also realistic?
Implicitly (by declaring the mobility a large value) we have assumed that each person (!) in the simulated world has about 40.000 acquaintances (!) and is ready to drive 200 km every day into a different direction to randomly meet one of them. That however is not what most people really do most of the time. Most of the time, they stay at home, or close to it. Does that matter? That's what we'll study next.
Continue with Flame fronts.
Back to main index Back to science Back to numerical epidemic