Group testing, introduced by Dorfman 
in 1943, is a powerful tool to identify infected individuals in a population using a minimum number of tests. In group testing, samples from multiple individuals are mixed and tested together. If disease prevalence in the population is low, mixed samples are not contaminated with high probability, which in turn results in gains in terms of number of tests.
Group testing algorithms where tests to be performed are designed in advance are called non-adaptive, and algorithms that use the results of previous tests are called adaptive . Traditional group testing approaches assume that infections are either i.i.d. in a population (i.i.d. model) or the number of infections is known (combinatorial model) [3, 4, 2]. Both of these assumptions are naive and do not hold in reality. Sparked by the ongoing covid-19 pandemic, many recent works have considered infection models with a community structure and proposed algorithms that exploit the community structure in order to reduce the required number of tests [5, 6, 7, 8].
Another limitation of traditional group testing approaches is the assumption that the infection status of individuals is static, whereas in practice there is a time dimension to disease spread. Using the SIR model , recent references [10, 11] consider community-aware group testing for the dynamic case. In 
, SIR model is based on a continuous-time Markovian process and the aim is to estimate the states of individuals while reducing the number of tests spent on each day using an entropy reduction approach. Entropy reduction refers to the idea that, in order to reduce the number of tests, entropy of each testing stage should be maximized[12, 13]. In , SIR model with a stochastic block model (SBM) is discretized and a theoretical guarantee for the order-optimality of the number of tests spent per day is given. In this paper, we consider a similar discrete-time SIR model with some variations in the community structure, introduce new ideas related to dynamic group testing and analyze their implications.
I-a Related Works
Our work is closely related to Dorfman’s group testing  and the group testing problem studied in  with discrete-time SIR-SBM. In , for an i.i.d. infection model, Dorfman divides the population of size into groups of size and tests these groups. This is the first stage of testing. In the second stage of testing, individuals belonging to contaminated groups are tested individually to find all infections. Dorfman finds the optimum group size to minimize expected number of tests.
In , the population consists of communities, such that the probability of infection spread within a community is larger than the probability of infection spread across communities. With a discrete-time SIR model, infections, infection spread, recoveries and interventions occur only at discrete time instants (days). In addition, test results come with one day delay; the result of a test registered on day becomes available on day . Based on these assumptions,  shows that, given the test results of the previous day, the discrete-time SIR-SBM reduces to a static group testing problem on the current day. As a result,  applies existing results from non-adaptive group testing  and shows them to be order optimal.
I-B Our Contributions
We adapt Dorfman testing to discrete-time SIR-SBM introduced in . We demonstrate the benefits of using Dorfman’s adaptive method compared to the non-adaptive method used in . As a stand-alone problem, we study the effects of quarantining individuals in a positive first stage test in a Dorfman type two-stage adaptive method, and find the optimum group size considering the opposing goals of minimizing the number of tests versus not quarantining uninfected individuals unnecessarily. The optimal group size so obtained is different than the optimal Dorfman group size.
We then apply the quarantine idea to discrete-time SIR-SBM. We analyze the trade-off between quarantine costs, test costs, and quarantine’s effect on infection spread over time. For a special case of dynamic i.i.d. infection model, we find the optimal dynamic Dorfman group size analytically, and show that it differs from the static Dorfman group size.
We provide extensive numerical results: For the SIR-SBM model, we compare the performance of the dynamic Dorfman testing proposed here with the state-of-the-art non-adaptive algorithm proposed in . For the i.i.d. dynamic setting, we show gains in terms of number of tests for static Dorfman group size versus dynamic Dorfman group size.
Ii SIR-SBM Model and Dorfman Adaptation
Ii-a Discrete-time SIR-SBM
We consider a population of size , that is partitioned into communities of size each. On any day , each individual belonging to community is in one of three states: where stands for susceptible, for infected and for recovered. We assume is an absorbing state, whereas states and are transient. During a day, the state of individuals may transition from to , or from to according to SBM that is detailed below. At time111In this paper, we use notations , , to mean the following. Ony any day, we have a fixed reference time, such as 9am. On day , means slightly before the reference time, e.g., 8:59am, when we receive the previous day’s test results; means slightly after the reference time, e.g., 9:01am, when we take measurements and submit (register) tests; and means the time between the submission of the tests on day until the test results are received on day , i.e., the time duration after and before . , infection starts to spread among population where each individual has i.i.d. infection probability, . On following days, infection spreads according to SBM with parameters . Namely: If an individual is in state at , then during it spreads infection to any of its susceptible neighbors in the same community with probability , and to members of other communities with probability . Any individual who was infected at time , can recover during with probability . The discrete-time SIR-SBM captures the disease progression of continuous-time SIR-SBM well . Although we assume that discrete-time instances are days, the model can be discretized with other time-units.
Ii-B Test Results
Infection status of an individual is denoted by , where iff . A group test takes samples from a set of individuals and tests them at once. The result of the test is , where stands for binary OR operation. The tests are registered on each day at time , shortly after that, during new infections occur. The results of the tests registered at become available at . If an individual is detected to be positive at time , it is isolated from the population indefinitely.
Ii-C Dorfman Adaptation
We use two-stage Dorfman testing on a daily basis to detect infected individuals and isolate them from the population. On the first day, we apply the first stage of Dorfman test. For the first stage testing at where , only individuals from the same community are grouped together. If an individual belongs to a contaminated group at , it participates in the second stage testing at . Any person that belongs to an uncontaminated group at is assigned to a new group at and tested as part of the first stage testing of Dorfman testing. If a person participated in the second stage testing at and was infected, we should learn the result at and isolate that individual indefinitely. On the other hand, if that individual is not infected, it will be assigned to a new group at for a first stage Dorfman testing.
We first briefly discuss why using Dorfman testing could be more beneficial compared to non-adaptive group testing used in . First, note that the use of a non-adaptive testing method, both for i.i.d. and non-i.i.d. priors, may result in classification errors. Hence, the assumption of independent infections argued in  does not hold when errors occur in decoding. Definite defective (DD) algorithm makes sure that no false-positive classification is made but it allows false-negative classifications. Moreover, since this is a dynamic problem with a time dimension, any error made at one step potentially accumulates over time. Hence, some individuals that get infected at cannot be found from the tests registered at , which will be available at . As a result they will spread infection until they are identified as infected. In fact, we will show with simulations how severely cumulative-error problems may affect disease spread.
In comparison, we use an adaptive testing method which has zero-error testing capacity . Hence, we do not make classification errors. A minor problem introduced by Dorfman testing is as follows: The infection status of individuals at time who are tested with a contaminated group cannot be determined from the results available at time , hence independence assumption of  cannot be used here. However, in order to determine an optimum Dorfman group size at , we have to know the number of infections present in each community at . We approximate this number with the expected number of infections for each contaminated first stage group with size of community as
where is the probability of infection for each individual. Using , we have . Hence each contaminated group can be assumed to contain a single defective individual. In conclusion, for an individual from community , who was susceptible at , the probability of being infected at , i.e., , can be approximated as
where is the sum of number of contaminated first stage groups and number of infected individuals in second stage tests in community at . Hence, is used to find the optimum first stage Dorfman group size at for community .
Another complication introduced by Dorfman testing is the amount of time each infected individual can potentially spread the infection. Note that, an individual who was tested together with an uncontaminated group at as part of a first stage test and who gets infected during will participate again in a first stage test at , and will be individually tested at . As a result, we will remove this individual from the population at . Thus, this individual will spread the infection during and . In the next section, we propose a novel quarantining approach and its costs in dynamic group testing to address this issue.
Iii Dorfman Testing with Quarantine Costs
Traditional Dorfman testing finds a group size for the first stage such that the expected total number of tests over the first and second stages is minimized. In a dynamical setting where disease spreads over time, and test results are not available immediately, the time between the first and second stage test results is critical in slowing down the further spread of infections. Hence, as a precaution, all individuals who belong to contaminated first stage groups at time can be put into quarantine from until . Any individual who is quarantined yet not infected will rejoin the population at . Moreover, it is not necessary to test those individuals at since they were in quarantine during . Hence, with quarantine, in (3) decreases to number of contaminated first stage groups of tests at . The decrease in decreases disease spread since also decreases. Moreover, as decreases, number of tests spent also decreases since we can mix more samples together in the first stage of Dorfman testing at . However, quarantining individuals is a burden to the functioning of the society, and even more so if many of those individuals were not actually infected. As a result, in a dynamic setting with Dorfman testing, there is a trade-off between test costs and quarantine costs, as well as disease spread. In this section, we analyze effects of this trade-off on Dorfman group sizes.
Expected test cost of traditional Dorfman testing is,
where is the first stage Dorfman group size, is the size of community , and is the infection prevalence rate. We model the quarantine cost as an exponential function of the number of people who were not infected but put into quarantine,
where is a design choice and is the number of people in community who are quarantined unnecessarily. The quarantine cost of each community is independent of others.
For analytical tractability purposes, we make a mild assumption that the first stage groups in each community are also independent. Although this undermines the exponential nature of the cost introduced in (5), without this assumption, optimum Dorfman size would depend on community size, which is not desirable for finding cost per person. However, the assumption still captures exponential behavior and the trade-off between quarantine versus test costs which is our main point here. Based on this assumption, the expected quarantine cost is,
Next, instead of minimizing the test cost in (4) alone, we minimize the weighted average of the test cost in (4) and the quarantine cost in (9), where is a design choice that determines the relative importance of test and quarantine costs,
Fig. 1 shows a comparison between the normalized Dorfman test cost alone, and weighted Dorfman test and quarantine costs, for . We plot optimal group sizes for each that are logarithmically spaced between . On the left -axis, we show optimal group sizes obtained by optimizing (4) and (10), respectively. On the right -axis, we show optimized normalized test and quarantine costs. As each unnecessarily quarantined individual has an exponential effect, we see that normalized quarantine cost of optimized (4) is greater by orders of magnitude than optimized (10), whereas normalized test costs are still of the same order. Hence, in settings with moderate and small to moderate , optimizing (10) instead of (4) decreases quarantine cost substantially without effecting test cost as much.
Iii-a Experimental Results
We consider the system model introduced in Section II with parameters SBM and . First, we experimentally show how a non-adaptive method like CCA cannot overcome the cumulative error introduced by dynamic settings if it uses comparable number of tests as dynamic Dorfman testing. Normally, on day with population size for CCA algorithm, we would have to choose number of tests as . However, as mentioned in Appendix of , the number of tests that will be used during initial days will be at least as large as and group testing will offer no advantage. Hence, for the purpose of comparing adaptive Dorfman algorithm with CCA, here we choose , which is on average more than what Dorfman testing would have used on a daily basis with these system parameters. Fig. 2 shows total number of infected people during a day testing period for different trajectories. Here, approximately of these trajectories end up with disease explosion due to cumulative errors.
Next, we examine how Dorfman testing performs for the same SBM setting for different trajectories. In Fig. 3, experimental results for Dorfman testing are displayed where we do not quarantine people who belong to contaminated groups and isolation is only applicable for individuals who test positive in the second stage. Without a quarantine procedure, of population contracts the disease, which is undesirable.
In Fig. 4, we show how these results change if we apply quarantine to contaminated groups based on the first stage results and individuals who are not infected yet quarantined join the population once their individual test results are available next day. Note that disease progression is decreased since an individual who gets infected during can spread infection during instead of during both and . As a result, number of tests spent decreases since decreases. Although the results are promising since we spend a small amount of tests and only of the population contracts the disease, unnecessary quarantine numbers are quite large which is undesirable.
Finally, when we use the objective in (10) instead of that in (4), and and choose , we obtain the results shown in Fig. 5. We observe that we can decrease quarantine costs substantially while increasing test costs. Also note that, total disease spread has increased from to since fewer uninfected individuals spend one day in quarantine during outbreak which results in vulnerability to contract the disease. Thus, (10) introduces a useful tool to trade-off quarantine costs, test costs, and disease spread.
Iv Optimizing Group Sizes for Dynamic Model with i.i.d. Infections over Time
In static Dorfman testing, the expected number of tests is minimized for a single day. For a dynamical model, on each day, group size for the first stage testing directly affects the number of people participating in the first stage of testing on the next day. Hence, optimizing the test cost for a single day may not be optimal for the entire horizon of testing. In this section, we investigate this problem for a tractable i.i.d. setting.
Iv-a System Model
Here, we consider the following simplified i.i.d. infection model: Each day, each individual that has not been infected so far can get infected i.i.d. with probability
. Any individual that has been infected is isolated indefinitely once it is classified as infected via Dorfman testing.
Iv-B Test Costs
Let denote the number of people entering the first stage Dorfman testing on day . Together with the second stage testing of these individuals, the expected number of total first stage tests on day and second stage (individual) tests that will be registered on day is,
where denotes the first stage group size on day .
is a random variable which depends onand as well as , where denotes and similarly for . To express in terms of these variables, let be the number of uncontaminated groups found from results of day and be the number of contaminated groups found from results of day . Note that . Also, let be the number of negative individuals of a contaminated group , which were tested together with some infected individuals on day as part of Dorfman first stage testing and let denote the individuals who do not catch the infection before the second stage test on day . We can express in terms of these variables as,
Then, we find expectation of each of these variables as,
Hence, by taking expectation of (13), we obtain,
Assuming that testing will take place between day and day , where individual testing stage of day will happen on day , the total expected number of tests can be expressed as,
This equation, in turn, can be solely expressed in terms of and by using (22) iteratively. Thus,
After is found, we can optimize this cost over . Let denote the optimum value for day . By inspecting (22) and (24), we see that does not depend on even though depends on since appears as normalization term. As a result, is uniquely determined by the value of . Once this is done, can be found using and . This can be iteratively done for all going backwards from to . Once we find , we proceed with the first stage Dorfman testing for day . After that, on day , we obtain the first stage results of day and we have to optimize the cost in (24) for where (and ) is no longer a random variable. We observe that impacts for . But this results in the same optimum values for since each only depends on and can only add a normalization factor for for . The same argument can be done for realization of on day for each . Hence, no matter what realization comes out for and , will be the same as initial optimum value found from (25), which means we do not have to worry about realizations of and .
Iv-C Experimental Results
In Fig. 6, we compare the performance of optimizing Dorfman group sizes on a daily basis using (11) with optimizing (25). Here, we choose , , . The curves show that by optimizing (25) we can get some benefits in terms of number of tests spent. Although optimum values of (25) are different from (11), rounding the group sizes to integer values removes some of the benefits of optimizing (25).
In Fig. 7 and Fig. 8, we compare the performance of Dorfman testing using (25) with dynamic non-adaptive group testing (CCA) using two different number of tests per day, , values. The infection model is as stated above, i.e., each day infections occur i.i.d. with , , . Here, we also show daily population size , as well as the number of people that have not been detected for more than days for the CCA algorithm (note that Dorfman testing requires at most days to find infected individuals). For CCA, if we chose the number of tests as , then, Dorfman testing outperforms CCA. If we decrease factor to as in Fig. 8, the number of undetected people explodes for the CCA algorithm.
In this paper, we introduced an adaptation of Dorfman group testing for dynamical settings with disease spread over time. We investigated the benefits as well as complications of the proposal adaptation, and compared its performance to that of a state-of-the-art non-adaptive testing method. By introducing the quarantine concept and its costs, we showed how optimal Dorfman group sizes can change, and investigated the trade-off between the test cost, quarantine cost, and disease progression. This theoretical quarantine modeling is similar to practically implemented close-contact tracing in communities during the ongoing covid-19 pandemic, where accurate tests like PCR may result in delays, during which time the individuals may be presumed potentially infected, and may be asked to be quarantined. We also showed that optimum dynamic Dorfman group sizes can differ from the static case in i.i.d. settings.
-  R. Dorfman. The detection of defective members of large populations. Annals of Mathematical Statistics, 14:436–440, 1943.
-  M. Aldridge, O. Johnson, and J. Scarlett. Group testing: An information theory perspective. Foundations and Trends in Communications and Information Theory, 15(3-4):196–392, 2019.
-  D.-Z. Du and F. K. Hwang. Combinatorial Group Testing And Its Applications. World Scientific, 2 edition, 1999.
-  J. Wolf. Born again group testing: Multiaccess communications. IEEE Transactions on Information Theory, 31(2):185–191, March 1985.
-  P. Nikolopoulos, S. R. Srinivasavaradhan, T. Guo, C. Fragouli, and S. Diggavi. Group testing for overlapping communities. In IEEE ICC, June 2021.
-  S. Ahn, W-N. Chen, and A. Ozgur. Adaptive group testing on networks with community structure. In IEEE ISIT, July 2021.
-  B. Arasli and S. Ulukus. Graph and cluster formation based group testing. In IEEE ISIT, July 2021.
-  P. Nikolopoulos, S. R. Srinivasavaradhan, T. Guo, C. Fragouli, and S. Diggavi. Group testing for connected communities. In AISTATS, April 2021.
-  I. Z. Kiss, J. C. Miller, and P. L. Simon. Mathematics of Epidemics on Networks, volume 46. Springer, 01-2017.
-  S. R. Srinivasavaradhan, P. Nikolopoulos, C. Fragouli, and S. Diggavi. An entropy reduction approach to continual testing. In IEEE ISIT, July 2021.
-  S. R. Srinivasavaradhan, P. Nikolopoulos, C. Fragouli, and S. Diggavi. Dynamic group testing to control and monitor disease progression in a population. Available at arXiv:2106.10765.
-  T. Li, C. L. Chan, W. Huang, T. Kaced, and S. Jaggi. Group testing with prior statistics. In IEEE ISIT, June 2014.
-  M. Doger and S. Ulukus. Group testing with non-identical infection probabilities. In IEEE REDUNDANCY, October 2021.