On Two Dimensional Orthogonal Knapsack Problem

In this paper, we study the following knapsack problem: Given a list of squares with profits, we are requested to pack a sublist of them into a rectangular bin (not a unit square bin) to make profits in the bin as large as possible. We first observe …

Authors: Xin Han, Kazuo Iwama, Guochuan Zhang

On Two Dimensional Orthogonal Knapsack Problem
On Tw o Dimensional Orthogonal Knapsac k Problem Xin Han 1 Kazuo Iw ama 1 Guo c h uan Zhang 2 School of Informatics, Kyoto Univ er sit y , K y oto 606-85 01, Japan hanxin, iwama@kuis.kyoto-u.ac.jp 2 Department of Mathematics, Zhejiang Universit y , China zgc@zju.edu.cn Abstract In this pap er, w e study the following knapsack problem: Given a list o f squar es with profits, we are requested t o pack a sublist of them into a rectang ula r bin (not a unit square bin) to make profits in the bin as la rge as p o ssible. W e first obser ve there is a Polynomial Time Approximation Scheme (PT AS) for the problem of packing w eighted squar es in to rectangula r bins with large resources, then apply the PT AS to the problem of packing squar es with profits into a r ectangular bin and get a 6 5 + ǫ a ppr o ximation a lgorithm. 1 In tro duction In this pap er we s tu dy the t w o-dimensional generaliza tion for Knapsack : w e are giv en a set of squares, eac h of which is asso ciated with a p r ofit. The goal is to p ac k a subset of the squares (items) in to a rectangle (bin) to maximize the total p r ofit pac ke d. The problem is NP-hard in the strong sense ev en if eac h item is an u n w eigh ted sq u are (i.e., its profit is equal to its area) [17]. A little surprisin gly , the researc h for appro ximation algorithm h as started quite recen tly: J ansen and Z hang [12], Caprara and Monaci [2], Harren [11] etc. Related W ork There are many literatures on rectangle p ac king and squ are p ac king. F o r a t w o dimensional knapsack problem in wh ic h a subset of a giv en set of rectangles are pack ed int o a giv en rectangular bin to maximize the total profits in the bin. Jansen and Zh ang prop osed 2 + ǫ appro ximation algorithm [12]. When all items are squares and their profits are equal to their areas, Fishkin, Gerb er, Jansen and S oli s-Ob a [8] pr esen ted a PT AS, whic h w as also obtained b y Han, Iwama and Zh ang indep enden tly [10]. Jansen and Z hang [13] prop osed a PT AS for p ac king squares in to a rectangular b in to maximize the num b er of squares pac k ed in the b in [13]. Harren [11] pr op osed 5 4 + ǫ appro ximation algorithm for packing squ ares into a unit squar e b in. But his algorithm is n ot applicable to pac k squares int o a r e ctangular b in since his algorithm requires that ev ery sid e of the bin must hav e the same length. Fishkin, Gerb er and Jansen [7] obtained a (1 − ǫ )-appro ximation algorithm for p ac king a set of rectangles with pr ofits in to a large resource bin w ith width 1 and heigh t larger than (1 /ǫ ) 4 . Another related work is 2 dimensional bin pac king problem in wh ic h all r ec tangles hav e to b e pac k ed in to a unit square bin to minimize the n umb er of bins r equired. When all items are squares, F e rr eira et al. [6] ga v e an approximat ion algo rithm with asymptotic w orst-case ratio b ound ed ab o ve b y 1.988. Kohay ak a w a et al. [16] and Seiden and v an S tee [19] indep enden tly obtained ap p ro ximation algorithms with asymptotic wo rst-case ratio of at most 14 / 9 + ε (for an y ε > 0). Th ese results w ere recen tly impr o ved by Bansal, Correa, Keny on and Svir id enk o [1]. They prop osed an asymptotic PT AS for pac king d -dimensional cub es in to the minimum num b er of un it cub es. F o r th e online case, if the n umb er of bins is unb ounded, the b est kn o wn asymptotic wo rst case ratio is 2.1439 [9]. 1 There are also some r esearch on the Multiple Knaps ac k Problem. Kellerer [14], fir s t ga ve a PT AS for a sp ecial case of this p roblem in whic h all th e knapsac ks ha ve id en tical capacit y [14]. Chekur i and Khanna [3] obtained a PT AS for the general multiple knapsac k p roblem. F or pac king rectangles int o m ultiple identical r ec tangular bins, Fishkin et al. [7] ga v e a 2 + ǫ approximati on algorithm. Main result s and T ec hniques: W e fi rst observ e that the tec hniques u s ed in Mutilple Knapsac k Problem [3] are useful f or the problem of pac king wei ghted squ ares in to rectangular bins (the bins ma y ha v e differen t dim en sions) w ith large resources, where lar ge r esour c e means that th e heigh t of a bin is muc h larger than the wid th, and giv e a Pol yn omial T ime App ro xim ation Scheme (PT AS) for the ab o v e problem, then apply the PT AS to the prob lem of p acking squares with profits in to a rectangular bin and get a 6 5 + ǫ appr o ximation algorithm. F o r pac king squaures into a r ec tangular bin, w e first int ro duce a simple algorithm by the tec hniques used in 2D bin pac king [1] problems and sho w that if there are to o man y large squ ares pack ed or th e rest area for packing squares is not small, the algorithm has a nice p erformance, then w e focus on the case in which there are a few large squares pac k ed and the r est area for small squares is also few. W e p rop ose a nov el app roac h of p ac king a few large items suc h that the pac king d oes not affect the futur e small items packing to o muc h , and call it c orner pac king. F o r pac king small squares into the rectilinear p olygons wh ic h is generate d after pac king large squ ares int o the bin, • we fir s t dissect the p olygo ns in to rectangular blocks suc h that the optimal v alue of p ac king small squares in to the blo c ks is near the optimal v alue of p ac king small squares int o the p olygons, • then call the m et h o d used in Multiple Knapsac k Prob lem [3], to gu ess one su blist wh ic h has a feasible pac king and profit at least (1 − ǫ ) O P T b , w here O P T b is the optimal v alue for p ac king small squ ares int o the blo c ks, • lastly , we exploit the tec hn iques used in s trip pac king [7, 15] to pac k items in eac h b loc k. W orst Case Ratio: W e adopt the standard measure worst c ase r atio to ev aluate appr oximati on algorithms. F or an y inp ut list L , let A ( L ) b e the total p rofit p ac ked by appro ximation algorithm A and O P T ( L ) b e the optimal v alue. T he worst c ase r atio of algorithm A is thus d efined as R A = sup L O P T ( L ) A ( L ) . p( · ), w( · ) : Giv en a square q , w e use p ( q ) and w ( q ) to denote its profit and area resp ectiv ely . And giv en a list of squares L = ( q 1 , . . . , q n ), w e d efine p ( L ) = P n i =1 p ( q i ) and w ( L ) = P n i =1 w ( q i ). 2 P ac king Squ ares in to Rectangular Bins with Large Resources INST ANCE : Giv en an input list S of n squares with p rofits and a set of rectangular bins B = ( B 1 , B 2 , . . . , B c ) where B i = ( w i , h i ) and max { w i , h i } ≥ ǫ 6 i − 1 for all i , c , ǫ are constant s. OBJECTIVE: Maximize the total profit p ac ke d in B . Based on the ideas from the semin al p apers [3, 15], we give a PT AS for the ab o v e problem. Ther e are thr ee steps in the PT AS. W e fi rst guess a sub set of squares which can b e pac ke d in to B and whose total profit is near the optimal v alue through the tec h nique of roundin g the input instance in to O ( ǫ − 2 ln n ) classes. Then for eac h bin, we guess the num b er of items pac k ed in that b in from eac h class suc h that our guess is also n ear the op timal solution, i.e.,w e d o not lose to o m uc h pr ofit. After matc hing items in to bins , w e u se the strip pac king algorithm to pac k items in eac h b in. 2 Rounding and guessing: Here, we consider square pac king. Sin ce there is an natural order relation b et w een any t wo squares, the tec hniques u sed in Multiple Knapsac k problem [3] are u seful for squ are pac king to o. W e first rou n d th e instance in to a w ell structured instance w hic h has O ( ǫ − 1 ln n ) distinct profits, and more items in eac h profit class ha v e at most ( ǫ − 1 ) distinct sizes (side length). Then w e select a su b set items whic h can b e p ack ed into the bins and h as the profit as least (1 − ǫ ) time the optimal solution. But, if the items are rectangles, w e d o not ha ve th e ab o ve r esu lt, since there is n ot an order relation b et wee n an y tw o rectangles. Lemma 1 Given an ab ove instanc e I = ( B , S ) with n items, in p olynomial time v = n O (1 / ǫ 3 ) , we c an obtain instanc es I 1 , . . . , I v such that • I j = ( B , S j ) for 1 ≤ j ≤ v , wher e S j is a sublist of list S . • F or 1 ≤ j ≤ v , items in S j have O ( ǫ − 1 ln n ) distinct pr ofits, and mor e items in e ach pr ofit c la ss have at most ( ǫ − 1 ) distinct sizes (side length). • Ther e is an index j , 1 ≤ j ≤ v , such that S j has a fe asible p acking i n B and p ( S j ) ≥ (1 − O ( ǫ )) OP T ( I ) . Pr o of. W e sh o w how to construct instance I 1 , . . . , I v from I = ( B , S ) suc h that one of them satisfies the conditions. There are four steps, wh ic h are basically f r om [3]. • Guess a v alue O such that (1 − ǫ ) O P T ≤ O ≤ O P T . • Roun d down th e p rofits of items in to O ( ǫ − 1 ln n ) classes suc h that p j 1+ ǫ ≤ p − j ≤ p j , w here p j is the j th item’s pr ofit and p − j is th e one after roun ding do wn, wh ere n is the num b er of items. • Guess a set of sub lists b ased the v alue O and the round ed profits of items suc h that one of them is f ea sible to p ac k in to th e set of bin s (blo c ks) B and its total pr ofit is at least (1 − O ( ǫ )) OP T . • Using the tec hn iqu es in bin pac king [5], in eac h distinct pr ofit class, r educe the num b er of distin ct sizes in to O ( ǫ − 1 ) such that we lose the profit at most O ( ǫ ) O P T . Hence, totally , eac h of sublists has O ( ǫ − 2 ln n ) distinct size v alues and pr ofi ts. Next, w e giv e the details for the ab o ve four steps. First, w e sho w ho w to guess O . Given a su fficien tly small constant ǫ > 0, let p max denote the largest v alue among item profits. W e know the optimal solution is b ound ed by n · p max . So we guess O fr om the set { p max (1 + ǫ ) i | 0 ≤ i ≤ 1 + ln 1+ ǫ n ≤ 2 ǫ − 1 ln n } . (1 + ln 1+ ǫ n ≤ 2 ǫ − 1 ln n follo ws from ln(1 + ǫ ) ≥ ǫ − ǫ 2 / 2 ≥ ǫ/ 2.) Th erefore, one of the v alues in the ab o v e set is guarantee d to satisfy th e desired prop erty for O . Giv en a v alue O such that max { p max , (1 − ǫ ) O P T } ≤ O ≤ O P T , then w e show ho w to massage the giv en in stance into a more stru ctured one has few distinct p rofits. 1. Discard all items with profits at most ǫ O /n . 2. Consider th e other items and divid e all profits by ǫ O /n suc h that after scaling eac h pr ofi t is at most n /ǫ . 3. Round down the profits of item to the nearest p ow er of (1 + ǫ ). 3 It is easily seen that only an O ( ǫ ) fraction of the optimal pr ofit lost b y the ab o v e transformation. Since (1 + ǫ ) i ≤ n/ǫ , we hav e i ≤ 2 ǫ − 1 ln n/ǫ ≤ 4 ǫ − 1 ln n . The last inequalit y follo ws from n/ǫ ≤ n 2 . Therefore, we can trans f orm the instance into a new instance with O ( ǫ − 1 ln n ) distinct pr ofits suc h th at only an O ( ǫ ) fraction of the optimal p rofit is lost. Next w e s ho w how to guess the items to pac k on the instance with O ( ǫ − 1 ln n ) d istinct pr ofi ts. Let h ≤ 4 ǫ − 1 ln n + 1 b e the n umb er of distinct p r ofits in our new instance. W e partition the input set of s quares S in to h set S 1 , ..., S h with items in eac h set ha ving the same profit. Let U b e the items c hosen in some optimal solution and let U i = S i ∩ U . Recall that we hav e an estimate O of the optimal v alue. If p ( U i ) ≤ ǫ O /h , w e ignore th e set S i ; no significant pr ofi t is lost. Hence we can assu m e that ǫ O /h ≤ p ( U i ) ≤ O and appr o ximately guess the v alue p ( U i ) for 1 ≤ i ≤ h , w here P ( U i ) is the tota l profit in U i . More p recisely , for eac h i w e guess a v alue k i ∈ [ h/ǫ 2 ] su c h that k i ( ǫ 2 O /h ) ≤ p ( U i ) ≤ ( k i + 1)( ǫ 2 O /h ) , where [ h/ǫ 2 ] stand s for the set of integ ers 0, 1,...., ⌊ h/ǫ 2 ⌋ . W e show ho w the num b ers k i enable u s to id en tify the items to p ac k and then sho w ho w the v alues k 1 , ...., k h can b e guessed in p olynomial time. Give n th e v alue k i w e order the items in S i in increasing size v alues (sid e length). Let a i denote the profit of an item in S i . If a i ≤ ǫ O /h , pic k the largest num b er of item from this ordered set whose cum ulativ e profit do es not exceed k i ( ǫ 2 O /h ) . If a i > ǫ O /h w e pic k the smallest n um b er of items, again in increasing order of side lengths, whose cum ulativ e profits exceeds k i ( ǫ 2 O /h ) . The c hoice of items is thus completely d ete rm in ed by the c hoice of th e k i . F or a tuple of v alues k 1 , ...., k h , let U ( k 1 , ..., k h ) d enote the set of items pac ked as describ ed ab o v e. F rom th e ab o ve selectio n, there exists a v alid tuple ( k 1 , ..., k h ) with eac h k i ∈ [ h/ǫ 2 ] such that U ( k 1 , ..., k h ) has a feasible packing in B and p ( U ( k 1 , ..., k h )) ≥ (1 − ǫ ) O . No w w e sh o w that the v alues k 1 , ...., k h can b e guessed in p olynomial time. Before that, w e in tro duce a useful claim. Claim 1 [3] L et f b e the numb er of g -tuples of non-ne gative inte gers such that the sum of tuple c o or dinates is e qual to d . Then f =  d + g − 1 g − 1  . If d + g ≤ αg then f = O ( e αg ) . By Claim 1, the num b er of h -tuples ( k 1 , ..., k h ) with k i ∈ [ h/ǫ 2 ] and P i k i ≤ h/ǫ 2 is O ( n O ( ǫ − 3 ) ). Next w e sho w ho w to reduce the num b er of distinct sizes (side length) in eac h pr ofi t class. The basic idea is the one u sed in app ro x im ation sc hemes for bin pac king [5]. Let A b e a set of g items with identica l pr ofit. W e order items in A in non-decreasing sizes and divide them in to t = (1 + 1 /ǫ ) groups A 1 , ..., A t with A 1 , ..., A t − 1 con taining ⌊ g /t ⌋ items eac h an d A t con taining ( g mo d t ) items. W e discard th e items in A t − 1 and for i < t − 1 w e in crease th e size of ev ery item in A i to the size of the smallest item in A i +1 . Sin ce A is ordered by s ize, no item in A i is larger than the smallest item in A i +1 for eac h 1 ≤ i < t . It is easy to see that if A has a feasible p ac king then the mo dified ins ta nce also has a feasible pac king. W e discard at m ost an ǫ fraction of the p rofit and the mo dified sizes ha ve at most 2 /ǫ d istinct v alues. App lying this to eac h profit class we obtain an in s ta nce with O ( ǫ − 2 ln n ) distinct size v alues. Hence, we hav e th is lemma. ✷ Distributing the selected items in to eac h bin After guessing a p olynomial num b er of su blists, n ext we consider h o w to distr ibute the selected items in eac h sublist into bin s . Easily to see, th e p ossibilities to assign the selected items in to bins is 4 b ounded b y c n , which is an exp onen tial size of n , where c is th e n umb er of bins and n is the num b er of items to b e pac k ed. But w e can guess a s ubset from the selected items in a p olynomial time such that the total pr ofit in the subset is n ea r th e optimal solution. After step 1, w e h a ve ( ǫ − 2 ln n ) classes in the in p ut instance. Let k i b e the num b er of items of the i th class and let l j i b e the num b er of items of the i th class pac ked in the j th bins, wh ere 1 ≤ j ≤ m . Lemma 2 We c an g u ess a set of numb ers h j i in p olynomial time such that (1 − ǫ ) l j i ≤ h j i ≤ l j i , wher e 1 ≤ ǫ − 2 ln n and 1 ≤ j ≤ c and c i s the numb er of bins. Pr o of. F or th e j th bin, w e guess h j i items from the i th class. If k i ≤ c ǫ (1+ ǫ ) then w e can guess a num b er h j i suc h that h j i = l j i in O ( c ǫ (1+ ǫ ) ) time. E lse, we guess a n umb er h j i from the set {⌊ (1 + ǫ ) x · ǫk i c ⌋| x = 1 , 2 , . . . } suc h that (1 − ǫ ) l j i ≤ h j i ≤ l j i . Since h j i ≤ k i , th e n umb er of guesses r equired to obtain a single h j i is b ounded by g = log 1+ ǫ c/ǫ ≤ O ( ǫ − 2 ln c ), for eac h class, the total num b er of guesses for all h j i is b ounded by g c ≤ O ( ǫ − 2 c c c ), w h ere 1 ≤ j ≤ c . Therefore for all th e O ( ǫ − 2 ln n ) size classes the total n umb er of guesses for is b ounded b y n ǫ − 2 , which is a p olynomial of n , where c and ǫ are constant s. ✷ Since all the items in eac h size class ha ve the same p rofit and b y Lemma 2 we hav e h j i ≥ (1 − ǫ ) l j i , there exists one assignmen t wh ic h is feasible to B and k eeps at least (1 − ǫ ) times the p rofits. Next w e consider h o w to pac king items into eac h bin . P ac king each sublist in to eac h bin : In eac h bin, w e h a ve the follo wing p rop ert y max { w, h } min { w, h } ≥ ǫ − 4 , then the tec hniqu es us ed in [15 , 7 ] are helpfu l to pac k all sq u ares int o th e bins. First, w e first give an imp ortan t lemma for pac king squares in to a bin with large resource, called cutting te c hnique . Lemma 3 Given an input list L of squar e s with sides at most ǫ and two r e ctangular bins B 1 = (1 , a ) , B 2 = (1 + 2 ǫ, a ) , then (1 − 4 ǫ ) · O P T ( L, B 2 ) ≤ O P T ( L, B 1 ) , wher e O P T ( L, B ) is the optimal value for p acking list L into bin B . Pr o of. No w we construct a packing in bin B 1 from an optimal packing in bin B 2 and prov e its profit is at least (1 − 4 ǫ ) · O P T ( L, B 2 ). Consider an optimal pac king in bin B 2 , we cut B 2 in to ⌊ 1 4 ǫ ⌋ pieces of s lices, sa y S 1 , S 2 , . . . , S ⌊ 1 4 ǫ ⌋ resp ectiv ely , suc h that eve ry slice has an exact wid th 4 ǫ (except the last one), shown as fi g. 1. (Note that some squares ma y b e cut into t w o p arts, one part in S i and another part in S i +1 ). Then w e find ... 4ε Figure 1: C u tting bin B 2 in to slices a slice S i suc h th at p ( S i ) ≤ 4 ǫO P T ( L, B 2 ) and remo v e all squares c ompletely cont ained in slice S i if an y . Observe that after the ab o ve remov al, all squares remaining in bin B 2 can b e pac ke d into B 1 . Hence, O P T ( L, B 1 ) ≥ (1 − 4 ǫ ) · O P T ( L, B 2 ). ✷ 5 Lemma 4 [15] Ther e is an algorithm A which, given a list L of n squar e and a p ositive ǫ , pr o duc es a p acking of L in a strip of width 1 and height A ( L ) such that A ( L ) ≤ (1 + ǫ ) O pt ( L ) + O (1 /ǫ 2 ) . Lemma 5 F or p acking smal l squar es into a c onstant numb er of bins, for e ach bin, if max { w, h } min { w ,h } ≥ ǫ − 4 , then ther e is a p olynomial time algorithm with an output at le ast (1 − O ( ǫ )) O P T , wher e O P T is the optimal value. Pr o of. Giv en an in stance I = ( B , S ), wh ere S is the set of small s q u ares with profits and B = ( B 1 , B 2 , . . . , B c ) is the set of rectangular bin s , by the metho d in Lemma 1, w e guess a sub set S j ⊆ S suc h that S j has a feasible pac king in B and p ( S j ) ≥ (1 − O ( ǫ )) O P T ( I ). In an instance I p = ( B , S p ), we first guess h j i b y Lemma 2. Then according to h j i v alue w e assign the items to eac h bin and use the APT AS in Lemma 4 to pac k items in eac h bin, where 1 ≤ j ≤ c . If in eac h bin ( w , h ) the heigh t u s ed by th e APT AS in Lemma 4 is b ound ed by (1 + ǫ ) max { w, h } + O (min { w, h } /ǫ 2 ), then we keep the assignment otherwise reject the assignmen t. Since there is a S p suc h that S p has a f ea sible pac king in B . After all th e guesses, there is at least one assignment remained. F or the assignment, we apply the APT AS in Lemma 4 and the cutting tec hniqu es in Lemm a 3 suc h that in eac h bin , the pr ofit k eeps at least (1 − ǫ ) times the optimal v alue. Hence we ha ve this lemma. ✷ 3 Previous Algorithms for P ac king Squares Based on previous tec h niques used f or 2D pac king problem [1, 11] and the gr e e dy pac king (which is giv en in app endix), w e in tro duce a simple algorithm A 1 whic h is im p lied in [1, 11] for pac king a set of squares in to a bin (1 , h ), wher e h ≥ 1. There are t wo steps in A 1 : firs t group all squ ares by their sizes and guess one group wh ic h do es not significan tly affect the optimal pac king and delete it fr om the input list, then pac k large items b y enumeration, lastly app end small items in the “gap” of the bin. Next, w e giv e th e details of th e t wo steps. Grouping : F or an integ er k = ⌈ 1 ǫ ⌉ , wh ere ǫ < (2 h + 2 h 2 ) − 1 is sufficiently small and h ≥ 1 is the bin heigh t, w e select k p oints in the region (0,1], P 1 , . . . , P k as follo ws P i = ǫ 6 i and 1 ≤ i ≤ k . Then the in terv al (0,1] is divided into k + 1 interv als, I 1 , . . . , I k +1 , w here I i = ( P i , P i − 1 ], 2 ≤ i ≤ k , I 1 = ( P 1 , 1] and I k +1 = (0 , P k ]. Notation: In th e f oll owing, giv en a list L of s q u ares, L i denotes the list in wh ic h all square’s s ides are in in terv al I i , w ( L i ) d en ot es the total area of L i , p ( L i ) the total p rofits of L i , | L i | the num b er of squares in L i , where 1 ≤ i ≤ k + 1. P ac king: 1. Guess an in dex i su c h that O P T ( L − L i ) ≥ (1 − ǫ ) O P T ( L ). 2. Get all feasible pac king for L i − 1 ∪ · · · ∪ L 1 , p ac k eac h of them in to the b in , then partition the unco ve red space int o rectangular bins(b lo c ks) in the metho d [1] and app end L i +1 ∪ · · · ∪ L k +1 in to these b ins b y the Gr e e dy algorithm. 3. Output the on e with the largest profit. Since th ere are k + 1 su blists L 1 , . . . , L k +1 in L , then the guess in step 1 of A 1 is alwa ys f ea sible, where k = ⌈ 1 ǫ ⌉ . After selecting an index i , we define all items in L i − 1 ∪ · · · ∪ L 1 as lar ge items and 6 all items in L i +1 ∪ · · · ∪ L k +1 as smal l items. Note that if i = 1 then there are no lar ge items, and if i = k + 1 then th ere are no smal l items. A 1 ’s w orst case r ati o is r ela ted to the num b er of lar g e items in L opt and the rest area for small items, where L opt is a sublist of L to pr odu ce an optimal solution. F act 1 [1] Given large items with sides lar ger than ǫ 6 i − 1 which c an b e p acke d in the bi n (1 , h ) , and small items with sides at most ǫ 6 i , wher e i ≥ 1 , if the total ar e a of al l the squar es is at most h − ǫ 4 × 6 i − 1 − 1 , wher e 2 h (1 + h ) < ǫ − 1 , then al l c an b e p acke d in the bin. Lemma 6 [1, 11] After p acking lar ge items, if the r est ar e a in the bin is at le ast ǫ − 1 δ , then A 1 ( L ) ≥ (1 − 2 ǫ ) O P T ( L ) , wher e δ = ǫ 4 × 6 i − 1 − 1 . Lemma 7 [11] L et m b e the numb er of large items in L opt . i) A 1 ( L ) ≥ (1 − ǫ ) OP T ( L ) if m = 0 ; i i ) else A 1 ( L ) ≥ m m +1 (1 − ǫ ) O P T ( L ) . Lemma 8 [11] Algorithm A 1 is r an in p olynomial time of n . 4 Corner pac king T o p ac k squares into a rectangular bin, there are a lot of approac hes, the most tw o studies are NFDH [1] and BL . In this section, w e first giv e a n ew approac h, called Corner pac king, whic h includes the ab o v e t w o appr oa ches. T h en we analyze the c orner pac king late r and sho w that it is one of the k ey p oin ts for impr o vin g the w orse case ratio. During packing squares in to the rectangular b in, the u nco vered space of th e bin m a y get int o the rectilinear p olygons. The c orner packing (sho wn as in Fig. 5 (b )) can b e regarded as a sequence of pac king. Eve ry time when one square is pac ked in to the bin, we ob ey the follo wing rules: • select one verte x of the curr en t rectilinear p olygons at which the interior angle is 90 d eg rees, • p lac e the square su c h that one of its corners coincides with th e v ertex we selected. After pac king, w e get the new rectilinear p olygons. Note that b oth NFDH and BL [12] b elong to Corner p ac king, where BL pac king is to pac k squ ares in the bin as b ottom as p ossible then as left as p ossible. Lemma 9 Assume n squar es ar e p acke d in the bin by c orner p acking, then i) ther e ar e at most 4 + 2 n vertic es of al l the r e ctiline ar p olygons, ii) ther e ar e at most 2 n ( n + 1)! p ossibilities to p ack these n squ ar es in the bin by c orner p acking. (refer to the pro of in the app endix). 5 A Refined A lgorithm for Pa c king in to a Rectangular Bin Let m b e the num b er of lar g e items in L opt , where L opt is a su blist of L to get the optimal solution. By Lemma 7 , if m is very large, th en algorithm A 1 has a go o d p erform ance. So, to impro ve algorithm A 1 , we h a ve to stud y the case in wh ic h m is very sm all . Note that when the bin is a unit square, the situation b ecomes a relativ ely simple. Since when m = 1 we can transform the original pac king in to a sp ecial strip packi n g; when m = 2 , 3 w e can estimate there must b e m uch more space left for small squares than the waste d area. This is the main idea in Harren’s pap er[11]. If the b in is n ot longer a unit squ are, his algorithm do es not work v ery we ll. T o impr o ve algorithm A 1 , we are f ac ed with tw o problems: 7 • How to pac k a few large items such that the packi n g do es not affect to o m uch th e futu re small items p ac king? (how to allocate large items in the bin.) • How to p ac k small items in the gaps (r ec tilinear p olygons) generated after pac king large items? Next, we giv e ou r solutions for the ab o ve questions and p rop ose a refin ed algorithm called A 2 with the wo rst case r ati o 6 5 + ǫ . 5.1 P ack ing a few large items Recall that, giv en an i > 1, if a square’s side length is at least ǫ 6 i − 1 then it is called lar ge , else its sid e length is at most ǫ 6 i then it is called smal l . And there is a gap b et w een large items and small items, whic h is v ery imp ortant for pac king large items. Next we show that c orner pac king is a go o d pac king whic h do es n ot significan tly affect future s mall square pac king when th ere are a few large items. Lemma 10 L et m b e the numb er of large items in L opt . If m ≤ 4 , then (1 − ǫ ) O P T ( L ) ≤ O P T ( L, ∗ ) , wher e O P L ( L ) is the optimal value of p acking L into the bin and O P T ( L, ∗ ) is the optimal value of p acking L into the bin such that al l lar ge squar es ar e p acke d by corner pac king . Pr o of. Here, we just give the p r oof when m = 4, since th e pro of for m = 1 , 2 , 3 is inv olv ed. Let a, b, c, d b e the four large squares in an optimal pac king L opt . Without loss of generalit y assume a, b, c, d are placed in the bin as Fig. 2(1 ). Note that a large item has sid e at least ǫ 6 i − 1 and a small item has side at most ǫ 6 i , w here i ≥ 1. W e cut the bin into three parts, t w o rectangular b locks I = ( x 1 , y 1 ), I I = ( x 2 , y 2 ) and a rectilinear p olygo n P as shown as Fig. 2(2). No w w e define tw o new r ec tangular (1) (3) (2) a c b d II I c d a b I II c d a b I II Figure 2: An optimal p ac king vs. its corn er p ac king blo c ks I ǫ = ( x 1 + 2 ǫ 6 i , y 1 ) and I I ǫ = ( x 2 , y 2 + 2 ǫ 6 i ). Th en w e hav e O P T ( L, B ) ≤ O P T ( L, I ǫ ∪ I I ǫ ∪ P ) , (1) where O P T ( L, B ) is the optimal v alue of pac king L into the bin B and O P T ( L, I ǫ ∪ I I ǫ ∪ P ) is the optimal v alue of pac king L into three rectilinear p olygons I ǫ ∪ I I ǫ ∪ P . This can b e seen as follo ws, all squares pack ed into the bin B as shown in Fig. 2(1) can b e pac ked int o three rectilinear p olygons I ǫ ∪ I I ǫ ∪ P . By Lemma 3, for any list L of small s quares, we hav e (1 − 4 ǫ 6 i ) O P T ( L, I ǫ ) ≤ O P T ( L, I ) and (1 − 4 ǫ 6 i ) O P T ( L, I I ǫ ) ≤ O P T ( L, I I ) . Then (1 − 4 ǫ 6 i ) O P T ( L, I ǫ ∪ I I ǫ ∪ P ) ≤ O P T ( L, I ∪ I I ∪ P ) . (2) 8 So, by (1), (2), (1 − 4 ǫ 6 i ) O P T ( L, B ) ≤ O P T ( L, I ∪ I I ∪ P ) . And w e hav e O P T ( L, I ∪ I I ∪ P ) ≤ O P T ( L, ∗ a ), w here O P T ( L, ∗ a ) is the optimal v alue of pac king L in to the bin with a at on e corner, shown as in Fig. 2(3). Hence (1 − 4 ǫ 6 i ) O P T ( L, B ) ≤ O P T ( L, ∗ a ) . (3) By the similar pro of, w e h a ve (1 − 4 ǫ 6 i ) O P T ( L, ∗ a ) ≤ O P T ( L, ∗ ab ) and (1 − 4 ǫ 6 i ) O P T ( L, ∗ ab ) ≤ O P T ( L, ∗ abc ) , (1 − 4 ǫ 6 i ) O P T ( L, ∗ abc ) ≤ O P T ( L, ∗ abcd ) where O P T ( L, ∗ X ) is the optimal v alue of pac king a set X int o th e bin with all the items in X at corners of the b in. Th erefore, we hav e O P T ( L, ∗ abcd ) ≥ (1 − 4 ǫ 6 i ) 4 O P T ( L, B ) ≥ (1 − ǫ ) O P T ( L, B ) . The last inequalit y follo ws f rom ǫ ≤ 1 / 2. Hence, this lemma holds. ✷ 5.2 P ack ing small items in to rect ilinea r p olygons After pac king large items, the un co vered space in the bin may b e a set of rectilinear p olygons. Our strategy for pac king small squares in to the p olygons are b elo w: • Dissect the p olygons into rectangular blo c ks suc h that th e optimal v alue of packing sm all squ ares in to the b locks is at least (1 − ǫ ) OP T p , wh er e O P T p is the optimal v alue for pac king sm all squ ares in to the p olygons. • T o p ac k small items in to blo c ks, we use the P T AS in S ec tion 2 of p ac king squares in to rectangular bins with large resources. Dissection: After packi n g few large squares int o th e bin b y c orner pac king, we dissect the recti- linear p olygons in to r ect angular blo c ks, such that the dissection do es not affec t the optimal pac king insignifican tly . Lemma 11 If ther e ar e at most 4 lar ge squar es p acke d, and the total ar e a of the lar ge squar es p acke d is at le ast h − ǫ 4 × 6 i − 1 − 2 , then ther e exist a disse ction of the p olygons (the unc over e d sp ac e of the bin) into blo cks such that O P T b ≥ (1 − ǫ ) O P T p , wher e O P T b ( O P T p ) is the optimal value of p acking smal l squar es into blo cks (p olygons). Pr o of. In this pro of, w e ju st giv e our d issect ion for f ou r large squ ares pac ke d, shown as in Fig. 3 and 4 (b y dotted lines), since the num b er of large squ ares is less than 4, we hav e the similar dissection. Except for case (d), if the rectilinear p olyg ons are dissected into blo c ks as shown in Fig. 3, then w e ha ve a s et of five r ectangular b loc ks B = { B i } , where B i = ( w i , h i ) and w i ≤ h i for 1 ≤ i ≤ 5. (Otherwise w e can exc h an ge w i and h i ) Using the same tec hniqu es in Lemma 10, we define a n ew set of five blo c ks B ′ = { B ′ i } , where B ′ i = ( w i , h i + 2 ǫ 6 i ) for 1 ≤ i ≤ 5. Let P b e th e p olygon(s) after 9 00000 00000 00000 00000 11111 11111 11111 11111 000000 000000 000000 000000 111111 111111 111111 111111 000000 000000 000000 000000 000000 111111 111111 111111 111111 111111 000000 000000 000000 000000 000000 111111 111111 111111 111111 111111 0000000 0000000 0000000 0000000 0000000 0000000 1111111 1111111 1111111 1111111 1111111 1111111 0000000 0000000 0000000 0000000 0000000 1111111 1111111 1111111 1111111 1111111 0000 0000 0000 1111 1111 1111 0000 0000 0000 1111 1111 1111 0000000 0000000 0000000 0000000 0000000 0000000 1111111 1111111 1111111 1111111 1111111 1111111 0000 0000 0000 1111 1111 1111 000 000 000 111 111 111 000 000 111 111 00000 00000 00000 00000 11111 11111 11111 11111 0000 0000 0000 1111 1111 1111 0000 0000 0000 1111 1111 1111 0000 0000 0000 1111 1111 1111 000 000 111 111 000 000 111 111 000 000 111 111 00 11 (a) (b) (c) (d) (e) Figure 3: Possible p ac king S 1 S 1 S 2 S 2 S 3 S 3 S 4 S 4 B 1 B 1 B 2 B 2 B 3 B 3 B 4 B 4 B 5 h h 1 1 (d1) (d2) Figure 4: T wo p ossibilities for the case (d) pac king large squares in the bin, and L b e a list of small squares. Since eac h sm all square h as side length at most ǫ 6 i , we h a ve O P T ( L, B ′ ) ≥ O P T ( L, P ) ≥ O P T ( L, B ) , where OPT(L,X) is the optimal v alue for pac king L into X . S ince eac h large sq u are has sid e length at least ǫ 6 i − 1 and h i ≥ w i , we ha ve h i ≥ ǫ 6 i − 1 . By Lemma 3, w e hav e O P T ( L, B ) ≥ (1 − ǫ ) O P T ( L, B ′ ) . Hence w e h av e O P T b = O P T ( L, B ) ≥ (1 − ǫ ) O P T ( L, P ) = (1 − ǫ ) OP T p . Next, w e study the case (d) of Fig. 3 and pr ov e that our strategy shown in Fig. 4 still w orks. There are t wo p ossibilitie s for th e case (d). W e assign S 1 , S 2 , S 3 , S 4 to the four large squares as sho wn in Fig. 4, where S i = ( s i , s i ). And the p olygon is dissected into 5 b lo c ks B 1 , . . . , B 5 , where B i = ( w i , h i ). F rom our dissections in Fig. 4, (by dotted lines), w e ha ve max { w i , h i } ≥ ǫ 6 i − 1 , for 1 ≤ i ≤ 4 . And since the total area of the large items in the bin is at least h − ǫ 4 × 6 i − 1 − 2 , i.e., the total area of the blo c ks is at most ǫ 4 × 6 i − 1 − 2 . W e hav e min { w i , h i } ≤ ǫ 4 × 6 i − 1 − 2 ǫ 6 i − 1 ≤ ǫ 2 × 6 i − 1 . The last inequalit y follo ws f rom i ≥ 2. 10 Let δ = ǫ 6 i − 1 , next w e pr ov e th at w 5 ≤ δ 2 in the cases (d1) and (d2). It is trivial to see w 5 ≤ δ 2 in the case (d1), since w 5 ≤ w 1 = min { w 1 , h 1 } . No w, we consider the case (d2), since s 1 + s 2 ≤ 1 an d s 1 − s 2 ≤ h 4 ≤ δ 2 , we ha v e s 1 ≤ 1 + δ 2 2 . Since s 3 + s 4 ≤ 1 and s 4 − s 3 ≤ h 2 ≤ δ 2 , we ha ve s 4 ≤ 1 + δ 2 2 . So, w 5 = s 1 + s 4 − 1 ≤ 1 + δ 2 − 1 = δ 2 . Therefore, we h av e in the cases (d1) and (d2), w 5 ≤ δ 2 ≤ ǫw 4 and h 5 ≤ h 4 , i.e., to compare with blo c k B 4 , b loc k B 5 is s ufficien tly small and can b e ignored. S o O P T ( S, B − ) ≥ (1 − O ( ǫ )) OP T ( S, B ) , where S is the set of small squares, B − = ∪ 4 i =1 B i , B = ∪ 5 i =1 B i . Hence when w e pac k small squares in to b loc ks ∪ 5 i =1 B i , we just consider ∪ 4 i =1 B i . T hen by the similar pro of f or other cases, we ha ve O P T b ≥ (1 − O ( ǫ )) OP T p . Hence, this lemma holds. ✷ 5.3 Algorithm A 2 and it s analysis Next, we giv e the details of algorithm A 2 whic h is similar to A 1 . Description of Algorithm A 2 1. Group items and guess an index i su c h that O P T ( L − L i ) ≥ (1 − ǫ ) OP T ( L ) and divide the remaining in to t wo classes, sa y lar ge and smal l , 2. Get all f ea sible pac king of L i − 1 ∪ · · · ∪ L 1 , f or eac h of them, (a) if there are at least 4 items or the total area of items is at most h − ǫ 4 × 6 i − 1 − 2 , then p ac k large an d small squares by algorithm A 1 . (b) else lo cate large items as Fig. 3 and divide the gaps in to blo c ks as Fig. 3 and 4, lastly app ly the m et h o d in Lemma 5 for smal l items. 3. Output the on e with the largest profit. Theorem 1 F or any input list L , O P T ( L ) A 2 ( L ) ≤ 6 5 (1 + O ( ǫ )) , wher e ǫ is sufficiently smal l. Pr o of. T o consider an optimal pac king solution L opt , if there are at least 5 large items in L opt or th e total area of large items in L opt at most h − ǫ 4 × 6 i − 1 − 2 , by F act 1, L emm as 6 and 7, A 2 ( L ) ≥ 5 6 (1 − 2 ǫ ) OP T ( L ) . Else, the total area of the large items in th e bin is at least h − ǫ 4 × 6 i − 1 − 2 and there are at most 4 pac k ed. 11 By the dissection of th e p olygo ns into rectangular blo c ks, sho wn as in Fig. 3 and 4, in eac h blo c k ( w, h ), w e make sur e that m ax { w , h } ≥ ǫ 6 i − 1 . S o, max { w, h } min { w, h } ≥ max { w, h } ǫ 4 × 6 i − 1 − 2 ǫ 6 i − 1 ≥ ǫ 2 × 6 i − 1 ǫ 4 × 6 i − 1 − 2 ≥ ǫ − 4 . The last inequalit y follo ws from i ≥ 2. (rememb er wh en i = 1, there is no large item.) By Lemmas 10, 5, we hav e A 2 ( L ) ≥ (1 − O ( ǫ )) O P T ( L ) By Lemm a 8, the time complexit y of Algorithm A 2 is a p olynomial time of n . Hence, this theorem holds. ✷ 6 Concluding remarks Note that algorithm A 2 can b e exp ended to multi-dimensional cub e packi n g. References [1] N. Bansal, J.R. Correa, C. K eny on M. S viridenk o, Bin pac king in multiple dimensions: I nappro x- imabilit y results and appro ximation sc hemes, M ath ematics of Op er ations R e se ar ch 31(1), 31–49, 2006 (SOD A 2004). [2] A. Caprara and M. Monaci, On the tw o-dimens ional knapsac k problem, Op er ations R ese ar ch L etters 32:5-14, 2004. [3] C. Chekuri and S. Kh anna, A p olynomial time app ro xim ation s c h eme for the multiple kn apsac k problem, SIAM J. Comput . 35(3): 713-72 8, 2005. [4] L. Epstein and R. v an Stee, Optimal onlin e b ound ed space multidimensional packing, SODA 207-2 16, 2004. [5] W.F ern an d ez de la V ega and G.S. Lu ek er, Bin packing can b e solv ed within 1 + ǫ in linear time. Combinatoric a , 1(4): 349-355, 1981 [6] C.E. F erreira, E.K. Miyaz a wa, and Y. W ak aba y ashi, Pac king squares into squ ares, Pesqu isa Op- er acional 19:223-237 , 1999. [7] A. V. Fishkin, O. Gerb er and K. Jansen, On w eight ed r ect angle pac king with big resources, Pr o c e e dings of the 3r d IFIP International Confer enc e on The or etic al Computer Scienc e , 237-250, 2004. [8] A. V. Fishkin , O . Gerb er and K. Jan s en, R. S olis- Ob a, P ac king w eigh ted rectangle s int o a square, MFCS pp.352-363, 2005. [9] Xin Han, Deshi Y e and Y ong Zhou, Imp ro v ed Online Hyp ercub e P ac king, Pr o c. the F ourth Work- shop on A ppr oximation and Online Algo rithms , L NCS 4368:2 26-239, 2006. [10] X. Han, K. Iwa ma and G. Zhang, Online remo v able square p acking, Pr o c. the Thir d Workshop on Appr oximation and Online Algorithms , 2005. [11] R. Harren, Approximati n g the Orthogonal Knapsack Problem for Hyp ercub es, ICALP (1) 2006 , 238-2 49. [12] K . Jansen and G. Z hang, On rectangle pac king: maximizing b enefits, SODA , 204-213, 2004. 12 [13] K . Jansen and G. Z hang, Maximizing the num b er of p ac ked rectangles, SW A T , 362-371, 2004. [14] H. Kellerer. A Po lynomial Time App ro ximation Sc heme for the Multiple Kn apsac k Problem. RANDOM- APPR OX 51-62, 1999. [15] C . Keny on, E. R´ emila, A Near-Optimal Solution to a Tw o-Dimensional Cutting Sto c k Prob lem, Mathematics of Op er ations R ese ar c h , 25(4): 645-65 6, 2000. [16] Y. Kohay ak a w a, F.K. Miy aza wa , P . Ragha v an , and Y. W ak abay ashi, Mu ltidimensional cub e pac king, Algorithmic a , 40(3) 173-187,20 04. [17] J .Y.- T. Leun g, T .W. T am, C.S. W ong, G.H. Y oung, and F.Y.L. Chin, P ac king sq u ares int o a square, J. Par al lel Distrib. Comput. , 10:271-27 5, 1990. [18] A.Meir and L. Moser, On p ac king of squ ares and cub es, Journal of c ombinatorial the ory , 5:126- 134, 1968. [19] S .S. Seiden and R. v an Stee, New b ounds for m ultidimensional pac king, Algorithmic a 36:261-2 93, 2003. 13 7 App endix 7.1 The pro of for Lemma 9 Pr o of. W e use in d uction to p ro ve part i). When n = 0, there are 4 v ertices in the bin . When n = 1, there are at most 6 vertice s in the rectilinear p olygon. So, w e assume that wh en n = k , p art i) holds, i.e., after pac king k items in the b in, there are at most 4 + 2 k vertic es in the rectilinear p olygons. When n = k + 1, w e use one of 4 + 2 k vertice s and generate at most 3 vertice s, hence the total n umb er of v ertices is at m ost 4 + 2 k − 1 + 3 = 4 + 2( k + 1) . Then w e can see there are at m ost 4 + 2( i − 1) w a ys to pac k the i -th squ are, wher e i ≥ 1. Hence to pac k n items in the bin, there are at most n Y i =1 (4 + 2( i − 1)) = 2 n n Y i =1 ( i + 1) = 2 n ( n + 1)! p ossibilities. ✷ 7.2 NFDH packi ng NFDH (Next Fit Decreasing Height) [18]. NFDH pac king b eha ve s as follo ws: First sort all squares by their heigh ts, then p ack them in the bin from the largest one lev el by lev el as sh o wn in Fig. 5(a). In eac h lev el, pac k them b y Next Fit, n amely , if the curren t lev el cannot accommo date the next item, then op en a new with heigh t equal to the current item’s heigh t. W e rep eat this pro cedure, u n til there is no space for a n ew level in th e bin. Here is a k ey pr operty of NFDH . 0000 0000 0000 0000 0000 0000 0000 0000 1111 1111 1111 1111 1111 1111 1111 1111 00 00 00 00 11 11 11 11 00 00 00 00 11 11 11 11 0 0 1 1 000 000 000 000 000 111 111 111 111 111 00 00 00 00 11 11 11 11 00 00 00 00 11 11 11 11 0000000000 1111111111 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 11111 11111 11111 11111 11111 11111 11111 11111 11111 11111 11111 00 00 00 00 11 11 11 11 000 000 000 000 000 000 111 111 111 111 111 111 000 000 000 000 000 000 111 111 111 111 111 111 00000 00000 00000 00000 00000 00000 00000 00000 00000 00000 11111 11111 11111 11111 11111 11111 11111 11111 11111 11111 00000 00000 00000 00000 00000 00000 00000 00000 11111 11111 11111 11111 11111 11111 11111 11111 0000 0000 0000 0000 0000 0000 0000 0000 1111 1111 1111 1111 1111 1111 1111 1111 000 000 000 000 000 000 111 111 111 111 111 111 00 00 00 00 00 11 11 11 11 11 (a) (b) level 3 level 2 level 1 Figure 5: NFDH and C orn er pac king Greedy Algorithm 1. Sort the in put list L su c h that p ( A 1 ) w ( A 1 ) ≥ · · · ≥ p ( A k ) w ( A k ) . 2. F or i from 1 to n do if ( a i ≥ ǫ ) and ( b i ≥ ǫ ) then (a) Find a maximal index m su c h that ( A 1 , A 2 , ..., A m ) can b e pac ked into the current bin b y NFDH an d pac k ( A 1 , A 2 , ..., A m ) in to ( a i , b i ). (b) Then u p d ate list L and re-index L . If L b ecomes emp t y then finish pac king. 14

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment