a minimal algorithm for the multiple-choice knapsack problem

23
A Minimal Algorithm for the Multiple-Choice Knapsack Problem. David Pisinger Dept. of Computer Science, University of Copenhagen, Universitetsparken 1, DK-2100 Copenhagen, Denmark. May, 1994 Abstract The Multiple-Choice Knapsack Problem is defined as a 0-1 Knapsack Problem with the addition of disjoined multiple-choice constraints. As for other knapsack problems most of the computational effort in the solution of these problems is used for sorting and reduction. But although O(n) algorithms which solves the linear Multiple-Choice Knapsack Problem without sorting have been known for more than a decade, such techniques have not been used in enumerative algorithms. In this paper we present a simple O(n) partitioning algorithm for deriving the optimal linear solution, and show how it may be incorporated in a dynamic pro- gramming algorithm such that a minimal number of classes are enumerated, sorted and reduced. Computational experiments indicate that this approach leads to a very efficient algorithm which outperforms any known algorithm for the problem. Keywords: Packing; Knapsack Problem; Dynamic Programming; Reduction. 1 Introduction Given k classes N 1 , ... ,N k of items to pack in some knapsack of capacity c. Each item j N i has a profit p ij and a weight w ij , and the problem is to choose one item from each class such that the profit sum is maximized without having the weight sum to exceed c. The Multiple-Choice Knapsack Problem (MCKP) may thus be formulated as: max z = k i=1 j N i p ij x ij subject to k i=1 j N i w ij x ij c, (1) * Technical Report 94/25, DIKU, University of Copenhagen, Denmark. 1

Upload: sulphuckerium

Post on 04-Jan-2016

41 views

Category:

Documents


1 download

DESCRIPTION

David Pisinger

TRANSCRIPT

Page 1: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

A Minimal Algorithm for the

Multiple-Choice Knapsack Problem.∗

David PisingerDept. of Computer Science, University of Copenhagen,

Universitetsparken 1, DK-2100 Copenhagen, Denmark.

May, 1994

Abstract

The Multiple-Choice Knapsack Problem is defined as a 0-1 Knapsack Problemwith the addition of disjoined multiple-choice constraints. As for other knapsackproblems most of the computational effort in the solution of these problems is usedfor sorting and reduction. But although O(n) algorithms which solves the linearMultiple-Choice Knapsack Problem without sorting have been known for more thana decade, such techniques have not been used in enumerative algorithms.

In this paper we present a simple O(n) partitioning algorithm for deriving theoptimal linear solution, and show how it may be incorporated in a dynamic pro-gramming algorithm such that a minimal number of classes are enumerated, sortedand reduced. Computational experiments indicate that this approach leads to avery efficient algorithm which outperforms any known algorithm for the problem.Keywords: Packing; Knapsack Problem; Dynamic Programming; Reduction.

1 Introduction

Given k classes N1, . . . , Nk of items to pack in some knapsack of capacity c. Each itemj ∈ Ni has a profit pij and a weight wij , and the problem is to choose one item from each

class such that the profit sum is maximized without having the weight sum to exceed c.The Multiple-Choice Knapsack Problem (MCKP) may thus be formulated as:

max z =k∑

i=1

j∈Ni

pijxij

subject tok∑

i=1

j∈Ni

wijxij ≤ c, (1)

∗Technical Report 94/25, DIKU, University of Copenhagen, Denmark.

1

Page 2: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

j∈Ni

xij = 1, i = 1, . . . , k,

xij ∈ {0, 1}, i = 1, . . . , k, j ∈ Ni.

All coefficients pij , wij, and c are positive integers, and the classes N1, . . . , Nk are mutually

disjoint, class Ni having size ni. The total number of items is n =∑k

i=1 ni.Negative coefficients pij , wij in (1) may be handled by adding a sufficiently large con-

stant to all items in the corresponding class as well as to c. To avoid unsolvable or trivialsituations we assume that

k∑

i=1

minj∈Ni

wij ≤ c <k∑

i=1

maxj∈Ni

wij . (2)

If we relax the integrality constraint xij ∈ {0, 1} in (1) to 0 ≤ xij ≤ 1 we obtain theLinear Multiple-Choice Knapsack Problem (LMCKP). If each class has two items, where

(pi1, wi1) = (0, 0), i = 1, . . . , k, the problem (1) corresponds to the 0-1 Knapsack Problem(KP). The linear version of KP will be denoted by LKP.

MCKP is NP-hard as it contains KP as a special case, but it can be solved in pseudo-polynomial time through dynamic programming (Dudzinski and Walukiewicz 1987). The

problem has a large range of applications: Capital Budgeting (Nauss 1978), Menu Plan-

ning (Sinha and Zoltners 1979), transforming nonlinear KP to MCKP (Nauss 1978),determining which components should be linked in series in order to maximize fault tol-

erance (Sinha and Zoltners 1979), and to accelerate ordinary LP/GUP problems by thedual simplex algorithm (Witzgal 1977). Moreover MCKP appear by Lagrange relaxation

of several integer programming problems (Fisher 1981).Several algorithms for MCKP have been presented during the last two decades: e.g.

Nauss (1978), Sinha and Zoltners (1979), Dudzinski and Walukiewicz (1984), and Dyer,Kayal and Walker (1984). Most of these algorithms start by solving LMCKP in order

to obtain an upper bound for the problem. LMCKP is solved in two steps: 1) The LP-dominated items are reduced by sorting the items in each class according to nondecreasing

weights, and then applying some dominance criteria to delete unpromising states. 2) Thereduced LMCKP is solved by a greedy algorithm.

After these two initial steps, upper bound tests may be used to fix several variables ineach class to their optimal value. The reduced MCKP problem is then solved to optimality

through enumeration (Dudzinski and Walukiewicz 1987).

The development in KP however indicates, that MCKP may be solved easier: Balasand Zemel (1980) proposed for the KP only to consider a small subset of the items —

the so-called core — where there was a large probability for finding an optimal solution.Such a core can be found in O(n) time through a partitioning algorithm, and since the

restricted KP defined on the core items is easy to solve for several classes of data instances,it means that many instances may be solved in linear time (Martello and Toth 1988,

Pisinger 1994a).Although O(n) algorithms for LMCKP have been known for a decade (Zemel 1984,

Dyer 1984), making it possible to derive a “core” reasonably easy, a similar technique

2

Page 3: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

has not been used for MCKP. It has been claimed (Martello and Toth 1990) that the

reduction of LP-dominated items in any case was necessary in order to derive upperbounds in a branch-and-bound algorithm. The current paper refutes this conjecture, but

several questions had to be treated:

