1 Introduction

The Corona pandemic has been with us for the last years and is still a major concern today. After the outbreak of the pandemic in 2019 people’s travel behaviour contributed to the rapid spread of the virus around the world. For this reason, the rate of contacts between people from different places plays an important role in this work. The infection caused long-term health problems for some and led to high mortality because vaccines were not available. Some statistical data is shown in Sect. 3.

After the virus had spread throughout the world and more and more people had deceased after contracting the virus, politicians were called upon to react. There were various ways to handle this situation. Countries like Italy, Spain and Germany pursued a strict strategy to suppress the spread [cf. Gibney (2020)]. Strict lockdown measures were state-imposed. They included school closings, shop closings, cancellation of public events and work from home where possible. Restrictions were imposed to keep the contact rate as low as possible and they were valid for the whole country at times. Sweden and at the beginning, in February and March 2020, also England pursued a different strategy, with little to no restrictions. The aim was to achieve herd immunity [cf. Gibney (2020)].

State intervention was strongly debated, because it effected negatively the economic situation of the respective country. Due to the many closures, production came to a standstill. In the catering sector for example, many people were put out of work and were left without salary. Restrictions caused economic damage. The focus of this paper is to find the best strategy to minimize the economic damage while taking the human damage caused by an infection into account. In order to decide whether or not measures are necessary, the spread of the Coronavirus must be considered.

As explained above, the mobility in a population expedites the virus spread. For that reason, it is appropriate to divide the considered area into smaller districts and consider traffic (contacts) among districts. Each district represents a node in a network and the weighted connections represent the contacts between the nodes.

To predict the spread of an infection we use a popular deterministic model, which is called SIRD model [cf. Fernández-Villaverde and Jones (2020)]. The population is divided into subgroups. SIRD are the states a person might go through, if exposed to the virus, see Fig. 1. At the beginning, every person is in state S, S means susceptible. If a person gets infected, this person’s state changes from S to I, I for infected. In state R a person is not infectious any more. This person is either recovered or it is dead. If a person is recovered from the illness, it is in state C for reCovered. Otherwise, the person is dead (D). Note that the SIRD approach assumes that those who are recovered (C) will not be infected again. For obvious reasons, the same is true for dead persons (D).

Fig. 1
figure 1

SIRD state transition

We assume in this paper a multi-group-SIRD (MG-SIRD) model, which means, that we have such state transitions in each district, i.e. for each district \(i \in {\mathcal {G}}\), \({\mathcal {G}}\) being the set of districts under consideration, we have \(S_i, I_i\) and \(R_i\). \(S_i, I_i\) and \(R_i\) denote the fraction of the respective subgroup from the total population in district i. For C and D we do not need district specific numbers. It is sufficient to consider total numbers for the recovered and dead ones. C and D are absolute values, not fractions. For two districts, you can see an illustration in Fig. 2. Note, that for each node \(i \in {\mathcal {G}}\) the equation \(S_i + I_i +R_i=1\) should hold. The total population size of district \(i \in {\mathcal {G}}\) will be denoted by \(N_i\). \(N_i\) is a fixed number and includes those who are dead.

Fig. 2
figure 2

SIRD state transition in two districts, [cp. Acemoglu et al. (2021)]

The special thing about a MG-SIRD model is that it takes into account the interconnectedness of the districts. We not only consider contacts between people from the same district, but also contacts between people from different districts. Figure 3 illustrates the situation in our example with two districts. The virus can spread further via these contacts from one district to the other. All other contacts are not relevant for studying the spread of the disease. E.g. contacts between people in \(R_1\) and people in \(S_2\) are not important here. That is why these contacts are disregarded. To predict the development of the pandemic, it is assumed that the contact rates remain constant. Roques et al. (2020) proved on the basis of different SIR and MG-SIR models that pandemic policy influences the prediction of deaths, using France as a case study. They show how restrictions on gatherings between districts and within districts decrease the number of deaths. Therefore, we also consider in this paper a MG-SIRD model.

Fig. 3
figure 3

SIRD state transition in two districts (with relevant contacts among people from different districts), [cp. Acemoglu et al. (2021)]

The contribution of this paper is that we not only simulate the pandemic by using a SIRD model, as it is commonly done, but we also optimize countermeasures on the basis of that model. For this purpose, a finite planning horizon is divided into discrete periods so that the dynamic nature of the situation can be taken into account. It is important to mention that we are looking at a time horizon before a vaccine is available. In order to optimize the most effective countermeasures, we are evaluating whether the measure is operational within a particular district or not. The impact of measures on the contact rate between districts and the spread of the virus is examined using examples. As a proof of concept, this optimization model is applied to a case study.

The structure of this paper is as follows: the next section provides a literature review. Section 3 shows some practical data of policy response and mortality rates in some selected countries during the first two years of the Covid pandemic. After a detailed problem formulation in Sect. 4 a mathematical model is shown in Sect. 5. In the sixth section, our model is applied to a few examples composed of cities in Germany.

