The balanced maximally diverse grouping problem with integer attribute values

The paper considers the assignment of items to groups according to their attribute values such that the groups are as balanced as possible. Although the problem is in general NP-hard, we prove that it can be solved in pseudo-polynomial time if attribute values are integer. We point out a relation to partition and more general to multi-way number partitioning. Furthermore, we introduce a mixed-integer programming (MIP) formulation, a variable reduction technique, and an efficient lower bound for the objective value. Our computational results show that the lower bound meets the optimal objective value in the most of our instances of realistic size. Hence, the MIP solves instances with several thousand items within seconds to optimality.


Introduction
How items should be assigned to groups is an intensively investigated combinatorial optimization problem from a theoretical as well as from a practical point of view. In the literature on combinatorial optimization, partition, multi-way number partitioning, and the maximally diverse grouping problem (MDGP) are well-investigated problems. Likewise these problems are applied in practical applications. The MDGP, for example, is used to assign students to groups, courses or teams but further applications like in parallel machine scheduling or surgery scheduling are possible (we elaborate on applications in Sect. 2). This paper is in line with the transfer of combinatorial optimization problems into practical applications. We consider the variant of the MDGP with attribute values proposed by . The author described the set of optimal solutions for the MDGP with attribute values by a set of equalities. These equalities are used as constraints to find the best balanced solution amongst all optimal solutions of the MDGP with attribute values. Furthermore, the paper presents a proof that the problem is N P-hard.
Attribute values are often integral in practical applications like student assignments (performance scores), surgery scheduling (surgery durations) or machine scheduling (processing times). Therefore, we restrict the problem setting of the balanced MDGP to integer attribute values in the paper on hand. Our contribution to the theoretical investigation of the problem is to prove that the problem can be solved in pseudopolynomial time and outline relations to partition and multi-way number partitioning. Moreover, we introduce a lower bound for the optimal objective value. By this, we are able to solve instances with several thousand items within seconds to optimality. Thus, we close the gap mentioned in  (considering discrete attribute values) and present an efficient solution approach, which can easily be used in applications.
The paper is structured as follows: First, we present a literature review especially from the point of view of applications (Sect. 2). Then, we define our problem, and prove that it is solvable in pseudo-polynomial time by a relation to the well-known PARTI-TION problem in Sect. 3. Our solution approach, a mixed-integer program (MIP), is introduced in Sect. 4. Afterwards, it is evaluated in a comprehensive computational study (Sect. 5). The paper closes with a conclusion in Sect. 6.

Literature review
In this section, we review two streams of the literature. First, regarding the MDGP which is the underlying problem of our approach and second, regarding practical applications that assign items with integer attributes values to groups with the objective to have groups as balanced as possible. Ideally, this means that there is a bijective mapping between each pair of groups such that each item has a partner with the same attribute value in each other group.
The MDGP considers a set of items i, j ∈ I with differences d i j ≥ 0 as well as a set of groups g ∈ G as given. The aim is to assign the items to the groups such that the diversity, which is measured by the sum of differences d i j of items assigned to the same group, is maximized. The problem can be formulated as a short integer program with the binary variable x ig , which is one if item i is assigned to group g and zero otherwise. max g∈G i∈I j∈I : j>i d i j x ig x jg (1) g∈G x ig = 1 ∀i ∈ I (2) i∈I x ig = |I |/|G| ∀g ∈ G x ig ∈ {0, 1} ∀i ∈ I , g ∈ G Beside the version with equal-sized groups (compare (3)), the number of items per group can also be required to be within a given range (Gallego et al. 2013). The MDGP is NP-hard (Feo and Khellaf 1990). However, a few papers present exact solution approaches based on mixed-integer programming for the MDGP. Gallego et al. (2013) conducted a computational study with both versions (equal-sized and not equal-sized). They could solve instances with 12 items to optimality within 1800 s. Papenberg and Klau (2021) presented a different model formulation [based on a work by Grötschel and Wakabayashi (1989)] for the version with equal-sized groups. With this version they were able to solve instances with 28 items within 950 s and with 30 items in almost 10000 s to optimality. For the MDGP with attribute values Schulz (2022c) introduced a mixed-integer programming formulation which is able to solve instances with 70 items and three attributes in 1800 s to (near) optimality.
As only small instances can be solved to optimality, most of the approaches presented in the literature are based on metaheuristics. Beside Gallego et al. (2013), who investigated a tabu search approach with strategic oscillation, examples are an artificial bee colony algorithm (Rodriguez et al. 2013), an iterated maxima search approach (Lai and Hao 2016) or a hybrid genetic algorithm (Singh and Sundar 2019). In the following, we focus our review on the practical applications.
In surgery scheduling, patients are assigned to operating rooms among others according to their surgery duration. A well-studied objective is the minimization of waiting times for emergency patients. As they are in danger to life, their immediate treatment is necessary. In the approach by Zhang et al. (2009), an entire operating room is reserved for emergency patients such that they do not need to be included in further planning. van Veen-Berkx et al. (2016) showed that this would lead to a higher utilization, less overtime, and fewer cancellations. The paper by Wullink et al. (2007) showed that reserving capacity for emergency patients in all operating rooms, and hence allowing emergency patients to enter all operating rooms, leads to a huge reduction of their waiting times. As long waiting times increase the risk of postoperative complications and morbidity for emergency patients (Wullink et al. 2007), several authors (as van der Lans et al. 2006, van Essen et al. 2012, and Schulz and Fliedner 2023 proposed approaches, in which elective and emergency patients share the same set of operating rooms. Transferring the requirements of emergency patients to the weekly scheduling level, it is important that they have appropriate access to operating rooms at each day. This means, it is natural to expand the aforementioned approaches to the weekly level by assigning surgeries to days such that the distribution of their durations is as similar as possible for each pair of days. Thus, a perfect assignment has a bijective mapping between the first day and any other day such that each surgery of the first day is mapped with a surgery of the other day which has exactly the same duration. If such a perfect assignment is possible, the same general schedule can be repeated at each day and randomly arriving emergency patients have the same expected waiting time at each day. As reserving the same number of resources at each point in time minimizes emergency patients' waiting times (Schulz and Fliedner 2023), the approach leads to an indirect minimization of emergency patients' waiting times by allowing the scheduler to schedule all surgery days as similar as possible (with the objective to minimize emergency patients' waiting times).
Further, well-studied objectives in surgery scheduling are maximization of utilization and minimization of overtime in operating rooms. As surgery durations are stochastic in reality (see e.g. Samudra et al. 2017), both goals are in conflict with each other such that a perfect utilization without a significant risk of overtime is unlikely to find (Van Houdenhoven et al. 2007). In the review by Cardoen et al. (2010), 47 out of 124 cited papers considered either underutilization/undertime (26 paper) or overutilization/overtime (45 paper) or both. Beside many others, Fei et al. (2010), Gul et al. (2011), Mannino et al. (2012, Astaraky and Patrick (2015), and Lin and Chou (2019) minimized overtime in more recent articles not yet considered in that review. Balancing the distribution of surgery durations over days and ideally having a partner surgery of the same length on each day, as we aim for, leads to the same expected over-/underutilization on all days, which hence has to be optimal if rejection is not allowed.
Our approach might, moreover, be useful in parallel machine scheduling, where jobs are assigned to identical machines (see Han et al. 2013, see also Korf and Schreiber 2013, who point out the relation to multi-way number partitioning) with the objective to minimize makespan (see Cheng and Sin 1990). As machine breakdowns occur randomly (Kaabi and Harrath 2014), assigning jobs to machines such that all machines have the same distribution of processing times might be an appropriate strategy; especially in the case where all machines are unavailable after a disruption occurs (Lee and Yu 2008).
A similar argumentation holds if the sum of completion times is minimized. As on a single machine shortest processing time first (SPT) is optimal (Smith 1956 andBiskup 1999), an assignment has to be optimal as well in which each identical parallel machine is scheduled according to SPT and each job on each machine has on each of the other machines a unique partner with the same duration (Conway et al. 1967).
Another field of application is the assignment of pupils to tutor groups (Baker and Benn 2001) or students to groups (Cutshall et al. 2007;Krass and Ovchinnikov 2006), projects (Beheshtian-Ardekani and Mahmood 1986) or teams (Galvão Dias and Borges 2017).
The assignment of students to some kind of groups is also the main application used in articles on the MDGP. However, in practice differences d i j between students are computed according to attribute values av i , i.e. d i j = |av i − av j |, like marks, 0, 1, and 2 for male, female, and diverse or 0 and 1 for non-international and international.  used this to introduce the MDGP with attribute values. In the case with attribute values, the set of optimal solutions can be described by (2), (4), and the block constraints introduced in Schulz (2021) (if the system of Eqs. (2), (4), and block constraints has a feasible solution). As the number of optimal solutions for the MDGP with attribute values can be very large, the paper further suggests to find the best balanced among them such that the diversity of each group is as similar as possible. Schulz (2021) used a mixed-integer program to solve the balanced MDGP.
In subsequent studies, the author generalized the approach to the case where (2), (4), and the block constraints have no feasible solution (Schulz 2023) or varying group sizes are allowed (Schulz 2022b). Schulz (2022c) used the idea of the block constraints to develop the mixed-integer programming formulation for the MDGP with attribute values as mentioned above.
However, like in the example with the students, attribute values are usually integer in practical applications. Thus, we see a need for approaches to distribute some kind of items according to integer attribute values to groups such that the groups are as balanced as possible. Ideally, we have a bijective matching between each pair of groups where each item has the same attribute value like its partner in the other group. In the paper on hand, we assign items according to a single integer attribute to groups such that the groups are as balanced as possible. Before we introduce our solution approaches in Sect. 4, we define the problem formally and investigate it theoretically in the following section.

Problem statement and theoretical analysis
We assume integer attribute values av i ∈ N 0 for all items i ∈ I . All items have to be assigned to groups g ∈ G such that each group gets the same number of items assigned. Otherwise, there cannot be a bijective mapping. Thus, the number of items per group |K | has to fulfil |I | = |G| · |K |. This is no restriction since items with attribute value zero can be used to fill up. We say the groups are perfectly balanced if the sum of pairwise absolute differences of all items assigned to a group g ∈ G, i.e. i, j assigned to g:i< j is equal for all groups g ∈ G.
Moreover, we divide all items into blocks according to the following pattern: The |G| items with the largest attribute values are assigned to the first block k = 1, the |G| items with the next largest attribute values are assigned to the second block k = 2, and so on until the |G| items with the smallest attribute values are assigned to the last block k = |K |. Then, exactly one item of each block has to be assigned to each group.   Each item is assigned to exactly one block k ∈ K as described before. QUESTION: Can all items i ∈ I be partitioned into |G| disjunct subsets I 1 , ..., I |G| such that each subset gets exactly one item of each block assigned and i, j∈I g :i< j |av i − av j | = |G| g=1 i, j∈I g :i< j |av i − av j | |G| for all g ∈ {1, ..., |G|}?

Complexity analysis
Although the more general version of BMDGPIAV (with av i ∈ Q ≥0 ) is N P-hard ), the following theorem shows that our problem with integer attribute values is solvable in pseudo-polynomial time if the number of groups is restricted.
The contribution of an item i, i.e. j∈I g |av i − av j |/2, in depends on all other items assigned to the same group. Therefore, we introduce the following lemma, which repeals this dependency, to get a well-arranged notation before we prove the theorem. For a proof of the lemma and an example see .
Lemma 2 (Schulz 2021) If |K | > 1, an item of block k with attribute value av has a share on the within-group diversity div g of for even |K | and for odd |K |, where med is the median of all attribute values of the group. For even |K | sort all attribute values in decreasing order and set med to any value between the two attribute values in the middle.
Let b ki be a binary parameter which is one if item i is assigned to block k according to the aforementioned pattern, i.e. the |G| items with the largest attribute values are assigned to the first block, the items with the next |G| largest attribute values to the second, and so on. With the help of Lemma 2 we are able to determine the contribution of an item i in the objective value as |K | k=1 b ki · c k · |av i − med| and express div g as i∈I g |K | k=1 b ki · c k · |av i − med|. By this, the evaluation of the assignment of an item to a group becomes independent of the other items assigned to the same group. We use this fact in the proof of Theorem 1.

Proof of Theorem 1
The following dynamic programming algorithm, based on the same idea as the PARTITION algorithm in (Garey and Johnson 1979, p. 90-91), solves the problem. Setāv i = |av i − med|, i ∈ I . Then, Then, the answer to (5) is "yes" iff s(|K |, B, ..., B) = true.
Note that there are |G|! permutations on the right side of (9).

Optimization version of the problem
Although Theorem 1 states that we are able to decide in pseudo-polynomial time, whether a given instance has a perfectly balanced solution or not, we need an optimization version to find a best balanced solution if a perfect balance is not possible. Therefore, we minimize the following objective There is a detailed motivation for the objective and the choice of blocks in . We only mention briefly that the kind of objective in (10) weights larger differences between attribute values assigned to the same group with a larger value. Consider a solution with div 1 = 1, div 2 = 2, div 3 = 3, and div 4 = 4. Then, The factors 3 and 1 correspond to the c k values in Lemma 2. Because of this, the objective aims at reducing each summand |div g − div g | of (10) as far as possible but has a higher weight on the larger differences.
On the other hand, the block constraints take care of our requirement that each group gets the same number of items assigned and the total diversity is maximized as it is shown in . Consider the following example with eight items with attribute values 1, 1, 3, 3, 3, 3, 5, 5 (items are represented by their attribute value). It has the solution (1,1,3,3) and (3,3,5,5) where both groups have a value of 8 for i, j |av i − av j |. Hence, it is optimal due to the second part of (5) and (10) but not maximal for (12) and not perfect in our sense that each item of each group should have a unique partner with the same attribute value in each other group. With block constraints the optimal solution due to (10) and (12) would be (1,3,3,5) and (1,3,3,5) with a diversity of 12 for both groups, which is perfectly what we want.

Relation to PARTITION
The proof of Theorem 1 indicates a strong relation to PARTITION in the case of two groups or to the multi-way number partitioning problem in general. Whereas there is even an equivalence between our problem for two groups and PARTITION , our objective differs from the one of the multi-way number partitioning problem, where the sum of attribute values assigned to the same group and the range between the largest and lowest one are considered as objective (Korf 2009). Korf (2009) asserts that in any optimal three-way partitioning solution each pair of groups must be an optimal solution for the appropriate PARTITION(O) (optimization version of PARTITION) instance with all numbers assigned to these two groups, but this is not the case for any optimal four-way partitioning solution. In other words, take two groups a and b of an optimal solution of a multi-way number partitioning instance and solve the corresponding PARTITION(O) instance with all items in a and b. For three-way partitioning, the original assignment into the groups a and b is also an optimal solution for the PARTITION(O) instance. For four-way partition, the original assignment of two groups a and b is not necessarily an optimal solution for the corresponding PARTITION(O) instance. For the optimization version of BMDGPIAV and for any number of groups (ways) each pair of groups a and b is an optimal solution for the PARTITION(O) instance with all items in a and b like the following theorem shows.

Theorem 3 In any optimal solution of the optimization version of BMDGPIAV, the partition of any two groups corresponds to an optimal solution of the PARTITION(O)
instance with all items assigned to these two groups.
Note that c 1 = c |G| > c 2 = c |G|−1 > ... ≥ 0 for an odd number of days and If the solution in the corresponding instance of PARTITION(O) is for a pair of two groups G 1 and G 2 not optimal, we can solve it to optimality (item sizes s where div G j , j = 1, 2, is the within-group diversity of the transformed optimal PARTITION(O) instance. Let further w.l.o.g div G 1 > div G 2 and div G 1 > div G 2 . Then, (13) implies that div G 1 > div G 1 and div G 2 < div G 2 holds. Note that one item of each block is assigned to each group which means that the value of (12) is independent of the item assignment to the groups. Therefore, div G 1 + div G 2 = div G 1 + div G 2 . A case-by-case analysis shows that this leads to a reduction of F, which is a contradiction because we assumed to consider an optimal solution. The case-by-case analysis is given in Appendix 1. Thus, the solution of the corresponding PARTITION(O) instance has to be optimal as well.
The following example shows that it is not sufficient for global optimality to prove that the partition of any two groups corresponds to an optimal solution of the corresponding PARTITION(O) instance. Nevertheless, it is sufficient for a local optimum relating to the neighbourhood, where two solutions are neighboured if they differ in the assignment of only two groups.
Example 4 Consider the instance given in Table 1 with 12 items which have to be assigned to three groups with four items each.
The first block contains items a, b, and c, the second items d, e, and f , the third g, h, and i, and the fourth j, k, and l, i.e. each group gets exactly one item out of a, b, and c assigned. Table 2 gives a local optimal solution on the left and a global optimal solution on the right side. The numbers in brackets are the values for |K | k=1 b ki ·c k ·āv i such that div is   the sum of them. For item a, which is in block 1, (7)) andāv a = av a − med = 12 − 8 = 4, where med can be set to any value between 7 (attribute value of i) and 8 (attribute value of d); here med = 8.
While the first two blocks are equal in both solutions, the last blocks' difference is within our neighbourhood ( j is assigned to group one in both cases such that there is only a swap of items k and l). However, in the third block no swap of two items is possible which leads from the assignment (g, h, i) on the left side to (h, i, g) on the right side, i.e. both solutions are not neighbouring. Furthermore, the lower part of Table 2 presents the within-group diversities (div) and the objective values F, which shows that the right solution is better than the left one. Nevertheless, the left one is a local optimum such that the result of Theorem 3 is necessary but not sufficient for global optima.
Theorem 3 and Example 4 show that our objective leads-in contrast to the one in the multi-way number partitioning problem-to a necessary condition for optimal solutions, although it is not sufficient. Korf (2010) mentions three objectives for multi-way number partitioning: minimize the largest sum of items assigned to the same group, maximize the smallest sum of items assigned to the same group, and minimize the difference between them. Cong and Lim (1998) point out that it is reasonable to solve the multi-way number partitioning problem by optimizing the PARTITION(O) instances with all items currently assigned to only two groups and assign the items of each partition to one of the two groups afterwards. Our objective could be an alternative objective for the multi-way number partitioning problem, which leads even to a stronger reference to PARTITION. Theorem 1 Theorem 1 (more efficient) Implementation

Solution approaches
This section presents our two solution approaches: a dynamic program (DP, Sect. 4.1) and a mixed-integer program (MIP, Sect. 4.2).

Dynamic program
Our first solution approach is based on the dynamic program (DP) proposed in the proof of Theorem 1. In the proof, the algorithm adds one block after the other. In the first row, s(1, j 1 , ..., j |G| ) = true for all permutations ( j 1 , ..., j |G| ) of the |G| values av of the items of the first block. In the second row, s(2, j 1 +π 1 , ..., j |G| +π |G| ) = true if s(1, j 1 , ..., j |T | ) = true and (π 1 , ..., π |G| ) is a permutation of the valuesãv of the items of the second block. The same procedure is done for the remaining blocks. Table 3 summarizes the worst case effort (dependent on the number of groups |G|) for eight blocks for the implementation in Theorem 1 (column 2), a more efficient version of it (column 3), and for our implementation (column 4). In the more efficient implementation of the algorithm in Theorem 1, the first block is set in any fixed sequence due to symmetry. Afterwards, each solution of the previous step, k − 1, is combined with each permutation of block k (|G|! permutations) except the last step. In the last step, group diversities of the previous step are sequenced in decreasing order and combined with the last blocks' attribute values in increasing order. This leads to the best possible assignment. Figure 1 describes the procedure of our DP, again for eight blocks. In the first step, two blocks are combined each, i.e. one block is fixed (symmetry) and the other is added in all |G|! permutations (upper level in the figure). In the second step, all combinations of one pair (up to |G|! entries) of the previous step are combined with all permutations of another pair (up to |G|! entries times |G|! permutations) and so on (middle level in the figure). In the last step, direct assignments between the considered combinations (one in increasing and one in decreasing order) lead to the best solution (lower level in the figure); thus, the permutation factor |G|! can be omitted. In total, Table 3 shows that our implementation is more efficient in the worst case. Nevertheless, in all transitions between s(k, * ) and s(k + 1, * ) in (9) all new solutions, consisting of all previous solutions and all permutations of the current block, have to be evaluated. Therefore, this approach is very time intensive. Hence, we develop a different solution approach in the following subsection.
However, an interesting aspect of our DP lies in the asymptotic behaviour. For a block with |G| items with identical attribute values all permutations yield to the same result. They can be assigned to the groups in any sequence. It is unnecessary to include them in the solution approach. This means that at the most max i av i blocks have to be considered (if the attribute values in all these blocks vary only by one). Hence, the computational effort of our DP is bounded even if |K | is unbounded. However, the effort for finding these max i av i blocks is unbounded if |K | is.

Mixed-integer program
We present a mixed-integer program to solve the optimization version of BMDGPIAV in this section. The following model is an adapted version of the one by Schulz (2021): blocks (|K | equates the number of items per group) where av i is the attribute value of item i, med is the median attribute value, and c k is the corresponding block value from Lemma 2 b ki is 1 if item i is in block k and 0 otherwise Positive variables div g diversity within group g Binary variables x ig is 1 if item i is assigned to group g and 0 otherwise F = min g,g ∈G:g >g div g − div g with the constraints (2), (4) Objective function (14) minimizes the differences of within-group diversities. Constraints (2) ensure that each item is assigned to exactly one group. Constraints (15) make sure that exactly one item of each block is assigned to each group (block constraints; compare ). Constraints (16) compute the within-group diversities while Constraints (17) eliminate symmetric solutions by ordering the groups in decreasing order of their within-group diversities (which is also the reason why we do not need the absolute values in (14)). Finally, Constraints (4) are the binary restrictions.
Often techniques based on a branch-and-bound procedure are used to solve models with binary variables. However, the LP-relaxation of our model is poor because x ig = 1/|G| is a valid solution with div g = div g for all g, g ∈ G and, therefore, an objective value of zero. To reduce this drawback and improve the search, we introduce a technique to reduce the number of binary variables and a valid lower bound for the objective value in the following.
The model can be strengthened by eliminating all blocks in which all items have the same attribute value because the objective value is independent of their assignment. They can be assigned blockwise in a post-processing step in any order to the groups. Moreover, not all items of a block have to be modelled since only differences are relevant. Then, (15) has to be relaxed to For example, in a block with five items with attribute values 60, 60, 60, 65, and 70 it is sufficient to model the last two items with attribute values of 5 · c k and 10 · c k (c k from Lemma 2). In a post-processing step, all within-group diversities are increased by 60 · c k , and the first three items are assigned (in any order) to the three groups to which none of the last two items is assigned to. By this, the number of modelled items can be reduced by a factor of at least 1 |K | . Furthermore, the restriction to integer values allows us to compute a lower bound for F with the remainder of i∈Iã v i |G| (average group diversity). Let A = i∈Iã v i |G| and r be the remainder, i.e. r = i∈Iã v i − A · |G|.

Theorem 5 A valid lower bound is given by
c k with c k from Lemma 2.
Proof We use Lemma 2 for this proof, i.e. the groups are the items and their diversities (div) the attribute values. Each block contains only a single group. This means |K | = |G| and each group forms its own block in decreasing order of their diversities div g (in line with (17)). Therefore, we use k and g synonymously.
With the help of Lemma 2 with med = div |G| 2 and because c g = c |G|+1−g . Because of (17) and since c 1 > ..., r and div g = A for g = r + 1, ..., |G|. Due to the definition of A it holds that div g ≥ A for all g ∈ G. Thus, we can subtract A from div g and div |G|+1−g in (19) and accordingly from both div g in (20). With div g = 1 for g = 1, ..., r and div g = 0 for g = r + 1, ..., |G| (20) equals c g and the theorem follows. Table 4 gives an example with five groups.
With the help of the c k values in Lemma 2, LB can be computed as the sum of four (= c 1 = c 5 if |K | = 5) times the difference between the values in columns 3 and 7 and twice (= c 2 = c 4 if |K | = 5) the difference between the values in columns 4 and 6.

Computational study
In this section, our computational study regarding the MIP (2), (4), (14)- (17) is presented. We add the factor 2 |G|·(|G|−1) = 1 |G|·(|G|−1) 2 to the objective value and present 2 |G|·(|G|−1) · F in the results. So, the objective value is the average absolute pairwise difference of group diversities. This makes the objective values comparable for different instance sizes. The dynamic program was implemented in C++. The MIP was implemented in G AM S (version 39) and solved with C P L E X (version 20.1). The first subsection explains the composition, the second presents the results.

Composition
Attribute values are uniformly distributed between one and 500, as this covers most practical applications like surgery durations (in minutes), measures for academic achievements, and processing times (in minutes). Our approach uses the block constraints [see  and (15)], i.e. the more items have the same attribute value, the easier our model can deal with the instance. A uniform distribution reduces such cases; so, we choose instances which are more complicated for our model. The tested instances are presented in Table 5. The number of groups is varied between five and 15, and 20. For each of them four, ten, 50, 100, 200, and 300 blocks are considered. Note that instances with three blocks can be solved optimally by a direct assignment . We generated for each parameter setting 60 instances independently from each other. The time limit was set to ten minutes, i.e. the search was interrupted after ten minutes. Table 6 presents the results regarding the DP in Sect. 4.1. We only present results for the first four settings with four blocks, as larger instances required more than ten minutes of computation time. The table shows the number of items |I |, the number of blocks |K |, and the number of groups |G| in the first three columns. Afterwards, the average objective value over all 60 instances ∅F and the average computation time are presented. The DP solves all instances to optimality. For the first three settings the DP requires only up to a few seconds to solve the instances. For the next larger setting  with only four items more already more than 120 s are needed. This effect is explained by the factorial function of the number of groups shown in Table 3. Although the DP is only helpful for small instances, it is superior to the MIP for these instances as we will see in the following. The results for best-bound search are shown in Table 7. The first three columns show the parameter settings containing the numbers of items |I |, blocks |K |, and groups |G|. The fourth column gives the average objective value of all instances where a feasible solution was found. The following column presents the average objective value of all optimally solved instances. The sixth column contains the average time required for them to solve and the last three columns give the number of optimally solved instances, the number of optimally solved instances in which the optimal solution was the lower bound, and the number of instances in which a solution was found within the time limit of ten minutes.   For five to seven groups all instances were solved to optimality within seconds. Beside the smallest setting with four blocks, all instances were solved to optimality for at most nine groups within ten minutes. From ten groups on an increasing number of instances of the biggest setting with 300 blocks could not be solved to optimality any more. From 12 groups on, the same is true for the remaining settings. The same ∩-structure can be observed for the number of solutions found and at least 14 groups. The contrary ∪-structure can be observed for the average computation times.

Results
The reason for this interesting relation might be located in a trade-off between more difficult instances due to instance size, and therefore higher computation times, and the high average objective values for small numbers of blocks. A high objective value leads to a larger gap to a perfectly balanced assignment (objective value: zero) and to our lower bound. So the solver has to increase the lower bound to close this gap (compare column #(LB = opt.)). But in a relaxed-fractional-problem it is easy to find a good balanced solution. Thus, it is hard to increase the lower bound. In fact, the lower bound improved only in 23.2% of all 426 instances in which a solution was found, but optimality was not proven within ten minutes (all with four blocks, compare Table 8). Another indicator are the average objective values, which are for small instances up to 13 groups (four blocks) smaller than the average objective values of all optimally solved instances. So, C P L E X was able to find good solutions but could not close the gap. In summary, the model is fast because it often finds a solution which meets the lower bound (compare columns #opt. and #(LB = opt.)). If there is no solution meeting the lower bound (especially if |K | = 4) or instances are large enough, the model needs significantly more computation time. Korf (2009) mentioned that for multi-way number partitioning exactly the opposite ∩-structure is observed for computation times. Small instances are easy to solve due to the small number of possible solutions. Large instances are again easy to solve because there is only a little number of possible subset sum differences in comparison with the number of possible partitions. Schreiber (2014) investigated in his dissertation exact algorithms for multi-way number partitioning. In one part, a cached iterative weakening algorithm is proposed with which instances up to 60 items and 12 groups were solved optimally for large numbers (Schreiber and Korf 2014). For the same instance sizes, an overview of state-of-the-art algorithms subject to number of items and groups is given by Schreiber et al. (2018). Frias Faria et al. (2019 implemented a variable neighbourhood search approach, which has a good performance for instances with three or four groups. A reason for the difference in the size of solvable instances between our problem and multi-way number partitioning lies in the data structure, since we draw attribute values-due to realistic sizes in applications-uniformly between one and 500 while Schreiber et al. (2018) considered uniformly distributed samples in the range [1, 2 48 − 1]. We did another test with the parameter setting 600 items, six groups, 100 blocks, and attribute values between one and 1.000.000. Only 15 out of 60 instances were solved optimally within ten minutes (in 14 instances the optimal objective value equals the lower bound in Theorem 5). C P L E X needed 292.8 s on average for them. In comparison with an average time of 0.81 s to proven optimal solutions for instances with processing times between one and 500. Thus, there is a strong dependency on the range of possible attribute values. A reason is that the number of blocks with identical attribute values will be much smaller for a wider range. Another reason might lie in the more restrictive structure of our problem. In contrast to multi-way number partitioning, we only allow one item of each block to be assigned to a group, and hence restrict the number of possible assignments, and require that each group gets the same number of items assigned. Furthermore, the c k values of Lemma 2 restrict the set of possible products with attribute values. Nevertheless, algorithms from the multiway number partitioning literature might be adaptable for BMDGPIAV -especially to solve instances with a small number of blocks more efficiently.
In most of the instances which could be solved to optimality, the optimal solution equals the lower bound in Table 7. We discussed already that it is hard to improve the lower bound, which explains why only a few of the other instances could be solved to optimality. A reason why it is not that hard to find a good solution is the limited range of possible attribute values and thereforeãv i values. In the last paragraph, we discussed that a larger range for attribute values leads to worse results. Given the restricted range between 1 and 500, we have blocks in which each item has the same attribute value (up to 6000 items). These blocks can be ignored in the solution procedure and added afterwards in any feasible way. Thus, instance sizes reduce. Moreover, the small range makes it likely that attribute values within a block vary only by a small number. Hence, it is likely that a difference in the assigned diversity of one block can be balanced by another block. The chance to balance the groups' diversities increases with an increased number of blocks. An easy strategy would be to assign the next block's items always in decreasing order of theirãv i values to the groups ordered in increasing order of their so far diversity.
The results in Table 7 were computed with best-bound search, the standard G AM S − C P L E X option. Because of the decreasing number of instances in which solutions were found and the bad objective values found for a larger number of groups, we repeated our computational experiments with the depth-first search adjustment in G AM S − C P L E X. The results are presented in Table 9. In comparison, best-bound search leads in general to more optimal solutions. Furthermore, as expected, objective values of large instances in which no proven optimal solution was found decreased for depth-first search.  Moreover, as expected, computation times increased for both search strategies, a fixed number of blocks, and an increasing number of groups in general. As a conclusion the model works well for up to 15 groups with limitations for small and large numbers of blocks.

Conclusion
The paper introduces an approach for the assignment of items to groups according to their integer attribute values. As the block constraints lead to a maximal total diversity (Schulz 2021), we search for the best balanced solution of all optimal solutions of the MDGP. The paper introduces a new lower bound for the objective value and a variable reduction technique for the problem. Our computational study (Sect. 5) showed that the model works well for up to 15 groups in general (except for very small and very large instances). The main reason for the good performance is the lower bound, which is often met by optimal solutions.
One of the possible applications mentioned in the literature review (Sect. 2) is surgery scheduling. Several authors mentioned the importance of a balanced surgery schedule: van Oostrum et al. (2008) stated that an unbalanced surgery schedule often leads to demand fluctuation in other departments like surgical wards or intensive care units. Beliën et al. (2006) developed a master surgical schedule which levels bed occupancy. Marcon et al. (2003) balanced the workload over all operating rooms referring to the number of beds in the Postanesthesia Care Unit. Ogulata and Erol (2003) provided an approach to balance the distribution of surgeries between surgeon groups with respect to surgery days and length of surgery times. Adan et al. (2011) stated that master surgical schedules can lead to balanced use of resources such as beds, operating rooms, and nursing staff and Vanberkel et al. (2011) pointed out that it should lead to a balanced workload.
This indicates that there are several different resources that should be balanced in a surgery schedule to minimize resource requirements or, relating to staff, overtime. We think that there is further research demand in integrated approaches which allow balanced schedules with respect to many different resources. One possible approach is given in this paper. Further research demand lies in the evaluation of whether other resource requirements can be integrated in this approach in the way that surgery durations as well as these resource requirements are balanced over days and how this effects other stakeholders like surgeons, nurses, and elective patients. Besides, further research demand lies in the application to other practical problems and in the relation to multi-way number partitioning (compare Sects. 3 and 5). Future research might also focus on effective heuristic solution approaches-especially for instances with a small number of blocks and large instance sizes.
Funding Open Access funding enabled and organized by Projekt DEAL. This research did not receive any specific grant from funding agencies in the public, commercial, or not-for-profit sectors.

Data Availability
The program codes as well as the test instances were generated by the author and saved on a server of the University of Hamburg. They are available from the author on reasonable request.
The case div G 1 < med or div G 2 > med is analogous.
3. If div G 1 > med > div G 1 , the previous cases are complemented by this case. The contribution of div G 1 in the objective value is med − div G 1 while div G 2 = div G 2 + |div G 1 − div G 1 | < med holds. Since c k G 2 > c k G 1 , the objective value reduces. The case div G 2 > med > div G 2 works analogously. Publisher's Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.