Some constrained partitioning problems and majorization

15
Some constrained partitioning problems and majorization Geir Dahl Truls Flatberg March 2003 Abstract We consider some constrained partitioning problems for a finite set of objects of different types. We look for partitions that are size- and type-similar, and, in addition, for a pair of such partitions that are “very different” in a certain sense. The motivation stems from a problem in- volving the partitioning of a set of students into smaller groups. We give these problems precise mathematical formulations and investigate these problems using the notion of majorization. A special case of one of the problems leads to a result concerning the packing of matchings in a bi- partite graph. 1 Introduction Let V be a finite set of N objects. Associated with each object is a certain type which is a number in {1, 2,...,m}. We consider different problems involving partitions of V into subsets with certain properties. Each subset in a partition of V will be called a group. We require the groups to be size- and type-similar. Basically this means that each group contains about the same number of objects of each given type. Before we define these problems in precise terms, we present the main moti- vation for the present study. The motivation springs from a problem one faces at the Faculty of Medicine at the University of Oslo, but we believe the problem should have a broader interest. In 1996 a new six year medical curriculum was implemented focusing on the integration of pre-clinical and clinical subjects, a high degree of self-regulated learning, early patient contact and improved skills and communication training. Traditional lectures were to a large extent re- placed by problem based learning (PBL) where 6-8 students work together in a group with the guidance of a teacher. Simultaneously with this restructuring, a common curriculum was introduced for students of medicine, odontology and nutrition during their first two yearsof study. To develop the students’ abilities to work with people of different professions in frequently changing settings, it was decided that the PBL-groups should be re-assembled in a special manner twice every term. The ideal goal was that both sexes and all three professions 1

Transcript of Some constrained partitioning problems and majorization

Some constrained partitioning problems and

majorization

Geir Dahl Truls Flatberg

March 2003

Abstract

We consider some constrained partitioning problems for a finite set

of objects of different types. We look for partitions that are size- and

type-similar, and, in addition, for a pair of such partitions that are “very

different” in a certain sense. The motivation stems from a problem in-

volving the partitioning of a set of students into smaller groups. We give

these problems precise mathematical formulations and investigate these

problems using the notion of majorization. A special case of one of the

problems leads to a result concerning the packing of matchings in a bi-

partite graph.

1 Introduction

Let V be a finite set of N objects. Associated with each object is a certain typewhich is a number in {1, 2, . . . , m}. We consider different problems involvingpartitions of V into subsets with certain properties. Each subset in a partitionof V will be called a group. We require the groups to be size- and type-similar.Basically this means that each group contains about the same number of objectsof each given type.

Before we define these problems in precise terms, we present the main moti-vation for the present study. The motivation springs from a problem one facesat the Faculty of Medicine at the University of Oslo, but we believe the problemshould have a broader interest. In 1996 a new six year medical curriculum wasimplemented focusing on the integration of pre-clinical and clinical subjects, ahigh degree of self-regulated learning, early patient contact and improved skillsand communication training. Traditional lectures were to a large extent re-placed by problem based learning (PBL) where 6-8 students work together in agroup with the guidance of a teacher. Simultaneously with this restructuring,a common curriculum was introduced for students of medicine, odontology andnutrition during their first two years of study. To develop the students’ abilitiesto work with people of different professions in frequently changing settings, itwas decided that the PBL-groups should be re-assembled in a special mannertwice every term. The ideal goal was that both sexes and all three professions

1

should be proportionally equally present in all groups and that no students whohad previously worked together in a PBL-group should meet again. To beginwith, the assembling of the groups was done manually with no particular al-gorithm, but the task was found both very time-consuming and unsatisfying.We were therefore consulted to develop a computerized method to perform theallocations.

The paper is organized as follows. Section 2 discusses the initial partitioningproblem and an algorithm solving the problem is given. Section 3 describesthe reallocation problem in terms of the notion of move matrices. Section 4discusses a special case of the reallocation problem leading to a result concern-ing the packing of matchings in a bipartite graph. The general problem withsolution algorithms are given in Section 5. We shall use some terms and resultsfrom majorization theory (see Section 2). For a comprehensive treatment ofthe theory and applications of majorization, see Marshall and Olkin [4]. Weremark that many different partitioning problems have been investigated in theliterature, many of these problems are NP-hard. We refer to Dahlhaus et al. [2]for a treatment of multiterminal cut problems and further references.