• Which items or classes should be included in the core?

• How should we derive upper bounds in a branch-and-bound algorithm when LP-

dominated items have not been deleted?

• How should a core be derived? Zemel (1984) and Dyer (1984) only give algorithms

for solving LMCKP, so some modification is necessary.

• The partitioning algorithms by Zemel and Dyer operate on the dual to LMCKPmaking them complicated to implement for practical purposes. Some simplifications

like those by Martello and Toth (1988) or Pisinger (1994a) for KP, seem necessary.

The present paper is a counterpart to a minimal algorithm for KP by Pisinger (1993): A

simple algorithm is used for solving LMCKP, and for deriving an initial feasible solution toMCKP. Starting from this initial solution we use dynamic programming to solve MCKP,

adding new classes to the core by need. By this technique we are able to show that aminimal number of classes are considered in order to solve MCKP to optimality.

This paper is organized in the following way: First, Section 2 brings some basic def-initions, and shows fundamental properties of MCKP, while Section 3 presents a simple

partitioning algorithm for the solution of LMCKP. Next, Section 4 shows how gradients

may be used in an expanding-core, as well as presenting some logical tests which maybe used to fix some variables at their optimal value, before a class is added to the core.

Section 5 gives a description of the dynamic programming algorithm, and Section 6 showshow we keep track on the solution vector in dynamic programming. Finally Section 7

gives the main algorithm proving the minimality, and Section 8 brings computationalexperiments.

2 Fundamental properties

Definition 1 If two items r and s in the same class Ni, satisfy

wir ≤ wis and pir ≥ pis, (3)

then we say that item r dominates item s.

Proposition 1 Given two items r, s ∈ Ni. If item r dominates item s then an optimalsolution to MCKP with xis = 0 exists.

Proof Let x∗ be an optimal solution to (1) with xis = 1. Then a solution x′ equal to x∗

except that x′ir = 1, x′

is = 0 will be feasible and it will have an objective value at least as

good as x∗ due to (3). ✷

3

Page 4: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

w

p

(wit − wir, pit − pir)(−pit + pir, wit −wir)

(wis − wir, pis − pir)r

s

t

r

r

r

�����✒

❅❅

❅❅❅■

✟✟✟✟✯

Figure 1: Item s is LP-dominated by items r and t.

Definition 2 If items r, s, t ∈ Ni, with

wir ≤ wis ≤ wit and pir ≤ pis ≤ pit, (4)

and the projection of vector (wis − wir, pis − pir) on the normal to (wit − wir, pit − pir) is

negative, i.e. if

det(wis − wir, pis − pir, wit − wir, pit − pir) = (5)

(wis − wir)(pit − pir)− (pis − pir)(wit − wir) ≥ 0,

then we say that item s is LP-dominated by items r and t. See Figure 1.

Proposition 2 If two items r, t ∈ Ni LP-dominate an item s ∈ Ni then an optimal

solution to LMCKP with xis = 0 exists.

Proof See Sinha and Zoltners (1979). ✷

As a consequence, we only have to consider LP-undominated items Ri in the solution

of LMCKP. Note, that these items form the upper convex boundary of the set Ni, asillustrated in Figure 2. The set of LP-undominated items may be found by ordering the

w

p

r

r

r

r

✆✆✆✆✡✡✡✏✏✏✏✏

Figure 2: LP-undominated items Ri (black) form the upper convex boundary of Ni.

4

Page 5: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

items in each class Ni according to increasing weights, and successively test the items

according to criteria (3) and (6). If two items have the same weight and profit, choose anarbitrary of them. Now LMCKP may be solved by using the greedy algorithm:

Algorithm 1 Greedy.

1 Find the LP-undominated classes Ri (ordered by increasing weights) for all classesNi, i = 1, . . . , k.

2 Choose the lightest item from each class (i.e. set xi1 = 1, xij = 0 for j =

2, . . . , |Ri|, i = 1, . . . , k) and define the chosen weight and profit sum as W =∑ki=1wi1, resp. P =

∑ki=1 pi1.

3 For all items j 6= 1 define the slope λij as

λij =pij − pi,j−1

wij − wi,j−1

, i = 1, . . . , k, j = 2, . . . , |Ri|. (6)

This slope is a measure of the profit-to-weight ratio obtained by choosing item j

instead of item j − 1 in class Ri (Zemel 1980). Clearly a greedy algorithm shouldchoose the most profitable changes first, therefore order the slopes {λij} in nonde-

creasing order.

4 Take the next slope λij from {λij}. If W + wij > c goto step 5. Otherwise set

xij = 1, xi,j−1 = 0 and update the sums W = W +wij−wi,j−1, P = P +pij−pi,j−1.Repeat step 4.

5 If W = c we have an integer solution and the optimal objective value to LMCKP(and MCKP) is z∗ = P . Otherwise let λij be the next slope in the list. We have two

fractional variables xij =c−W

wij−wi,j−1respectivly xi,j−1 = 1− xij , which both belong

to the same class. The optimal objective value is

z∗ = P + (c−W )λij. (7)

Although several orderings of {λij} exist in step 3 when more items have the same slope,we will assume in the following definitions that one specific ordering has been chosen.

The LP-optimal choices bi obtained by Algorithm 1 are those variables, where xibi = 1.

The class containing two fractional variables in step 5 will be denoted the fractional classNa, and the fractional variables are xaba , xab′a

(possibly with xab′a= 0). An initial feasible

solution to MCKP may be constructed by choosing the LP-optimal variables, i.e. settingxibi = 1 for i = 1, . . . , k and xij = 0 for i = 1, . . . , k, j 6= bi. The solution will be denoted

the break solution and the corresponding weight and profit sum is W resp. P .

Proposition 3 An optimal solution x∗ to LMCKP satisfies the following: 1) x∗ has atmost two fractional variables xaba and xab′a

. 2) If x∗ has two fractional variables they must

be adjacent variables within the same class Na. 3) If x∗ has no fractional variables, then

the break solution is an optimal solution to MCKP.

5

Page 6: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

w

p

r

r

r

r

r

r

r

r

r

r

r

bi✡

✡✡

λ−i

✏✏✏✏✏✏λ+

i

Figure 3: Gradients λ+

i , λ−i in class Ni.

Proof A consequence of Algorithm 1. ✷

The presented greedy algorithm demands O(∑k

i=1 ni logni) for the sorting and deter-

mination of LP-undominated classes which gives the complexity O(n logmax i=1,...,k ni).Next, the ordering of slopes is done in O(n logn) time, with n =

∑ki=1 |Ri|. Thus the

overall complexity is O(n logn). It should be mentioned, that when the classes form a

