1 Introduction

Personnel scheduling problems traditionally consist of optimizing work timetables, i.e., determining the appropriate times and shifts the employees of a company should work. Several objectives can be considered, such as minimizing duty costs, maximizing productivity, or minimizing the number of employees. The solutions generated must meet different criteria, for example, maximum number of working days, maximum amount of working hours, and so on. Due to the recent Covid-19 pandemic, we introduce a novel and emerging aspect: the risk of contagion among the workers. Covid-19 is now widely known to be highly contagious, and the interested reader may refer to, e.g., [11, 13, 20] for further information regarding the transmission of the virus and the source of the disease, respectively.

On the one hand, there is a rich body of literature on how governments can avoid the spread of pandemic diseases [e.g., 1, 9, 7], or how physicians can deal with certain scenarios arising in medical centers, where they are faced with a growing, sometimes even uncertain, demand for emergency care [15, 21]. On the other hand, the same does not happen when it comes to investigating optimized personnel scheduling policies that take into account the risk of disease spreading in specific environments. This is the case of companies that must remain open to provide essential services during a possible quarantine period. In this work, we attempt to start filling this gap by studying and solving a real-world personnel scheduling problem during Covid-19 pandemic, arising in a large Italian pharmaceutical distribution warehouse operated by Coopservice [3]. It consists of a large service company operating in several fields such as transportation, logistics, cleaning and security services.

There is a vast literature on personnel scheduling and we refer to [5, 6, 22] for detailed surveys and to [2] for models and complexity results. According to the classification scheme presented in [5], we can categorize the scheduling made by the company before and after Covid-19 pandemic as demand-based and shift-based, respectively. The latter is extensively adopted in nurse scheduling studies [e.g., 4, 17]. In particular, a variant of the problem was tackled in [23], in which nurses with the same skills, or that are married to each other and with children, were not allowed to work together during the same shift. This situation somewhat resembles the one found in our problem (see Sect. 2), where an employee originally assigned to a sector can no longer be reassigned to another one during the workday, as it often happened before the pandemic. More recently, the study described in [19] proposed and solved a nurse rostering problem arising in Covid-19 pandemic, where the author considered an emergency scenario by allowing nurses to work in multiple shifts during a workday. The objective was to decrease the occurrences of shifts with an insufficient number of nurses, and to balance the schedules by minimizing the working hours of the nurses.

To solve the problem introduced in this paper, we propose a mathematical formulation based on mixed integer linear programming (MILP). The results obtained show that our optimized solution is capable of improving the manual one produced by the company by 37.3%, while keeping the same number of workers. In addition, we demonstrate that the model is capable of obtaining, on average, high quality solutions on larger instances generated at random within an acceptable CPU time.

The remainder of the paper is organized as follows. Section 2 formally introduces our personnel scheduling problem. Section 3 shows the solutions adopted by the company before and after Covid-19 pandemic, as well as the performance measures used to evaluate the solutions. Section 4 describes the proposed mathematical model. Section 5 contains the results of the computational experiments. Finally, Sect. 6 presents the concluding remarks.

2 Problem description

The activities that Coopservice need to perform are to receive, organize and distribute pharmaceutical products to hospitals. The company manages large regional warehouses in Italy, where goods are received, stored, picked-up, and finally delivered to the hospitals, according to their demand. Therefore, Coopservice is responsible for managing the last phase of the pharmaceutical supply chain: from the inbound activity to the last-mile delivery [12]. The interest reader may refer to [18] for an overview on how to manage the supply chain between a distribution center (as the one considered in this paper) and a hospital pharmacy.

In this work, we study the case of a regional warehouse located in Tuscany, one of the largest regions in Italy. The warehouse is composed of two floors: the top floor stores all pharmacological items (e.g., antiblastic, fridge drugs, toxic and inflammable), whereas the ground floor the non-pharmacological ones (food, paper, plastic, masks, gloves, syringes, etc.). Each floor has two working sectors, thus leading to a total of four sectors. There are 23 employees working in the warehouse. In the following, we use E and A to define the sets of employees and sectors, respectively.

The arise of Covid-19 brought into light a new issue that affected the movement of workers in the warehouse. Before the pandemic, all of them could move from one sector to the other, when required, during the workday. This became no longer possible during the pandemic period, meaning that each employee \(e \in E\) should work in exactly one sector \(a\in A\) during the workday, with a view of avoiding contagion. As a result, the company was forced to modify the personnel scheduling policy by creating groups of employees that must always work together, both in the same shift and in the same sector.

In our problem, we also consider a set of shifts S where the employees can work. We denote by \(s=1\) and \(s=2\) the morning and afternoon shifts, respectively, from Monday to Friday. Because of the emergency scenario, employees must also work in sector \(a = 1\) on Saturday morning, here referred to as shift \(s=3\). Each shift \(s \in S\) has a maximum amount of weekly working hours for each sector \(a \in A\), represented by \(\lambda _{sa}\).

To balance the activities, each group of employees alternate their shift every week, i.e., if a group works on the morning shift during a week, in the next week the same group will have to work on the afternoon shift. Moreover, for each sector \(a \in A\) and each shift \(s \in S\), we define by \(\tau _{sa}\) the weekly minimum amount of working hours imposed by the company to ensure the required productivity level. In addition, each employee \(e \in E\) has a contractual amount of working hours \(h^{max}_e\) per week. Finally, we define \(c_{ea}\) as a binary input parameter indicating whether employee \(e \in E\) can work in sector \(a \in A\) (\(c_{ea} = 1\)) or not (\(c_{ea} = 0\)). This corresponds to the skill matrix of employees.

Let W be the set of weeks. The aim of this work is to solve the personnel scheduling problem for 2 consecutive weeks (i.e., \(W=\{1,2\}\)), satisfying the new shift regulation for the emergency period issued by the authorities. The objective of the problem is to minimize the sum of the deviations from the contractual amount of working hours of each worker formally given by the absolute difference between the weekly working time in the solution and \(h^{max}_e\). Both positive and negative deviations imply in additional costs for the company (if negative, the missing hours need to be paid nevertheless to the worker, if positive, the extra hours impose an extra cost).

Table 1 shows the schedule manually built by the company to solve the problem for sector 1 before and after the pandemic. Note that the morning shift starts at 06:00 and finishes at 12:00, while the afternoon shift starts at 12:00 and finishes at 20:00. For each employee \(e \in E\), we report the sum of weekly working hours \(\sum h_e\) and the deviation \(\varDelta _{ew}\) in each \(w \in W\) with respect to \(h^{max}_{e}\). It can be seen that before the pandemic there was no deviation at all (\(\varDelta _{ew} = 0\) \(\forall e \in E, w \in W\)), whereas the same did not occur after the pandemic (where, e.g., employee 5 has a deviation of 10 working hours in week 2).

Table 1 Personnel scheduling for sector 1 before and after Covid-19 pandemic

3 Personnel scheduling in a normal scenario and during Covid-19 pandemic

In this section, we analyze the schedules adopted by the company before and after the pandemic. Table 2 reports the weekly value of \(\varDelta _{ew}\) for each employee. One can clearly observe that the schedule determined by the company in a normal scenario successfully met the amount of contractual working hours for all employees but 11, 18 and 21. The new schedule generated by the company led, however, to many deviations, as highlighted in the bottom part of the table.

Table 2 Weekly working hours before and after Covid-19 pandemic

In addition to the evaluation of \(\varDelta _{ew}\), we also need to evaluate the contagion risk. To this aim, Fig. 1 depicts a network graph, before and after the pandemic, where the vertices denote the employees and the edges indicate whether a pair of employees worked together in the same shift and in the same sector (for at least 1 h). From this graph representation, we introduced a contagion risk factor R to measure the risk of infection, based on the average vertex degree of the graph. Let \(G^{aw}\) be a graph associated with each sector \(a \in A\) and each week \(w \in W\). Every graph has a vertex-set \(V(G^{aw})\) and edge-set \(E(G^{aw})\). For each vertex \(u \in V(G^{aw})\) we define \(\varOmega (u)\) as its corresponding degree (number of first neighbors). The risk factor \(R_{aw}\) for each sector a and for each week w is thus formally defined as:

$$\begin{aligned} R_{aw} = \frac{\sum _{u \in V(G^{aw})} \varOmega (u)}{|V(G^{aw})|}. \end{aligned}$$
(1)

We can then determine the value of the risk factor \(R_a\) for each sector a as follows:

$$\begin{aligned} R_a = \frac{\sum _{w \in W} R_{aw}}{|R_{aw}|}. \end{aligned}$$
(2)

For example, when considering Sector 2, we can observe that the average vertex degree (i.e., the risk factor R) before and after the pandemic were 3 and 1, respectively.

Fig. 1
figure 1

Network of relationships between employees, the vertices represent the employees and the edges indicate that they worked at least once at the same time in the same sector

Table 3 shows the average values of R for each sector before and after the pandemic. It can be seen that the new schedule visibly decreases the risk of disease spreading, as the values of R are considerably smaller, when compared to the previous situation.

Table 3 R values before and after Covid-19 pandemic in a company solution

4 Proposed mathematical formulation

Let \(x^{wa}_{se}\) be a binary variable assuming the value one if employee \(e \in E\) is assigned to shift \(s \in S\) to work in sector \(a \in A\) in week \(w \in W\), 0 otherwise. In addition, let \(y^{wa}_{se}\) be the amount of working hours spent in sector \(a \in A\) by employee \(e \in E\) assigned to shift \(s \in S\) in week \(w \in W\). Finally, the excess and lack of working hours associated with employee \(e \in E\) in week \(w \in W\) are defined by variables \(\delta ^+_{ew}\) and \(\delta ^-_{ew}\), respectively. The MILP formulation can be written as follows.

$$\begin{aligned} \text {min }&\varDelta : \sum _{e \in E} {\sum _{w \in W}{\delta ^-_{ew} + \delta ^+_{ew}}} \end{aligned}$$
(3)
$$\begin{aligned} \text {s.t.}&\quad \sum _{a \in A}{\sum _{s \in \{1,2\}}{x^{wa}_{se}}} = 1 \quad&w \in W, e \in E \end{aligned}$$
(4)
$$\begin{aligned}&\sum _{s\in \{1,2\}} {x^{1a}_{se}} = \sum _{s\in \{1,2\}} {x^{2a}_{se}}\quad&a \in A, e \in E \end{aligned}$$
(5)
$$\begin{aligned}&\sum _{a \in A}{\sum _{w \in W} {x^{wa}_{se}}} = 1 \quad&e \in E, s \in \{1,2\} \end{aligned}$$
(6)
$$\begin{aligned}&{x^{w1}_{3e} \le x^{w1}_{1e} }\quad&{e \in E, w \in W} \end{aligned}$$
(7)
$$\begin{aligned}&x^{wa}_{3e} = 0 \quad&w \in W, a \in \{2,3,4\}, e \in E \end{aligned}$$
(8)
$$\begin{aligned}&y^{wa}_{se} \le \lambda _{sa} x^{wa}_{se} \quad&w \in W, e \in E, a \in A, s \in S \end{aligned}$$
(9)
$$\begin{aligned}&\sum _{e \in E}{y^{wa}_{se}} \ge \tau _{sa} \quad&w \in W, a \in A, s \in S \end{aligned}$$
(10)
$$\begin{aligned}&\sum _{a \in A}{\sum _{s \in S}{y^{wa}_{se} + \delta ^-_{ew} -\delta ^+_{ew}}} = h_e^{max} \quad&w \in W, e \in E \end{aligned}$$
(11)
$$\begin{aligned}&{x_{se}^{wa} \le c_{ea}} \quad&{w \in W, e \in E, a \in A, s \in S} \end{aligned}$$
(12)
$$\begin{aligned}&x^{wa}_{se} \in \{0,1\} \quad&w \in W, e \in E, a \in a, s \in S \end{aligned}$$
(13)
$$\begin{aligned}&y^{wa}_{se} \ge 0 \quad&w \in W, e \in E, a \in A, s \in S \end{aligned}$$
(14)
$$\begin{aligned}&\delta ^+_{ew}, \delta ^-_{ew} \ge 0 \quad&e \in E, w \in W. \end{aligned}$$
(15)

Objective function (3) minimizes the total deviation \(\varDelta \) between the amount of weekly contractual hours for each worker (\(h^{max}_e\)) and the actual working hours (\(y^{wa}_{se}\)). Constraints (4) impose that each employee must be weekly assigned to exactly one shift \(s \in \{1,2\}\) and one sector \(a \in A\). Constraints (5) ensure that if an employee \(e \in E\) is designated to sector \(a \in A\) in the first week (\(w = 1\)), he/she must work in the same sector in the next week (\(w = 2)\). Constraints (6) impose each employee to work in exactly one sector per shift. Constraints (7) state that an employee can only work on the Saturday shift (\(s=3\)) if he/she is assigned to the morning shift \(s=1\) to work in sector \(a=1\). Constraints (8) forbid all employees to work in sectors 2, 3 and 4 on the Saturday shift. Constraints (9) enforce a maximum amount of weekly working hours, whereas constraints (10) ensure that the working hours requested for every shift in each sector are respected. Moreover, constraints (11) indicate the contractual amount of weekly working hours for each employee. Constraints (12) ensure the compatibility of designating an employee \(e \in E\) to work in sector \(a \in A\). Finally, constraints (13)–(15) define the domain of the variables.

5 Computational results

The model was coded in Python using PuLP [16] and executed on an Intel i5-8250U 1.60 GHz with 8 GB of RAM running Windows 10. CBC (https://github.com/coin-or/Cbc) from COIN-OR [14] was used as a MILP solver. A time limit of 600 seconds was imposed for each execution of the model.

Two scenarios were considered in our testing. Scenario I assumes that the employees are only eligible to work on the same sectors associated with the solution generated by the company, i.e., the values of \(c_{ea}\) are taken directly from such solution. The goal is to verify whether it is possible to obtain an improved solution while keeping the same groups of employees per sector. In Scenario II, we use the values of \(c_{ea}\) provided by the company, which were determined according to the ability of a given employee \(e \in E\) to work on a specific sector \(a \in A\), thus allowing new groups of employees to be formed.

Table 4 compares the results produced by the company with those obtained in each of the two scenarios. It can be verified that solution found in Scenario I yielded an improvement of 9% with respect to the solution generated by the company after the pandemic. This can be considered a very good result, given that the groups of employees are the same in both solutions. Nevertheless, the gains in Scenario II were way more substantial. More precisely, allowing the model to form new groups of employees, while respecting their corresponding skills, led to an improvement of 37.3% on the value of \(\varDelta \). We also mention that the CPU time in seconds spent by CBC in Scenarios I and II were 0.58 and 0.91, respectively, so the model was very quick in solving the instance.

The average values of R are the same for all scenarios, equaling the one obtained by the solution generated by the company after the pandemic. Note that it is not possible to improve the value of R any further because of constraints (10), which in turn impose a certain amount of working hours for each shift \(s \in S\) and each sector \(a \in A\).

Table 4 Comparison between the solutions produced by the company and by the model

Table 5 shows the optimized solution found for sector 1, considering scenarios I and II. Note that the solution obtained is used in a cyclic fashion, i.e., one first determines the schedule for 2 weeks and then one repeatedly uses this periodically as long as there are no changes in the personnel. We remark that the company did not face any difficulties during the practical implementation of the optimized solution.

Table 5 Personnel scheduling for sector 1 in scenario I and scenario II

We also conducted experiments on 27 randomly generated instances by varying the number of employees (25, 35, and 45) and sectors (3, 4, and 5), as well as by considering different probabilities for having \(c_{ea} = 1\), namely, 65%, 75% and 85%. In this case, the goal is to measure the performance of the model in terms of scalability, solution quality and risk factor when trying to solve larger instances with different characteristics.

Table 6 presents the results found on these instances, where for each of them we report the CPU time in seconds, together with the gap, \(\varDelta \) and R values, respectively. One can see that only 18 instances were solved to optimality, but the average gaps were, in most cases, relatively small (below of equal to 5%), with the exception of instances E25-A5-85, E35-A5-65, E35-A5-75, E35-A5-85, E45-A5-75 and E45-A5-85.

Table 6 Results found by the proposed model on 27 randomly generated instances

We also performed a further analysis on how the value of \(\varDelta \) varies as the density of the skill matrix increases. For this testing, we have generated more instances with other probability values for \(c_{ea}\), considering the case involving 4 sectors. The results of the experiments are presented in Fig. 2. In the x-axis we report the probability for \(c_{ea}\) to assume value 1, while in the y-axis we provide the corresponding \(\varDelta \) values obtained. The graph shows how the value of \(\varDelta \) decreases as the skill matrix becomes more dense. When considering 25 and 35 employees, the reduction is more prominent for up to 75%, whereas the reduction is more consistent for 45 employees.

Fig. 2
figure 2

Influence of \(c_{ea}\) on the objective function

It is important to highlight that, for practical reasons, we decided to use CBC as a MILP solver, which is open-source and so easily adoptable in many applications. Nonetheless, for the sake of comparison, we also performed tests using Gurobi 9.02 [10], and it was observed that the optimal solutions for all instances were found in up to two seconds.

6 Concluding remarks

This paper studied a real-life personnel scheduling problem, motivated by Covid-19 pandemic, from a large Italian pharmaceutical distribution warehouse operated by Coopservice. A MILP formulation was proposed for the problem, which was solved using an open-source optimization software, namely CBC from COIN-OR. The optimal solution obtained by our formulation was capable of considerably improving the schedule adopted by the company, which has started to create a plan to exchange operators using the holiday plan starting from June 2020, in order to maintain the distance of at least 15 days between new contacts. Tests were also performed on larger and randomly generated instances to measure the scalability of CBC when solving our model, and the results found were of high quality for the vast majority of the cases. In addition, we conducted experiments using Gurobi 9.02, which quickly managed to find the optimal solutions for all instances. Nevertheless, for larger warehouses with a considerable amount of employees, one may consider using heuristics if the model is not able to scale up.

Because Coopservice spends a large part of its budget on human resources (more than 20,000 employees), it is crucial to have a strategy to properly manage the personnel, especially during emergency situations such as epidemic crises. In general, this problem faces the issue of reducing the risk of contagion, and of organizing the schedule of the shifts in these type of scenarios. Therefore, our findings can be of general interest, especially under the circumstances related to pandemics. The solution of this problem in the specific case of Coopservice is not only relevant for demonstrating a successful case study, but is also interesting for many related applications. For example, the problem of organizing activities in close spaces or in warehouses with aisles containing highly skilled employees that are not allowed to work together.

Other promising research avenues may include the development of a bi-objective model by adding the risk of contagion in the objective function. Moreover, we believe that the model can be extended to produce a fair work-shift distribution. Since in the warehouse there are people with more expertise than others, which is an attribute that goes beyond the skill matrix, one may consider inserting a factor to balance the expertise within a shift in the objective function [8].