2 The initial partitioning problem

We want to partition the set of N objects into n groups with certain properties.We use the following notation:

N : the number of objects, i.e., elements in V .n: the number of groups.m: the number of types.di: the total number of objects of type i (i ≤ m), so

i di = N .d: d = (d1, d2, . . . , dm)pi, qi: defined (uniquely) by di = pi · n + qi, 0 ≤ qi < n.d: “mean of d”: d = (d1/n, d2/n, . . . , dm/n).

For a m × n matrix A we let rA ∈ Rm denote the row sum vector of A,

i.e., rAi =

∑nj=1 ai,j . Similarly, cA ∈ R

n denotes the column sum vector, so

cAj =

∑mi=1 ai,j .

We are interested in the case when m is smaller than n, typically in the realproblems presented to us, m was about n/3. A “type” may be described interms of several characteristics as in our application with students of medicinewhere each type is a combination of both sex and profession.

The way objects of each type are distributed among groups may be repre-sented by a nonnegative integral matrix A = [ai,j ] of dimension m × n. Herethe entry ai,j denotes the number of objects of type i in group j. We have thatrAi =

∑nj=1 ai,j = di for i ≤ m. Moreover, the columnsum cA

j =∑

j ai,j is thenumber of objects in group j; we call it the group size. A nonnegative integralm × n matrix A satisfying rA = d will be called a distribution matrix. So theith rowsum in A is di.

Example 1. Let n = 5, m = 4 and d = (16, 12, 2, 18), so N = 48. Then

2

d = (3.2, 2.4, 0.4, 3.6). A possible distribution matrix is

A =

4 3 2 4 31 4 3 2 20 0 1 0 14 2 4 5 3

.

The group sizes are given by the column sum vector cA = ( 9 9 10 11 9 ).We want to find a distribution matrix such that

(i) group sizes are almost equal, and

(ii) each group j contains (nearly) the same number of objects from type i.

One reasonable way to make this problem mathematically concise is as fol-lows. Let f : R → R be a symmetric convex function. We are interested in thefollowing problem

(P1): Initial partitioning problem. Find a distribution matrix A suchthat F (A) :=

i,j f(ai,j − di) is minimized and group sizes vary by at most one.Here the function f is used to measure the deviation from the “ideal”, but

possibly fractional distribution d.We now review the notion of majorization (see [4]). If x = (x1, x2, . . . , xn)

and y = (y1, y2, . . . , yn) are real vectors, we say that x is majorized by y if∑k

j=1 x[j] ≤∑k

j=1 y[j] for k = 1, 2, . . . , n−1 and∑n

j=1 xj =∑n

j=1 yj where x[j]

is the jth largest component in x. We then write x ≺ y. This means, looselyspeaking, that the components of x are less spread out than the components ofy. Define I(b, n) as the set of integral vectors z = (z1, z2, . . . , zn) satisfying

z1 ≥ z2 ≥ · · · ≥ zn,n

j=1

zj = b.

Then I(b, n) equipped with the majorization ordering ≺ is a partially orderedset, in fact it is a lattice. The unique minimal vector in I(b, n) w.r.t. themajorization ordering will be denoted by l∗(b, n). If b = kn+s where 0 ≤ s < n,then l∗(b, n) is given by

l∗(b, n) = (k + 1, k + 1, . . . , k + 1, k, k, . . . , k)

where the first s components are equal to k + 1. We will use the followingimportant result due to Hardy, Littlewood and Polya (see [4] p. 108).

Theorem 2.1 Let x, y ∈ Rn. Then x ≺ y holds if and only if

∑ni=1 f(xi) ≤

∑ni=1 f(yi) holds for every convex function f : R → R.

In particular, if f is a given convex function, the minimal vector l∗(b, n) is anoptimal solution to the problem of minimizing the function g(z) :=

∑ni=1 f(zi)

for z ∈ I(b, n).

3

We now return to the problem (P1). Consider the following algorithm forconstructing a distribution matrix A. In the algorithm, column indices are cal-culated modulo n (so e.g., 1 and n+1 are identified). An interval in {1, 2, . . . , n}consists of consecutive integers in this set, for instance, n−1, n, 1 is an interval.Recall that qi is the remainder when di is divided by n. We remark that thereordering done in step 0 will play a role later in the paper.