KP, algorithm 1 is exactly the greedy algorithm for LKP, and the objective value (7)corresponds to the Dantzig upper bound for KP (Dantzig 1957).

An optimal solution to MCKP generally corresponds to the break solution, except forsome few classes where other items than the LP-optimal choices have been chosen. This

property may be illustrated the following way: Define the positive and negative gradientλ+

i and λ−i for each class Ni, i 6= a as (see Figure 3)

λ+

i = maxj∈Ni, wij>wibi

pij − pibiwij − wibi

, i = 1, . . . , k, i 6= a, (8)

λ−i = min

j∈Ni, wij<wibi

pibi − pijwibi − wij

, i = 1, . . . , k, i 6= a, (9)

and we set λ+

i = 0 (resp. λ−i = ∞) if the set we are maximizing (resp. minimizing) over

is empty. The gradients are a measure of the expected gain (resp. loss) per weight unit

by choosing a heavier (resp. lighter) item from Ni instead of the LP-optimal choice bi.

The gradient of the fractional class Na is defined as

λ =pab′a − pabawab′a

− waba

. (10)

In Figure 4 we have ordered the classes according to decreasing λ+

i and show how

often the IP-optimal solution to MCKP differ from the LP-optimal choice in each classNi. The figure is a result of 5000 randomly generated data instances (k = 100, ni = 10),

where we have measured how often the IP-optimal choice j (satisfying w ij > wibi since weare considering forward gradients) differ from the LP-optimal choice b i in each class Ni.

It is seen, that when λ+

i is decreasing, so is the probability that bi is not the IP-optimal

6

Page 7: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣♣

♣♣ ♣♣ ♣♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ class Ni

λ+

i % differences

10 100

1.0 25

0.2 5

λ+

i

frequency

Figure 4: Frequency of classes Ni where IP-optimal choice differ from LP-optimal choice,compared to gradient λ+

i .

choice. Similarly in Figure 5 we have ordered the classes according to increasing λ−i to

show how the probability for changes decreases with increased λ−i .

This observation motivates considering only a small number of the classes N i, namely

those classes where λ+

i or λ−i are sufficiently close to λ. Thus at any stage the core is

simply a set of classes {Nr1 , . . . , Nrm} where r1, . . . , rm ∈ {1, . . . , k}. Initially the core

consists of the break set Na and we expand the core by need; alternately including thenext unused class Ni which has largest λ+

i or smallest λ−i .

Since a complete enumeration of the core demands considering up to nr1 · nr2 · · ·nrm

states, care should be taken before including a new class to the core. We use a simple

upper bound test to fix as many variables at their optimal value as possible in the classbefore it is included in the core. If only one item remains, the class may be fathomed.

Otherwise we order the remaining variables by nondecreasing weight and use test (3) todelete dominated items. The remaining class is added to the core and the new choices

are enumerated through dynamic programming.

♣ ♣ ♣ ♣ ♣♣ ♣ ♣ ♣ ♣♣ ♣ ♣ ♣ ♣♣ ♣ ♣ ♣♣ ♣ ♣ ♣♣ ♣ ♣ ♣♣ ♣ ♣ ♣♣ ♣ ♣ ♣♣ ♣ ♣♣ ♣ ♣♣ ♣ ♣♣ ♣ ♣♣ ♣♣ ♣♣ ♣♣ ♣♣ ♣♣ ♣♣ ♣♣ ♣♣♣♣

♣♣

♣ ♣♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ ♣ class Ni

λ−i % differences

10 100

1.0 25

0.2 5

λ−i

frequency

Figure 5: Frequency of classes Ni where IP-optimal choice differ from LP-optimal choice,

compared to gradient λ−i .

7

Page 8: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

3 A partitioning algorithm for the LMCKP

Dyer (1984) and Zemel (1984) independently of each other developed O(n) algorithms

for LMCKP. Both algorithms are based on the convexity of the LP-dual problem to (1),which makes it possible to pair the dual line segments, so that at each iteration at least

1/6 of the line segments are deleted. When the classes form a KP the algorithms reduceto that of Balas and Zemel (1980) for LKP. As Martello and Toth (1988) modified the

Balas and Zemel algorithm for LKP to a primal approach which is easier to implement,we will now modify the Dyer and Zemel algorithm for LMCKP in a similar way.

Assume that Na is the fractional class and that items ba and b′a are the fractionalvariables in Na, such that xaba + xab′a

= 1, possibly with xab′a= 0. Moreover let bi be

the LP-optimal choice in class Ni, i = 1, . . . , k, i 6= a. Due to the properties of LMCKPgiven in Proposition 3, LMCKP may be reformulated as finding the slope

λ =δp

δw=

pab′a − pabawab′a

− waba

, (11)

such that the weight sum of the LP-optimal choices satisfy∑

i 6=a

wibi + waba ≤ c <∑

i 6=a

wibi + wab′a, (12)

and

det(wij, pij, δw, δp) ≤ det(wibi, pibi , δw, δp), i = 1, . . . , k, j = 1, . . . , ni. (13)

Here (12) ensures that Na is the fractional class, and (13) ensures that each item bi ∈ Ni

is at the upper convex boundary of the set.

The formulation (11)-(13) allows us to use a partitioning algorithm for finding theoptimal slope λ. In the following algorithm we assume that the classes of items N i are

represented as a list [N1, . . . , Nk] and items in each class are also represented as a list[j1, . . . , jni

]. Elements may be deleted from a list by swapping the deleted element to the

end of the list, and subsequently decreasing the list’s length. Thus at any step k and ni

refer to the current number of elements in the list. The partitioning algorithm looks like

this:

Algorithm 2 Partition.

0 Preprocess. For all classes i = 1, . . . , k let αi and βi be indices to the items havingminimal weight (resp. maximal profit) in N i (see Figure 6). In case of several items

satisfying the criterion, choose the item having largest profit for α i and smallest

weight for βi.If

∑ki=1wiαi

> c no solution exists so stop. If∑k

i=1wiβi≤ c we have a trivial solution

consisting of the items βi, so stop.Set W = P = 0, and remove those items j 6= βi which have wij ≥ wiβi

and pij ≤ piβi,

since these are dominated by item βi. If the class Ni has only one item left, savethe LP-optimal choice bi = βi and set W = W + wibi, P = P + pibi , then delete

class Ni.

8

Page 9: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

w

p

αi

βi

r

r

r

r

r

r

r

r

Figure 6: Preprocessing of Ni. White nodes are dominated by βi.

1 Choose median. For M randomly chosen classes Ni define the corresponding slope

λi =δpiδwi

=piβi

