# Theoretical Computer Science 508 (2013) 35–40

Contents lists available at ScienceDirect

Theoretical Computer Science
journal homepage: www.elsevier.com/locate/tcs

2D knapsack: Packing squares✩
Yan Lan a , György Dósa b , Xin Han c,∗ , Chenyang Zhou c , Attila Benko b
a b c

Dalian Neusoft Institute of Information, China Department of Mathematics, University of Pannonia, Veszprém, Hungary School of Software of Dalian University of Technology, China

abstract
In this paper, we study a two-dimensional knapsack problem: packing squares as many as possible into a unit square. Our results are the following: (i) we propose an algorithm called IHS (Increasing Height Shelf), and prove that the packing is optimal if in an optimal packing there are at most 5 squares, and this upper bound is sharp; , we propose a simple and fast algorithm (ii) if all the squares have side length at most 1 k
k+2 in time O(n log n); with an approximation ratio k +k3 2 (iii) we give an EPTAS for the problem, where the previous result in Jansen and Solis-Oba (2008) [16] is a PTAS, not an EPTAS. However our approach does not work on the previous model of Jansen and Solis-Oba (2008) [16], where each square has an arbitrary weight.
2

1. Introduction The knapsack problem is one of the most classical and well studied problems in the combinatorial optimization field and has a lot of applications in the real world [17]. The (classical) knapsack problem is given a knapsack and a set of items with weights and sizes, to maximize the total weight of selected items in the knapsack satisfying the capacity constraint. In this paper, we study a geometric version of the 2D knapsack problem, where items are squares with weight 1 and side at most 1 and the knapsack is a unit size square and the objective is to maximize the total number of squares packed in the knapsack. In the packing, the sides of the items should be parallel to the corresponding sides of the knapsack and overlapping is not allowed. The problem was first studied by Baker et al. [2]. They gave an approximation algorithm with an asymptotic ratio 4/3. As mentioned in [16], this geometric packing problem has received a lot of attention recently [15,16,14,9,4], and has its applications in stock cutting, advertisement placement, image processing, and VLSI design [15,9]. Related work: It is well-known that the 1D knapsack problem is NP-hard and admits fully polynomial time approximation schemes (FPTAS) and the corresponding fractional problems can be solved by a greedy algorithm [1,5,11,17]. For the 2D geometric knapsack, in [3] Caprara and Monaci gave a simple algorithm with an approximation ratio 3 + ϵ . Jansen and

✩ Partially supported by the NSFC (11101065) and ‘‘the Fundamental Research Funds for the Central Universities’’. The last author is supported in part by Project TAMOP-4.2.2/B-10/1-2010-0025. ∗ Corresponding author. Tel.: +86 411 87571630. E-mail addresses: lanyan@neusoft.edu.cn (Y. Lan), dosagy@almos.vein.hu (G. Dósa), hanxin.mail@gmail.com (X. Han), zcy1988@gmail.com (C. Zhou), benko.attila@almos.vein.hu (A. Benko).