Algorithm 1:

0.) Reorder the types so qi is nondecreasing.Let k := 0.

1.) For i = 1, 2, . . . , m do the followinga) let ai,j = pi+1 for j = k+1, k+2, . . . , k+qi,b) let ai,j = pi for all remaining entries in row i,c) let k := k+qi (mod n).

The correctness of this algorithm is shown in the following theorem.

Theorem 2.2 The matrix A constructed by Algorithm 1 is an optimal solutionof problem (P1). The ith row of A is a permutation of the vector l∗(di, n), andthe column sum vector of A is l∗(N, n). In particular, the group sizes vary byat most one.

Proof. Since f is convex, it follows from the remark given after Theorem 2.1that every permutation of the vector l∗(di, n) minimizes

∑nj=1 f(xij−di). Clearly

the constructed matrix A is a distribution matrix since row i is a permutationof l∗(di, n). One can show by a small inductive argument that the sum of the k

first rows is the vector l∗(∑k

i=1 di, n). In fact, due to Step 1 a) of Algorithm 1,the column sum vector for the k first rows is monotone and the entries vary byat most one. It follows that cA = l∗(N, n).

The results given in Theorem 2.2 are very intuitive, but note that this is ageneral result holding for all functions f of the required form.

Example 2. If we apply the algorithm to the distribution in Example 1,d = (16, 12, 2, 18), we get the following distribution matrix

A =

4 3 3 3 32 3 3 2 20 0 0 1 14 4 4 3 3

.

3 The reallocation problem

In this section we consider the second partitioning problem mentioned in Section1. The problem is to re-assemble the PBL-groups of students to obtain newgroups that are very different from the old groups. More precisely, one wants to

4

minimize the number of revisits, where a revisit is a pair of students (or objects)being in the same groups in both assignments.

Note that when we are looking for a new assignment, only the type and oldgroup of an object matter to us. Thus, we need not consider individual objects,but we may concentrate on the numbers ai,j in the fixed distribution matrixA that we are given from solving problem (P1). We shall represent the newassignment by a set of n× n matrices, each describing “moves” of objects fromold groups to new groups. Define a move matrix as a n × n matrix B = [bi,j ]with entries in the set {0, 1, . . . , m}. Here bi,j = k means that one object oftype k is “moved” from old group i to new group j. If k = 0 it indicates thatno object was moved from i to j. Note that at most one object is moved fromgroup i to group j. Thus, a single move matrix represents moving at most n2

objects from old groups to new groups. We may need several move matrices inorder to move all the objects to their new groups.

Example 1, continued. We return to Example 1 in Section 2. The fol-lowing matrix is a valid move matrix for the given set of groups

B =

1 1 2 4 44 1 1 2 44 4 1 1 22 4 4 1 11 2 4 4 1

.

Consider the first row of this matrix. It says that we move one object of type1 from old group 1 to each of the new groups 1 and 2. Moreover, we move oneobject of type 2 from old group 1 to new group 3 and one object of type 4 toeach of the groups 4 and 5. Note that this move matrix B is cyclic; each row isobtained from the previous row by shifting one position to the right in a cyclicmanner. Thus B represents that 5 objects are moved from each old group, 2of type 1, 1 of type 2 and 2 of type 4. Moreover, each new group contains 5objects, 2 of type 1, 1 of type 2 and 2 of type 4.

If we apply the moves given by the move matrix B above, the following(“distribution”) matrix describes the remaining objects in the old groups:

A =

2 1 0 2 10 3 2 1 10 0 1 0 12 0 2 3 1

.

Let B1, B2, . . . , Bt be move matrices used to reallocate all objects. A singlerevisit will then correspond to nonzero elements in position i, j in two of themove matrices. Define

γ(p) =

(

p2

)

=1

2p(p − 1) for p = 1, 2, . . . .

5

Let Bs = [bsi,j ], then the total number of revisits can be expressed as

R(B1, B2, . . . , Bt) :=∑

i,j

γ(

t∑

s=1

I(bsi,j)),

where

I(bsi,j) =

