Skip to main content
Log in

On the approximability of the two-phase knapsack problem

  • Published:
Journal of Combinatorial Optimization Aims and scope Submit manuscript

Abstract

We consider a natural generalization of the knapsack problem and the multiple knapsack problem, which has two phases of packing decisions. In this problem, we have a set of items, several small knapsacks called boxes, and a large knapsack called container. Each item has a size and profit, each box has a size and the container has a capacity. The first phase is to select some items to pack into the boxes, and the second phase is to select the boxes (each includes some packed items) to pack into the container. The total profit of the problem is determined by the items that are selected and packed into the container within some packed box, and the objective is to maximize the total profit. This problem is motivated by various practical applications, e.g., in logistics. It is a generalization of the multiple knapsack problem, and hence is strongly NP-hard. We mainly propose three approximation algorithms for it. Particularly, the first one is a \(\frac{1}{4}\)-approximation algorithm based on its linear programming relaxation; the second one is based on applying the algorithms for the multiple knapsack problem and the knapsack problem, and has an approximation ratio \(\frac{1}{3} - \epsilon \) for any small enough \(\epsilon >0\). We finally provide a polynomial time approximation scheme for this problem.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6

Similar content being viewed by others

Notes

  1. In practice, it is more reasonable and efficient to pack the remaining items into the boxes in \(S_1\), if there is any remaining space. However, we can see from the later analysis and the tight example that it will not improve the theoretical lower bound of the approximation algorithm. For convenience of the analysis, we still say that the remaining items are packed into the box \(S_2\), and similar in the subsequent procedures in this algorithm.

References

  • Chekuri C, Khanna S (2005) A polynomial time approximation scheme for the multiple knapsack problem. SIAM J Comput 35(3):713–728

    Article  MathSciNet  Google Scholar 

  • Chen L, Zhang G (2016) Packing groups of items into multiple knapsacks. In: Ollinger N, Vollmer H (eds) STACS 2016. LIPIcs, vol 47, pp 28:1–28:13

    Article  MathSciNet  Google Scholar 

  • Dudziński K, Walukiewicz S (1987) Exact methods for the knapsack problem and its generalizations. Eur J Oper Res 28(1):3–21

    Article  MathSciNet  Google Scholar 

  • Faaland BH (1981) The multiperiod knapsack problem. Oper Res 29(3):612–616

    Article  MathSciNet  Google Scholar 

  • Feige U, Vondrak J (2006) Approximation algorithms for allocation problems: improving the factor of \(1 - 1/e\). In: FOCS’06, pp 667–676

  • Fernandez de la Vega W, Lueker GS (1981) Bin packing can be solved within 1 + \(\epsilon \) in linear time. Combinatorica 1(4):349–355

    Article  MathSciNet  Google Scholar 

  • Fleischer L, Goemans MX, Mirrokni Vahab S, Sviridenko M (2011) Tight approximation algorithms for maximum separable assignment problems. Math Oper Res 36(3):416–431

    Article  MathSciNet  Google Scholar 

  • Garey MR, Johnson DS (1979) Computers and intractability: a guide to the theory of NP-completeness. Freeman, New York

    MATH  Google Scholar 

  • Hariri AMA, Potts CN, Van Wassenhove LN (1995) Single machine scheduling to minimize total weighted late work. ORSA J Comput 7(2):232–242

    Article  Google Scholar 

  • Ibarra OH, Kim CE (1975) Fast approximation algorithms for the knapsack and sum of subset problems. J ACM 22(4):463–468

    Article  MathSciNet  Google Scholar 

  • Jansen K (2010) Parameterized approximation scheme for the multiple knapsack problem. SIAM J Comput 39(4):1392–1412

    Article  MathSciNet  Google Scholar 

  • Johnston RE, Khan LR (1995) Bounds for nested knapsack problems. Eur J Oper Res 81(1):154–165

    Article  Google Scholar 

  • Kellerer H, Pferschy U, Pisinger D (2004) Knapsack problems. Springer, Berlin

    Book  Google Scholar 

  • Kosuch S (2014) Approximability of the two-stage stochastic knapsack problem with discretely distributed weights. Discrete Appl Math 165:192–204

    Article  MathSciNet  Google Scholar 

  • Kosuch S, Lisser A (2011) On two-stage stochastic knapsack problems. Discrete Appl Math 159(16):1827–1841

    Article  MathSciNet  Google Scholar 

  • Lawler EL (1979) Fast approximation algorithms for knapsack problems. Math Oper Res 4(4):339–356

    Article  MathSciNet  Google Scholar 

  • Murgolo FD (1987) An efficient approximation scheme for variable-sized bin packing. SIAM J Comput 16(1):149–161

    Article  MathSciNet  Google Scholar 

  • Nip K, Wang Z (2013) Combination of two-machine flow shop scheduling and shortest path problems. In: Du D-Z, Zhang G (eds) COCOON 2013. LNCS, vol 7936. Springer, pp 680–687

  • Nip K, Wang Z, Talla NF, Leus R (2015a) A combination of flow shop scheduling and the shortest path problem. J Comb Optim 29(1):36–52

    Article  MathSciNet  Google Scholar 

  • Nip K, Wang Z, Xing W (2015b) Combinations of some shop scheduling problems and the shortest path problem: complexity and approximation algorithms. In: Xu D, Du D, Du D-Z (eds) COCOON 2015. LNCS, vol 9198. Springer, pp 97–108

  • Nip K, Wang Z, Xing W (2016) A study on several combination problems of classic shop scheduling and shortest path. Theor Comput Sci 654:175–187

    Article  MathSciNet  Google Scholar 

  • Shmoys DB, Tardos É (1993) An approximation algorithm for the generalized assignment problem. Math Program 62(3):461–474

    Article  MathSciNet  Google Scholar 

  • Wang Z, Cui Z (2012) Combination of parallel machine scheduling and vertex cover. Theor Comput Sci 460:10–15

    Article  MathSciNet  Google Scholar 

  • Williamson DP, Shmoys DB (2011) The design of approximation algorithms. Cambridge University Press, New York

    Book  Google Scholar 

  • Xavier EC, Miyazawa FK (2006) Approximation schemes for knapsack problems with shelf divisions. Theor Comput Sci 352(1):71–84

    Article  MathSciNet  Google Scholar 

  • Ye Y (1997) Interior point algorithms: theory and analysis. Wiley, London

    Book  Google Scholar 

Download references

Acknowledgements

This work has been supported by NSFC No. 11801589, No.11771245 and No. 11371216.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Kameng Nip.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

An extended abstract has appeared in COCOON 2018, LNCS 10976, pp. 6375, 2018.

Appendices

A Shmoys and Tardos’s LP rounding algorithm for GAP (Shmoys and Tardos 1993)

Theorem A.1

(Shmoys and Tardos 1993) Given an optimal solution to LP relaxation of a generalized assignment problem (LPR\(_{b}\)), there is an \(O(n^2\log n)\) time algorithm that returns an integral solution such that

  • the objective value is at least \(OPT_{\mathrm {LPR}}\);

  • each item j packed into box i satisfies \(w_{j} \le s_{i}\);

  • the size of all items packed into box i is at most \(2s_{i}\), and furthermore, the total size of items except the largest one is at most \(s_{i}\).

It has been pointed out that in Chekuri and Khanna (2005) that the LP relaxation algorithm above can return a feasible assignment with at least half of the optimal profit. To see this, for each box i and items returned by the algorithm above, let \(j_{i1}\) be the item with largest size, and \(j_{i2}, ..., j_{in'}\) be the remaining items. If the profit of \(j_{i1}\) is larger than the total profit of \(j_{i2}, ..., j_{in'}\), then we select \(j_{i1}\) and pack it into the box i; otherwise we select the remaining items and pack them into box i. Since by the last property of the LP relaxation algorithm above, both two set of items have total size at most \(s_{i}\). Applying this procedure for each box, we can obtain a feasible assignment of items to the boxes, where the total profit is at least \(OPT_{\mathrm {LPR}}/2\).

We also remark that the \(O(n^2\log n)\) time complexity stands for the GAP problem with unrelated case, i.e., the weight of item j packed into box i is defined as \(w_{ji}\). The problem studied in our paper corresponds to the identical case, i.e., \(w_{ij} = w_{j}\) for each i. Therefore, the running time of the LP rounding algorithm in our problem becomes linear.

B Chekuri and Khanna’s PTAS for MKP (Chekuri and Khanna 2005)

We roughly state the procedure of Chekuri and Khanna’s PTAS for the multiple knapsack problem as below:

  1. 1.

    Given any given positive value in \(\epsilon \in (0, 1/2)\). Guess a value \({\widetilde{P}}\) in \(\{p_{\max }(1 + \epsilon )^{i} | 0 \le i \le 2\lfloor \epsilon ^{-1} \ln n\rfloor \}\) with polynomial time such that \(\max \{p_{\max }, (1 - \epsilon ) OPT\} \le {\widetilde{P}} \le OPT\), where \(p_{\max }\) is the largest profit among all items. Discard all the items with profit no more than \(\epsilon {\widetilde{P}}/n\). Round down the profits \(p_j\) to the nearest value in \(\{\frac{\epsilon {\widetilde{P}}}{n}(1 + \epsilon )^{i}|0 \le i \le 2\lfloor \epsilon ^{-1} \ln n\rfloor \).

  2. 2.

    Let \(I_1\), ..., \(I_h\) be the partition of sets of items with each having the same profit, U be the set of items chosen in some optimal solution, and \(U_i = I_i \cap U\) for \(i = 1, ..., h\). Guess the total profit \(P(U_i)\) of \(U_i\) for each i in polynomial time. Particularly, guess by enumeration for a tuple \((k_1, ..., k_h)\) with \(k_i\) in \(\{0, ..., \lfloor h/\epsilon ^2\rfloor \}\) and \(\sum k_i \le \lceil h/\epsilon ^2\rceil \), such that \(k_i\epsilon ^2{\widetilde{P}}/h \le P(U_i) \le (k_i + 1)\epsilon ^2{\widetilde{P}}/h\). Then, pick \(k_i\) items into the knapsacks in increasing order of their sizes until the profit exceeds \(k_i\epsilon ^2{\widetilde{P}}/h\) for each set \(I_i\). [The guessing can be finished in polynomial time, which are guaranteed by Lemmas 2.3–2.5 in Chekuri and Khanna (2005).]

  3. 3.

    Use the shift technique of bin packing problem (Fernandez de la Vega and Lueker 1981). For a set of items with identical profits, divide them into \((1 + 1/\epsilon )\) groups. Discard the group with the largest size, and for each other group, the size of every item is increased to the size of the smallest item in the next group larger than this group. Now the instance has at most \(O(\epsilon ^{-1} \ln n)\) distinct profit values and \(O(\epsilon ^{-2} \ln n)\) distinct size values, which can be packed into the knapsacks, and the total profit is at least \(\left( 1 - O(\epsilon )\right) OPT\).

  4. 4.

    Group the knapsacks such that \(B_i\) consists of all knapsacks having capacities c with \((1 + \epsilon )^{i} \le c < (1 + \epsilon )^{i + 1}\). Call a group G small block if \(|B_i| \le 1/\epsilon \), and large block otherwise. It is enough to keep the \(t = 1/\epsilon + \lceil 4\epsilon ^{-1}\ln 1/\epsilon \rceil \) small blocks with largest capacities, with losing at most \(\epsilon \) fraction of the total profit. Particulary, it uses one knapsack in the largest \(1/\epsilon \) knapsacks of the small block, to pack all the items in the removing small blocks [the feasibility is guaranteed by Lemma 2.8 in Chekuri and Khanna (2005)]. Then guess for the remaining small blocks, the \(1/\epsilon \) most profitable items which are packed in the optimal solution, which uses at most \(n^{O(\ln (1/\epsilon )/\epsilon ^3)}\) time.

  5. 5.

    Call an item is packed as a large item if its size is at least \(\epsilon \) times the capacity of the knapsack to which it is packed, otherwise it is said to be packed as small. An item can be packed as a large item in at most \(f = \lceil 2\epsilon ^{-1}\ln {1/\epsilon }\rceil \) different blocks. Guess all items which are packed as large and to guess also the blocks to which they are packed, it requires \(n^{O(1/\epsilon ^5)}\) time with losing at most \(O(\epsilon )\) fraction of the total profit. Find a packing for these items in polynomial time by the APTAS for bin packing (Murgolo 1987), with most \(\epsilon |B_i|\) extra knapsacks of capacity \(c_i\) for each group \(B_i\), where \(c_i = (1 + \epsilon )^{i}\).

  6. 6.

    Packing the remaining items to the knapsacks by Shmoys and Tardos (1993)’s algorithm for the generalized assignment problem. Together with the extra knapsacks obtained in Step 5, there are at most \(3\epsilon |B_i|\) extra knapsacks of capacity \(c_i\) for each group \(B_i\). Choose the \(|B_i|\) most profitable knapsacks among the current solution, and the obtained solution has total profit at least \(\left( 1 - O(\epsilon )\right) OPT\).

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Nip, K., Wang, Z. On the approximability of the two-phase knapsack problem. J Comb Optim 38, 1155–1179 (2019). https://doi.org/10.1007/s10878-019-00442-w

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10878-019-00442-w

Keywords

Navigation