2 Literature review

Due to the Corona pandemic interest in the spread of viruses and the possibilities of preventing them increased. Already in the year 1927 Kermack and McKendrick (1927) and Kermack and McKendrick (1932) dealt with an influenza epidemic in London and its spreading. They partitioned the population according to different states a person can go through when suffering from influenza. Their resulting model was a predictive model and serves as the basis for all SIR models. In their work they came to the conclusion that, for a pandemic to break out, the percentage of infected people has to exceed a critical number.

More and more scientists from the fields of physics and mathematics as well as epidemiologists have been looking into the topic of the spreading of diseases especially in networks. Pastor-Satorras et al. (2015) published an overview paper about different approaches for studying epidemic spread in networks. Among other models, the SIS model is discussed, which is another form of the SIR model, based on the assumption that, after an infection, people are not immune and repeated infections are possible. Pastor-Satorras et al. (2015) not only presented different model variants, but they also examined different networks like weighted, directed or bipartite networks.

Simulating a pandemic using SIR-based models is very common and the SIR model can be extended in many ways. Hethcote (2000) added the group E of exposed people that are those, who are infected, but not yet infectious. It can include people, who had contact to an infected person, or who are unaware of an infection. This subgroup is important if testing and quarantine are included in the simulation of virus spread, which is what Berger et al. (2020) analysed. This extension of the SIR model is then called SEIR model. Hethcote (2000) modelled the spread of infectious diseases with different scenarios. Hethcote (2000) not only added the subgroup E to the SIR model, he also analysed passive immunity of newborns, if mothers were infected during pregnancy. Chari et al. (2020) call the subgroup E \({\hat{I}}\)-agents, who are not known to be infected. They also model virus spread with and without testing and with quarantine. Another modelling approach are SIRD models, which include a mortality rate and the distinction between survivors of the disease C and the deceased D. Group R is split into groups C and D, see Fernández-Villaverde and Jones (2020) or Acemoglu et al. (2021). Rowthorn and Maciejowski (2020) simulate different lockdown strategies in England with a SIRD model with the assumption, that group D is a part of group R. Their SIRD model and their paper Rowthorn and Maciejowski (2020) is based on Rowthorns publication in 2020 (Rowthorn 2020).

There exist several more options to extend a SIR model. In addition to the already mentioned extensions SIS and SEIR, there is also a SEIRDC and a SIRS model variant. SEIRDC is just another name for a SIRD model, and SIRS means that a recovered person loses immunity after a certain time.

An extension that is very different from the previous SIR models is a multi-group (MG)-SIR model. As with the SIR model, there are also several options for multi-group models. Each extension (SEIR, SEIRDC, SIS, SIRS,...) can be transformed into a MG model. For example, Acemoglu et al. (2021) assume a multi-group model. In Lin and Jiang (2013) a MG-SIR model with parametric stochastic perturbations is examined and the existence of an endemic equilibrium in the form of weak stability is proven. Global stability of an endemic equilibrium in multi-group models is analysed and proven in the papers Muroya et al. (2013), Guo et al. (2006) and Sun (2010).

Alfaro et al. (2020) studied both, a SIR and a MG-SIR model, whereas the latter is being called SIR-Network. In their prediction, Alfaro et al. take into account the behaviour of individuals. Fear influences the reaction in pandemic. They assume that vulnerable people reduce social activity or younger people are considerate of older people. They simulate lockdown measures under these conditions to determine the impact of decisions on the spread of infectious diseases. Makris (2021) assumed two types of individuals in group S, high-risk and low-risk susceptible individuals where individuals in the high risk group are more cautious. Markis discussed the impact of various scenarios, higher degrees of social distancing and the length of a lockdown on UK data. Dolbeault and Turinici (2021) used a different kind of multi-group model. They divided S into subgroups \(S_k\), different age groups differ in their susceptibility to infections. The rate of infected people remained unchanged in group I. This way quarantining susceptible groups could be simulated.

During the Covid pandemic optimization of policies, lockdown sanctions or optimal vaccine distribution became interesting. Jordan et al. (2021) published a literature review consisting of publications from 2020 till 2021. Jordan et al.’s (2021) review includes publications that not only analyse the prediction of the virus spread but also includes studies in connection with the prediction and control of the pandemic. The studies address optimisation of test strategies, predictive models, resource allocation, vaccine distribution, spread control measures and decision support.

The control of the virus vaccine distribution often plays a big role, as in the paper of Gaff and Schaefer (2009) and Sharomi and Malik (2017). Gaff and Schaefer minimize the number of infected people and thus indirectly the number of people who die from the disease. They investigate studies on SIR-, SEIR-, and SIRS models including different vaccination and treatment options with different infection and death rates. Just as with Gaff and Schaefer, the vaccine also acts as a control variable in Sharomi and Malik (2017). Their aim also is to minimize the number of infections but also to minimize the vaccination costs. They proof theorems, which show that an optimal control variable exists for the following models: SIR, SIR with quarantine and isolation and SIR with Infected who need medical treatment.

