Approximation Algorithms for Generalized Multidimensional Knapsack
Abstract
We study a generalization of the knapsack problem with geometric and vector constraints. The input is a set of rectangular items, each with an associated profit and nonnegative weights (-dimensional vector), and a square knapsack. The goal is to find a non-overlapping axis-parallel packing of a subset of items into the given knapsack such that the vector constraints are not violated, i.e., the sum of weights of all the packed items in any of the dimensions does not exceed one. We consider two variants of the problem: the items are not allowed to be rotated, items can be rotated by 90 degrees.
We give a -approximation algorithm for this problem (both versions). In the process, we also study a variant of the maximum generalized assignment problem (Max-GAP), called Vector-Max-GAP, and design a PTAS for it.
1 Introduction
The knapsack problem is a fundamental well-studied problem in the field of combinatorial optimization and approximation algorithms. It is one of Karp’s 21 NP-Complete problems and has been studied extensively for more than a century [15]. A common generalization of the knapsack problem is the 2-D geometric knapsack problem. Here, the knapsack is a unit square and the items are rectangular objects with designated profits. The objective is to pack a maximum profit subset of items such that no two items overlap and all the items are packed parallel to the axes of the knapsack (called axis-parallel or orthogonal packing). There are two further variants of the problem depending on whether we are allowed to rotate the items by 90 degrees or not. Another well-studied variant of the knapsack problem is -D vector knapsack problem, where we are given a set of items, each with -dimensional weight vector and a profit, and a -dimensional bin ( is a constant). The goal is to select a subset of items of maximum profit such that the sum of all weights in each dimension is bounded by the bin capacity in that dimension.
In this paper we study a natural variant of knapsack problem, called Knapsack, which considers items with both geometric dimensions and the vector dimensions. In this -D geometric knapsack problem with -D vector constraints (where is a constant), or KS in short, the input set consists of items. For any item , let denote the width, height and the profit of the item, respectively, and let denote the area of the item. Also, for any item , let denote the weight of the item in the dimension. The objective is to pack a maximum profit subset of items into a unit square knapsack in an axis-parallel, non-overlapping manner such that for any , .
We will also study a variant of Maximum Generalized Assignment Problem (Max-GAP). In Max-GAP problem, we are provided with a set of machines with designated capacities, and a set of items; an item’s size and value depends on the machine to which it is going to be assigned. The objective is to assign a subset of items to machines such that the obtained value is maximized while making sure that no machine’s capacity is breached. We define a variant of the Max-GAP problem called Vector-Max-GAP. In this problem, we additionally have a -dimensional weight vector associated with every item and a -dimensional global weight constraint on the whole setup of machines. The objective is to find the maximum value obtainable so that no machine’s capacity is breached and the overall weight of items does not cross the global weight constraint.
1.1 Our contributions
Our two main contributions are a approximation algorithm for the KS problem define a new problem called Vector-Max-GAP and obtain a PTAS for it.
To obtain the approximation algorithm for KS, we first obtain a structural result using corridor decomposition, which shows that if we consider an optimal packing and remove either vertical items (heightwidth) or horizontal items (widthheight), we can restructure the remaining packing to possess a ‘nice’ structure that can be efficiently searched for.
In [9], which deals with the 2-D geometric knapsack problem, the authors use the PTAS for the maximum generalized assignment problem (Max-GAP) to efficiently search for such a nice structure. But due to the presence of vector constraints, we needed a generalization of the Max-GAP problem which we call the Vector-Max-GAP problem and obtain a PTAS for it to obtain the desired approximation algorithm for KS.
1.2 Related work
The classical knapsack problem admits a fully polynomial time approximation scheme (FPTAS) [14, 21]. Both 2-D geometric knapsack (2D GK) and 2-D vector knapsack problem are W[1]-hard [12, 20], thus do not admit an EPTAS unless W[1]=FPT. 111EPTAS is a PTAS with running time where is a constant that does not depend on . However, -D vector knapsack problem admits a PTAS [7]. On the other hand, it is not known whether the 2D GK is APX-Hard or not, and finding a PTAS for the problem is one of the major open problems in the area. The current best approximation algorithm [9] for this problem without rotations achieves an approximation ratio of . If rotations are allowed, the approximation ratio improves to . In a special case known as the cardinality case where each item has a profit of one unit, the current best approximation factor is without rotations and with rotations (see [9]). PTASes exist for the restricted profit density case, i.e., the profit/area ratio of each item is upper bounded and lower bounded by fixed constants (see [2]) and the case where all the items are small compared to the dimensions of the bin. EPTAS exists for the case where all the items are squares [13]. In the case where we can use resource augmentation, i.e., we are allowed to increase the width or height of the knapsack by a factor of , we can construct a packing which gives the exact optimal profit in polynomial time (see [13]). 2GK has also been studied under psedopolynomial setting [17, 11]. The following table summarizes the results for 2GK problem.
without rotations | with rotations | |
---|---|---|
General case | [9] | [9] |
Cardinality case | [9] | [9] |
Restricted profit density | PTAS[2] | PTAS[2] |
Small items | folklore FPTAS (Lemma 15) | folklore FPTAS (Lemma 15) |
Square items | EPTAS [13] | irrelevant |
Resource Augmentation | exact solution[13] | exact solution[13] |
A well-studied problem closely related to the knapsack problem is bin packing. A natural generalization of the bin packing problem is the 2-D geometric bin packing (2GBP) problem where items are rectangles and bins are unit squares. The current best asymptotic approximation ratio of for 2GBP is due to [4]. Another generalization of bin packing is the vector bin packing problem (VBP) where each item has multiple constraints. For the current best approximation ratios of VBP, we refer the reader to [3].
1.3 Organization of the Paper
In Section 2, we study the Vector-Max-GAP problem and design a PTAS for it. Section 3 describes the approximation algorithm for the Knapsack problem. In Sections 3.1 and 3.2, we use a structural result involving corridor decomposition and reduce our problem to a container packing problem. In Sections 3.3 and 3.4 we will discuss how to model the container packing problem as an instance of the Vector-Max-GAP problem. Finally, in Section 3.5, we put everything together to obtain the approximation algorithm for the Knapsack problem.
2 Vector-Max-GAP problem and a PTAS
We will formally define the Vector-Max-GAP problem. Let be a set of items numbered 1 to and let be a set of machines, where is a constant. The machine has a capacity . Each item has a size of , value of in the machine (). Additionally, each item also has a weight in the dimension (, is a constant). Assume that for all , and , are all non-negative.
The objective is to assign a subset of items to the machines such that for any machine , the size of all the items assigned to it does not exceed . Further, the total weight of the set in any dimension must not exceed , which is the global weight constraint of the whole setup in the dimension. Respecting these constraints, we would like to maximize the total value of the items in .
Formally, let be the subset of items picked and be the items assigned to the machine (). The assignment is feasible iff the following constraints are satisfied:
Let , , , .
Let , . .
An instance of this problem is given by . We say that the set of items is feasible for iff can fit in machines of capacity given by and satisfy the global weight constraint given by where item sizes and weights are given by and respectively.
2.1 Dynamic-Programming Algorithm for Integral Input
Consider the case where item sizes and weights are integers. W.l.o.g., we can assume that the capacities of machines, and weight constraints, , are also integers (otherwise, we can round them down to the closest integers).
Arbitrarily order the items and number them from onwards. Let be the maximum value obtainable by assigning a subset of the first items to machines with capacities given by respecting the global weight constraint . We can express as a recurrence.
can be computed using dynamic programming. We can find the subset of items that gives this much value and it is also easy to ensure that no item assigned to a machine has value 0 in that machine. There are items in the state space and each iteration takes time. Therefore, time taken by the dynamic programming solution is .
2.2 Optimal Solution with Resource Augmentation
Let and be vectors whose values will be decided later. For , define . For , define .
Lemma 1.
Let be feasible for . Then is also feasible for .
Proof.
For any dimension , .
Let be the items in assigned to the machine. Then .
Lemma 2.
Let be feasible for . Then is also feasible for .
Proof.
For all
Let be the items in assigned to the machine.
Let and for all and . Let be the optimal solution to . Let be the optimal solution to . By Lemma 1, . By Lemma 2, is feasible for . Also, observe that is a polynomial in . Similarly, and hence the optimal solution to can be obtained using the dynamic-programming algorithm in polynomial time. Therefore, the optimal solution to can be obtained using the dynamic-programming algorithm in time .
Let us define a subroutine which takes as input set with associated values, , and gives as output the optimal feasible solution to .
2.3 Trimming
Consider a set of items where each item has length and profit (in this subsection, is an instance of the knapsack problem instead of the Vector-Max-GAP problem).
Suppose for all and . We’ll show that there exists an such that and . We call this technique of removing a low-profit subset from so that it fits in a bin of length 1 trimming.
Arbitrarily order the items and arrange them linearly in a bin of size . Let . Create intervals of length and intervals of length . Place -intervals and -intervals alternately. They will fit in the bin because
Number the -intervals from to and let be the set of items intersecting the -interval. Note that, all are mutually disjoint. Let .
Removing will create an empty interval of length in the bin, and the remaining items can be shifted so that they fit in a bin of length 1.
2.4 Packing Small Items
Consider a Vector-Max-GAP instance . Item is said to be -small for this instance iff and for all . A set of items is said to be -small iff each item in is -small.
Suppose is -small. Let be a feasible solution to . Let be the items assigned to the machine.
For each , use trimming on for sizes and then for each , use trimming on for weights . In both cases, use and . Let be the removed items and be the remaining items. Total value lost is less than and is feasible for .
Therefore, any resource-augmented solution of small items can be transformed to get a feasible solution of value at most .
2.5 A Structural Result
Theorem 3.
Let be a feasible solution to . Let be the items assigned to the machine. Then for all , there exist sets and such that and and
Proof.
Let , where , and , where . We know that . Therefore, . Also, . Therefore, . Let . is therefore the set of items in that are in some sense ‘big’. Note that .
If , set and and we’re done. Otherwise, set , , and . If , set and and we’re done. Otherwise, set , , and . If , set and and we’re done. Otherwise, similarly compute and check if , and so on. Extending the similar arguments about , it follows that for all , .
Since every is disjoint, there will be some such that .
Now set and . We can see that and . Note that all items in are small because of the way was constructed. Hence it follows that
2.6 PTAS for Vector-Max-GAP
Let be an optimal assignment for . Let be the items assigned to the machine.
By Theorem 3, can be partitioned into sets , and such that and . Let and . Then is -small for .
For a set , define as the set of -partitions of . Then the pseudo code in Algorithm 1 provides a PTAS for the Vector-Max-GAP problem.
Correctness: Since is feasible for , is feasible for .
Approximation guarantee:
For some iteration of Algorithm 1,
and .
When that happens, and .
Let be the maximum value -small assignment of items to the
machines with capacities given by and over all weight constraints .
Therefore, .
To try to find an optimal assignment of small items, we’ll forbid non-small items to be assigned to a machine. To do this, if for item , , set to 0. Using our resource-augmented Vector-Max-GAP algorithm, we get . By the property of trimming, .
This gives us a -approx solution. The running time can be easily seen to be polynomial as runs in polynomial time and the number of iterations of the outer loop in Algorithm 1 is polynomial in and for one iteration of the outer loop, the inner loop runs at most constant number of times.
3 Algorithm for (2, ) Knapsack Problem
In this section, we will obtain a -approximation algorithm for the (2, ) knapsack problem both with and without rotations. First, we show the algorithm for the case without rotations. An algorithm for the case rotations are allowed is similar except for some small changes.
Let be a set of (2, )-dimensional items. We are given a (2, )-dimensional knapsack and we would like to pack a high profit subset of in the knapsack. Let us denote this optimal profit by . Let , , . For an item , let and let .
In the whole section, a container is a rectangular region inside the knapsack. For our purposes, every container can be one of the four types: large, wide, tall, area. A large container can contain at most one item. An area container can only contain items that are -small for the container i.e. an item can be packed into an area container of width and height only if the item has width at most and height at most . In a wide (resp. tall) container, items must be stacked up one on top of another (resp. arranged side by side). We also require that the containers do not overlap amongst themselves and no item partially overlaps with any of the containers.
We also use the notation in place of , where is an arbitrary constant and is a function which solely depends on the value of , when we do not explicitly define what is. Similarly, represents and so on.
3.1 A Structural Result
Consider a set of items that are packed in a knapsack. We now state a structural result, inspired by [9], where only a subset of items is packed into the knapsack. We may lose some profit but the packing has a nice structure which can be searched for, efficiently.
Theorem 4.
Let denote a set of items that can be feasibly packed into a knapsack and let be any small constant. Then there exists a subset such that . The items in are packed into the knapsack in containers. Further, the number of containers formed is and their widths and heights belong to a set whose cardinality is and moreover, this set can be computed in time .
Now, let us go back to our original problem instance . Let be the set of items packed into the knapsack in an optimal packing .
Let us apply Theorem 4 to the set of items with ( will be defined later). Let be the resulting analog of in the theorem (there can be many candidates for but let us pick one). Therefore,
(1) |
3.2 Proof of the Structural Result
In this subsection, we will prove Theorem 4.
The strategy to prove the theorem is to use the corridor decomposition scheme, essentially taken from [1]. First, we assume that we can remove number of items at the cost of zero profit loss from the originally packed items. Under this assumption, we show that we lose at most half profit by our restructuring. Finally, we show how to get rid of this assumption by using shifting argumentations.
Removing Medium items: Let be two fixed constants such that . We partition the items in based on the values of and as follows:
-
•
-
•
-
•
-
•
-
•
We call the items in as small items as they are small in both the dimensions. Similarly, we call the items in as big, wide, tall, medium respectively.
By standard arguments, it is possible to choose the constants and such that the total profit of all the medium items is at most . Hence, we can discard the items in from while losing a very small profit. We omit the proof as it is present in many articles on packing (see, for example, [9]).
3.2.1 Corridors
First, let us define what a subcorridor is. A subcorridor is just a rectangle in the 2D coordinate system with one side longer than and the other side having a length of at most . A subcorridor is called wide (resp. tall) if the longer side is parallel to the -axis (resp. -axis).
A corridor is just a subcorridor or a union of at most subcorridors such that each wide (resp. tall) subcorridor overlaps with exactly two tall (resp. wide) subcorridors, except for at most two subcorridors which are called the ends of the corridors and can overlap with exactly one subcorridor. The overlap between any two subcorridors should be in such a way that one of their corners coincide.
3.2.2 Corridor Decomposition
For now, let’s consider a generic packing of a set of items that can contain big, small, wide, tall items.
Since the number of big items packed can be at most a constant, and since we assumed that we can remove a constant number of items at no profit loss, let us remove all the big items from the packing. Let’s also get rid of the small items for now (we will pack the small items later). Hence, we are left with wide and tall items packed in the knapsack. Let’s name these items as skewed items and denote the set of these items by .
Lemma 5 (Corridor Packing lemma [1]).
There exist non-overlapping corridor regions in the knapsack such that we can partition into sets , , such that
-
•
-
•
-
•
Every item in is fully contained in one of the corridors. The number of corridors is and in each corridor, the number of subcorridors is at most .
-
•
Each subcorridor has length at least and breadth less than (assuming length to denote the longest side and breadth to denote the smallest side).
Remark 6.
The total number of subcorridors after the corridor partition is .
We also remove items in since they are at most a constant in number and items in since their total profit is very less.
The last point of the lemma ensures that a skewed item is completely contained in at most one subcorridor. Hence for every skewed item contained in a corridor, we can tell which subcorridor it belongs to. The last point also ensures that, there can not be a subcorridor which completely contains both wide and tall items. This fact allows us to label each subcorridor as wide or tall: If a subcorridor contains only wide (resp. tall) items, we say that it is a wide (resp. tall) subcorridor.
Removing either wide or tall items: Now, we will simplify the above structure of skewed items while losing at most half of the original profit.
Assume w.l.o.g. that the total profit of wide items is at least as much as the total profit of the tall items. Hence, if we get rid of the tall items, we lose at most half of the original profit. With this step, we can also remove all the tall subcorridors since they are all empty. We are left with wide items packed in wide subcorridors. Since the subcorridors are just rectangles and they no longer overlap, we just call these subcorridors as boxes.
Next, we will describe how to reorganize the items in these boxes into containers at a very marginal profit loss.
3.2.3 Reorganizing Boxes into Containers
Note that the boxes contain only wide items. And since the width of the wide items is lower bounded by , we can create an empty wide strip in each box at the loss of very small profit and at most a constant number of items. This is described in the following lemma.
Lemma 7.
Let be a box of dimensions such that each item contained in it has a width of at least , where is a constant. Let the total profit packed inside the item be and let be a small constant. Then, it is possible to pack all the items barring a set of items of profit at most and a set of number of items into a box of dimensions .
Proof.
Assume the height of the box is along the -axis and width of the box is along the -axis and say, the bottom left corner of the box is situated at the origin. Draw lines at for such that . These lines will partition the box into regions. For all , let be the set of items completely contained in the region. Then, there must exist some region such that . We will remove all the items in . Also, the number of items partially overlapping with the region can be at most , which is . By removing these items, we create an empty strip of size and hence the remaining items can be packed in a box of size . ∎
We apply the above lemma to each and every box with small enough and . Consider a box and let be the items packed inside . Also, let be the dimensions of the box. Let be the set of items in the knapsack after performing the steps in Lemma 7. can be packed within the box and we are left with some empty space in the vertical direction. Hence, we can apply the resource augmentation lemma, which is taken from [9].
Lemma 8 (Resource Augmentation Lemma).
Let be a set of items packed inside a box of dimensions and let be a given constant. Then there exists a container packing of a set inside a box of size such that
-
•
-
•
The number of containers is and the dimensions of the containers belong to a set of cardinality .
-
•
The total area of the containers is at most
Applying the above lemma to the box , we obtain a packing where is packed into box of size . We will choose such that the product .
Lemma 9.
The total area of containers obtained is at most
Proof.
The second upper bound directly follows from the last point of Lemma 8: Area of the containers in a box of dimensions is at most . Summing over all boxes we get the bound .
For the first upper bound, observe that every box of dimensions is shrunk into a box of dimensions . Since all the original boxes were packable into the knapsack, the total area of the boxes (and hence the containers) after shrinking is at most times the area of the knapsack itself, which is 1. ∎
To this end, we have completed packing all the items into containers (except the constant number of discarded items and the small items). We will analyze the number of containers created. A box was partitioned into containers as given by Lemma 8 and boxes are nothing but subcorridors whose number is by Remark 6. Hence the total number of containers formed is . This fact is going to be crucial in order to pack the small items.
3.2.4 Packing Small Items
In this subsection, we show how to pack small items that have been removed from the packing temporarily. Let the set of small items be denoted by . Let .
Let us define a uniform grid in the knapsack where grid lines are equally spaced at a distance of . It is easy to see that the number of grid cells formed is at most which is at most a constant. We mark a grid cell as free if it has no overlapping with any container and non-free otherwise. We delete all the non-free cells and the free cells will serve as the area containers that we use to pack the small items.
Lemma 10.
For some choice of and , the total area of non-free cells is at most
Proof.
Let be the total area of containers and be the number of containers. The total area of cells completely covered by containers is at most . The partially overlapped cells are the cells that intersect the edges of the containers. Since, the number of containers is and each container has 4 edges and each edge can overlap with at most number of cells, the area of completely and partially overlapped cells is at most
As we noted before, which doesn’t depend on in some sense. Hence, we can choose a very small (when compared to ), and ensure that the above quantity is at most .
By Lemma 9, the value of is bounded by
Hence, the total area of deleted cells is at most
For and by choosing , we get the desired result. ∎
We now show that there is a significant area of free cells left to pack the small items profitably.
Lemma 11.
The area of free cells is at least
Proof.
Since and were packable in the knapsack, .
Now if , then the area of free cells is at least
On the other hand, if , then the area of free cells is at least which in turn is at least . ∎
Each free cell has dimensions and a small item has each side at most . Hence, all small items are -small for the created free cells and these can be used to pack the small items. Using NFDH, we can pack a very high profit in the area containers as described in the following lemma.
Lemma 12.
Let be a set of items and let there be identical area containers such that each item is -small for every container and the whole set can be packed in these containers. Then there exists an algorithm which packs a subset in these area containers such that .
Proof.
W.l.o.g., assume that each container has dimensions . So, we can assume that every item has a width of at most and a height of at most . Order the items in in non-increasing ratio of profit/area (we call this profit density) breaking ties arbitrarily and also order the containers arbitrarily.
Start packing items into the containers using NFDH. If we are able to pack all the items in , we are done. Otherwise, consider an arbitrary container . Let be the items we packed in and let be the item we could not pack in . Then by Lemma 15, . But since , . Hence, we have packed at least fraction of the total area of the containers with the densest items and thus the claim follows. ∎
To this end, we have packed at least fraction of the total profit in the original packing assuming that we can leave out a constant number of items at no cost.
3.2.5 Shifting Argumentation
We assumed that we can drop number of items from at no profit loss. But this may not be true because they can carry significant amount of profit in the original packing. The left out constant number of items are precisely the big items and items in and the items partially overlapping with the removed strip in Lemma 7.
The main idea is to fix some items in the knapsack and then carry out our algorithm discussed in the previous sections with some modifications. Again, we may leave out some items with high profit. We fix these items too and repeat this process. We can argue that at some point, the left out items have a very less profit and hence this process will end.
Let us define the set as the set of items that were removed in the above process. If the total profit of is at most , then we are done. If this is not the case, then we use shifting argumentation.
Assume that we completed the iteration for some and say for all . Let . We will argue that for every , is at most a constant. Then is also at most a constant if (in fact, we will argue that will not go beyond ).
Let us define a non-uniform grid induced by the set as follows: The and coordinates of the grid are given by all the corners of the items in . Note that the number of horizontal (resp. vertical) grid lines is bounded by . This grid partitions the knapsack into a set of cells . Since is at most a constant, the number of grid cells created is also at most a constant.
Let us denote an arbitrary grid cell by and the items in which intersect and which are not in by . For an item in , let and denote the width and height of the overlap of an item with . We categorize the items in relative to as follows.
-
•
-
•
-
•
-
•
We call an item small if it is not in for some cell . We call an item big if it is in for some cell . We call an item wide (resp. tall) if it is in (resp. ) for some cell .
We call an item medium if there is a cell such that or .
It is easy to observe that an item must belong to exactly one of small, big, wide, tall, medium categories. Note that the width and height of a small item are at most . We call an item skewed if it is either wide or tall.
Again by standard arguments, we can select and such that the profit of the medium items is at most . Hence, we remove all the medium items. We also remove all the small items for now, but we will pack them at the end exactly as in Section 3.2.4. We add all the big items to . We can do this because the big items are at most constant in number: Consider any cell . The number of big items associated with it is at most a constant and the number of cells themselves is at most a constant.
We create a corridor decomposition in the knapsack with respect to the skewed items as follows: First we transform this non-uniform grid into a uniform grid by moving the grid lines and simultaneously stretching or compressing the items. This transformation is to ensure that every wide (resp. tall) item associated with a cell has at least a width (resp. height) of . We apply Lemma 5 on the set of skewed items into a set of corridors. Let be the sets obtained similar to Lemma 5. The set is the set of items that are packed in the corridors completely. We add the set to since they are constant in number. As the set has a very small profit, we discard them. We also remove all the items in tall subcorridors assuming, w.l.o.g., that their profit is at most that of the items in wide subcorridors.
Now, we have the items in fixed inside the knapsack and the items in boxes (obtained after deleting the tall items and hence deleting the tall subcorridors). We would like to split the boxes into containers as in Section 3.2.3 but there is an issue: There can be items in which overlap with the boundaries of the boxes. But these are at most a constant in number and hence we can resolve this issue in the following way.
Consider an item in partially overlapping with a box. We extend each of its horizontal edge that is inside the box in both the directions till the ends of the box. This extended edge and divide the items in the box into at most five categories: The items intersecting the extended edge, the items to the left of , the items to the right of , the items above and the items below . We note that the items in the first part are at most a constant in number and hence add them to . Thus splits the box into at most four smaller boxes. We repeat this process for all the items in partially overlapping with the box. We obtain smaller boxes but with the required property that there are no partially overlapping items in with the boxes. This is depicted in Figure 2.
We apply Lemma 7 to these smaller boxes and while doing this, we add all the items partially overlapping with the removed strip to . Then, we apply Lemma 8 to these new smaller boxes to split them into containers as in Section 3.2.3. At this point, the round ends and we look at the set . If , we end; otherwise we continue to round . We can argue that the number of rounds are at most : and are disjoint for all . Hence, for some , we can guarantee that is at most .
Therefore, after the round, we end the process and we add the small items to the packing as described in Section 3.2.4.
In [9], it is also shown how to modify the formed containers so that their widths and heights come from a set of cardinality . The basic idea is as follows. First note that a large container contains only one item. Hence, the size of the container can be shrunk to that of the item. Now, consider a wide container . Items are lying one on top of another inside . So, can be expressed as the sum of heights of all the items. Also, can be expressed as the maximum among all the widths of items in the container. If there are at most number of items in , then can belong to a set containing at most values. If has more than number of items, then we consider the tallest number of items in . Let this set be . There must certainly exist an item whose profit is at most . We remove the item from the container and readjust the height of so that its height belongs to a polynomial set of values. Now consider an area container . Since all items in are -small with respect to the dimensions of , we can leave out a subset of items carrying a very marginal profit and create some space in both the horizontal and vertical directions so that the width and height of can be readjusted. For full proof one can refer to [9]. This proves Theorem 4.
3.3 Container Packing Problem and Vector-Max-GAP
From now on, our main goal would be to derive an algorithm to construct the nice structure as in Theorem 4. We first formally define the problem of packing items into containers which we call the container packing problem. We then model the container packing problem as an instance of the Vector-Max-GAP problem. Since we have a PTAS for the Vector-Max-GAP problem, it follows that there exists a PTAS for the container packing problem.
Let be a set of items and let denote the associated widths, heights, profits and weights respectively.
Let be a given set of containers such that the number of containers is constant. Out of , let denote area, wide, tall and large containers respectively.
In the Container Packing Problem, we would like to pack a subset of into these containers such that
-
•
A large container can either be empty or can contain exactly one item.
-
•
In a wide (resp. tall) container, all the items must be stacked up one on top of another (resp. arranged side by side).
-
•
The total area of items packed in an area container must not exceed times the area of the container itself (assume that is a constant given as a part of the input).
-
•
The total weight of items packed in all the containers in any dimension should not exceed one.
We denote an instance of the container packing problem by the tuple .
Now, let us define the Vector-Max-GAP problem. Let be a set of items and let us say, we have machines such that the machine has a capacity . An item has a size of , value of in the machine and weight in the dimension. The objective is to assign a maximum value subset of items , each item to a machine, such that the total size of items in a machine does not exceed the capacity of that machine. We also require that the total weight of does not exceed (a non-negative real) in any dimension .
Let , , , , .
Also, let , . We denote an instance of Vector-Max-GAP by .
3.4 Reduction of Container Packing Problem to Vector-Max-GAP
Let denote an instance of the container packing problem. In this subsection, we show how to reduce to an instance of the Vector-Max-GAP problem.
We retain from . Since we have unit vector constraints over all the containers combined in the container packing problem, we initialize to be the vector of all ones. We choose the number of machines in to be same as the number of containers in . Let and . The vectors are defined as follows:
In the above definitions of and , varies from 1 to , varies from 1 to and varies from 1 to .
Let denote a subset of packed in a feasible solution to . Then can also be feasibly assigned to the machines of our Vector-Max-GAP problem: Just assign all the items in a container to the machine.
-
•
If is a large container, then the only item packed into it has size 1 in machine and capacity of is also 1 and hence assigning this item to the machine is feasible.
-
•
If is a wide (resp. tall) container, the items packed in are wide and stacked up (resp. tall and arranged side by side). Hence their total height (resp. width), which is the total size of items assigned to the machine, does not exceed the total height (resp. width) of the container, which is the capacity of the machine.
-
•
If is an area container, the total area of items packed in does not exceed which yields that the total size of items assigned to the machine does not exceed the capacity of the machine.
The total weight of all the items assigned to machines does not exceed (which is equal to the all ones vector) as we did not change while reducing to . This proves that the optimal value obtainable for is at least as much as that of the container packing problem .
On the other hand, consider any feasible assignment of a subset of items to the machines in our instance . Let be the subset of items assigned to the machine. We can pack into container in the following way: Since the assignment is feasible, the size of all items in does not exceed the capacity of . If is wide (resp. tall), (resp. ). Hence, all the items in can be stacked up (resp. arranged side by side) inside the container . If is an area container, then consists of only small items which are -small for and . Hence, by Lemma 15, we can pack the set into using NFDH. If an item is assigned to a large container, then it occupies the whole capacity (since item size and machine capacity are both equal to 1) and hence, only a single item can be packed in a large container.
The above arguments prove that the container packing problem is a special instance of the Vector-Max-GAP problem. Hence, we can use the PTAS for the Vector-Max-GAP problem from Section 2 to obtain a PTAS for the container packing problem.
The reduction in the case when rotations are allowed is exactly the same except for the values of in the reduction of Container Packing Problem to an instance of the Vector-Max-GAP problem: If is a tall (resp. wide) container,
If is a large container, we set if does not fit in with or without rotations. Otherwise we set to 1. In case of being an area container, is same as the case without rotations. The correctness of the reduction follows by similar arguments as above.
Theorem 13.
There exists a PTAS for the container packing problem with or without rotations.
3.5 Algorithm
Our main goal is to search for the container packing structure in Theorem 4.
For this we need to guess the set of containers used to pack the items in of (1). As mentioned in Section 3.2, the number of containers used is at most a constant (let this number be denoted by ) and they have to be picked from a set whose cardinality is in (let this cardinality be denoted by ). Therefore, the number of guesses required is which is in turn in .
Once we have the containers, we need to guess which of them are large containers, wide containers, tall containers and area containers. The number of guesses required is at most which is a constant.
Then we use the PTAS of the container packing problem with approximation factor , and since the optimal profit of the container packing problem is at least , by choosing and , we get the desired approximation factor of for the (2, ) knapsack problem.
4 Conclusion
We study the Knapsack problem and design a approximation algorithm using corridor decomposition and the PTAS for Vector-Max-GAP problem, which could be of independent interest. We believe that the approximation ratio might be improved to , however, it will require involved applications of complicated techniques like -packings as described in [9]. One might also be interested in studying a further generalization of the problem, the Knapsack where items are dimensional hyper-rectangles with weights in dimensions. One major application of our result will be in designing approximation algorithms for Bin Packing problem, a problem of high practical relevance. In [19], we use the presented approximation algorithm for Knapsack as a subroutine to obtain an approximation algorithm for the Bin Packing problem.
References
- [1] Anna Adamaszek and Andreas Wiese. A quasi-PTAS for the two-dimensional geometric knapsack problem. In SODA, pages 1491–1505, 2015.
- [2] Nikhil Bansal, Alberto Caprara, Klaus Jansen, Lars Prädel, and Maxim Sviridenko. A structural lemma in 2-dimensional packing, and its implications on approximability. In ISAAC, pages 77–86, 2009.
- [3] Nikhil Bansal, Marek Eliás, and Arindam Khan. Improved approximation for vector bin packing. In SODA, pages 1561–1579, 2016.
- [4] Nikhil Bansal and Arindam Khan. Improved approximation algorithm for two-dimensional bin packing. In SODA, pages 13–25, 2014.
- [5] Henrik I. Christensen, Arindam Khan, Sebastian Pokutta, and Prasad Tetali. Approximation and online algorithms for multidimensional bin packing: A survey. Computer Science Review, 24:63–79, 2017.
- [6] Edward G. Coffman, Jr, Michael R. Garey, David S. Johnson, and Robert E. Tarjan. Performance bounds for level-oriented two-dimensional packing algorithms. SIAM Journal on Computing, 9:808–826, 1980.
- [7] A. M. Frieze and M. R. B. Clarke. Approximation algorithms for the -dimensional knapsack problem: worst-case and probabilistic analyses. EJOR, 15:100–109, 1984.
- [8] Waldo Gálvez, Fabrizio Grandoni, Afrouz Jabal Ameli, Klaus Jansen, Arindam Khan, and Malin Rau. A tight (3/2+) approximation for skewed strip packing. In APPROX/RANDOM, volume 176, pages 44:1–44:18, 2020.
- [9] Waldo Gálvez, Fabrizio Grandoni, Sandy Heydrich, Salvatore Ingala, Arindam Khan, and Andreas Wiese. Approximating geometric knapsack via l-packings. In FOCS, pages 260–271, 2017.
- [10] Waldo Gálvez, Fabrizio Grandoni, Salvatore Ingala, and Arindam Khan. Improved pseudo-polynomial-time approximation for strip packing. In FSTTCS, pages 9:1–9:14, 2016.
- [11] Waldo Galvez, Fabrizio Grandoni, Arindam Khan, Diego Ramirez-Romero, and Andreas Wiese. Improved approximation algorithms for 2-dimensional knapsack: Packing into multiple l-shapes, spirals, and more. In Symposium on Computational Geometry (SoCG), page To appear, 2021.
- [12] Fabrizio Grandoni, Stefan Kratsch, and Andreas Wiese. Parameterized Approximation Schemes for Independent Set of Rectangles and Geometric Knapsack. In ESA, volume 144, pages 53:1–53:16, 2019.
- [13] Sandy Heydrich and Andreas Wiese. Faster approximation schemes for the two-dimensional knapsack problem. In SODA, pages 79–98, 2017.
- [14] Oscar H. Ibarra and Chul E. Kim. Fast approximation algorithms for the knapsack and sum of subset problems. J. ACM, 22(4):463–468, October 1975.
- [15] Hans Kellerer, Ulrich Pferschy, and David Pisinger. Knapsack problems. Springer, 2004.
- [16] Arindam Khan. Approximation algorithms for multidimensional bin packing. PhD thesis, Georgia Institute of Technology, Atlanta, GA, USA, 2016.
- [17] Arindam Khan, Arnab Maiti, Amatya Sharma, and Andreas Wiese. On guillotine separable packings for the two-dimensional geometric knapsack problem. In Symposium on Computational Geometry (SoCG), page To appear, 2021.
- [18] Arindam Khan and Madhusudhan Reddy Pittu. On guillotine separability of squares and rectangles. In APPROX/RANDOM, volume 176, pages 47:1–47:22, 2020.
- [19] Arindam Khan, Eklavya Sharma, and K. V. N. Sreenivas. Geometry meets vectors: Approximation algorithms for multidimensional packing. In Manuscript, 2021.
- [20] Ariel Kulik and Hadas Shachnai. There is no eptas for two-dimensional knapsack. Information Processing Letters, 110(16):707–710, 2010.
- [21] Eugene L. Lawler. Fast approximation algorithms for knapsack problems. In FOCS, pages 206–213, 1977.
- [22] Tobias Mömke and Andreas Wiese. Breaking the barrier of 2 for the storage allocation problem. In ICALP, volume 168 of LIPIcs, pages 86:1–86:19, 2020.
Appendix A Appendix
A.1 Next Fit Decreasing Heights (NFDH)
NFDH, introduced in [6], is a widely used algorithm to pack rectangles in a bigger rectangular bin. It works as follows. First, we order the rectangles in the decreasing order of their heights. We then place the rectangles greedily on the base of the bin until we do not cross the boundaries of the bin. At this point, we “close” the shelf and shift the base to top edge of the first rectangle and continue the process. For an illustration of the algorithm, see Fig. 3.
Now, we state a well-known and important lemma about NFDH.
Lemma 14.
[2]. Let be a set of rectangles and let and denote the largest width and largest height in , respectively. Consider a bin of dimensions . If , then NFDH packs all the rectangles into the bin.
The above lemma suggests that NFDH works very well if all the rectangles are small compared to the biun dimensions. The following lemma will be crucial for our purposes.
Lemma 15.
Consider a set of rectangles with associated profits and a bin of dimensions and assume that that each item in has width at most and height at most . Suppose denotes the optimal profit that can be packed in the bin. Then there exists a polynomial time algorithm that packs at least profit into the bin.
Proof.
Let us first order the rectangles in the decreasing order of their profit/area ratio. Then pick the largest prefix of rectangles such that . By the above lemma, NFDH must be able to pack all the items in into the bin. On the other hand, since each rectangle has area at most , it follows that . Furthermore, since contains the highest profit density items, it follows that . ∎