−piαi

wiβi−wiαi

. Using an O(n) median algorithm (Aho et. al. 1974) let

λ = δpδw be the median of these M slopes.

2 Find the conclusion. For each class Ni find the items which maximize the projection

on the normal to (δw, δp), i.e. which maximize the determinant

det(wij, pij , δw, δp) = wijδp− pijδw. (14)

See Figure 7. We swap these items to the beginning of the list such that they have

indices {1, . . . , ℓi} in class Ni.

3 Determine weight sum of conclusion. Let gi, hi be the lightest (resp. heaviest) itemamong {1, . . . , ℓi} in class Ni, and let W ′ and W ′′ be the corresponding weight sums.

Thus W ′ = W +∑k

i=1wigi and W ′′ = W +∑k

i=1wihi.

4 Check for optimal partitioning. If W ′ ≤ c ≤ W ′′ the partitioning at (δw, δp) isoptimal. First, choose the lightest items from each class by setting b i = gi, W =

W+wibi, P = P+pibi . Then whileW−wigi+wihi≤ c run through the classes where

ℓi 6= 1 and choose the heaviest item by setting bi = hi, W = W −wigi +wibi, P =

P −pigi +pibi . The first class where W −wigi +wihi> c is the fractional class Na and

w

p

���✒(δw, δp)

❅❅

❅■

(δw, δp)αi

βi

r

r

r

r

r

r

r

r

��

��

Figure 7: Conclusion of Ni.

9

Page 10: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

w

p

αi

βi

r

r

r

r

❅❅❅❅❅

❅❅❅❅❅

❅❅❅❅❅

❅❅❅

❅❅❅

Figure 8: Partition set Ni.

an optimal objective value to LMCKP is zLMCKP = P + (c−W )λ. If no fractional

class is defined, the LP-solution is also the optimal IP-solution. Stop.

5 Partition. We have one of the following two cases: 1) If W ′ > c then the slope λwas too small (see Figure 8). For each class Ni choose βi as the lightest item in

{1, . . . , ℓi} and delete items j 6= βi with wij ≥ wiβi. 2) If W ′′ < c then the slope

λ =δpδw was too large. For each class Ni choose αi as the heaviest item in {1, . . . , ℓi}

and delete items j 6= αi with pij ≤ piαi(items j with wij ≤ wiαi

are too light, and

items with wij > wiαi, pij ≤ piαi

are dominated). If the class Ni has only one itemleft, save the LP-optimal choice bi = βi and set W = W +wibi, P = P + pibi , then

delete class Ni. Goto Step 1.

The above algorithm may be further improved by introducing LP-dominance reductions:Each time αi or βi is changed in a class Ni, we use criterion (6) to test whether any items

are LP-dominated by αi and βi. In this way each class will only consist of the itemsclose to the upper convex boundary. Computational experiments do however indicate,

that Algorithm 2 does not become considerably faster by the addition of LP-dominancecriteria.

Depending on the choice of M in step 1, we obtain different behavior of the algorithm.

The best performance is obtained by choosing λ as the median of all slopes λ i, i = 1, . . . , k(i.e. choose M = k) but for practical purpose M ≤ 15 works well. Note that in the KP

case, Algorithm 2 becomes the partitioning algorithm of Balas and Zemel (1980).

Proposition 4 If we choose λ = δpδw

as the exact median of M different slopes λi =δpiδwi

in step 1 of Algorithm 2, at least ⌈M/2⌉ items are deleted at each iteration.

Proof Since λ is the median of the M classes, we have λi ≤ λ for ⌈M/2⌉ classes, sofor these classes at least one item j 6= αi exists which maximizes (14). Similarly we

have λi ≥ λ for ⌈M/2⌉ classes, so for these classes at least one item j 6= βi exists whichmaximizes (14). If W ′ > c in step 5, at least ⌈M/2⌉ items {βi} will be deleted. Otherwise

if W ′′ < c, at least ⌈M/2⌉ items {αi} will be deleted. ✷

10

Page 11: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

Corollary 1 If M = 1 at least one item is deleted at each iteration of Algorithm 2,

yielding a complexity of O(n2).

Proposition 5 If M = k and the size of each class ni is bounded by a constant C,

Algorithm 2 runs in O(n).

Proof Due to Proposition 4 at least k2items are deleted at each iteration. Since ni is

bounded by C it means that at least 1

2Cn items are deleted at each iteration, yielding the

complexity. ✷

4 Expanding core

Balas and Zemel (1980) proposed for KP to consider only a small amount of the items —

the so-called core — where there was a large probability for finding an optimal solution.However the core cannot be identified a-priori, implying that in some cases optimality of

the core solution cannot be proved.Pisinger (1994a) noted, that even though the core cannot be identified before KP

is solved, it can be identified while the problem is solved by using an expanding core.

Moreover Pisinger developed an algorithm which is always using a minimal core (Pisinger1993).

We will use the same concept for MCKP, but now the core consists of the smallestpossible number of classes Ni, such that an optimal solution may be determined and

proved. Where the core for KP naturally consists of items having profit-to-weight ratioclose to that of the break item, there is no natural way of ordering the classes in MCKP.

Instead we use the gradients to identify a core: Define the positive and negative gradientλ+

i and λ−i for each class Ni, i 6= a by (8) and (9). Due to (13) we have that

λ+

i ≤δp

δw≤ λ−

i . (15)

Order the sets L+ = {λ+

i } according to nonincreasing values, and L− = {λ−i } according

to nondecreasing values. Initially the core C only consists of the fractional class Na, and

then we repeatedly add classes Ni corresponding to the next gradient from the orderedsets L+ and L−. Since each class occur twice (once in each set L+ and L−), we always

check whether the class already has been added to the core.

4.1 Class reduction

Before adding a class Ni to the core C it is appropriate to fathom unpromising itemsfrom the class. We check whether each item j ∈ Ni has an upper bound larger than the

currently best solution z. For this purpose we use the weak upper bound, obtained byrelaxing the constraint in (1) on the fractional variables ba, b

′a ∈ Na from xba , xb′a

∈ {0, 1}to xba , xb′a

∈ R. The upper bound on item j ∈ Ni is then

uij = P − pibi + pij + λ(c−W + wibi − wij), (16)

11

Page 12: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

and if uij < z+1 we may fix xij to 0. Since the bound (16) is evaluated in constant time,

the complexity of reducing class Ni is O(ni).If the reduced set N ′

i has only one item left, we fathom the class, since no choices have

to be done. Otherwise we order the items in N ′i according to nondecreasing weights and

delete dominated items by applying (3). The computational effort is concentrated on the

sorting, yielding a complexity of O(n ′i logn

′i) where ni is the size of N

′i . In Section 8 it will

be demonstrated that a large majority of the items may be fixed at their optimal value

by the reduction (16), thus significantly decreasing the number of items which need to besorted.

5 A dynamic programming algorithm

The core is a set of currently included classes C = {Nr1, . . . , Nrm}, so the set of partial

vectors in C is given by

YC = { (y1, . . . , ym) | yi ∈ {1, . . . , nri}, i = 1, . . . , m }, (17)

where each variable yi determines that variable xiyi = 1 while the remaining binaryvariables inNi are set to zero. The weight and profit sum of a vector yi = (y1, . . . , ym) ∈ YC

corresponds to the weight and profit sum of the chosen variables yri when Nri ∈ C, and

to the LP-optimal choices bi when Nri 6∈ C. Thus

µi =∑

Ni∈C

wiyi +∑

Ni 6∈C

wibi , (18)

πi =∑

Ni∈C

piyi +∑

Ni 6∈C

pibi. (19)

It is convenient to represent each vector yi ∈ YC by a state (µi, πi, vi), where µi, πi are

given above, and vi is a (not necessarily complete) representation of y i. According to theprinciple of optimality (Ibaraki 1987) we may fathom some of these states:

Definition 3 Given two states (µi, πi, vi) and (µj, πj , vj). The state i is said to dominate

the state j if µi ≤ µj and πi ≥ πj .

Proposition 6 If a state i dominates another state j we may fathom the dominated

state j.

Proof Similar to Proposition 1. ✷

We will keep the set YC = {(µ1, π1, v1), . . . , (µm, πm, vm)} ordered according to increasing

weight and profit sums (µi < µi+1 and πi < πi+1) in order to easily fathom dominatedstates.

When a new class N is added to the core C, we must enumerate the new choices anddelete dominated states. A clever way of doing this is by using a divide and conquer

algorithm (Pisinger 1994b), which takes advantage of the ordering of YC and N .

12

Page 13: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

The idea is to divide N recursively in two equally sized parts NA and NB until the

hereby obtained sets have size 1. A set NA of size 1 is trivially multiplied with the setY simply by adding the remaining item (w, p) to each state in Y , and the product set

Y ′′A will still be ordered. Finally the sets Y ′′

A and Y ′′B are merged two by two, and the

dominated states are removed.

Algorithm 3

procedure divide(Y , N , var Y ′);

{ Determine Y ′ = Y ×N , where the product is Y ′ = {(µ′1, π

′1, v

′1), . . . , (µ

′m′, π′

m′ , v′m′)}, and }{ the multipliers are Y = {(µ1, π1, v1), . . . , (µm, πm, vm)} resp. N = {(wf , pf), . . . , (wl, pl)}. }if (f = l) then

for i := 1 to m do (µ′i, π

′i, v

′i) := (µi − wb + wf , πi − pb + pf , vi ∪ {f}); rof;

m′ := m;else

d := ⌊(f + l)/2⌋;NA := {(wf , pf), . . . , (wd, pd)};NB := {(wd+1, pd+1), . . . , (wl, pl)};divide(Y,NA, Y

′A); divide(Y,NB, Y

′B); conquer(Y ′

A, Y′B, Y

′);

fi;

procedure conquer(Y , Y ′, var Y ′′);

{ Determine Y ′′ = Y + Y ′, where the sum is Y ′′ = {(µ′′1, π

′′1 , v

′′1), . . . , (µ

′′m′′ , π′′

m′′ , v′′m′′)}, and the }{ addends are Y = {(µ1, π1, v1), . . . , (µm, πm, vm)} resp. Y ′ = {(µ′

1, π′1, v

′1), . . . , (µ

′m′ , π′

m′ , v′m′)}. }i := 1; j := 1; k := 1; (µm+1, πm+1, vm+1) := (∞,∞, {}); (µ′

m′+1, π′m′+1, v

′m′+1) := (∞,∞, {});

if (µ1 ≤ µ′1) then (µ′′

1, π′′1 , v

′′1) := (µ1, π1, v1); i := 2; else (µ′′

1, π′′1 , v

′′1) := (µ′

1, π′1, v

′1); j := 2; fi;

repeat

if (µi ≤ µ′j) then { Choose smallest weight to ensure ordering. }

if (µi, πi, vi) is not dominated by (µ′′k, π

′′k , v

′′k) then

if (µi, πi, vi) does not dominate (µ′′k, π

′′k , v

′′k) then k := k + 1; fi;

(µ′′k, π

′′k , v

′′k) := (µi, πi, vi);

fi; i := i+ 1;else

if (µ′j, π

′j, v

′j) is not dominated by (µ′′

k, π′′k , v

′′k) then

if (µ′j, π

′j, v

′j) does not dominate (µ′′

k, π′′k , v

′′k) then k := k + 1; fi;

(µ′′k, π

′′k , v

′′k) := (µ′

j, π′j , v

′j);

fi; j := j + 1;fi;

until (i = m+ 1) and (j = m′ + 1);m′′ := k;

To extend the core C with a new class Ni simply call divide(YC, Ni, YC∪{Ni}) to obtainthe new set of states YC∪{Ni}. The algorithm has time complexity O(mn i log2(ni)) where

m is the size of YC and ni the size of Ni. For most data instances a great majority of

13

Page 14: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

the new states are deleted by dominance such that far less than the expected mni states

are generated. The structure of Algorithm 3 implies that many of the dominated statesmay be deleted already when the first sets are merged, leading to a considerably faster

computation.

5.1 Reduction of states

Although the number of states in YC at any time is bounded by the capacity c due to thedominance criterion (3), the enumeration may be considerably improved by adding some

upper bound tests in order to delete unpromising states.Assume that the core C is obtained by adding classes corresponding to the first m

gradients from L− and L+ and that Ns and Nt are the next classes to be added from eachset. Thus the gradients satisfy

maxNi 6∈C

λ−i ≤ λ−

s , (20)

minNi 6∈C

λ+

i ≥ λ+

t . (21)

By this assumption we get the following upper bounds on a state i given by (µ i, πi, vi)

u(i) =

πi + (c− µi)λ+t if µi ≤ c,

πi + (c− µi)λ−s if µi > c.

(22)

For conveniency we set λ+t = 0 if the set L+ is empty, and λ−

s = ∞ if L− is empty,ensuring that states which cannot be improved further are fathomed.

The bound (22) may also be used for deriving a global upper bound on MCKP. Sinceany optimal solution must follow a branch in YC , the global upper bound corresponds to