Aspri et al. (2021) added a new subgroup of asymptomatic people (A), which are infected but with no symptoms, and studied an SEIAR model. Intervention by political measures on the economic, as well as the number of deaths as an indicator of the epidemic were considered. However, only the intensity of the measures were analysed and simulated. Caulkins et al. (2021a) analysed the optimal intensity of a lockdown, taking into account the resulting economic and humanitarian damage. The health damage is represented by deaths and the economic damage by unemployment. Caulkins et al. (2020) analysed the optimal length of a lockdown using an SLIR model and Skiba points. Here the subgroup L are the asymptomatic and pre-symptomatic individuals. The duration of a lockdown depends on the start time of the lockdown. The later it starts the shorter it is. They showed that different strategies can be optimal. Caulkins et al. (2021a) extended these studies by the fatigue of people during a longer lockdown where fewer people follow the rules. They analysed strategies ranging from long lockdowns to short lockdowns. In the same year Caulkins et al. (2021b) revised the parameters of previous publications to cover the new “UK Variant” with greater infectivity.

Alvarez et al. (2021) used a SIR model with quarantine and lockdown influences. They also studied the duration and intensity of a lockdown by minimizing the resulting costs due to a lack of productivity in the economy and due to deaths.

Acemoglu et al. (2021) simulated for each age group a SIRD model and studied “targeted policies that apply differential lockdowns on the various risk groups” (Acemoglu et al. 2021, p. 2). The goal was to minimize the economic damage caused by the quarantine of infected people and by deaths. Hsu et al. (2020) analysed a MG-SIRD model considering work from home and containment. They analysed South Korea’s containment policy in comparison to other countries.

Cont et al. (2021) looked at targeted policies in 133 regions in England. Targeted measures based on local control were shown to be more effective in dumping a pandemic than large-scale measures at the country level. To model the epidemic dynamic they used a MG-SEIAR model. Multi-group means in the paper Cont et al. (2021) that each region is a group. In addition, the population in each group was divided into age groups. For each homogeneous subgroup (region and age), the pandemic spread was modelled by an SEIAR model. Instead of a deterministic model, they used a stochastic model based on a continuous-time Markov process. Cont et al. (2021) showed that the protection of targeted subgroups contributes to the reduction of mortality.

The following papers are about the allocation of resources based on simulations with a MG-SIR model. Shamsi Gamchi et al. (2021) deal with a spreading infection after a natural disaster. They combined a vehicle routing problem with a MG-SIR model to optimize the vaccination strategy. Every district has its own MG-SIR model before and after the start of vaccination. Different priority groups can only be infected by each other within one district. Contacts between districts and different priority groups are not considered. In contrast, such contacts were considered in the paper by Nonato et al. (2022). The contact rate between districts is called infection rate in Nonato et al. (2022). The commuter traffic during the day and at night was taken into account. For the state of São Paulo in Brazil, two case studies examine the impact of different policies on intensive care bed capacity. For Birge et al. (2022) the aim was not to provide decisions on closures but to highlight the value of targeted measures. Closures through targeted measures cause a lower economic cost than an “all districts” closure per se. A MG-SEIR model served as a basis. Districts are counties in New York City and outside of New York City. In the optimisation problem the goal is to dampen the pandemic by reducing the number of infections. At the same time, the goal is to minimize the economic costs of closures. In this case, particular attention was paid to unemployment due to lockdowns when working at home is not possible. As in Nonato et al. (2022) mobility plays an important role in Birge et al. (2022). It is divided into commuter traffic and leisure activity. Lockdown sanctions influence the movements between nodes and the associated contact rates between infected and exposed persons. It is shown in Birge et al. (2022) why the consideration of movements between districts is important and that it has a high influence on optimal solutions. Freiberger et al. (2022) also considered movements between districts. Again, a MG-SIR model is considered and each node represents a district. Freiberger et al. (2022) extended the SIR model by including tests and quarantine. Infectious people are divided into light and heavy cases. Light cases are people without or with light symptoms which are detected through tests. Both light cases and heavy cases are isolated in quarantine. Measures reduce the transmission rate between susceptibles and light cases. Measures are not differentiated into concrete measures in the process. The aim is to find the optimal test and transmission rate to minimize resulting costs. The costs under consideration consist of costs for testing, treatment costs, costs of lost lives and costs for reducing transmission rate.

Abdin et al. (2021) took into account tests and quarantines. The focus is on the optimal testing time and level. They added a lot of new characteristics to a MG-SIRD model, such as, for example, risk levels, symptomatic and asymptomatic infections, tested and untested people, and hospitalized patients.

