Packing a Knapsack of Unknown Capacity
Abstract
We study the problem of packing a knapsack without knowing its capacity. Whenever we attempt to pack an item that does not fit, the item is discarded; if the item fits, we have to include it in the packing. We show that there is always a policy that packs a value within factor 2 of the optimum packing, irrespective of the actual capacity. If all items have unit density, we achieve a factor equal to the golden ratio . Both factors are shown to be best possible.
In fact, we obtain the above factors using packing policies that are universal in the sense that they fix a particular order of the items and try to pack the items in this order, independent of the observations made while packing. We give efficient algorithms computing these policies. On the other hand, we show that, for any , the problem of deciding whether a given universal policy achieves a factor of is -complete. If is part of the input, the same problem is shown to be -complete for items with unit densities. Finally, we show that it is -hard to decide, for given , whether a set of items admits a universal policy with factor , even if all items have unit densities.
1 Introduction
In the standard knapsack problem we are given a set of items, each associated with a size and a value, and a capacity of the knapsack. The goal is to find a subset of the items with maximum value who’s size does not exceed the capacity. In this paper, we study the oblivious knapsack problem where the capacity of the knapsack is not given. Whenever we try to pack an item, we observe whether or not it fits the knapsack. If it does, the item is packed into the knapsack and cannot be removed later. If it does not fit, we discard it and continue packing with the remaining items. The central question of this paper is how much we loose by not knowing the capacity, in the worst case. The oblivious variant of the knapsack problem naturally arises whenever items are prioritized by a different entity or at a different time than the actual packing of the knapsack.
A solution to the oblivious knapsack problem is a policy that governs the order in which we attempt to pack the items, depending only on the observation which of the previously attempted items did fit into the knapsack and which did not. In other words, a policy is a binary decision tree with the item that is tried first at its root. The two children of the root are the items that are tried next, which of the two depends on whether or not the first item fits the knapsack, and so on. We aim for a solution that is good for every possible capacity, compared to the best solution of the standard knapsack problem for this capacity. Formally, a policy has robustness factor if, for any capacity, packing according to the policy results in a value that is at least a -fraction of the optimum value for this capacity.
We show that the oblivious knapsack problem always admits a robustness factor of 2. In fact, this robustness factor can be achieved with a policy that packs the items according to a fixed order, irrespective of the observations made while packing. Such a policy is called universal. We provide an algorithm that computes a 2-robust, universal policy in time for a given set of items. We complement this result by showing that no robustness factor better than 2 can be achieved in general, even by policies that are not universal. In other words, the cost of not knowing the capacity is exactly 2.
We give a different efficient algorithm for the case that all items have unit density, i.e., size and value of each item coincide. This algorithm produces a universal policy with a robustness factor of at most the golden ratio . Again, we show that no better robustness factor can be achieved in general, even by policies that are not universal.
While good universal policies can be found efficiently, it is intractable to compute the robustness factor of a given universal policy and it is intractable to compute the best robustness factor an instance admits. Specifically, we show that, for any fixed , it is -complete to decide whether a given universal policy is -robust. For unit densities we establish a slightly weaker hardness result by showing that it is -complete to decide whether a given universal policy achieves a given robustness factor . Finally, we show that, for given , it is -hard to decide whether an instance of the oblivious knapsack problem admits a universal policy with robustness factor , even when all items have unit density.
Related work
The knapsack problem has been studied for different models of imperfect information. In the stochastic knapsack problem, sizes and values of the items are random variables. It is known that a policy maximizing the expected value is -hard to compute, see Dean et al. [7]. The authors assume that the packing stops when the first item does not fit the knapsack, and give a universal policy that approximates the value obtained by an optimal, not necessarily universal, policy by a factor of . They also provide a non-universal policy within a factor of of the optimal policy. Bhalgat et al. [3] give an algorithm with an improved approximation guarantee of . They also give a PTAS for the case that it is allowed to violate the capacity of the knapsack by a factor of .
In robust knapsack problems, a set of possible scenarios for the sizes and values of the items is given. Yu [24], Bertsimas and Sim [2], Goetzmann et al. [12], and Monaci and Pferschy [19] study the problem of maximizing the worst-case value of a knapsack under various models. Büsing et al. [5] and Bouman et al. [4] study the problem from a computational point of view. Both allow for an adjustment of the solution after the realization of the scenario. Similar to our model, Bouman et al. consider uncertainty in the capacity.
The notion of a robustness factor that we adopt in this work is due to Hassin and Rubinstein [13] and is defined as the worst-case ratio of solution and optimum, over all realizations. Kakimura et al. [15] analyze the complexity of deciding whether an -robust solution exists for a knapsack instance with an unknown bound on the number of items that can be packed. Megow and Mestre [17] study a variant of the knapsack problem with unknown capacity closely related to ours. In contrast to our model, they assume that the packing stops once the first item does not fit the remaining capacity. In this model, a universal policy with a constant robustness factor may fail to exist, and, thus, Megow and Mestre resort to instance-sensitive performance guarantees. They provide a PTAS that constructs a universal policy with robustness factor arbitrarily close to the best possible robustness factor for every particular instance.
The concept of obliviousness is used in various other contexts (explicitly or implicitly), such as hashing (Carter and Wegman [6]), caching (Frigo et al. [10], Bender et al. [1]) routing (Valiant and Brebner [23], Räcke [21]), TSP (Papadimitriou [20], Deineko et al. [8], Jia et al, [14]), Steiner tree and set cover (Jia et al, [14]), and scheduling (Epstein et al. [9], Megow and Mestre [17]). In all of these works, the general idea is that specific parameters of a problem instance are unknown, e.g., the cache size or the set of vertices to visit in a TSP tour, and the goal is to find a universal solution that performs well for all realizations of the hidden parameters.
Universal policies for the oblivious knapsack problem play a role in the design of public key cryptosystems. One of the first such systems – the Merkle–Hellman knapsack cryptosystem [18] – is based on particular instances that allow for a -robust universal policy for the oblivious knapsack problem. The basic version of this cryptosystem can be attacked efficiently, e.g., by the famous attack of Shamir [22]. This attack uses the fact that the underlying knapsack instance has exponentially increasing item sizes. A better understanding of universal policies may help to develop knapsack-based cryptosystems that avoid the weaknesses of Merkle and Hellman’s.
2 Preliminaries
An instance of the oblivious knapsack problem is given by a set of items , where each item has a non-negative value and a strictly positive size . For a subset of items, we write and to denote its total value and total size, respectively, of the items in . A solution for instance is a policy that governs the order in which the items are considered for packing into the knapsack. The policy must be independent of the capacity of the knapsack, but the choice which item to try next may depend on the observations which items did and which items did not fit the knapsack so far. Formally, a solution policy is a binary decision tree that contains every item exactly once along each path from the root to a leaf. The packing of for a fixed capacity is obtained as follows: We start with and check whether the item at the root of fits the knapsack, i.e., whether . If the item fits, we add to and continue packing recursively with the left subtree of . Otherwise, we discard and continue packing recursively with the right subtree of .
A universal policy for instance is a policy that does not depend on observations made while packing, i.e., the decision tree for a universal policy has a fixed permutation of the items along every path from the root to a leaf. We identify a universal policy with this fixed permutation and write . Analogously to general policies, the packing of a universal policy for capacity is obtained by considering the items in the order given by the permutation and adding every item if it does not exceed the remaining capacity.
We measure the quality of a policy for the oblivious knapsack problem by comparing its packing with the optimal packing for each capacity. More precisely, a policy for instance is called -robust for capacity , , if it holds that , where denotes an optimal packing for capacity . We say is -robust if it is -robust for all capacities. In this case, we call the robustness factor of policy .
3 Solving the Oblivious Knapsack Problem
In this section, we describe an efficient algorithm that constructs a universal policy for a given instance of the oblivious knapsack problem. The solution produced by our algorithm is guaranteed to pack at least half the value of the optimal solution for any capacity . We show that this is the best possible robustness factor.
The analysis of our algorithm relies on the classical modified greedy algorithm (cf. [16]). We compare the packing of our policy, for each capacity, to the packing obtained by the modified greedy algorithm instead of the actual optimum. As the modified greedy is a 2-approximation, to show that our policy is 2-robust it is sufficient to show that its packing is never worse the one obtained by the modified greedy algorithm. We briefly review the modified greedy algorithm.
Let denote the density of item . The modified greedy algorithm (MGreedy) for a set of items and known knapsack capacity first discards all items that are larger than from . The remaining items are sorted in non-increasing order of their densities, breaking ties arbitrarily. The algorithm then either takes the longest prefix of the resulting sequence that still fits into capacity , or the first item that does not fit anymore, depending on which of the two has a greater value. In the latter case, we say that is a swap item (for capacity ) that and is a swap capacity. In both cases, we refer to as the greedy set for capacity . See Algorithm 1 for a formal description.
For our analysis, it is helpful to fix the tie-breaking rule of the greedy algorithm. To this end, we assume that there is a bijection , that maps every item to a tie-breaking index , and that the modified greedy algorithm initially sorts the items decreasingly with respect to the tuple , i.e., the items are sorted non-increasingly by density and whenever two items have the same density, they are sorted by decreasing tie-breaking index. In the following, for two items , we write if and only if , or and , and say that has higher density than .
We evaluate the quality of our universal policy by comparing it for every capacity with the solution of MGreedy. This analysis suffices because of the following well-known property of the modified greedy algorithm.
Theorem 1 (cf. [16]).
For every instance of the standard knapsack problem with known capacity, .
We are now ready to describe our algorithm Universal (Algorithm 2) that produces a universal policy tailored to imitate the behavior of MGreedy without knowing the capacity.
First, Universal determines which items are swap items. It then starts with an empty permutation, and considers the items in order of non-decreasing sizes, inserting each item into the permutation. Swap items are always placed in front of all items already in the permutation, and all other items are inserted in front of the first item in the permutation that has a lower density.
We prove the following result.
Theorem 2.
The algorithm Universal constructs a universal policy of robustness factor .
Before we prove this theorem, we first analyze the structure of the permutation output by Universal in terms of density, size, and value. First, we prove that every item following a non-swap item has lower density.
Lemma 3.
For a sequence returned by Universal, we have for every non-swap item , .
Proof.
For , let be the index of the iteration in which Universal inserts into . We distinguish two cases.
If , then the item cannot be a swap item, since it would appear in front of the item if it was. As each non-swap item is inserted into such that all items left of it are larger with respect to , the claim follows.
If , since it is not a swap item, is put in front of because it has a higher density. ∎
We prove that no item preceding a swap item has smaller size.
Lemma 4.
For a permutation returned by Universal, we have for every swap item , and every other item .
Proof.
Since is a swap item, it stands in front of all items inserted earlier into . Hence, all items that appear in front of in have been inserted in a later iteration of Universal. Since Universal processes items in order of non-decreasing sizes, we have . ∎
We prove that no item preceding a swap item has smaller value.
Lemma 5.
For a permutation returned by Universal, we have for every swap item , and every other item .
Proof.
We distinguish three cases.
First case: is a swap item and . By Lemma 4, we have , and the claim trivially holds.
Second case: is a swap item and . Since is a swap item, there is a capacity such that
In particular, for we obtain
(1) |
Finally, the next lemma gives a legitimation for the violation of the density order in the output permutation. Essentially, whenever an item precedes denser items, we guarantee that it is worth at least as much as all of them combined.
Lemma 6.
For a permutation returned by Universal, we have
for every item .
Proof.
We distinguish whether is a swap item, or not.
If is a swap item, by definition, is worth more than the greedy set for some capacity . Thus,
Since items whose size is strictly larger than are inserted into at a later iteration of Universal, they can only end up behind if they are smaller with respect to . Hence,
and thus , as claimed.
We now prove Theorem 2.
of Theorem 2.
We show that for every set of items , the permutation satisfies for every capacity . By Theorem 1, it suffices to show for all capacities. We distinguish between swap capacities and capacities where MGreedy outputs a greedy set.
First, assume that is a swap capacity, and let be the swap item returned by the modified greedy algorithm. Then, contains at least one item with . By Lemma 5 we have
Now assume that is not a swap capacity. Let be the set of items in the greedy set for capacity that are not packed by the permutation . Similarly, let . If , then and we are done. Suppose now that . Then, also . For all items , we have and . Since is not a swap capacity, is the greedy set for capacity , and thus for all and . By definition of and since , we also have , i.e., the first item in is encountered before every item from . It follows that
Using and (Lemma 6) we get
∎
While it is obvious that Universal runs in polynomial time, we show that it can be modified to run in time .
Theorem 7.
The algorithm Universal can be implemented to run in time .
Proof.
We first argue how all swap items can be determined in time . We use that an item is a swap item if and only if it is worth more than all smaller items of higher density combined. This is true, because every item that is worth more than all smaller items of higher density is a swap item for capacity . Conversely, a swap item for capacity is worth more than all items of higher density that are smaller than .
We maintain a balanced search tree for items that is ordered by size and stores the total value of the items of both subtrees in the corresponding root. Inserting an item into this tree as well as determining whether an item is worth more than all smaller items in the tree both takes time . To determine the set of swap items, we iterate over all items in order of decreasing densities and insert items one by one into the search tree. After each insertion, we query whether the newly inserted item is worth more than all smaller items in the tree. This is true if and only if the item is worth more than all smaller items of higher density, i.e., if and only if the item is a swap item. Including the initial sorting by density, we can determine all swap items in time .
We construct the output permutation by iterating over the items in order of increasing size, as in Algorithm 2. We maintain a list of balanced search trees, each ordered by density. Except for the last tree in , every tree contains exactly one swap item, which is the item of smallest density in the tree. The density of a tree is the density of this swap item (or 0 if the tree has no swap item). Each tree stores the items in to the left of the corresponding swap item (if it exists) and to the right of the swap item of the preceding tree in (if it exists). We start with a list containing a single tree with no corresponding swap item, which eventually holds all non-swap items that end up behind the last swap item in . Whenever we encounter a new swap item, we add a new tree consisting of only this swap item to the front of . For each non-swap item, we have to find the correct tree to insert it into. Once we know the tree, we can determine the position at which to insert the item into the tree, and thus in , in time simply by searching the tree.
To complete the proof, we need an efficient way to find the correct tree in for a non-swap item. For this purpose, we maintain a sublist of that contains only those trees that are needed for the remainder of the algorithm. Whenever a new swap item adds a tree to the front of , we also add the tree to the front of . Observe that from this point on no items are inserted into trees of a higher density than . Hence, before inserting the tree of to , we may remove trees of higher density from the front of . This guarantees that remains sorted by density. We can thus implement as a balanced search tree order by density. This way, we can find the correct tree for each non-swap item in time . Since every tree is removed at most once from , the amortized cost for maintaining the sublist is constant for each swap item.
Since Universal requires iterations, the total running time is . ∎
We now give a general lower bound on the robustness factor of any policy for the oblivious knapsack problem. This shows that Universal is best possible.
Theorem 8.
For every , there are instances of the oblivious knapsack problem where no policy achieves a robustness factor of .
Proof.
We give a family of instances, one for each size . We ensure that for every item of the instance of size , there is a capacity , such that packing item first can only lead to a solution that is worse than by a factor of at least . This completes the proof, as the factor approaches for increasing values of .
The instance of size is given by with
where denotes the -th Fibonacci number ().
We need to show that, no matter which item is tried first (i.e., no matter which item is the root of the policy), there is a capacity for which this choice ruins the solution. Observe that both values and sizes of the items are strictly increasing. Assume that item is packed first. Since the smallest item has size , for capacity , no additional item fits the knapsack. However, the unique optimum solution in this case is . These two items fit the knapsack, as . By definition,
Hence, policies that first pack item do not achieve a robustness factor .
Now, assume that one of the two smallest items is packed first. For capacity , no additional item fits the knapsack. The unique optimum solution, however, is to pack item . It remains to compute the ratios
Hence, policies that first pack item 1 or item 2 do not achieve a robustness factor . ∎
4 Unit Densities
In this section we restrict ourselves to instances of the oblivious knapsack problem, where all items have unit density, i.e., for all items . For two items we say that is smaller than and write if , or and , where is the tiebreaking index introduced in Section 3. We give an algorithm UniversalUD (cf. Algorithm 3) that produces a universal policy tailored to achieve the best possible robustness factor equal to the golden ratio . The algorithm considers the items from smallest to largest, and inserts each item into the output sequence as far to the end as possible, such that the item is not preceded by other items that are more than a factor smaller. Intuitively, the algorithm tries as much as possible to keep the resulting order sorted increasingly by size; only when an item dominates another item by a factor of at least the algorithm ensures that it precedes this item in the final sequence. Note that, even though is irrational, for rationals the condition can be tested efficiently by testing the equivalent condition .
Theorem 9.
The algorithm UniversalUD constructs a universal policy of robustness factor when all items have unit density.
Proof.
Given an instance of the oblivious knapsack problem with unit densities and any capacity , we compare the packing that results from the solution ) with an optimal packing . We define the set of items in for which at least one smaller item is not in , i.e., more precisely, let .
We first consider the case that and set to be the smallest item in with respect to ‘’. Consider the iteration of UniversalUD in which is inserted into , i.e., . By definition of , there is an item with Let be the first such item in . Since , we have . From and , it follows that precedes in (and thus in ). Let be the item directly preceding in . If , was compared with when it was inserted into , with the result that and thus . If , by definition of , we still have . Also, either and thus , or was compared with when it was inserted into in an earlier iteration of UniversalUD, with the result that . Again, .
In both cases it follows from that , and using we get
Now, assume that . Intuitively, this means that consists of a prefix of (the smallest items). Let be the items in , and let be the items in . As consists of a prefix of , we have and thus . If , the claim trivially holds. Otherwise, since is empty, we have . Is suffices to show for all . To this end, we consider any fixed . From it follows that
This implies that cannot precede all items of in , as . Hence, there is an item that precedes in . Since , in the iteration when UniversalUD inserted into , was already present. From the fact that ended up preceding it follows that was compared with and thus . We obtain
which implies the result. ∎
A naïve implementation of UniversalUD runs in time . We improve this running time to .
Theorem 10.
The algorithm UniversalUD can be implemented to run in time .
Proof.
To improve the running time from the naïve , we maintain a balanced search tree that stores a subset of the items in sorted decreasingly by their sizes. Whenever an item gets inserted to the front of , and only then, we also insert it into . This way, the items in remain sorted by their positions in throughout the execution of the algorithm. We need an efficient way of finding, in each iteration of UniversalUD (Algorithm 3), the first item in for which , or detecting that no such item exists. We claim that, if such an item exists, it is stored in and can thus be found in time .
It suffices to show that for every item and its predecessor in we have that none of the items that precede in are smaller than . To see this, we argue that none of the items between and in are smaller than . We can then repeat the argument for and its predecessor , etc. For the sake of contradiction, let be the first item between and with . None of the items between and are smaller than , hence both and are inserted into earlier than all of them. Let be the iteration in which is inserted into . Since is inserted earlier into , and since is inserted to the front of , is at the front of . This is a contradiction to not being in . ∎
We now establish that UniversalUD is best possible, even if we permit non-universal policies.
Theorem 11.
There are instances of the oblivious knapsack problem where no policy achieves a robustness factor of , for any , even when all items have unit density.
Proof.
Consider an instance of the oblivious knapsack problem with five items of unit density and values equal to , for sufficiently small . We show that no algorithm achieves a robustness factor of for this instance. To this end we consider an arbitrary algorithm and distinguish different cases depending on which item the algorithm tries to pack first.
-
(a)
If tries item 1 or item 2 first, it cannot fit any additional item for a capacity equal to , as even . For this capacity is worse by a factor of than the optimum solution, which packs item 5.
-
(b)
If tries item 3 first, it cannot fit any additional item for a capacity equal to , as even . For this capacity is worse by a factor of than the optimum solution which packs items 1 and 2.
-
(c)
If tries item 4 first, it cannot fit any additional item for a capacity equal to , as even . For this capacity is worse by a factor of than the optimum solution which packs items 2 and 3.
-
(d)
If tries item 5 first, it cannot fit any additional item for a capacity equal to , as even . For this capacity is worse by a factor of than the optimum solution which packs items 3 and 4.
∎
5 Hardness
Although we can always find a -robust universal policy in polynomial time, we show in this section that, for any fixed , it is intractable to decide whether a given policy is -robust, even if it is universal. This hardness result also holds for instances with unit densities when is part of the input. As the final – and arguably the most interesting – result of this section, we establish -hardness of the the problem to decide for a given instance and given , whether the instance admits a universal policy with robustness factor . All proofs rely on the hardness of the following version of SubsetSum.
Lemma 12.
Let be a set of positive integer weights and be a target sum. The problem of deciding whether there is a subset with is -complete, even when
-
1.
for some integer ,
-
(a)
all weights are in the interval ,
-
(b)
all weights have a difference of at least 2 to the closest power of 2.
-
(a)
Proof.
Without Properties 1 to 1b, the SubsetSum problem is well known to be -complete (e.g., Garey and Johnson [11]). Given an instance of this classical problem, we construct an equivalent instance with Properties 1 to 1b. We first multiply all weights in as well as the target sum with to obtain an equivalent instance . In the new instance, all weights are even but not a power of 2, hence they have distance at least 2 to the closest power of 2. We set , with and define two new weights
We set to obtain the final instance . Properties 1 and 1a are satisfied by construction. Also, any solution to the instance has to include both and , since . Hence, the instance remains equivalent to the original instance . Since , and since is a power of two, the new items and are far enough from the closest power of 2 (which either is or ). ∎
We first show that it is intractable to determine the robustness factor of a given universal policy.
Theorem 13.
For any fixed and polynomially representable it is -complete to decide whether a given universal policy for the oblivious knapsack problem is -robust.
Proof.
Regarding the membership in , note that if a universal policy is not -robust, then there is a capacity such that . Thus, together with is a certificate for not being an -robust solution.
For the proof of -hardness, we reduce from the variant of SubsetSum specified in Lemma 12. An instance of this problem is given by a set of positive integer weights in the range and a target sum for some integer . Let be polynomially representable. We may assume without loss of generality that as we can ensure this property by multiplying and all items in by a sufficiently large power of 2.
We construct an instance and a sequence such that is an -robust universal policy for if and only if the instance of SubsetSum given by and has no solution. To this end, we introduce for each weight an item with value and size equal to . In this way, the optimal knapsack solution for capacity is at least if the instance of SubsetSum has a solution. Furthermore, we introduce a set of additional items that make sure that the robustness factor for all capacities except is at most while maintaining the property that the optimal knapsack solution for capacity is strictly less than if the instance of SubsetSum has no solution.
We now explain the construction of and is detail. Let , i.e., . Note that by our assumptions on and . For each weight , we introduce an item with . The set of these items is called regular and is denoted by . Furthermore, we introduce a set of auxiliary items. Let . Then, for each , we introduce an auxiliary item with size and value . Denoting the set of auxiliary items by , we have . Finally, we introduce a dummy item with and
The universal policy is defined as . The hardness proof relies on the claim that is a -robust universal policy for all capacities except , i.e.,
(2) |
As all item sizes are integer, it suffices to consider integer capacities. To prove (2), let us first consider capacities . Since the density of each item with size not larger than is bounded from above by , it is sufficient to show that . To this end, we show that every capacity is packed without a gap by the exponentially decreasing sequence of items . We prove this statement by induction over . For , the statement is true, since there is only a single item with length , which packs the capacity optimally. Now assume that the statement is true for all and consider the sequence . We distinguish two cases. For capacities , item is packed and, using the induction hypothesis, the residual capacity can be packed without a gap by the remaining sequence . For capacities , item is not packed, and, again using the induction hypothesis, we derive that can be packed by . This completes the proof of our claim for .
Let us now consider our claim for capacities . In this case, and we can trivially bound the robustness factor of by observing that
We proceed to show that is an -robust universal policy if and only if the instance of SubsetSum given by and has no solution. Let us first assume that the instance of SubsetSum has no solution. We prove that is -robust. For all capacities except this is clear from claim (2). For capacity , we argue as follows: As there is no packing of with items of density 1, we bound from above by , whereas packs all auxiliary items. We get
Now, assume that the instance of SubsetSum has a solution. Then, and thus
and we conclude that is not -robust. ∎
We give a result similar to Theorem 13 for instances in which each item has unit density. Note that this time we require to be part of the input.
Theorem 14.
It is -complete to decide whether, for given , a given universal policy for the oblivious knapsack problem is -robust, even when all items have unit density.
Proof.
Membership in follows from Theorem 13. To prove hardness, we again reduce from SubsetSum (Lemma 12) using a similar construction as in the proof of Theorem 13. Let the set of weights and the target sum of an instance of SubsetSum be given, with . We proceed to explain the construction of a universal policy for which the decision whether is -robust is -hard, for some .
For each weight , we introduce an item with value . The set of these items is called regular and is denoted by . Let and . For each , we introduce an auxiliary item with value . Denoting the set of auxiliary items by , we have . We further introduce a set of dummy items , where . We set for each , and . The values of the dummy items sum up to . In total, the sum of the values of all dummy and auxiliary items is
(3) |
Finally, we define the sequence as
i.e., first tries to pack the dummy items in decreasing order, then the auxiliary items in decreasing order, and finally the regular items in non-increasing order. Let . We proceed to prove the statement of the theorem by showing that is an -robust universal policy if and only if the instance of SubsetSum has no solution. To this end, we first prove that is always an -robust universal policy for all capacities except the critical capacities in the interval . Then, we argue that is -robust for the critical capacities if and only if the instance of SubsetSum has no solution.
We start by proving that is within an -fraction of for all capacities . Since the regular items are of integer values and the values of the auxiliary items each are an -fraction of an integer, only capacities for which the ratio is not smaller than can be packed without a gap. Otherwise, the value of an optimal solution is bounded from above by . For capacities , we obtain
(4) |
The value packed by is given by
(5) |
From (4) and (5) it follows that
(6) |
for all .
We proceed to prove that is within an -fraction of an optimal solution for all capacities . We distinguish two cases for each such capacity .
First case: , i.e., all auxiliary items are packed by . Since, in , the dummy item with value precedes all auxiliary items, and since , this case can only occur for capacities
(7) |
On the other hand, the gap is at most the gap left after trying all dummy items and packing all auxiliary items, i.e., . Thus,
Second case: , i.e., not all auxiliary items are packed. This implies that the gap is at most . We calculate
Next, we consider capacities . For these capacities, all dummy items and all auxiliary items are packed by . Using that the gap is at most , we obtain
To finish the proof, let us finally consider the critical capacities . We proceed to show that is within an -fraction of for all if and only if does not have a solution. Let us first assume that does not have a solution. Then, and we obtain
for all . If, on the other hand, has a solution, then , implying that
i.e., is not an -robust universal policy. ∎
Finally, we prove that it is hard to decide whether a given instance admits an -robust universal policy when is part of the input.
Theorem 15.
It is -hard to decide whether, for given , an instance of the oblivious knapsack problem admits an -robust universal policy, even when all items have unit density.
Proof.
We again reduce from SubsetSum. To this end, let be an instance of SubsetSum (Lemma 12), let be the set of items constructed from in the proof of Theorem 14, and let . We proceed to show that admits an -robust universal policy if and only if the instance of SubsetSum has no solution.
For the case that has no solution, an -robust universal policy is constructed in the proof of Theorem 14. Thus, it suffices to show that if has a solution, does not admit an -robust universal policy.
First, we claim that any -robust universal policy contains the auxiliary items in decreasing order. Otherwise, for the sake of contradiction, let be the first auxiliary item in that is preceded by a smaller auxiliary item . Consider the capacity . As all dummy items are larger than , only auxiliary and regular items can be in . Since precedes , we have .
If contains only auxiliary items, since the sum of the values of the auxiliary items smaller than is , we can use that to obtain . If contains a regular item , then , and hence the gap cannot be packed with a value more than . It follows that . In either case we have
This is a contradiction to the assumption that is -robust. We conclude that the auxiliary items appear in in decreasing order.
Second, we claim that if contains a regular item, then is not -robust. By the argument above, we may assume that the auxiliary items in are ordered decreasingly. Let be the regular item contained in that appears first in . Consider the capacity The auxiliary items that appear before in (if any) are ordered decreasingly. All of them must be larger than , otherwise, the gap left after packing them for capacity would be too small to fit . By Lemma 12, we have that neither nor are a power of 2, thus does not contain any of the auxiliary items preceding . All regular items that appear before in are larger than , since they are not in . Hence, does not contain any regular items except . We conclude that . On the other hand, is an integer multiple of and can be packed without a gap by auxiliary items only. We obtain
We conclude that if an -robust universal policy exists, then does not contain regular items. It follows that and, thus, Using that the SubsetSum instance has a solution, we obtain
which implies that no -robust universal policy exists. ∎
References
- [1] M. A. Bender, R. Cole, and E. D. Demaine. Scanning and traversing: maintaining data for traversals in a memory hierarchy. In Proceedings of the 10th European Symposium on Algorithms (ESA), pages 139–151, 2002.
- [2] D. Bertsimas and M. Sim. Robust discrete optimization and network flows. Mathematical Programming, 98:49–71, 2003.
- [3] A. Bhalgat, A. Goel, and S. Khanna. Improved approximation results for stochastic knapsack problems. In Proceedings of the 22nd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1647–1665, 2011.
- [4] P. C. Bouman, J. M. van den Akker, and J. A. Hoogeveen. Recoverable robustness by column generation. In Proceedings of the 19th European Symposium on Algorithms (ESA), pages 215–226, 2011.
- [5] C. Büsing, A. M. Koster, and M. Kutschka. Recoverable robust knapsacks: the discrete scenario case. Optimization Letters, 5(3):379–392, 2011.
- [6] J. L. Carter and M. N. Wegman. Universal classes of hash functions. Journal of Computer and System Sciences, 18:143–154, 1979.
- [7] B. C. Dean, M. X. Goemans, and J. Vondrák. Approximating the stochastic knapsack problem: The benefit of adaptivity. In Proceddings of the 45th IEEE Symposium on Foundations of Computer Science (FOCS), pages 208–217, 2004.
- [8] V. G. Deineko, R. Rudolf, and G. J. Woeginger. Sometimes travelling is easy: The master tour problem. In Proceedings of the 3rd European Symposium on Algorithms (ESA), pages 128–141. 1995.
- [9] L. Epstein, A. Levin, A. Marchetti-Spaccamela, N. Megow, J. Mestre, M. Skutella, and L. Stougie. Universal sequencing on an unreliable machine. SIAM Journal on Computing, 41(3):565–586, 2012.
- [10] M. Frigo, C. Leiserson, H. Prokop, and S. Ramachandran. Cache-oblivious algorithms. In Proceedings of the 40th Symposium on Foundations of Computer Science (FOCS), pages 285–297, 1999.
- [11] M. R. Garey and D. S. Johnson. Computers and Intractability, A Guide to the Theory of NP-Completeness. W.H. Freeman and Company, 1979.
- [12] K.-S. Goetzmann, S. Stiller, and C. Telha. Optimization over integers with robustness in cost and few constraints. In Proceedings of the 9th Workshop on Approximation and Online Algorithms (WAOA), pages 89–101, 2011.
- [13] R. Hassin and S. Rubinstein. Robust matchings. SIAM Journal on Discrete Mathematics, 15(4):530–537, 2002.
- [14] L. Jia, G. Lin, G. Noubir, R. Rajaraman, and R. Sundaram. Universal approximations for TSP, Steiner tree, and set cover. In Proceedings of the 37th Annual ACM Symposium on Theory of Computing (STOC), pages 386–395, 2005.
- [15] N. Kakimura, K. Makino, and K. Seimi. Computing knapsack solutions with cardinality robustness. In Proceedings of the 22nd International Conference on Algorithms and Computation (ISAAC), pages 693–702, 2011.
- [16] B. Korte and J. Vygen. Combinatorial Optimization. Theory and Algorithms. Springer, 2nd edition, 2002.
- [17] N. Megow and J. Mestre. Instance-sensitive robustness guarantees for sequencing with unknown packing and covering constraints. In Proceedings of the 4th Conference on Innovations in Theoretical Computer Science (ITCS), pages 495–504, 2013.
- [18] R. Merkle and M. E. Hellman. Hiding information and signatures in trapdoor knapsacks. IEEE Transactions on Information Theory, 24(5):525–530, 1978.
- [19] M. Monaci and U. Pferschy. On the robust knapsack problem. In Proceedings of the 10th Cologne-Twente Workshop on Graphs and Combinatorial Optimization (CTW), pages 207–210, 2011.
- [20] C. H. Papadimitriou. Computational Complexity. Addison-Wesley, 1994.
- [21] H. Räcke. Survey on oblivious routing strategies. In Proceedings of the 5th Conference on Computability in Europe: Mathematical Theory and Computational Practice (CiE), pages 419–429, 2009.
- [22] A. Shamir. A polynomial time algorithm for breaking the basic Merkle-Hellman cryptosystem. In Proceedings of the 23rd Symposium on Foundations of Computer Science (FOCS), pages 145–152, 1982.
- [23] L. G. Valiant and G. J. Brebner. Universal schemes for parallel communication. In Proceedings of the 13th Annual ACM Symposium on Theory of Computing (STOC), pages 263–277, 1981.
- [24] G. Yu. On the max-min 0-1 knapsack problem with robust optimization applications. Operations Research, 44(2):407–415, 1996.