{

1, if bsi,j > 0,

0, otherwise.

Formally, this leads to the following two problems.(P2s): Strongly constrained reallocation problem. Given an opti-

mal solution A of (P1), find move matrices B1, B2, . . . , Bt (for some t) thatreallocate all objects such that R(B1, B2, . . . , Bt) is minimized and the resultingdistribution matrix equals A.

(P2w): Weakly constrained reallocation problem. Given an optimalsolution A of (P1), find move matrices B1, B2, . . . , Bt (for some t) that re-allocate all objects such that R(B1, B2, . . . , Bt) is minimized and the resultingdistribution matrix A is optimal in (P1).

Let R∗

s denote the minimum of R(B1, B2, . . . , Bt) for move matrices B1, B2, . . . ,Bt (where t is arbitrary) in problem (P2s). The corresponding minimum inproblem (P2w) is denoted by R∗

w. Clearly, we have that

R∗

w ≤ R∗

s .

We remark that in the application concerning partitioning of a school classthe weakly constrained reallocation problem seems to be the more natural prob-lem to consider. However, the strongly constrained reallocation problem has atheoretical interest.

We now establish a lower bound on R∗

w (and therefore also for R∗

s). Definek and q by

N = kn2 + q, 0 ≤ q < n2.

We then have the following result.

Lemma 3.1 A lower bound on R∗

w is

L = n2γ(k) + qk. (1)

Proof. Consider move matrices B1, B2, . . . , Bt such that the resulting distri-bution matrix is optimal in (P1). Let H = [hij ] be the n×n matrix with compo-

nents hij =∑t

s=1 I(bsi,j). Thus, hij is the number of objects moved from group i

to group j (i, j ≤ n). Then R(B1, B2, . . . , Bt) =∑

i,j γ(hij) and∑

i,j hij = N .Since γ(·) is a convex function, we may apply Theorem 2.1 with f = γ. Con-

sidering the vector y = (h11, h12, . . . , hn,n) ∈ Rn2

, it follows from the commentafter Theorem 2.1 that the minimum of R(·) is achieved by setting y = l∗(N, n2).Thus we have a lower bound on R∗

w of (n2−q)γ(k)+qγ(k+1) = n2γ(k)+qk.

6

Remark. We can also see from our proof when this lower bound is attained.This happens if, for example all move matrices are completely filled (i.e. theycontain no zeros) except for possibly one. This corresponds to having each oldgroup j redistributed among the new groups according to the distribution vectorl∗(cj , n), or some permutation of this vector.

In section 5 we describe a procedure for finding such a new feasible as-signment for which R∗

w = L. Such an assignment must clearly be optimal forproblem (P2w). First, however, we shall concentrate on problem (P2s) in acertain special situation. This is done in the next section.

4 A special case and packing of matchings

In this section we consider the strongly constrained reallocation problem (P2s)for the special case when di < n. Interestingly, this special case may be turnedinto a problem of packing perfect matchings on subgraphs of a complete bipartitegraph.

Since di < n we have that pi = 0 and qi = di for each i. Consequently, thematrix A1 constructed by Algorithm 1 is a (0, 1)-matrix. Moreover, A1 has avery special structure which we call the consecutive increasing interval property(CII-property). This means that:

(i) the number of ones in every row is no less that the number of ones in theprevious row (follows from the reordering at the beginning of Algorithm1),

(ii) the positions of the ones in each row is an interval (recall our modulo ncalculation of indices), and

(iii) the interval in row i starts one position to the right of the last 1 of theinterval in row i − 1.

Example 3. In this example n = 10 and m = 4.

A1 =

1 1 0 0 0 0 0 0 0 00 0 1 1 1 0 0 0 0 00 0 0 0 0 1 1 1 0 01 1 0 0 0 0 0 0 1 1

Note that the next row would start with ones in column 3.The (P2s) problem consists in finding move matrices. We now switch to a

different representation in terms of a bipartite graph. Let G = (I, J, E) be thecomplete bipartite graph with color classes I and J where I = {u1, u2, . . . , un}and J = {v1, v2, . . . , vn}. Consider the m × n (0, 1)-matrix A1 and define, fori ≤ m,

Ii = {uk ∈ I : a1i,k = 1},

Ji = {vk ∈ J : a1i,k = 1}.

7

Since A1 has the CII-property, I1, I2, . . . , Im resp. J1, J2, . . . , Jm are consecutiveintervals in I resp. J .

Let i ≤ m and consider a perfect matching Mi in the subgraph G[Ii ∪ Ji]induced by the vertex sets Ii and Ji. The interpretation of Mi is that it tells ushow the objects of type i should be “moved” from their old groups Ii to theirnew groups Ji. If we can find such perfect matchings Mi for i ≤ m that arepairwise disjoint, then it is possible to set up a corresponding move matrix Bwith R(B) = 0, i.e. no pair of objects meet again. This is our goal.

The next algorithm finds the perfect matchings that we are looking for.

Algorithm 2:

For k = 1, 2, . . . , m do the following

1.) Let Gk denote the subgraph of G \ ∪k−1i=1 Mi which is induced by the