Many publications search for the most effective measures or the intensity of measures through various simulations using a SIRD model. The contribution of this paper is to optimize one’s strategy based on that model and taking into account accruing costs. Policy measures and their effects on contact rates and the negative effect of economic costs are investigated. The aim is to minimize the economic costs arising from the measures and, at the same time, to minimize the economic and medical costs due to infections. We analyse different measures and different sizes of districts. The cost to reduce the contact rates between the districts also varies by district size.

3 Practical data from selected countries

Data from the Covid pandemic is available from ourworldindata.org, a daily updated website where Corona statistics for every country is compiled. This section presents data on deaths and a stringency index for selected countries over the years 2020/2021. The countries considered are the United States, the United Kingdom, Sweden, Brazil, Austria, Germany, Hungary and Italy. These countries prove relevant because they show significant differences not only in the implementation of Corona policies, but also in the number of fatalities at different points in time.

In Fig. 4 the Covid-19 stringency index is shown, see Oxford Coronavirus Government Response Tracker (2022). This index is a value from 0 to 100 and is shown from January 2020 to December 2021. A higher score indicates a stricter response. This index is a composite measure based on nine policy response indicators, including: “school closures; workplace closures; cancellation of public events; restrictions on public gatherings; closures of public transport; stay-at-home requirements; public information campaigns; restrictions on internal movements; and international travel controls” [Our World in Data (Mathieu et al. 2020b)]. After having developed a Corona vaccine, nations differentiated their policies in January 2021. Restrictions on the non-vaccinated continued to be strongest, they are depicted by the upper lines in Fig. 4. The lowest lines represent the stringency index for vaccinated people. The line in the middle is a weighted average of vaccinated and non-vaccinated.

Fig. 5 displays the 7-day rolling average of confirmed Covid-19 deaths per million people in the period from March 2020 to December 2021. In Fig. 5 death figures are shown for the same countries as in Fig. 4. The range of the 7-days rolling average is on the ordinate between 0 to 25 deaths per million. These are estimated numbers. “Due to varying protocols and challenges in the attribution of the cause of death, the number of confirmed deaths may not accurately represent the true number of deaths caused by Covid-19” [Our World in Data (Mathieu et al. 2020a)].

It can be seen that over time, Corona measures have increased and decreased at similar times in many countries. Comparing the countries, the stringency index decreased the most in Austria and Hungary in the summer of 2020. In the other countries, the index also decreased, but by a much smaller percentage than at the beginning of the year. Once the vaccine was available, there were differences in the measures taken in different countries. Countries like Germany, Austria or Italy have the greatest differences in restriction policies regarding vaccinated and non-vaccinated populations.

Fig. 4
figure 4

Covid-19 Stringency Index in 2020 and 2021. Source: Last updated Nov 14, 2022 https://ourworldindata.org/covid-stringency-index (Mathieu et al. 2020b): quoted from: Hale, T., Angrist, N., Goldszmidt, R. et al. A global panel database of pandemic policies (OxfordCOVID-19 Government Response Tracker). Nat Hum Behav 5, 529–538 (2021). https://doi.org/10.1038/s41562-021-01079-8

Fig. 5
figure 5

Daily new confirmed Covid-19 deaths per million people, 7-day rolling average. Mar 1, 2020–Dec 31, 2021. Source: Johns Hopkins University CSSE COVID-19 DataSource, Last updated Nov 14, 2022 https://ourworldindata.org/covid-deaths (Mathieu et al. 2020a)

In Fig. 5 similar progressions of data over time can be seen across the countries, especially in Austria, Germany, Sweden and the United States, where the death rate increased and decreased at similar times. A correlation can also be observed between the death rate and stringency index. A higher stringency index means more measurements and therefore fewer infections. A lower number of infections causes a lower number of deaths. After the increase in the number of deaths in October/November 2020 in all countries, the stringency index rose in all countries to control this outbreak. In Austria and Hungary, which had the least restrictions in that summer, the number of deaths from Covid increased the most in November compared to the other European countries shown here. Additionally, the graphics in Fig. 5 show that in Italy and Hungary the number of death rose, after having decreased in February 2021. In the countries Austria and Germany, the number of deaths continued to fall. In Hungary, the number of deceased reached its maximum in April 2021. In the UK, after a small decline of the death rate at the end of 2020, the number of deaths almost tripled in January 2021. On 7 November the rate was 7 deaths per million people and on 20th of January 2021 the value reached a peak of 20.5 deaths per million people. You can see that the number of deaths rises high in the UK and as a consequence, the stringency index reached its highest value (ca. 87) over the period under consideration. As you can see directly, the peak in January 2021 was not the first big peak in the UK. At the beginning of the pandemic in early 2020, the stringency index was really low because the aim of the government was to achieve herd immunity, as mentioned in the introduction. Figure 5 shows that this leads to a rapid increase in the number of deaths in March and April 2020. As a consequence, you can see in Fig. 4 that government changed the strategy and the stringency index raised in March 2020. Compared to other European countries, Sweden pursued a different strategy. The stringency index in Sweden was always smaller than the average value of the other countries. This is particularly noticeable at the beginning of the pandemic and after the vaccine was available. This could be one of the reasons why, at the beginning of the year 2020 and at the beginning of the year 2021, the peak of deaths per million in Sweden is as high or even higher than, for example, in the United States. The course of the stringency index in the US is similar to that of Sweden in 2020, which suggests a similar trend in mortality rates.

