The model of the city is a rectangle on a two-dimensional r×c square lattice, which is composed of b blocks and streets around each block. The width of the streets is 10 meters, and each block is a 40×100 meters rectangle made of 5 floors buildings. Each floor consists of the 50 house, so each block contains 250 house. The population is divided into four groups: Healthy (H), Infected (I), Critically Affected by Infection (C), and Recovered Healthy cases (R). Each cell in the lattice can either be occupied by one person, or remain empty. To simplify the algorithm, one separate matrix is defined for each case, and the state of each cell is represented by either 1 (existence of case) or 0 (empty space). According to the real world’s available data, the average time between exposure to COVID 19 and recovery is approximately 14 days in both mild cases and C cases. In the simulation, three dimensional matrices are defined for I and C cases. So the state of the street matrices is defined by H[i][[j],R[i][[j],,I[i][[j][[k],, andC[i][[j][[k]where 1≤i≤r, 1≤j≤c, and 1≤k≤14, with k representing how many days a case has been infected. These four matrices are transparent and imposed over each other in such a way that each cell of the street can be either occupied by only one kind of a case or empty. In other words, the sum of these elements for all k must be equal to 0 or 1. A separate state for dead people is not considered, and during the simulation these cases simply will be removed from the city. The H, I, and R cases can move inside and outside of their home, but C cases, because they need special care, are transferred to their home at each time step and remain there until their fate has been decided. In the street, people can move, but no movement at home is accounted for. The basic supposition is that the space of the home is small and peoples are in close contact with each other. The maximum population at each home is limited to 6 people. All homes in the city can be represented by one matrix with b×250 rows and 6 columns. Each row of matrix represents one home. To simplify the algorithm, for each case a separate matrix is defined and the home matrix is made by imposing these 4 transparent matrices. So the state of the home matrices is defined by Hhome[m][[n],Rhome[m][[n],,Ihome[m][[n][[k],, andChome[m][[n][[k]where 1≤m≤b×250, 1≤n≤6, and 1≤k≤14. The sum of these elements of home matrices for all k must be equal to 0 or 1.
Each time step in the simulation is equal to one hour and composed of several stages. In the first stage, one person from each home will be selected randomly and moved to another randomly selected empty location in the street with a Pexit probability. The value of the Pexit depends on the quarantine conditions. In this stage, H, I, and R cases can come out of the home and distributed randomly in streets, but C cases remain in their home. We know that many infected people are not aware of their infection, so I cases can come outside freely, but C cases need special care and remain in their home or in a hospital. When each case has left its home, its state in the home matrices is represented by the number 2. These numbers will be helpful because, in the final stage, each person must come back to its own home, otherwise quarantining is meaningless.
The second stage, called the reaction stage, is converting the cases according to the following transition rules. For the H cases in the street, the Moore neighborhood is used. If the H case has at least one I or C case in its neighborhood, it will be converted to an I case with a k = 1, with the probability of infection represented by PI. Otherwise, the H case remains an H. As shown in the next section, the value of PI is very important, and we do not have any experimental knowledge about it, but with available data from the growth of the number of infected cases in each country, the value of PI can be estimated for that country. If at least one I or C case stays at home, the H cases at home will be infected with a PI probability and converted to an I case with a k = 1. Otherwise, the H cases remain an H.
The transition rules for the I and C cases at home or in the street at this stage are as follows:
For an I case with a k = 14, the infected case can recover and become a healthy R case with a PR probability. Otherwise, the I case converts to a C case with a k equal to 1. For an I case with a k < 14, after each 24 time steps, one day will be added to its k value (k will be changed to k +1).
For critically affected cases with a k equal to 14, the C case may die with a PD probability and its state will be either replaced by zero or recovered to become a healthy R case with a 1-PD probability. For a C case with a k < 14, after each 24 time steps one day will be added to its k value (k will be changed to k +1). The recovered healthy case remains an R in the reaction stage.
At home, if Hhome[m][[n] = 2 orRhome[m][[n] = 2 or Ihome[m][[n][[k] = 2 orChome[m][[n][[k] = 2, their condition will not change and only their k will be replaced with a k +1 after each 24 time steps. If Ihome[m][[n][[14] = 2 orChome[m][[n][[14] = 2, they remain unchanged during the reaction stage because number 2 is an indicator reminding us that we had one case in the corresponding location before the cases moved out of the home.
After the reaction stage, we let the cases move in the street. For the movement of the cases, the algorithm first introduced by Vanag9 is used. In this method, the lattice is partitioned into 3 by 3 squares. In each partition, in each time step, the number of H, I, C, and R cases will be counted and redistributed randomly in such a way that the number of each case remains fixed. In the second, third, and fourth time steps, partitions move one cell to the right, down, and left respectively. In the next time step partitions move one cell up, and this procedure will be continued throughout the simulation. This method is similar to the random movements of the cases, and the movement of the partitions allows the cases to walk in the streets.
In the final stage, all cases can come back to their homes. The movement of the cases from the streets to home must be done with care. We must pay attention that the number of members in each home not exceed its initial state. The second point is that in the real world, the I and C cases must not move freely between homes and each case must come back to his or her original home. But so long as we put such polite manners and morality aside, returning to one’s original home will not matter in a simulation, as long as the I and C cases return to any home with similar conditions to their original homes. We know in the reaction stage the number of all cases will change, and we need a simple strategy for manipulating the movement of the cases from the streets to their home. The number of H cases in the street will be reduced during the simulation, because in the reaction step, the H cases may be converted to I cases. So each H case can leave the street with a 1-Pexit probability and come back to a randomly chosen home with Hhome[m][[n] = 2 and the number 2 will be replaced with 1. What about the infected cases? The infected cases in the streets have two sources. Some of them have come from a home in the first stage and some of them are created in the reaction stage from H cases. So, at first, each infected case with a k (I[i][[j][[k] = 1) can leave the street with an 1-Pexit probability and come back to a randomly chosen home with Ihome[m][[n][[k] = 2 and stay there. If there is not a home with an Ihome[m][[n][[k] = 2, then it goes to a randomly chosen home with a Hhome[m][[n] = 2. In other words, we set Hhome[m][[n] = 0 and Ihome[m][[n][[k] = 1, because this additional infected cases came from H cases and all the H cases had been at a home at the beginning of simulation. All C cases must be removed from the streets because they need special care or hospitalization. Remember that the C cases in the street have a k = 1 (they are created in the reaction stage) and are produced from the infected cases whose k = 14, which themselves have two sources as explained. So each C case must go to one randomly chosen home which has an Ihome[m][[n][[14] = 2, then one C case with a k = 1 will be placed in the corresponding location. In other words, Chome[m][[n][[1] will be equated to 1 and Ihome[m][[n][[14] will be equated to zero. If there was not a home with an Ihome[m][[n][[14] = 2, then C case goes to a randomly chosen home with a Hhome[m][[n] = 2. In other words, we set Hhome[m][[n] = 0 and Chome[m][[n][[1] = 1. The recovered healthy cases in the street come from two sources. They may have come from a home in the first stage, or they may have been created by I cases with k = 14 in the reaction stage, and we know that all the infected cases were healthy at the beginning of the simulation. So each R case can leave the streets with a 1-Pexit probabilityand sit at a randomly chosen home which preferably contains either an Rhome[m][[n] = 2 if not an Ihome[m][[n][[14] = 2 or lastly an Hhome[m][[n] = 2.