vertex set Ik ∪ Jk.2.) Choose a perfect matching Mk in the subgraph Gk.

Note that this algorithm is polynomial since it requires to solve m maximumcardinality matching problems in a bipartite graph for which there are effectivealgorithms (see Ahuja et al. [1]).

With the notation above we have the following theorem concerning thisproblem of packing matchings.

Theorem 4.1 Consider a (0, 1)-matrix A1 of size m×n having the CII-property.Assume that the following condition is satisfied for 1 ≤ k ≤ m

|Ik| ≥2

n

k∑

i=1

|Ii| − 2 for |Ik | even,

|Ik| ≥2

n

k∑

i=1

|Ii| − 1 for |Ik | odd.

(2)

Then Algorithm 2 finds m pairwise disjoint edge sets M1, M2, . . . , Mm such thatMi is a perfect matching on the subgraph G[Ii ∪ Ji].

In particular, if m ≤ bn/2c+ 1, then (2) holds and therefore the conclusionabove.

Proof. Assume that the condition (2) holds. Let 1 ≤ k ≤ m and assume thatwe have found the desired perfect matchings M1, M2, . . . , Mk−1. We need toshow that Gk (as defined in Algorithm 2) contains a perfect matching, for thenthe result holds by induction (as M1 clearly exists).

Now, for each i < k the set Mi is a perfect matching in the subgraph Gi andtherefore Mi must be a matching in G. Due to the CII-property these matchingsoccur “consecutively”. We explain this by reference to Fig. 1.

The upper dots in the figure corresponds to the vertices u1, u2, . . . , un of G.The (four) lines below represent the sets I1, I2, . . . , Im (confer the numbers inboldface) and these are consecutive intervals. The purpose of these lines is to

8

�� �� �� �� ��

���

���

���

���

���

���

���

���

u 2 u u4u1 3u

n−1u n

1 2 3

4 65

7 86

9 10

Figure 1: Representation of the intervals.

indicate the number of “rounds”. For instance, consider the interval I10. Itis contained in I7 ∪ I8 on the third round and I10 is contained in I5 ∪ I6 onthe second round. In general we pass to a new round for interval Ip whenever∑p−1

i=1 |Ii| ≤ qn and∑p

i=1 |Ii| > qn for some nonnegative integer q. Since|Ii| ≤ n, each interval lies in either one or two rounds (e.g., I6 lies in round 2and 3).

Consider now the interval Ik. Then we clearly have the following.Property 1: Ik “finishes” in round q := d 1

n

∑ki=1 |Ii|e.

Consider a round h ∈ {1, 2, . . . , q − 1}. Then there are some consecutiveintervals in round h that cover Ik (if h = q − 1, they may only partially coverIk), say that these are Ii, Ii+1, . . . , Ii′ . Associated with these intervals there arematchings Mi, Mi+1, . . . , Mi′ . Let M∗

h be the set of edges lying in the union ofthese matchings and having both endvertices in Ik∪Jk. Since M1, M2, . . . , Mk−1

are pairwise disjoint matchings (the induction hypothesis) and |Ik| ≤ n thefollowing property must hold.

Property 2: M∗

1 , M∗

2 , . . . , M∗

q−1 are pairwise disjoint matchings in G[Ik ∪

Jk]. Moreover, these matchings contain all the edges in ∪k−1i=1 Mi that have both

endvertices in Ik ∪ Jk.Assume now that condition (2) holds. We shall prove by contradiction that

the subgraph Gk contains a perfect matching. So assume that Gk has no perfectmatching. Gk is a bipartite graph with color classes Ik and Jk with |Ik| = |Jk|.Then it follows from Hall’s theorem (see e.g. Lovasz and Plummer [3] p. 5 ormost books in graph theory) that there is a S ⊆ Ik such that

|S| > |N(S)|

where N(S) ⊂ Jk denotes the set of vertices that are adjacent to at least onevertex in S. Define s = |S|, t = |Ik| = |Jk| and p = t − |N(S)|. So we have

p ≥ t − s + 1.

Let M = ∪k−1i=1 Mi. Clearly M must contain every edge joining a vertex in S and

a vertex in Jk \ N(S). Let E′ denote this edge set, so E ′ ⊆ M and |E′| = s · p.

9

It follows from Property 2 that

E′ ⊆ ∪q−1i=1 M∗

i .

But each of these matchings M∗

i contains at most min{s, p} edges in E ′ (sinceM∗

i ∩ E′ is a matching) and |E′| = s · p. Thus, the number q − 1 of thesematchings must satisfy

q − 1 ≥ ds · p/ min{s, p}e = dmin{s, p} · max{s, p}/ min{s, p}e =max{s, p} ≥ d(t + 1)/2e.

The last inequality is due to p ≥ t − s + 1 so s + p ≥ t + 1 and therefore eithers or p must be at least d(t + 1)/2e. So we have

q ≥ d(t + 1)/2e+ 1. (3)

Consider first the case when t = |Ik | is odd. Now, from our assumption (2),

we have that t = |Ik | ≥ (2/n)∑k

i=1 |Ii| − 1 for |Ik | odd. From this inequality

we now obtain t/2 + 1/2 ≥ (1/n)∑k

i=1 |Ii|. Since the left hand side is integer,we get the following when we combine with Property 1

q = d1

n

k∑

i=1

|Ii|e ≤ d(t + 1)/2e.

But this contradicts (3). Similarly one can show a contradiction if t = |Ik | iseven. So we conclude that Gk contains a perfect matching as desired. Thisproves the first part of the theorem, so it only remains to prove that m ≤bn/2c+ 1 implies (2).

Since k ≤ m and |I1| ≤ |I2| ≤ · · · ≤ |Ik| (as A1 has the CII-property) weobtain

1

n

k∑

i=1

|Ii| ≤k

n|Ik | ≤

m

n|Ik |.

Assume first that n is even. Then mn ≤ n/2+1

n = 12 + 1

n and since |Ik| ≤ n, thisimplies that

1

n

k∑

i=1

|Ii| ≤ (1

2+

1

n)|Ik| ≤

1

2|Ik| + 1.

By rearranging we get

|Ik| ≥2

n

k∑

i=1

|Ii| − 2.

Similarly, when n is odd, we have that mn ≤ n/2−1/2+1

n = 12 + 1

2n so

1

n

k∑

i=1

|Ii| ≤ (1

2+

1

2n)|Ik| ≤

1

2|Ik | +

1

2.

10

which gives

|Ik| ≥2

n

k∑

i=1

|Ii| − 1.

This completes the proof.

The following consequence of Theorem 4.1 is now immediate.

Corollary 4.2 Consider the (P2s) problem where we assume that m ≤ bn/2c+1 and di ≤ n (i ≤ m). Then, based on Algorithm 2, we find an optimal movematrix B with R(B) = 0, so there is a new assignment with no revisits.

Proof. Just define the move matrix B = [bi,j ] by bi,j = k if [ui, vj ] ∈ Mk

(i, j ≤ n, k ≤ m).We conclude this section with a few remarks concerning Algorithm 2. The-

orem 4.1 assures that Algorithm 2 works, i.e., that the subgraph Gk contains aperfect matching for each k ≤ m. In fact, the analysis of the algorithm given inthe proof of Theorem 4.1 shows that any choice of a perfect matching in Gk willwork. The following example shows that this may not be case if the conditionsof the theorem do not hold.

Example 4. In this example n = 6 and m = 6. We consider the followingdistribution matrix with the CII-property.

A =

1 1 0 0 0 00 0 1 1 0 00 0 0 0 1 11 1 0 0 0 00 0 1 1 1 01 1 0 0 0 1

Let the five first matchings be M1 = {u1v1, u2v2}, M2 = {u3v3, u4v4}, M3 ={u5v5, u6v6}, M4 = {u1v2, u2v1}, M5 = {u3v5, u4v3, u5v4}. We are then leftwith the problem of finding a perfect matching in the graph shown in figure 2.This problem clearly has no solution, and closer examination reveals that nochoice of perfect matchings will give a reallocation without revisits.

u1

2

6v

v

v

6u

2

1

u

Figure 2: Subgraph in example 3.

An interesting question is to find weaker assumptions than m ≤ bn/2c +1 such that the conclusion of Theorem 4.1 still holds. This requires a more

11

sophisticated choice of the perfect matchings involved. We note that in theprevious example (where m = n = 6) it is not possible to find pairwise disjointedge sets M1, M2, . . . , Mm such that Mi is a perfect matching on the subgraphG[Ii ∪Ji]. So m < n is required for the mentioned conclusion to hold in general.

5 The weakly constrained reallocation problem

We now return to the weakly constrained reallocation problem (P2w). Considera cyclic move matrix B (i.e. a move matrix which is cyclic). The first row ofB contains p1 entries that are k1, followed by p2 entries that are k2 etc., andeventually pt entries that are kt. Here we may assume that k1, k2, . . . , kt aredistinct numbers in {0, 1, . . . , m} and p1 + p2 + · · · + pt = n. The matrix Btherefore corresponds to moving pr objects of type kr (r ≤ t) from each oldgroup in such a way that each new group receives pr objects of type kr (r ≤ t).The cyclic move matrix B will be denoted by

B = C(k1, p1; k2, p2; . . . ; kt, pt).

A move matrix has the property that it moves objects that were in the samegroup to different groups. In addition a cyclic move matrix has the importantproperty that it moves an equal number of objects to and from each group.So, for instance, if a single cyclic move matrix, B1 is sufficient to move all theobjects, we have a new assignment with R(B1) = 0, so an optimal reallocation(in problem (P2w)) has been found. In general, however, we need more thanone move matrix.

We say that a move matrix B is completely filled if it contains no zeros.Clearly, if all objects can be moved using completely filled cyclic move matrices,we will have an optimal reallocation. This is possible if and only if n divides di

(for i ≤ m) and n2 divides N . In general, when these conditions do not hold,we will need a more sophisticated algorithm.

The general algorithm may be described as follows. Let initially A0 := Awhere A is an optimal distribution matrix from problem (P1) (in particular,the entries in each row vary by at most one) and let A1 be the zero matrix ofsize m × n. Throughout the execution of the algorithm the (i, j)th entry of A0

represents the number of objects of type i and in old group j that remains tobe moved. Similarly, the (i, j)th entry of A1 represents the number of objects oftype i that have been moved to the new group j. Define the s’th diagonal of amatrix of order n as the positions (i, s + i) for i = 1, 2, . . . , n where the columnindex is calculated modulo n.Algorithm 3:

1.) Let zi be the minimum number in row i of A0 (i ≤ m). If∑

i zi ≥ n,choose nonnegative integers z′

i ≤ zi (i ≤ m) such that∑

i z′i = n and go to step2. If

i zi < n, go to step 3.2.) Consider the cyclic move matrix B whose first row contains z ′

i entriesthat are i for those positive numbers z′

i found in step 1. So B is completely

12

filled. Update A0 by subtracting z′

i from each entry in row i of A0 (i ≤ m), andupdate A1 by adding z′

i to each entry in row i of A1 (i ≤ m). Go to step 1.3.) Let B be the cyclic move matrix whose first row contains zi entries equal

to i for those zi that are positive and the remaining, say s, entries are zero.Note that s ≥ 1 as

i zi < n. We update A0 and A1 as in step 2. The resultingmatrix A0 must be a (0, 1)-matrix where column sums vary by at most 1. (Infact, differences between any pair of columnsums are invariant throughout theexecution of the algorithm because we move the same number of objects fromeach group.) Moreover, the ith rowsum of A0 equals qi where qi is uniquelydetermined by di = pin + qi and 0 ≤ qi < n. (So qi ≡ di (mod n)).

4.) If each qi is zero, stop with the current set of move matrices. Otherwise,modify the move matrix B from the previous step by using the s diagonals withzeros. This gives sn positions that can be changed to nonzeros. There are qi

objects of type i that remain to be moved. Start with the (n − s)’th diagonal,set the first q1 components equal to 1 and update A0 and A1 accordingly. Thenset the next q2 elements equal to 2. Continue in this way to fill the diagonal bygoing through the the matrix row by row, updating A0 and A1 after each row. Ifall elements in a diagonal are filled, continue with the next diagonal until B iscompletely filled or A0 = 0.