Brazil, as a South American country, has a very different pattern of deaths and also reaches the highest values at other times. It is to mention, that in July 2021, in each country shown here, the deaths per million people were nearly zero except for Brazil. On the other hand, at the end of 2020, the number of deaths was lower in Brazil than in all other considered countries. Also no new increase can be seen in Brazil towards the end of 2021, which is different from what we see in Hungary, Austria or Germany. At the same time, the stringency index is higher in Brazil than in these other countries. In Hungary, the stringency index is really low at the end of 2021, which could facilitate the spread of the virus.

These real-world data show us that there is a correlation between policies against Coronavirus and death rates. Few measures can lead to high number of infections and as a consequence thereof a high number of deaths. This leads us to include death rates in our model when looking for the best strategy.

4 Basics of modelling the spread of a pandemic

4.1 Problem description

As already mentioned in the introduction, the main question is how strict the Corona policy has to be so that not only the rate of death but also the economic loss through measures is minimized. It is assumed, that we face a number of connected districts. These areas will be denoted as nodes. For each node, we can categorize the population into four categories. The susceptible group, which can be infected through the second group, the infected. The third and fourth group are those who can no longer contribute to the spread of the disease. They are either immune or have passed away. Both groups are proportional to the size of the subgroup of infected people. Furthermore, we assume that there are different contact rates and so contagiousness between and within the nodes, more precisely between the susceptible population of one node and the infectious population of another node.

We have a set of policy measures. A measure in one node reduces the contact rate in the node itself and to all connected nodes, which leads to a decreasing number of infections and deaths. On the other hand, a measure has also a negative effect on the economy in a node. Costs rise due to unemployment and insolvency, for example. The aim is to find the best strategy and to decide in which node which lockdown measure should be applied to decrease the resulting cost of economic loss and new infections, which indirectly leads to a reduction of infections and deaths.

Table 1 Notation

The following assumptions are made: we assume a discrete time horizon \(\{0,...,T_2\}\), which is divided into two parts \(\{0,...,T_1\}\) and \(\{T_1+1,...,T_2\}\). At any period t during the interval \(\{1,..., T_1\}\) we have a control variable \(y_{ilt}\) for each district \(i\in {\mathcal {G}}\) and each measure \(l\in L\). For the time horizon \(\{T_1+1,..., T_2\}\), we have a variable \(z_l\) to indicate if a measure l is active in any of the nodes in any of the periods in \(t \in \{T_1+1,..., T_2\}\). The idea is that we make a detailed plan for \(\{0,..., T_1\}\), but only a rough estimate of what happens in the future. A rolling planing process could then be applied. For the initial situation in time zero the values \(S_i^{0}\) and \(I_i^{0}\) are given for each district \(i \in {\mathcal {G}}\). The values of the transitions between the subgroups \(S^t_i\) and \(I^t_j\) is given by \(b_{ij}\) for \(t\in \{0,1,...,T_2\}\), as well as a deceasing rate \(\delta\) and a recovering rate \(\gamma\). We also assume a given set of policy measures L, explicit measures to reduce the contact rate like banning events, closing schools or closing kindergartens. The effect of a lockdown measure \(l\in L\) in district i incurs a cost \(w_{il}\) per period and the cost \({\hat{w}}\) per infected person is given too. Later in the model you can see, that the effect of the contact rate \(b_{ij}\) becomes smaller when a measure is active in either district i or district j. Since a measure in a district has a twofold negative impact on the contact rate within that district, it is necessary to assume that a measure can reduce the contact rate by a maximum of 50%. A recap of all notations is shown in Table 1.

4.2 A MG-SIRD model

The underlying SIRD model is a deterministic model used to predict the spread of the pandemic. The following state equations show how the values \(S_i, I_i,R_i, D\) and C depend on each other considering discrete time periods to model the dynamic nature of the process under concern. The equations show the state transition from period \(t-1\) to period t. The way of writing the SIRD model equations is based on Roques et al. (2020).

$$\begin{aligned} S^t_i&=S^{t-1}_i - \sum _{j \in {\mathcal {G}}} b_{ij} S^{t-1}_i I^{t-1}_j \quad i \in {\mathcal {G}} \end{aligned}$$
(1)
$$\begin{aligned} I^t_i&= I^{t-1}_i(1-\gamma ) +\sum _{j \in {\mathcal {G}}}b_{ij} S^{t-1}_i I^{t-1}_j \quad i \in {\mathcal {G}} \end{aligned}$$
(2)
$$\begin{aligned} R_i^t&=R_i^{t-1}+ \gamma I^{t-1}_i \quad i \in {\mathcal {G}}\end{aligned}$$
(3)
$$\begin{aligned} D^t&= D^{t-1}+ \sum _{i \in {\mathcal {G}}} \delta \gamma I^{t-1}_i N_i\end{aligned}$$
(4)
$$\begin{aligned} C^t&= C^{t-1} + \sum _{i \in {\mathcal {G}}} (1-\delta ) \gamma I^{t-1}_i N_i \end{aligned}$$
(5)

The difference between fraction \(S^{t-1}_i\) and fraction \(S^{t}_i\) and the associated decrease of susceptible persons in district i depends on the contact rates \(b_{ij}\) to all infection subgroups \(I^{t-1}_j\). The more contact there is between susceptible people of district i to infected people, the greater the likelihood that people from group \(S^{t-1}_i\) will be infected and the fraction of susceptible will fall. On the other hand, the amount \(I^{t-1}_i\) increases by the amount \(S^{t-1}_i\) decreases minus those who are no longer infected. If an average infectious duration is, for example, four days, \(4=\frac{1}{\gamma }\), we can assume that, on average, a quarter of the patients are no longer infected every day. These people will be in subgroup \(R^t_i\). The group of no longer infected contains people, who are recovered from this infection and people, who died from the disease. The amount of all recovered people are in subgroup \(C^t\). Those who died will be in subgroup \(D^t\). The death rate is \(\delta\) for groups \(R^t_i\). It must be mentioned here that theoretically, the group \(R^t_i\) is not required. For our optimisation problem we are interested in the mortality rate. The immunised part \(C^t\) is not considered further, but for the sake of completeness it was included in the explanation of the SIRD model.

5 Minimizing humanitarian and economic damage in pandemic situations

Our optimisation problem has two objectives. One aim is to minimize economic damage caused by any measures. Every measure \(l \in L\) in a node \(i\in {\mathcal {G}}\) increases the economic loss by \(w_{il} \in [0,1]\) per period. For example, store closures do not result in any revenue but only recurring costs for the owners. These resulting costs are included in the calculated economic losses. The effect of a lockdown measure on economic costs could be evaluated on the basis of past experience. The other aim is to minimize the humanitarian damage caused by an infection of the virus. In order to minimize the number of deaths, we are pursuing the goal of minimizing the number of infections in our model by minimizing the total incurred cost caused by infections. The number of deaths as well death related costs depend on the number of infections. The number of deaths at one point in time depends on the number of infections the periods before. It is easier to calculate the cost of an infection than the costs of a decease. The cost of an infection can be interpreted in different ways. The infection not only causes health problems but also costs for medical treatment and economic costs. Employers incur costs when their employees are unable to work due to an infection. Therefore, we minimize the cost due to lockdown measures and due to infections.

A maximum mortality \({\mathcal {D}}\) is a given parameter to keep the focus on the death rate. Even if the number of deaths is reduced by minimizing the number of infections, the maximum mortality is given to restrict the number of deaths in each period to a maximum number. Indirectly, this also limits the number of infections, which can be an advantage in avoiding hospital overload. \({\mathcal {D}}\) is not a scientifically defined constant, and should be determined wisely.

The following mixed integer program minimize economic damage caused by measures and humanitarian damage caused by infections during the planning horizon.

$$\begin{aligned}&\min \quad \sum _{t =1}^{T_1} \sum _{i\in {\mathcal {G}}}\sum _{l\in L} y_{ilt}\; w_{il} + (T_2- T_1) \sum _{l\in L} z_{l}\;\cdot \left( \sum _{i \in {\mathcal {G}}} w_{il} \right) +\sum _{t =1}^{T_2 }\sum _{i\in {\mathcal {G}}}{\hat{w}} N_i I_i^t \end{aligned}$$
(6)
$$\begin{aligned}&s.t. \nonumber \\&S^t_i=S^{t-1}_i - \sum _{j \in {\mathcal {G}}} b_{ij} \left( 1-\sum _{l\in L}y_{jlt}q_l-\sum _{l\in L}y_{ilt}q_l\right) S^{t-1}_i I^{t-1}_j\quad i \in {\mathcal {G}} \quad t\in \{1,...,T_1\} \end{aligned}$$
(7)
$$\begin{aligned}&I_i^t= I_i^{t-1} (1-\gamma ) + \sum _{j \in {\mathcal {G}}}b_{ij}\left( 1-\sum _{l\in L}y_{jlt}q_l-\sum _{l\in L}y_{ilt}q_l\right) S^{t-1}_i I_j^{t-1} \quad i\in {\mathcal {G}} \quad t\in \{1,...,T_1\} \end{aligned}$$
(8)
$$\begin{aligned}&S^t_i=S^{t-1}_i - \sum _{j \in {\mathcal {G}}} b_{ij} \left( 1-2\cdot \sum _{l\in L}z_{l} q_l\right) S^{t-1}_i I^{t-1}_j \quad i \in {\mathcal {G}} \quad t\in \{T_1+1,...,T_2\} \end{aligned}$$
(9)
$$\begin{aligned}&I_i^t= I_i^{t-1} (1-\gamma ) + \sum _{j \in {\mathcal {G}}}b_{ij}\left( 1-2\cdot \sum _{l\in L}z_{l} q_l\right) S^{t-1}_i I_j^{t-1} \quad i\in {\mathcal {G}} \quad t\in \{T_1 +1,...,T_2\} \end{aligned}$$
(10)
$$\begin{aligned}&\sum _{i \in {\mathcal {G}}} \delta \gamma N_i I_i^{t-1} \le {\mathcal {D}} \quad t\in \{1,...,T_1\} \end{aligned}$$
(11)
$$\begin{aligned}&y_{ilt}\in \{0,1\} \quad l\in L \quad i\in {\mathcal {G}} \quad t\in \{1,...,T_1\} \end{aligned}$$
(12)
$$\begin{aligned}&z_{l}\in [0,1] \quad l\in L \end{aligned}$$
(13)
$$\begin{aligned}&S_i^t, I_i^t \ge 0 \quad i\in {\mathcal {G}} \quad t\in \{1,...,T_2\} \end{aligned}$$
(14)

The first two terms in objective function (6) show the total economic loss incurred over the whole period \(\{0,....,T_2\}\). The first term computes the economic loss up to period \(T_1\) and the second one is an estimate of the cost in the near future \(\{T_1 +1,...,T_2\}\). To compute this estimate we omit details and consider a common decision on measure in all nodes over all periods. The third term in the objective function represents the cost for infections. Both types of cost should be minimized. (1) and (2) become (7) and (8) for \(t \in \{1,...,T_1\}\). For the horizon \(t \in \{T_1+1,...,T_2\}\) (1) and (2) become (9) and (10). A reduced contact rate leads to a smaller amount of infection. In (7) and (8) the effect of the contact rate decreases proportionately to \(q_l\), if measure l is placed in node i or node j at time t. We assume that measures within a district have more influence than between districts. If a measure is applied in a district, the effect of the contact rate within the district \(b_{ii}\) is reduced by two times \(q_l\).

In order to limit the proportion of people who die in one period, constraint (11) must apply. It limits the number of deaths within a period to a maximum of \({\mathcal {D}}\). This value equals \(D^t - D^{t-1}\), see (4).

The state variables \(S_i^t, I_i^t\) are non-negative decision variables. (12) states that \(y_{ilt}\) is a binary variable for all \(i\in {\mathcal {G}}\), \(l \in L\) at each time \(t \in \{0,...,T_2 \}\) and (13) states that \(z_l\) is continuous for all \(l\in L\).

6 A case study with data from Germany

As a case study we consider a region in Germany with a high population density. The most densely populated federal state in Germany that consists of more than just one city is North Rhine-Westphalia. We consider the cities Duisburg, Oberhausen, Mülheim and Essen. Since the districts are not far from each other, there is a high mobility between them. Duisburg and Essen are among the cities in North Rhine-Westphalia with the largest daily commute flows [cf. Landesbetrieb IT.NRW (2021)]. The other two districts Oberhausen and Mülheim are geographically between these cities. The contact rate between the districts is derived from the proportion of daily commuters between the districts, see matrix B [cf. Landesbetrieb IT.NRW (2021)].

$$\begin{aligned} B =\left( \begin{array}{rrrr} 0.7887 &{} 0.0829 &{} 0.0671 &{} 0.0404 \\ 0.0829 &{} 0.7363 &{} 0.0833 &{} 0.0565 \\ 0.0671 &{} 0.0833 &{} 0.7357 &{} 0.1005 \\ 0.0404 &{} 0.0565 &{} 0.1005 &{} 0.8197 \\ \end{array}\right) \end{aligned}$$

As measures we regard school closures, venue closures and event bans. Venue closures include closures of activities, shops or restaurants. Measures such as restrictions on gatherings, masking requirements, school closures and workplace closures, have the strongest influence on the increase in the number of infected people, see Pozo-Martin et al. (2020). Banholzer et al. (2020) analysed the decrease in new infections through lockdown measures in 20 countries. The values for \(q_l\) were selected on the basis of their results (see Table 2).

Table 2 Effects and costs of a lockdown measures and population size of the districts