the upper bound of the most feasible branch in YC . Therefore a global upper bound onMCKP is given by

uMCKP = maxyi∈YC

u(i). (23)

Since the gradient λ+t will be decreasing during the solution process, and the gradient λ−

s

will be increasing, uMCKP will become more and more tight as the core is expanded. For

a complete core C = {N1, . . . , Nk} we get uMCKP = z for the optimal solution z.

6 Finding the solution vector

According to Bellman’s classical description of dynamic programming (Bellman 1957),the optimal solution vector x∗ may be found by backtracking through the sets of states,

implying that all sets of states should be saved during the solution process. In the com-putational experiments it is demonstrated that the number of states may be half a million

in each iteration and since the number of classes may be large (k = 10000) we would need

14

Page 15: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

to store billions of states. Pisinger (1993) proposed to save only the last a changes in the

solution vector in each state (π, µ, v). If this information is not sufficient for reconstruct-ing the solution vector, we simply solve a new MCKP problem with a reduced number of

variables. This is repeated till the solution vector is completely defined. More preciselywe do the following:

Whenever an improved solution is found during the construction of YC , we save thecorresponding state (µ, π, v). After termination of the algorithm, the solution vector is

reconstructed as far as possible. First, all variables are set to the break solution meaningthat xibi = 1 for i = 1, . . . , k and xij = 0 for i = 1, . . . , k, j 6= bi. Then we run through

the vector v in the following way:

Algorithm 4

procedure definesolution(µ, π, v);

for h := 1 to a do { v = {v1, . . . , va} are the last a changes in the solution vector. }i := vh.i; { i is the class corresponding to vh. }j := vh.j; { j is the variable corresponding to vh. }µ := µ− wij + wibi; π := π − pij + pibi ; xij := 1; xibi := 0;

rof;

If the backtracked profit and weight sums µ, π correspond to the profit and weight sums

of the break solution W,P , we know that the constructed vector is correct. Otherwise wesolve a new MCKP, this time with capacity c = µ, lower bound z = π − 1, and global

upper bound u = π. The process is repeated until the solution vector x is completelydefined. This technique has proved very efficient, since generally only a few iterations

are needed. With a = 10, a maximum of 4 iterations has been observed for large datainstances, but generally the optimal solution vector is found after the first iteration.

7 Main algorithm

The previous sections may be summed up to the following main algorithm:

Algorithm 5

procedure mcknap;Solve LMCKP through a partitioning algorithm.

Determine gradients L+ = {λ+

i } and L− = {λ−i } for i = 1, . . . , k, i 6= a.

Partially sort L+ in decreasing order and L− in increasing order.

z := 0; C := {Na}; YC := reduceclass(Na);repeat

reduceset(YC); if (YC = ∅) then break; fi;Ni := L−

s ; s := s+ 1; { Choose next class to be included. }if (Ni is not used) then

Ri := reduceclass(Ni);if (|Ri| > 1) then add(YC , Ri);

fi;

15

Page 16: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

reduceset(YC); if (YC = ∅) then break; fi;

Ni := L+t ; t := t + 1; { Choose next class to be included. }

if (Ni is not used) then

Ri := reduceclass(Ni);if (|Ri| > 1) then add(YC , Ri);

fi;

forever;Find the solution vector.

The first step of the algorithm is to solve the LMCKP as sketched in Section 3. Hereby

we obtain the fractional class Na, the break solution {bi} as well as the corresponding

weight and profit sum W and P .

The gradients λ+

i and λ−i are determined and the sets L+ and L− are ordered. Since we

initially do not need a complete ordering, we use a partial ordering as presented in Pisinger

(1994a): Using the quicksort algorithm for sorting (Hoare 1962), we always choose theinterval containing largest values (resp. smallest for L−) for further partitioning, while

the other interval is pushed onto a stack. In this way we continue until the largest (resp.smallest) values have been determined. Later in Algorithm 5, if more values are needed,

we simply pop the next interval from the stack by need and partition it further.

Our initial core is the fractional class Na, which is reduced by procedure reduceclass.Here we apply criterion (16) to fix as many variables as possible at their optimal value. If

the reduced class has more than one item left, we sort the items according to increasingweight, and then apply criterion (3) to remove dominated items. Hereby we obtain the

reduced class Ra which is the current set of states YC.

The set of states YC is reduced by procedure reduceset which apply criterion (22) tofathom unpromising states. Moreover the procedure checks whether any feasible state

(µ ≤ c) has improved the lower bound z, and updates the current best solution in thatcase.

Now we alternately include classes from L+ and L−, each time reducing the class to

see if it must be added to the core. The reduced class Ri is added to the set of states YC

by using Algorithm 3, indicated by procedure add above.

The iteration stops when no more states are feasible, meaning that no improvements

can occur. Note that we set λ+t = 0 when L+ is empty, and λ−

s = ∞ when L− is empty,meaning that the iteration in any case will stop when all classes have been considered.

7.1 Minimality

We claim Algorithm 5 solves MCKP to optimality with a minimal core and with minimal

effort for sorting and reduction. More precisely we have:

Definition 4 Given a core C and the corresponding set of states YC . We say that the

core problem has been solved to optimality if one (or both) of the following cases occur:

1 YC = ∅ meaning that all states were fathomed due to an upper bound test.

16

Page 17: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

2 All classes Ni 6∈ C could be reduced to contain only the LP-optimal choice bi.

Definition 5 MCKP has been solved with a minimal core if the following invariant holds:A class Ns (resp. Nt) is only added to the core C if the corresponding core problem could

not be solved to optimality, and the set Ns (resp. Nt) has the smallest gradient λ−s (resp.

largest gradient λ+t ).

The definition states, that a class Ns (resp. Nt) should be added to the core only if itcannot be avoided by any upper bound test, and if all classes with smaller (resp. larger)

gradients have been considered. The definition ensures that if MCKP has been solved

to optimality with a minimal core C, no smaller subset core C ′ ⊂ C exists. Anyway asmaller sized core C ′ may exist if C 6⊂ C ′ and C ′ 6⊂ C but according to our definition

such cores are not comparable. Algorithm 5 finds the minimal core (of several possible)which is symmetric around Na.

Definition 6 The effort used for reduction has been minimal if a class N i is reduced onlywhen the core C could not be solved to optimality, and Ni is the next class to be included

according to the rule in definition 5.

Definition 7 The sorting effort has been minimal if 1) A class N i is sorted only when

the current core C could not be solved to optimality, 2) Ni is the next class to be includedaccording to definition 5, and 3) only items which have passed the reduction criterion (22)

are sorted.

Proposition 7 The presented algorithm solved MCKP with a minimal core, using min-