5.) If A0 = 0, stop. Otherwise construct a new move matrix by using theprocedure described in step 4, starting with the first diagonal.

Note that the move matrix constructed in step 4 may not be cyclic. Still,the crucial point in step 4 is that the remaining objects to be moved occurconsecutively along the diagonals of B. This implies that in the distributionmatrix A corresponding to the new assignment the column sums differ by atmost one, and that the qi objects in each row is distributed to different groupsi.e., A is an optimal solution of (P1).

Example 5. To illustrate the steps of the algorithm consider the followingoptimal distribution matrix for problem (P1)

A0 =

4 4 4 3 33 2 2 3 30 1 1 1 04 4 4 3 4

,

so z1 = 3, z2 = 2, z3 = 0 and z4 = 3. Choosing z′

1 = 3, z′2 = 2, z′3 = z′4 = 0, wego to step 2 and update A0 accordingly

A0 =

1 1 1 0 01 0 0 1 10 1 1 1 04 4 4 3 4

.

Returning to step 1, we have z1 = z2 = z3 = 0 and z4 = 3. We go to step 3 and

13

update A0 and A1 in accordance with the move matrix C(4, 3; 0, 2)

A0 =

1 1 1 0 01 0 0 1 10 1 1 1 01 1 1 0 1

A1 =

3 3 3 3 32 2 2 2 20 0 0 0 03 3 3 3 3

.

The last move matrix used, Bbefore = C(4, 3; 0, 2), will now be modified (step4) to the matrix Bafter.

Bbefore =

4 4 4 0 00 4 4 4 00 0 4 4 44 0 0 4 44 4 0 0 4

Bafter =

4 4 4 1 23 4 4 4 11 3 4 4 44 2 3 4 44 4 2 4 4

.

We use the move matrix Bafter and update A0 and A1:

A0 =

0 0 0 0 00 0 0 0 00 0 0 0 01 1 1 0 0

A1 =

4 3 3 4 42 3 3 2 31 1 1 0 03 3 3 4 3

.

Note that all columnsums in A1 are equal. The last three objects are movedusing the move matrix

B =

4 0 0 0 00 4 0 0 00 0 4 0 00 0 0 0 00 0 0 0 0

and the final distribution of the new groups after reassignment is

A1 =

4 3 3 4 42 3 3 2 31 1 1 0 04 4 4 4 3

.

Theorem 5.1 Algorithm 3 finds an optimal set of matrices B1, B2, . . . , Bt forproblem (P2w). In fact, the optimal value is R(B1, B2, . . . , Bt) = R∗

w = L givenin (1).

Proof. As remarked above the move matrices B1, B2, . . . , Bt constructed bythe algorithm result in a reallocation such that the corresponding distributionmatrix is an optimal solution of (P1). Thus we have found a feasible set of movematrices. From the construction of the move matrices, we see that all thesematrices except possibly the last one are completely filled. The reallocation willtherefore achieve the lower bound on the number of revisits; see the remarkafter Lemma 3.1. This proves the theorem.

14

6 Concluding remarks

The algorithms have been implemented and tested on data from real studentgroups with success, reducing both planning time and the number of revisitscompared to the ones obtained manually. The manual plans though considersome constraints not imposed in our model. For instance, due to timetableconstraints the set of available groups may be reduced for some of the students.

As mentioned in the introduction the re-assembling of students happens morethan once. A natural extension of the problem is to define revisits with regardto all previous partitionings of the student group. This is not possible in thecurrent framework, and would require changes in both model and algorithms.

Acknowledgment. The authors wishes to thank Per Grøttum for bringingthese problems to our attention, and also for interesting discussions about thetopic.

References

[1] Ravindra K. Ahuja, Thomas L. Magnati, and James B. Orlin. Network flows: theory, algorithms, and applications. Prentice-Hall, 1993.

[2] E. Dahlhaus, D.S. Johnson, C.H. Papadimitriou, P.D. Seymour, and M. Yan-nakakis. The complexity of multiterminal cuts. SIAM J. Comput., 23:864–894, 1994.

[3] L. Lovasz and M.D. Plummer. Matching theory. North-Holland, 1986.

[4] Albert W. Marshall and Ingram Olkin. Inequalities : Theory of Majorizationand Its Applications. Academic Press, 1979.

15