Question: Exercise 1 . ( 1 0 0 points ) Epidemic Model In this exercise, we write code to simulate the spread of contagious diseases. In

Exercise 1.(100 points) Epidemic Model
In this exercise, we write code to simulate the spread of contagious diseases. In particular, we assume:
1. There are m hosts of a certain contagious disease.
2. These hosts are located on a two dimensional grid.
3. There are three different types of hosts:
(a) susceptible hosts - have not been infected by the disease
(b) infected hosts - have been infected by the disease and have not yet recovered
(c) recovered hosts - have recovered from the disease (Note: recovered hosts will not be infected by
the disease any more)
Initially there is a single infected host located at (0,0), and the rest of the m 1 hosts are susceptible hosts,
and they are randomly located on a 2D grid with edges that warp around (like Pacman). The center of the
grid is at (0,0), and the four corners are at (k,k),(k,k),(k, k) and (k, k), respectively. When a host
moves outside of a border, they will appear on the opposite side. For example, if a host at (x, k) moves
up, they will appear at (x,k), where k <= x <= k. The hosts move according to a 2D random walk. Use
rand()%4 to generate a direction according to the following mapping:
0- up
1- right
2- down
3- left
When a susceptible host is at the same location as one or more infected hosts, the susceptible host becomes
infected and will be contagious at the next time step. An infected host will become a recovered host T time
steps after they are infected. As time goes by, the number of infected hosts will eventually drop to 0. When
this happens, the number of susceptible and recovered hosts will not change any more. The simulation will
be stopped at this moment. In the end, we print out the proportions of hosts which are susceptible, infected,
and recovered. Hint: the number of infected should always be zero at the end of the simulation!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!