Measures that restrict mobility are effective in curbing the outbreak of a pandemic, but they also cause a high economic loss [cf. Bundesbank (2021)]. Restricting mobility leads to social distancing. Juneau et al. (2020) analysed the cost-effectiveness of measures. They found out, that measures for social distancing like closing work and schools are effective but also cost-intensive. The costs arising from school closures, are not only the economic costs due to the care of children and non-productive work, it is also the lack of school performance and the associated lower education and qualification of pupils [cf. ECDC (2021)].

The decline in Gross Domestic Product (GDP) in many countries at times, when measures were in place, show that measures have a major impact on the economy. Since economic activity is measured at quarterly intervals in terms of GDP, it is not possible to estimate exactly which measures have caused what economic damage [cf. Bundesbank (2021)]. Kocher and Steiner (2020) analyse the arising costs owing to school closures. The analysis shows that school closures caused a \(0.5\%\) decrease in GPB per month. Additionally, they found out, that an average loss of 270 EUR arise per person per month. This results in a loss of 0.75 EUR per person per day. Based on this statement, we estimate the economic cost \(w_l\) by considering the relation of the effects. The values are shown in Table 2. The economic cost per city due to measures depend on the population size of the city, \(w_l * N_i\). In Table 2 the population sizes \(N_i\) are given.

There are also several studies to determine the cost of an infection \({\hat{w}}\). Hospitalization costs on average 10.700 EUR [cf. Zeitung (2020)]. We reduced this cost, because just \(10\%\) of all infected have to be in hospital [cf. Robert Koch Institut (2021)]. On the other hand each infection rise economic cost due to work absences. We simulate our model with a rate of \({\hat{w}}=300\) per day. The values for average infectious duration (10 days) and a death rate per day are also from Robert Koch Institut (2021). The program is solved with Gurobi Optimizer.

Fig. 6
figure 6

Pandemic spread in four districts for four scenarios (district 1 - “- -”, district 2 - “.-”, district 3 - line, district 4 - dots)

For the four German cities in our case study we analysed a period of \(T_2=16\) days and one week (\(T_1=7\) days) with binary decision variables. The outbreak of the pandemic is assumed to happen in one district. A longer time horizon was not feasible as the short time horizon is a result of the solvers limitations. To simulate a pandemic outbreak, we assumed that in one district i, we have \(I_i^0 = 0.01\) and \(S_i^0=0.99\). In all other districts \(j \in {\mathcal {G}}/ \lbrace i\rbrace\) there is no infection, so \(S_j^0 =1\) and \(I_j^0=0\). We show the outbreak in district \(i=4\) with the largest population and the related infections in all districts by using different colours in Fig. 6a, b. (c) and (d) show the outbreak in the district \(i=3\) with the smallest population. The falling curves on the left show the share of the falling susceptible fraction in the districts and the rising curves on the right show the growing fraction of new infections. In Fig. 6b, d the outbreak is simulated with a SIRD model without any measures. (a) and (c) present the resulting spread with measures determined by our mixed integer program. Due to the contacts between the cities, the number of infections rise in all districts, most in that district, in which the pandemic outbreak happened. The optimal solution is that all measures at any time apply, both for the outbreak in the largest district (a) and the outbreak in the smallest district (c). The outbreak in the smallest town results in 2566 deaths and the other case in 3896 deaths. Without measures the numbers rise to 48,034 and 63,291 deaths. This extent can also be seen from the numbers of infected people in (b) and (d). In an outbreak in the largest district (b), the highest level of infected people in that district is 80%. In the other case (d) all districts have nearly the same highest level with 70%. Due to the short time horizon, no statement can be made how high the maximum amount of infected people per day will be. However, due to the measures, the increase in the number of infections was flatter. One reason why we work on a suitable solution procedure.

7 Conclusion

In this paper we contributed to the field by showing that operations research techniques can be much more beneficial to counteract pandemics like, e.g., the Covid pandemic. Mathematical models that capture the spread of infections do exist and are well-established. However, they are mostly used for simulations. This is already very helpful, but on the downside, only those scenarios can be evaluated that are defined by the planner. The benefit of an optimization approach, which is what we propose, is that scenarios are computed, i.e. they are output but not input. For the sake of completeness, we have reviewed real-world data during the Corona pandemic to illustrate that countermeasures are indeed relevant and have an impact on the spread of a disease. Based on the well-established SIR model, we have formulated an optimization problem that can be used for networks of districts to compute when and where measures of counteraction are in order. To illustrate the outcome of such an optimization problem, we have used real data from four German cities that are close to each other so that the travel behaviour of the people causes an infection to spread among these cities. We solved the optimization problem by means of standard software to compute a scenario telling the planner what to do when and where. It should be noted that both, humanitarian and economic effects have been included in that model. This is, of course, just a very first step towards enabling better help during pandemics. Future work should focus on tailor-made solution procedures so that much larger networks and much longer time periods can be handled. Furthermore, the underlying SIR model can be extended in many ways. Among other things, it can be extended to the scenario of vaccine availability.