imal reduction and sorting effort.

Proof A consequence of Section 4 (minimal core), and Algorithm 5 (minimal reduction,sorting). ✷

8 Computational experiments

The presented algorithm has been implemented in ANSI-C, and a complete listing is

available from the author on request. The following results have been achieved on aHP9000/730 computer.

We will consider how the algorithm behaves for different problem sizes, test instances,and data-ranges. Five types of randomly generated data instances are considered, each

instance tested with data-range R1 = 1000 or R2 = 10000 for different number of classesk and sizes ni:

• Uncorrelated data instances (uc): In each class we generate ni items by choosingwij and pij randomly in [1, R].

• Weakly correlated data instances (wc): In each class, wij is randomly distributed in

[1, R] and pij is randomly distributed in [wij − 10, wij + 10], such that pij ≥ 1.

17

Page 18: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

• Strongly correlated data instances (sc): For KP these instances are generated as wj

randomly distributed in [1, R] and pj = wj + 10, which are very hard indeed. Suchinstances are trivial for MCKP, since they degenerate to subset-sum data instances,

but hard instances for MCKP may be constructed by cumulating strongly correlatedKP-instances: For each class generate ni items (w′

j , p′j) as for KP, and order these

by increasing weight. The data instance for MCKP is then wij =∑j

h=1w′h, pij =∑j

h=1 p′h, j = 1, . . . , ni. Such instances have no dominated items, and form an

upper convex set.

• Subset-sum data instances (ss): wij randomly distributed in [1, R] and pij = wij.

Such instances are hard since any upper bound will yield u ij = c.

• Sinha and Zoltners (sz): Sinha and Zoltners (1979) constructed their instances ina special way. For each class construct ni items as (w′

j, p′j) randomly distributed in

[1, R]. Order the profits and weights in increasing order, and set wij = w′j , pij =

p′j , j = 1, . . . , ni. Note that such data instances have no dominated items.

The constant M in Algorithm 2 is chosen as M = 15 and for each data instance the

capacity c is

c =1

2

k∑

i=1

(minj∈Ni

wij +maxj∈Ni

wij

). (24)

We construct and solve 100 different data instances for each problem type, size and range.

The presented results are average values or extreme values.

First Table I shows the average core size (measured in classes) for solving MCKP tooptimality. For most instances only a few classes need to be considered in the dynamic

programming. The strongly correlated data instances however demand that almost allclasses are considered.

Table II shows how many classes have been tested by criterion (16). It is seen, that

when many classes are present, only a few percent of the classes are reduced, meaningthat we may solve the problem to optimality without even considering a large majority

UC WC SC SS SZk ni R1 R2 R1 R2 R1 R2 R1 R2 R1 R2

10 10 2 2 8 8 8 9 2 4 6 5100 10 8 9 11 16 85 84 2 4 17 171000 10 15 20 7 12 791 775 0 2 18 33

10000 10 10 28 1 10 7563 7800 0 0 11 33

10 100 2 3 4 5 8 8 1 2 7 8100 100 7 10 3 6 84 95 0 1 15 341000 100 6 17 1 4 839 915 0 0 11 41

10 1000 1 2 2 2 4 8 0 1 6 9100 1000 1 6 0 2 25 82 0 0 9 30

Table I: Final core-size. Average of 100 instances.

18

Page 19: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

UC WC SC SS SZk ni R1 R2 R1 R2 R1 R2 R1 R2 R1 R2

10 10 52 55 87 88 85 88 23 37 83 82100 10 46 63 14 19 87 86 2 4 68 80

1000 10 20 52 1 1 82 82 0 0 18 7010000 10 0 26 0 0 78 80 0 0 0 19

10 100 42 60 43 55 81 81 10 19 80 90100 100 23 56 3 6 84 95 0 1 23 82

1000 100 1 29 0 0 84 92 0 0 2 21

10 1000 10 48 16 20 45 79 0 11 66 97100 1000 1 20 0 2 25 82 0 0 11 39

Table II: Percentage of all classes which have been tested by weak upper bound. Average

of 100 instances.

of the classes. The strongly correlated data instances again demonstrate that almost allclasses must be considered.

The efficiency of the weak upper bound (16) is given in Table III. The entries showhow many percent of the tested items which are reduced. Generally a large majority of

the variables are fixed to their optimal value this way.

To illustrate the hardness of the dynamic programming, we measure the largest set

of states YC for each data instance in Table IV. It is seen that strongly correlated datainstances may result in more than half a million states. Still this is far less than the c

states, which is the guaranteed maximum.

Finally Table V gives the average computational times. Easy data instances are solvedin a fraction of a second. Only the strongly correlated instances demand more computa-

tional effort, but are still solved within 30 minutes.

The above results indicate that the presented algorithm outperforms any algorithmfor MCKP (see Sinha and Zoltners 1979, Armstrong et. al 1983, Dyer, Kayal and Walker

1984), implying that the stated minimal properties cause drastical reductions in the com-putational times.

UC WC SC SS SZk ni R1 R2 R1 R2 R1 R2 R1 R2 R1 R2

10 10 83 84 48 27 45 34 0 0 70 73100 10 88 88 62 56 51 51 0 0 86 86

1000 10 89 90 68 49 53 54 0 0 88 8910000 10 86 90 80 68 50 52 0 0 72 90

10 100 98 98 75 61 84 79 0 0 86 85100 100 99 99 87 68 85 85 0 0 93 97

1000 100 98 99 94 86 84 85 0 0 94 98

10 1000 100 100 87 58 50 94 0 0 89 90100 1000 100 100 94 85 50 94 0 0 93 96

Table III: Percentage of tested items which are reduced. Average of 100 instances.

19

Page 20: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

UC WC SC SS SZk ni R1 R2 R1 R2 R1 R2 R1 R2 R1 R2

10 10 0 0 1 10 3 24 4 47 0 0100 10 0 0 4 52 7 68 4 38 0 01000 10 1 0 4 39 20 194 0 28 2 3

10000 10 1 4 5 46 84 572 0 0 4 12

10 100 0 0 4 40 1 10 3 28 1 1100 100 0 0 4 40 4 26 3 28 3 31000 100 0 1 3 43 10 106 0 0 4 8

10 1000 0 0 3 35 3 4 0 30 3 10100 1000 0 0 3 36 25 9 0 20 4 31

Table IV: Largest set of states in dynamic programming (in thousands). Maximum of 100instances.

UC WC SC SS SZk ni R1 R2 R1 R2 R1 R2 R1 R2 R1 R2

10 10 0.00 0.00 0.01 0.05 0.01 0.09 0.01 0.17 0.00 0.00100 10 0.00 0.00 0.02 0.28 0.37 5.16 0.01 0.11 0.01 0.011000 10 0.03 0.03 0.03 0.23 7.30 92.46 0.01 0.09 0.04 0.05

10000 10 0.25 0.31 0.24 0.42 169.94 1628.57 0.17 0.17 0.33 0.41

10 100 0.00 0.00 0.03 0.58 0.02 0.19 0.06 1.05 0.01 0.02100 100 0.02 0.02 0.03 0.55 0.33 6.93 0.01 0.68 0.05 0.071000 100 0.14 0.17 0.16 0.43 9.57 195.75 0.13 0.13 0.24 0.32

10 1000 0.02 0.03 0.12 2.75 1.64 0.14 0.02 12.55 0.19 0.74100 1000 0.12 0.15 0.18 1.11 173.69 2.97 0.13 0.15 0.41 2.66

Table V: Total computing time in seconds. Average of 100 instances.

9 Conclusions

We have presented a complete algorithm for the exact solution of the Multiple-Choice

Knapsack Problem. To our knowledge, it is the first enumerative algorithm which makesuse of the partitioning algorithms by Dyer (1984) and Zemel (1984). In order to do this,

it has been necessary to derive new upper bounds based on the positive and negativegradients, as well as choosing a strategy for which classes should be added to the core.

The algorithm satisfies some minimality constraints as defined in Section 7.1: It solvesMCKP with a minimal core, since variables only are added to the core if the current core

could not be solved to optimality, and the effort used for sorting and reduction is alsominimal according to the stated definitions.

Computational experiments document that the presented algorithm is indeed veryefficient. Even very large data instances are solved in a fraction of a second; only strongly

correlated data instances demand more computational effort. It is our hope that theappearance of this algorithm will promote the use of the MCKP model, since it is far

more flexible than e.g. a simple KP model.

20

Page 21: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

R1 R2

k minknap mcknap preproc minknap mcknap preproc

100 0.00 0.00 0.00 0.00 0.00 0.001000 0.00 0.02 0.01 0.00 0.02 0.0110000 0.01 0.13 0.12 0.02 0.21 0.12100000 0.10 1.37 1.36 0.16 1.53 1.34

Table VI: Total computing time in seconds for solving 0-1 Knapsack Problems. Uncorre-

lated data instances. Average of 100 instances.

Appendix A: 0-1 Knapsack Problems

The algorithm developed, may equally well be used for solving 0-1 Knapsack Problems,but this will naturally yield some overhead compared to specialized algorithms for the 0-1

Knapsack Problem.

Table VI compares the running times of mcknap with those of minknap (Pisinger

1994c). It is seen, that generally mcknap spends about 10 times more computationaltime for the solution than minknap. However column preproc shows, that most of

the overhead is spent for the preprocessing (sorting and removal of dominated items)where minknap obviously is able to use a faster algorithm for these steps, as there are

no dominated items in the classes of a 0-1 Knapsack Problem.

In spite of the higher computational times for mcknap it is seen, that the developedalgorithm has a stable behavior, even in this extreme case.

References

Aho, A.V., J.E. Hopcroft and J.D. Ullman, The design and analysis of Computer

algorithms, Addison-Wesley, Reading, MA, 1974.

Armstrong, R.D., D.S. Kung, P. Sinha and A.A. Zoltners, “A ComputationalStudy of a Multiple-Choice Knapsack Algorithm,” ACM Transactions on Mathematical

Software, 2 (1983), 184-198.

Balas, E. and E. Zemel, “An Algorithm for Large Zero-One Knapsack Problems,”

Operations Research, 28 (1980), 1130-1154.

Bellman, R.E., “Dynamic Programming,” Princeton University Press, Princeton, N.J.,(1957).

Dantzig, G.B., “Discrete Variable Extremum Problems,” Operations Research, 5 (1957),

266-277.

Dudzinski K. and S. Walukiewicz, “A fast algorithm for the linear multiple-choice

21

Page 22: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

knapsack problem,” Operations Research Letters, 3 (1984) 205-209.

Dudzinski K. and S. Walukiewicz, “Exact methods for the knapsack problem and

its generalizations,” European Journal of Operational Research, 28 (1987) 3-21.

Dyer M.E., “An O(n) algorithm for the multiple-choice knapsack linear program,”Math-

ematical Programming, 29 (1984) 57-63.

Dyer M.E., N. Kayal and J. Walker, “A branch and bound algorithm for solving

the multiple choice knapsack problem,” Journal of Computational and Applied Mathe-

matics 11 (1984) 231-249.

Fisher, M.L., “The Lagrangian Relaxation Method for Solving Integer ProgrammingProblems,” Management Science, 27 (1981), 1-18.

Hoare, C.A.R., “Quicksort,” Computer Journal, 5, 1 (1962), 10-15.

Ibaraki, T., “Enumerative Approaches to Combinatorial Optimization - Part 2,” Annals

of Operations Research, 11 (1987).

Martello, S. and P. Toth, “A New Algorithm for the 0-1 Knapsack Problem,” Man-

agement Science, 34 (1988), 633-644.

Martello, S. and P. Toth, Knapsack Problems: Algorithms and Computer Imple-

mentations, Wiley, England, 1990.

Nauss, R.M., “The 0-1 knapsack problem with multiple choice constraint,” European

Journal of Operational Research, 2 (1978), 125-131.

Pisinger, D., “On the solution of 0-1 knapsack problems with minimal preprocessing,”Proceedings NOAS’93, Trondheim, Norway, June 11-12. (1993).

Pisinger, D., “An expanding-core algorithm for the exact 0-1 Knapsack Problem,” To

appear in European Journal of Operational Research (1994a).

Pisinger, D., “Solving hard knapsack problems,” DIKU, University of Copenhagen,

Denmark, Report 94/24 (1994b).

Pisinger, D., “A minimal algorithm for the 0-1 Knapsack Problem,” DIKU, University

of Copenhagen, Denmark, Report 94/23 (1994c).

Sinha, A. and A.A. Zoltners, “The multiple-choice knapsack problem,” Operations

Research 27 (1979) 503-515.

22

Page 23: A Minimal Algorithm for the Multiple-Choice Knapsack Problem

Witzgal, C., “On One-Row Linear Programs,” Applied Mathematics Division, National

Bureau of Standards (1977).

Zemel, E., “The linear multiple choice knapsack problem,” Operations Research 28(1980) 1412-1423.

Zemel, E., “An O(n) algorithm for the linear multiple choice knapsack problem and

related problems,” Information Processing Letters, 18 (1984) 123-128.

23