Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

download Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

of 20

Transcript of Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    1/20

    DOI: 10.1007/s00453-006-0194-5

    Algorithmica (2007) 47: 323342

    Algorithmica 2007SpringerScience+BusinessMedia,Inc.

    Maximizing the Total Profit of RectanglesPacked into a Rectangle1

    Klaus Jansen2 and Guochuan Zhang3

    Abstract. We consider the following rectangle packing problem. Given a set of rectangles, each of which

    is associated with a profit, we are requested to pack a subset of the rectangles into a bigger rectangle so that

    the total profit of rectangles packed is maximized. The rectangles may not overlap. This problem is strongly

    NP-hard even for packing squares with identical profits. We first present a simple (3 + )-approximationalgorithm. Then we consider a restricted version of the problem and show a (2 + )-approximation algorithm.This restricted problem includes the case where rotation by 90 is allowed (and is possible), and the case ofpacking squares. We apply a similar technique to the general problem, and get an improved algorithm with

    a worst-case ratio of at most 5/2 + . Finally, we devise a (2 + )-approximation algorithm for the generalproblem.

    Key Words. Rectangle packing, Approximation algorithms.

    1. Introduction. Bin packing is one of the fundamental problems in combinatorial

    optimization and computer science. The one-dimensional bin-packing problem has been

    extensively studied. Hundreds of research papers have appeared and there are still in-

    coming results in this area. The existence of asymptotic (fully) polynomial time approx-

    imation schemes was settled by Fernandez de la Vega and Lueker [5] and Karmarkar

    and Karp [11]. The FFD algorithm (First Fit Decreasing) was shown to be a best possi-

    ble algorithm in terms of the absolute worst-case ratio [20]. To overview the results on

    one-dimensional bin packing we refer the reader to an excellent survey given by Coff-

    man et al. [4]. In contrast, there exist many open problems for multiple-dimensional bin

    packing. In general, there are three versions extending the one-dimensional bin-packingproblem. We take two-dimensionalbin packing as an example.The first version is rectan-

    gle packing, which requires packing a set of rectangles without overlap into the minimal

    number of unit squares. The second version is called vector packing, where each item

    corresponds to a two-dimensional vector (xi , yi ) (xi , yi 1) and a bin corresponds tothe vector (1, 1). A number of items can be put into a bin if the sum of the vectors is

    bounded by (1, 1). The goal is to pack the items such that the number of bins used is

    1 A preliminary version was presented at the ACMSIAM Symposium on Discrete Algorithms (SODA) 2004.2 Institut fur Informatik und Praktische Mathematik, Universitat Kiel, Olshausenstr. 40, D-24098, Kiel, Ger-

    many. [email protected]. Research supported in part by the EU-Project CRESCCO, IST-2001-33135,

    EU-Project APPOL II, IST-2001-32007, and EU-Project ARACNE, HPRN-CT-1999-00112.3 Department of Mathematics, Zhejiang University, Hangzhou 310027, China. [email protected]. Research

    supported in part by the Alexander von Humboldt Foundation, the EU-Project CRESCCO, IST-2001-33135,andNSFC (10231060, 60573020). Theworkwas done whilevisiting theInstitutfur Informatik und Praktische

    Mathematik, Universitat Kiel, Germany.

    Received October 3, 2003; revised December 1, 2004, and February 15, 2005. Communicatedby A. Panconesi.

    Online publication March 13, 2007.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    2/20

    324 K. Jansen and G. Zhang

    minimum. The third one is called strip packing. In this version a set of rectangles is

    packed into a strip with a width of 1 and an infinite height. The goal is to minimize

    the height of the strip where the items can reach. Lodi and coworkers [15], [16] gave

    overviews of two-dimensional bin packing.

    In this paper we consider a rectangle packing problem to maximize the total profit.

    We denote a rectangle by a pair (height, width). In our problem we are given a set of

    rectangles Ri = (ai , bi ), i = 1, . . . , n. Each rectangle is associated with a profit pi .The goal is to pack a subset of rectangles into a bigger rectangle R = (a, b) such thatthe total profit of the packed rectangles is maximized. The rectangles may not overlap.

    Without loss of generality we assume that a b and that, for all i , ai a and bi b.Depending on some further restrictions below, different variants are obtained. In the

    general problem, denoted by RP, the rectangles may not be rotated. If rotation of 90 isfeasible, which means that rotation is allowed and max{ai , bi } min{a, b} for all i , theproblem is called RRP. Problem SP is to pack squares into a rectangle.

    Problem RRP was investigated as a cutting stock problem [2]. However, only exact

    algorithms were studied. To thebest of ourknowledge there areonly a few approximation

    results for special cases of the rectangle packing problem. Hochbaum and Maass [8]presented a PTAS applying a shifting technique to many geometric problems. One of

    the problems is packing a maximum number of identical squares into a rectangular grid.

    Baker et al. [1] showed an approximation algorithm with an asymptotic ratio of 4/3 for

    packing a maximum number of squares into a rectangle. Our paper is the first to deal

    with approximation algorithms for the general rectangle packing problem.

    The rectangle packing problem is motivated by scheduling parallel jobs with a com-

    mon due date to maximize the profit of accepted jobs (completed by the due date), where

    each job may require several processors consecutively allocated on a line. The problem

    also has applications in the advertisement placement problem on a board. Consider a

    rectangular board in which advertisements may be placed. Each advertisement appears

    as a rectangle with a height and a width and is associated with a profit. The problem is to

    maximize the total profit of the advertisements placed on the board without any overlap.

    If we regard the bigger rectangle R as a knapsack, the problem becomes a variant ofthe two-dimensional knapsack problem. Note that it is different from the well-defined

    two-dimensional knapsack problem in the literature (see [17], [18], and [14]), in which

    each item is associated with two parameters, say weight and volume, and the sum of

    weights and the sum of volumes of the items packed in the knapsack are bounded by the

    weight capacity and the volume capacity of the knapsack, respectively.

    Recently, Freund and Naor [6] dealt with an advertisement placement problem in-

    volving both space and time sharing. In this problem there is a set of advertisements that

    must be displayed in a shared display area. Several small advertisement may be packed

    into the display area and displayed simultaneously. The display is dynamic, meaning

    that its contents change every time unit (e.g., a banner on a Web page), cycling through

    a schedule of advertisements. The length of this schedule is fixed. Each advertisement

    has a display count specifying how many times it must be displayed within the schedule.

    The goal is to maximize the total profit of the accepted advertisements. In this problemeach advertisement has the same height, which equals the height of the display area, so

    the packing is one-dimensional (spatially). It is a generalization of the one-dimensional

    multiple knapsack problem. A (3 + )-approximation algorithm was derived.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    3/20

    Maximizing the Total Profit of Rectangles Packed into a Rectangle 325

    In this paper we first present an approximation algorithmwith performance ratio 3+,which is obtained by solving a one-dimensional knapsack problem and using Steinbergs

    algorithm [21]. We want to remark that an independent paper by Caprara and Monaci

    [3] achieved the same result. To improve the bound of 3+

    , we generalize Steinbergs

    theorem and derive an approximation algorithm with a performance ratio of at most

    2 + for a restricted problem (that contains RRP and SP). This algorithm is based onsolving a polynomial number of one-dimensional knapsack problems. Then we provide

    an algorithm with a performance ratio no more than 5/2 + for the general problemRP, based on solving a set of three-dimensional knapsack problems. Finally, we obtain

    a more theoretical approximation algorithm, which gives a worst-case ratio of at most

    2 + .The remainder of the paper is organized as follows. Section 2 presents some related

    results on strip packing which will be employed by our algorithms. In Section 3, using

    Steinbergs algorithm, a simple 3-approximation algorithm for the general problem RP

    is given. We further show preliminary ideas to improve the bound. Section 4 considers

    a restricted problem by providing a better algorithm with a performance ratio of at most

    2+ . An improved algorithm for Problem RP is presented in Section 5. Section 6 showsa (2 + )-approximation algorithm. Section 7 gives some concluding remarks.

    2. Preliminaries and Notations. For convenience, we often refer to the rectangles Rias items, and to the larger rectangle R as the bin. We denote the area of rectangle Riby si (i.e., si = ai bi ), and the area of R by C (i.e., C = ab). For a set T of items, wedenote by p(T) and by s(T) the total profit and total area, respectively, of the items in

    T. Finally, we distinguish items as either tall, wide, big, or small, as follows. Item Ri is

    tall ifai > a/2 and bi b/2; it is wide ifbi > b/2 and ai a/2; it is big ifai > a/2and bi > b/2; and it is small ifai a/2 and bi b/2.

    Our problem asks for a subset of items which forms a feasible packing (can be

    packed into R without overlap) and maximizes the total profit. We can use strip packing

    algorithms to check if a carefully selected subset of items can be packed into a bin. Thefollowing theorem/algorithm is used throughout this paper.

    STEINBERGS THEOREM [21]. For any number x , let x+ denote max{x, 0}. Let aL =maxi ai , bL = maxi bi , and SL =

    i ai bi . There exists an efficient algorithm that

    successfully packs the items in the bin whenever the following inequalities hold:

    aL a, bL b, and 2SL ab (2aL a)+(2bL b)+.

    The running time of the algorithm is O(n log2 n/loglog n).

    REMARK. It follows that if the height (resp. width) of every rectangle is at most a/2

    (resp. b/2), then any subset of rectangles with total area at most ab/2 can be packed

    into (a, b).

    Leung et al. [13] proved that the problem of determining whether a set of squares can

    be packed into a bigger square or not is strongly NP-complete. Therefore it is NP-hard in

    the strong sense to pack squares into a square for maximizing the number of the squares

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    4/20

    326 K. Jansen and G. Zhang

    packed. This implies that a very special case is already strongly NP-hard. We concentrate

    on finding approximation algorithms. To evaluate an approximation algorithm, we use

    the standard measure Performance Ratio, which is defined for maximization problems as

    RA = supI

    OPT(I)/A(I),

    where OPT(I) and A(I) are the optimal value and the objective value given by an ap-

    proximation algorithm A for any instance I, respectively. An algorithm A is called a

    -approximation algorithm ifOPT(I)/A(I) for any instance I. We sometimes useOPT instead ofOPT(I) when no confusion is caused.

    3. A (3+)-Approximation Algorithm. To design an approximation algorithm, we

    first find a subset of items, the total profit of which is close to an upper bound on the

    optimal value. Then we try to pack as many items from the subset as possible. Namely,

    we consider the following knapsack problem. (Recall that ai , bi , and pi are the height,

    width, and profit, respectively, of item Ri , and that a and b are the height and the width,

    respectively, of the bin.)

    KNAPSACK PROBLEM K P . Given a knapsack with capacity C = a b and a set ofitemsci (i = 1, . . . , n), where the size of item ci is ai bi and its profit is pi , find a subset ofitems whose total size is at most C and whose total profit is maximized.

    The knapsack problem admits an FPTAS [9], [12]. The running time of the FPTAS

    given by Kellerer and Pferschy [12] is

    O(n min{log n, log(1/)} + (1/2) min{n, (1/) log(1/)}).We useit to geta subsetof items, without loss of generality c1, . . . , cm (m n), satisfying

    mi=1 ci C and (1 + )

    mi=1 pi OPT1, where is any given small positive number

    and OPT1 is theoptimalvalue of theknapsack problem. Consider items Ri (of the originalproblem) corresponding to these m items ci . Adopting the results of Steinberg [21], they

    can be packed into a rectangle (a, 2b). Split this rectangle into two (a, b) rectangles.

    The items completely contained in each of these rectangles are properly packed, and the

    remaining items (i.e., the items crossing the dividing line) clearly can also be packed in

    an (a, b) rectangle. See Figure 1 for an illustration.

    a

    b b

    The first half ofbin (a, 2b)

    The second half ofbin (a, 2b)

    Fig. 1. Illustration of the (3 + )-approximation algorithm.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    5/20

    Maximizing the Total Profit of Rectangles Packed into a Rectangle 327

    The algorithm can be summarized as follows.

    ALGORITHM H1. Solve the knapsack problem with an FPTAS. Pack the resulting items

    into an (a, 2b) bin using Steinbergs algorithm. Split the bin and pack the items selected

    by the FPTAS into three (a, b) bins as described above. Choose the most profitable bin

    of the three.

    Algorithm H1 employs an FPTAS for the knapsack problem and the algorithm of

    Steinberg. We use the FPTAS given by Kellerer and Pferschy [12]. The running time of

    algorithm H1 is therefore O(n min{log n, log(1/)} + (1/2) min{n, (1/) log(1/)} +n log2 n/loglog n).

    THEOREM 1. The performance ratio of algorithm H1 is 3 + .

    PROOF. For any given small positive number , let 1 = /3. Let OPT1 be the opti-mal value of the knapsack problem. Clearly OPT1 is an upper bound on the optimum

    value OPT of the original rectangle packing problem (RP). Solve the knapsack problemwith an FPTAS such that the total profit of accepted items is at least OPT1/(1 + 1).From algorithm H1, the total profit of the items in the final feasible packing is at

    least OPT1/3(1 + 1). Therefore the performance ratio of Algorithm H1 is at most3(1 + 1) = 3 + .

    The following instance shows that the bound 3 is tight (even for SP): There are

    three large squares, each with an area of 13

    (the side length is

    3/3) and a profit of13

    . The remaining squares are small enough, each with an area of 2/(3k) and a profit

    of 2/(3k) 1/k2, where k is a sufficiently large positive integer. Obviously, when anapproximation algorithm is good enough, the corresponding knapsack problem will

    output the three large squares (items). Note that two large squares cannot be packed into

    a (1, 1) square. It implies that algorithm H1 can only provide a packing with total profit

    of 1

    3. However, the optimal packing will include one large square and many small squares

    (which can be packed into a (1, 1) square such that the square is almost full). Thus the

    optimal value can be arbitrarily close to 1.

    Clearly Algorithm H1 also works for Problem RRP and the above bound remains

    valid. The instance for the lower bound in Theorem 1 tells us that in order to improve

    Algorithm H1 we have to pre-select the rectangles more carefully than just to solve

    the knapsack problem. In the following, before developing strategies to improve the

    algorithm, we first see when a set of items admits a feasible packing.

    LEMMA 2. If the total area of a set T of items is at most C/2 and there are no tall items

    (or there are no wide items), then the items in T can be packed into a bin.

    PROOF. Assume that there are no tall items (the case without wide items can be proved

    analogously). If there is no big item, the lemma follows from Steinbergs theorem.

    Otherwise, we only need to consider the case with one big item. We present a packing

    and show that it is feasible.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    6/20

    328 K. Jansen and G. Zhang

    ...........................

    the big item

    the wide items

    Tl

    Ts

    Fig. 2. A feasible packing.

    Let x be the total height of the big item and the wide items. Clearly, x < a since

    s(T) C/2. Among the items of T, let Tl be the set of small items with height largerthan a x and let Ts be the set of small items with height at most a x . Place the bigitem in the lower left corner of the bin, and stack the wide items on top of it. Place the

    items ofTl side by side to the right of the big item, and pack the items ofTs into the freearea above the wide items. This free area is a rectangle with height a x and width b,and the packing is done using Steinbergs algorithm. Figure 2 gives an illustration of the

    packing.

    We now prove the feasibility of the above packing. Let abig and bbig be the height

    and the width of the big item, respectively. If the total width of items in Tl is larger than

    b bbig, then s(Tl ) > (b bbig)(a x). Since the total area of the big item togetherwith the wide items is at least abigbbig + (x abig)b/2, we get

    s(T) > abigbbig + (x abig)b/2 + (b bbig)(a x)= ab/2 + (abig + x a)(bbig b/2)> C/2,

    a contradiction. Therefore, the total width of items in Tl is at most b bbig, and they canbe packed to the right of the big item. Turning to Ts , observe that s(Ts ) < C/2xb/2 =(a x)b/2. In other words, the total area of items in Ts is less than half the area of arectangle (a x, b). The width of any item in Ts is at most b/2 (they are small items).Using Steinbergs theorem the items can be packed into the free area of the bin.

    Motivated by Lemma 2, it is reasonable to separate wide items and tall items before

    constructing a packing.

    4. A Restricted Problem. In this section we consider the restriction of Problem RP

    in which there are no tall items (or no wide items). It is easy to see that Problem SP is

    such a restricted problem, since b a (so there are no wide items). For Problem RRP,rotation of 90 is feasible, so tall items can be transformed into wide items. However, theoptimal solutions may also differ. At the end of this section we show that the algorithmic

    results hold for RRP too.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    7/20

    Maximizing the Total Profit of Rectangles Packed into a Rectangle 329

    Without loss of generality, let us assume that there are no tall items. We describe an

    algorithm with three phases.

    I. Pre-Selecting Items. Let N > 0 be a fixed integer (constant). Try all possibilities

    to pack up to N 1 items. Denote by P1 the value of the best packing among all thesepossibilities. Next, find all feasible packings with exactly N items. If no such packing

    exists, then P1 gives the optimum value. Otherwise, denote by X the set of feasible

    packings with exactly N items. The set of items involved in a feasible packing is called

    a candidate. Let |X| be the number of candidates in X.

    LEMMA 3. If an optimal packing contains at least N items, then the N most profitable

    items in that packing form one candidate of X.

    PROOF. It is obvious because the N items admit a feasible packing.

    II. Finding an Upper Bound for the Optimal Value. For each candidate Sj

    of X (j=1, . . . , |X|), we try to add more items with smaller profits such that the items form a

    nearly optimal solution of the following knapsack problem. Let c be the total area of

    items in Sj . Denote by Lj the set of items which are not included in Sj and have profits

    no larger than the profit of any item in Sj . Without loss of generality, denote the items

    of Lj by R1, . . . , Rkj . In the following integer program we also use Ri to represent the

    0-1 variables if no confusion is caused, where

    Ri =

    1, if Ri is accepted,

    0, otherwise.

    RESTRICTED KNAPSACK PROBLEM RKP (recall that si is the area of item Ri ).

    max p(Sj ) +kj

    i=1piRi

    s.t.

    kji=1

    siRi ab c

    Ri {0, 1}.

    Note that we have defined |X| integer programs. Let P2 be the profit of the best solutionamong these integer programs. The corresponding integer program is denoted I andthe corresponding candidate is denoted S.

    LEMMA 4. The best solution among the

    |X

    |integer programs gives an upper bound on

    the optimal solution of the restricted problem, i.e., P2 OPT.

    PROOF. Any optimal packing is also a feasible solution of one of the integer

    programs.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    8/20

    330 K. Jansen and G. Zhang

    Recall that the knapsack problem admits an FPTAS [12]. For any given > 0,

    there exists a polynomial time algorithm for I which results in a solution with profitP2 P2 /(1 + /2). If the total profit p(S) of items in S is at least P2/2, we stop andoutput the feasible packing of S. Clearly, this packing is a solution with profit at leastOPT/(2 + ), implying a performance ratio of no more than 2 + . Thus, it remains toconsider the case p(S) < P2/2. Let L be the set of the items in S together with theitems accepted by I. The number of items in L is more than N. Next we partition L

    into two subsets and try to pack almost all items of each subset into a bin.

    III. Partitioning and Packing the Items. Consider L. Put all items of S into a subsetT1. If the total area of the items of S

    is at least C/2, put all the remaining items of L

    into a subset T2. (In this case, p(T1) = p(S) < P2/2 and s(T1) = s(S) C/2, thenp(T2) > P2/2and s(T2) C/2.Thuswegetaperformanceratioof2 + withthe feasiblepacking ofT2 by Lemma 2.) Otherwise, sort the remaining items in non-increasing order

    of their profits. Take the items one by one from the sorted list of items and put them into

    T1 until the total area of the items assigned to T1 is at least C/2. Put the rest of the items

    into T2. Recall that p(T1)+ p(T2) = p(L) = P2 and s(T1)+s(T2) = s(L) C = ab.From the above assignment we get that s(T1) C/2 and s(T2) C/2. By Lemma 2,the items in T2 can be packed into a bin. If p(T2) P2/2, we get a feasible packingwith total profit at least P2 /(2 + ) OPT/(2 + ), yielding a performance ratio ofat most 2 + . Otherwise, p(T1) > P2/2. In this case T1 must contain some item otherthan those of S, so |T1| N + 1. Let Rl be the last item assigned to T1. Then Rl is theitem with the smallest profit in T1, and therefore p(Rl ) p(T1)/(N + 1). Obviously,immediately before Rl goes to T1, the total area of the items in T1 is less than C/2,

    i.e., s(T1 {Rl}) < C/2. By Lemma 2 we can pack T1 {Rl}. The better one betweenpacking T2 and packing T1 {Rl} results in a total profit of at least N P2/(2N + 1). Tosee this, note that if p(T2) < N P2/(2N + 1), then p(T1) > (N + 1) P2/(2N + 1) andp(T1 {Rl}) N p(T1)/(N + 1) > N P2/(2N + 1). This yields a performance ratio ofat most 2

    +1/N

    +. Therefore we have proved the following theorem.

    THEOREM 5. If there are no tall items (or there are no wide items), there exists an

    approximation algorithm with a performance ratio of at most2+ 1/N+, for any giveninteger N > 0 and any small number > 0.

    We estimate the running time of the algorithm. It depends mainly on the first two

    phases. Pre-selecting items takes O(nN2

    ) time for the enumeration. For any constant

    number (bounded by N) of items, the test for the existence of a feasible packing takes

    constant time (exponential in N2). The most naive way to find a feasible packing of

    N items (or determine that no such packing exists) is probably the following. Observe

    that if a packing exists, then there exists a packing in which each item is immediately

    adjacent to some item to its left (or to the bins left border) and to some item below (or

    to the bottom of the bin). In such a packing, the x-coordinate (within the bin) of the

    bottom left corner of every item is the sum of widths of a subset of items, and, similarly,

    the y-coordinate is the sum of heights of a subset of items. Thus there are at most 2 2N

    potential positions for each item, and therefore at most 22N2

    possibilities to consider.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    9/20

    Maximizing the Total Profit of Rectangles Packed into a Rectangle 331

    In the second phase, O(nN) knapsack problems are solved with an FPTAS [12].

    Basically, the (2 + )-approximation algorithm is out of practical interest because of theenumeration. However, it is efficient for small N and the performance ratio is also quite

    satisfying. For example, if N=

    3, the performance ratio is at most 7/3+

    . For N=

    2,

    the ratio goes up to 5/2 + .

    COROLLARY 6. There exist polynomial time algorithms with a performance ratio of

    2 + 1/N + for Problem RRP and for Problem SP, for any given integer N > 0 andany given small number > 0.

    PROOF. We only need a proof for Problem RRP. Analogously as above, we have three

    phases. In the pre-selection phasewe consider all possible rotations within each candidate

    (thus increasing thenumber of candidates by a factor of 2N). Then, in the next two phases,

    we use thesame algorithmas forthe restricted problem. In the final stage, if thealgorithm

    decides to return S, it should return it as it is. Otherwise, it should rotate the tall items

    (if any) before packing them. Note that Lemma 4 still holds, where OPT is the optimalvalue of Problem RRP, since the Knapsack Problem RKP only takes advantage of the

    area of the items. Thus the performance ratio holds for Problem RRP.

    Note that N can be chosen to be very large. We conclude that

    COROLLARY 7. There exist polynomial time algorithms with a performance ratio of

    2 + for RRP and for SP, for any given small number > 0.

    5. An Improved Algorithm for RP. In this section we return the general problem

    RP, in which we may have both tall items and wide items. The ideas for the restricted

    problem cannot directly apply. However, it can help us design an improved algorithmwith a performance ratio of at most 5/2 + . For the sake of simplicity, we also use threephases, analogously as in the last section, to describe the algorithm.

    I. Pre-Selecting Items. Since our goalistodesign a (5/2+)-approximation algorithm,in this phase we only need to assume that N = 2 and run the enumeration as the one inthe last section. Similarly, denote by X the set of the resulting feasible packings. The set

    of items involved in a feasible packing is called a candidate. Let K = |X| n2 be thenumber of candidates in X. Lemma 3 holds too.

    II. Finding an Upper Bound for the Optimal Value. To deal with ProblemRP, we have

    to consider how to pre-select wide items and tall items. In this phase, instead of the

    restricted knapsack problem, we introduce a three-dimensional knapsack problem.

    For each candidate Sj of X (j = 1, . . . , K), let p(Sj ) be the total profit of the itemsin Sj . Based on Sj , we try to add more items with smaller profits such that the items

    form a nearly optimal solution of the following three-dimensional knapsack problem.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    10/20

    332 K. Jansen and G. Zhang

    We introduce three parameters xi , yi and zi for each item Ri :

    xi

    = ai , ifbi > b/2,

    0, otherwise,

    yi

    = bi , ifai > a/2,

    0, otherwise,

    zi

    =ai bi .

    Let b be the total width of the tall items and big items in Sj and let a be the total height

    of the wide items and big items in Sj . Let c be the total area of items in Sj . Denote by Ljthe set of items which are not included in Sj and have profits no larger than the profit of

    any item in Sj . Without loss of generality, denote the items in Lj by R1, . . . , Rkj . In the

    following integer program we also use Ri to represent the 0-1 variables if no confusion

    is caused, where Ri = 1 if Ri is accepted and Ri = 0, otherwise.

    THREE-DIMENSIONAL KNAPSACK PROBLEM 3DK Pj .

    max p(Sj ) +kj

    i=1piRi

    s.t.

    kji=1

    xiRi a a,

    kji=1

    yiRi b b,

    kji=1

    ziRi ab c,

    Ri {0, 1}.

    Let P2 be theprofit of thebestsolution among the K integer programs. The correspondinginteger program is denoted I and the corresponding candidate is denoted S. Then we

    have

    LEMMA 8. The best solution among the K integer programs gives an upper bound on

    the optimal solution of RP, i.e., P2 OPT.

    The three-dimensional knapsack problem admits a PTAS [7]. For any given > 0,

    there exists a polynomial time algorithm for I which results in a solution with profitP2 P2 /(1 + /2). Similarly as in the last section, we only need to consider the casethat p(S) < P2/2. Let L be the set of the items ofS together with the items acceptedby I. Next we partition L into two subsets and try to pack almost all items of eachsubset into a bin.

    III. Partitioning and Packing the Items. Group the items of L into two subsets T1and T2 as follows. Start by putting the wide items in T1, and the tall items and the big

    item (if any) in T2. Then use LPF (Largest Profit First) to assign the small items one by

    one, maintaining the invariant that s(T1) C/2 and s(T2) C/2 as long as possible.If all the items get successfully assigned, then both T1 and T2 admit a feasible packing

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    11/20

    Maximizing the Total Profit of Rectangles Packed into a Rectangle 333

    (by Lemma 2). Choose the one with the larger profit. It gives a performance ratio of

    2 + . Otherwise, let Rl be the first item which can fit into neither T1 nor T2 withoutincreasing their area above C/2. If p(T1 {Rl}) P2/2 (resp. p(T2 {Rl}) P2/2),put the remaining items (excluding Rl ) in T2 (resp. T1) and obtain a subset that has total

    profit at least P2/2 and total area at most C/2. By Lemma 2, this subset admits a feasible

    packing. It gives a performance ratio of at most 2 + .It remains to handle the case p(T1 {Rl}) > P2/2 and p(T2 {Rl}) > P2/2. Recall

    that p(S) < P2/2 and S consists of the two items with largest profits. This impliesthat T1 and T2 both contain at least two items. Let = min{s(T1 {Rl}) C/2, s(T2 {Rl}) C/2}. Then (s(T1) + sl ) + (s(T2) + sl ) C = s(T1) + s(T2) + sl . Thisimplies that sl 2. Note that Rl is a small item. We thus get C/8. There are twocases to consider.

    Case 1: = s(T1 {Rl}) C/2. Add Rl to T1 and the remaining items to T2. If T1contains at least three small items, Rl is the one with the smallest profit among them.

    Then remove Rl . If T1 contains exactly two small items, merge all wide items of T1 as

    one item (its profit is the total profit of the items merged). Then we have three items:

    two small items and a new wide item (which is actually not a regular item, but we canconsider it as a wide item without causing any problem). Remove theone with thesmaller

    profit between Rl and the new wide item. The remaining two items have larger profit

    and admit a feasible packing.

    Now assume that T1 contains exactly one small item (Rl ). If T1 contains (at least)

    two wide items with area at least , compare them with Rl and remove the one among

    them with the smallest profit. If there is one wide item with area at least , merge all the

    other wide items as one item. There are three items after the merging. Remove the one

    with the smallest profit. If it is Rl or the wide item with area at least , the remaining

    items have total area at most C/2 and are packable. Otherwise, only two items remain:

    a small item (Rl ) and a wide item. They can clearly be packed together. If all wide items

    have area less than , merge the wide items into two new items such that both have area

    at least . Note that C/2

    sl

    sl

    2 (since Rl is a small item, sl

    C/4). Then

    s(T1) sl = C/2 + sl 3. It means that the wide items can always be merged intotwo items such that both have an area at least . Now remove the item with the smallest

    profit. Clearly, the total area of the remaining items goes down to at most C/2. Thus,

    the remaining items admit a feasible packing. Comparing it with the packing of T2 and

    choosing the better one gives a profit of at least 25

    P2. It shows a performance ratio of at

    most 5/2 + .Case 2: = s(T2 {Rl}) C/2. Put Rl in T2 and assign the remaining items to T1. IfT2 does not contain a big item, we can deal with it the same as in Case 1 by considering

    tall items instead of wide ones. If T2 contains a big item, we do the following. If T2contains at least two small items (including Rl ), we can regard the big item as a tall

    item and treat the case the same as above. If T2 contains no small items except Rl , we

    merge all tall items as one. Then there are three items: Rl , the big item, and the new

    tall item Rt. We remove the one among the three items which has the smallest profit.By then comparing T1 and T2, and selecting the better set, we get a profit of at least25

    P2. Note that if T2 is selected, it may not be packable. This can happen (only) if Rt is

    the item that gets removed, in which case the remaining items are Rl and the big item,

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    12/20

    334 K. Jansen and G. Zhang

    which may not be packable together. In this case, however, T2 contains two items and

    therefore p(T2) p(S) (since S consists of the two most profitable items in L). Wecan therefore use S, which is packable, instead of T2.

    We have thus proved the following theorem.

    THEOREM 9. There exists an approximation algorithm with a performance ratio of at

    most5/2 + , for any small number > 0.

    The running time of the algorithm is dominated by solving O(n2) three-dimensional

    knapsack problems with a PTAS [7] (Phase II). In Phase I it takes O(n2) time to find

    all candidates. In Phase III the running time for partitioning and packing the items is

    bounded by O(n2) too.

    We cannot prove a performance ratio of 2 + even if we choose a very large N in thepre-selecting phase. The key point is that in Phase III (Partitioning and Packing) we may

    lose some items with a big total profit. This difficulty is overcome in the next section.

    6 . A ( 2 +)-Approximation Algorithm forRP. Stated roughly, the main idea used in

    the previous sections was to solve a knapsack problem bounding our rectangle packing

    problem, and then, if all else fails, to partition the items into two sets and select the

    one with greater profit. We relied on Lemma 2 to ensure that the sets were packable. To

    satisfy the conditions of Lemma 2 we had to ensure that the total area of each set was

    at most C/2which we achieved by discarding one or more itemsand that each set

    was homogeneous, that is, did not contain a mixture of tall and wide items. In Section 4

    homogeneity was automatic, and the area condition was achieved by the removal of a

    single item. We used a large candidate (which we were able to place en bloc in one of

    the sets) to ensure that the profit loss due to the items removal was small (since the item

    did not belong to the candidate). In Section 5 we were forced to deal with both tall and

    wide items. To ensure homogeneity, we had to place all tall items in one set, and all wide

    ones in the other. Thus we could no longer guarantee that the candidate was containedin one of the sets, or even in their union. Consequently, the offending item ( Rl ) could

    belong to the candidate, and we were unable to make the profit loss arbitrarily small.

    In this section we combine the above two ideas by using what may be viewed as an

    extended candidate. The extended candidate consists of a large core whose items are

    never discarded, and an extension consisting of the tall and wide items in the knapsack

    solution. We are able to achieve both homogeneity and small area by discarding only

    items that do not belong to the core, thus ensuring that the profit loss can be made

    negligible.

    To understand what we mean by extension, and how it is used, consider packings

    that can be constructed as follows. First, fix k and select a candidate of k items. Then

    define a set of at most 2k + 1 wide rectangles. These rectangles are not part of theinput. Rather, they are artificially defined rectangles intended to serve as containers

    for wide items, and there are limitations (which we stipulate later) on the choice of

    their dimensions. Define similarly a set of at most 2k + 1 tall containers for the tallitems. Then pack the candidate items and the containers without overlap, except that tall

    containers may intersect wide containers. Finally, select a subset of items with profits

    bounded by the minimum profit of a candidate item. Pack the wide and tall items (these

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    13/20

    Maximizing the Total Profit of Rectangles Packed into a Rectangle 335

    items constitute the extension) in the wide and tall containers, respectively, and pack

    the small items anywhere. Clearly, the best such packing may be sub-optimal, since the

    tall and wide items are restricted to being packed into a limited number of containers.

    Moreover, the restrictions placed on the allowable dimensions of the containers limit the

    set of solutions even further. However, we shall see that for a suitable candidate size the

    loss is negligible, so we can use an upper bound on the profit of these restricted packings

    as a near upper bound on the optimal solution for RP. Unfortunately, the proper choice

    of candidate size is not easy to compute, but a constant upper bound N is. We therefore

    compute N, and try all choices ofk N.Throughout this section we treat big items as wide or tall; it makes no difference

    exactly which.

    We now provide a (somewhat inaccurate) high-level overview of the algorithm. The

    algorithm begins by computing a constant N (which depends only on ). Then, for all

    k N, it considersall combinationsof a candidateof size k,atmost2k+1 tallcontainers,and at most 2k+ 1 wide containers. When considering combinations of containers, thealgorithm considers all possible combinations of dimensions. (As we shall see, the choice

    of dimensions is restricted, and there are only a polynomial number (exponential in k)of combinations to consider.) For each combination the algorithm attempts to pack the

    candidate and the containers. If successful, the algorithm then solves a knapsack LP to

    fill in the containers with wide and tall jobs and to add small jobs in the remaining space.

    It then rounds the optimal (fractional) LP solution, and obtains a set of items. Based

    on the value of the fractional solution and the set of items, the algorithm then packs a

    subset of these items with a profit of nearly half the LP value (or more). This is done in a

    manner similar to our previous algorithms. The algorithm returns the best solution thus

    found.

    The details of the algorithm are spelled out in the following subsections. In Sec-

    tion 6.1 we discuss the containers. In Section 6.2 we describe the LP defined by each

    candidate/containers combination, and the rounding procedure used to extract a set of

    items from its fractional solution. In Section 6.3 we show how to choose and pack an

    appropriate subset of the items found by the rounding procedure. In Section 6.4 we dis-cuss the choice ofkand the value ofN. Finally, in Section 6.5 we tie everything together

    and present the algorithm as a whole.

    6.1. Gap Structure and Containers. Let X be an optimal solution. Fix 0 k |X|,and let S be the set of k most profitable items in X (i.e., the corresponding candidate).

    Consider a packing of X. We define the horizontal gaps relative to the candidate by the

    following procedure. First, remove all items except for the candidate items. Then, for

    each item in the candidate, extend its upper and lower boundary to the left and to the

    right until it hits another item (or the bins border). Thus the space left by the candidate

    is partitioned into rectangular horizontal gaps. See Figure 3 for an illustration.

    Horizontal gaps with width greater than b/2 are called wide. Since there are at most

    2kdistinct horizontal line segments and no two wide gaps can coexist horizontally, there

    are at most 2k+ 1 wide gaps.Now add back the wide items to the packing. At most one wide item can cross a

    horizontal line segment, so there are at most 2k wide items not fully contained in the

    gaps. Let us discard them. Now consider a wide gap G containing at least one wide item.

    Let w be the width of the widest item packed in G; let h be the height of the tallest

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    14/20

    336 K. Jansen and G. Zhang

    wide gap

    wide gap

    wide gap

    wide gap

    wide gap

    Fig. 3. Illustration of gape structure.

    wide item packed in G; and let htotal be the total height of the wide items packed in G.

    Let m = htotal/ h. Define the wide container corresponding to gap G as the rectangle(w, m h). We can easily pack into this container all of the wide items packed in Gexcept perhaps the tallest, which we discardand we can place the container inside thegap (since its dimensions are not greater than the gaps). Thus we can pack S and the

    wide containers without overlap, and then we can pack all wide items in X, except for at

    most 4k+ 1 of them, into the wide containers. Note that each wide container is definedby three numbers: w, which is the width of some wide item; h, which is the height of

    some wide item; and m, which isin the range 1, . . . , n. Thus there are at most n3 possible

    distinct wide containers. We define the space of wide containers as the set of rectangles

    (x, i y) such that x is the width of some wide item, y is the height of some wide item,and 1 i n.

    We define the vertical gaps analogously (by extending the left and right borders of

    items vertically), and, similarly, the tall gaps and the space of tall containers. (Note that

    the wide gaps and the tall gaps may intersect.) As before, there are at most n3 possible

    distinct tall containers.

    The purpose of the wide and tall containers is to reduce the number of packings thatneed to be examined (at the cost of losing some of the items). To formalize this notion,

    let us define the following container packing problem. We are given a number k, a set

    of items I consisting of a candidate S (of size k) and items of smaller profit, a collection

    W of at most 2k + 1 (not necessarily distinct) wide containers (i.e., rectangles drawnfrom the space of wide containers) such that S and W are packable without overlap, and

    a collection T of at most 2k+ 1 (not necessarily distinct) tall containers (i.e., rectanglesdrawn from the space of tall containers) such that S and T are packable without overlap.

    (The packing ofS may be different with W and with T.) The goal is to select a maximum

    profit subset S L I such that the wide items in L S can be packed in the widecontainers, the tall items in L S can be packed in the tall containers, and the total areaof L is at most C (the bin size). Let OPTCP denote the optimum for this problem. The

    discussion above gives the following lemma.

    LEMMA 10. For all k, there exists a candidate S of size (at most) k and a choice of at

    most2k+1 wide containers packable with S and at most2k+1 tall containers packablewith S, such that OPTCP OPT D1, where D1 is the sum of profits of at most 8k+ 2distinct items with profits bounded by miniS pi .

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    15/20

    Maximizing the Total Profit of Rectangles Packed into a Rectangle 337

    As we shall see in Section 6.4, there exists a choice of k bounded by a constant N

    (that depends only on ) such that D1 OPT, where > 0 is arbitrarily small. Wethus arrive at the following algorithm:

    For all k N, consider all combinations of a candidate S of size k, at most 2k+ 1wide containers, and at most 2k + 1 tall containers. For each combination, test(separately) whether the wide containers are packable with S and whether the tall

    ones are packable with S, and if so, solve the container packing problem for this

    combination. Return the best solution thus found.

    Note that for each value of k, there are only n O (k) combinations to test.

    The above algorithm achieves a performance ratio of 1 + . There are two problems,however. First, it is not clear how to solve the container packing problem efficiently.

    Second, the solution found is not really a solution to RP, since we are not guaranteed

    that S and both types of containers are all packable together, and, furthermore, we do not

    know how to pack the small items that might be present in the solution for the container

    packing problem. To solve the first problem, we use linear programming rounding,

    as described in the next subsection. To solve the second problem, we use Steinbergs

    algorithm, as described in Section 6.3. This increases the performance ratio to 2 + .

    6.2. Linear Program and Rounding Procedure. We wish to solve an instance of the

    container packing problem. We are given a set of items I containing a candidate S

    (consisting of the k most profitable items in I), a set W of wide containers packable

    with S, and a set T of tall containers packable with S. We construct a linear program as

    follows. Let Iw, It, and Is denote the subsets of wide, tall, and small items (respectively)

    in I\S. We define a variable xc,i for each item i Iw and container c W such that i fitsinto c. Similarly, we define variables for the tall items and containers. These variables

    indicate whether the corresponding item is packed into the corresponding container. We

    also define a variable xi for each small item i Is, indicating whether it is selected ornot. Let wc and hc denote the width and height of container c, respectively. The linearprogram is

    max p(S) +iIw

    picW

    xc,i +iIt

    picT

    xc,i +iIs

    pixi

    s.t.iIw

    aixc,i hc, c W,iIt

    bixc,i wc, c T,iIs

    sixi +iIw

    sicW

    xc,i +iIt

    sicT

    xc,i ab s(S),

    cWxc,i 1, i Iw,cT

    xc,i 1, i It,

    0 x 1.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    16/20

    338 K. Jansen and G. Zhang

    The last constraint says that all variables are in the range [0, 1]. Also, undefined variables

    (i.e., xc,i where item i does not fit into container c) should be understood to be omitted

    from the sums. Clearly, the integral feasible solutions of the above LP are in one to one

    correspondence with solutions to the container packing instance.

    We solve the LP and obtain a fractional optimal solution. We round this solution by

    viewing it as a solution to a certain assignment problem, which we define next, and using

    an established rounding procedure for that problem.

    The assignment problem is the following. We are given a set of machines and a set

    of jobs. For each machine c and job i , there is a cost kc,i and a processing time tc,iassociated with assigning job i to machine c. Each job must be assigned to exactly one

    machine. The goal is to minimize both the makespan (maximum total processing time

    on a machine) and the cost. We can express an assignment of jobs to machines by a

    0-1 assignment to a vector of variables yc,i indexed by machine (c) and job (i), wherec yc,i = 1 for all i . A fractional assignment is an assignment that is not necessarily

    0-1, but satisfies the above constraint as well as 0 yc,i 1 for all c and i . The cost ofthe assignment isc,i kc,iyc,i .

    Shmoys and Tardos [19] describe an efficient rounding procedure for the above as-signment problem. Given a fractional assignment y, let Tc denote the total process-

    ing time of machine c, i.e., Tc =

    i tc,ixc,i . The rounding procedure of Shmoys

    and Tardos returns a 0-1 solution y with the following properties. (Shmoys and Tar-dos make a slightly weaker claim, but they actually prove the claim stated here. See

    also [10].)

    1. The cost of y is not greater than the cost of y.2. Every job i is assigned in y to a machine c such that yc,i > 0.3. For each machine c there is at most one job r assigned by y to c such that if we

    remove r, the total processing time of the remaining jobs assigned to c is at most

    Tc. Stated differently, if

    i tc,iyc,i > Tc, then there exists r such that y

    c,r = 1 and

    itc,iy

    c,i Tc + tc,r.

    Returning to our LP, let x be a fractional optimal solution. Let us restrict our attentionto the wide items Iw and the wide containers. We can view the containers as machines

    and the items as jobs, where the processing time of item i on container c is ai . Under

    this interpretation, we have Tc hc for all c, and it seems that we can use the roundingprocedure. There are two problems, though. The first is that in the assignment problem

    every job must be fully assigned (i.e.,

    c yc,i = 1 for all i ), whereas this is not thecase for our LP. Also, the objectives are different: our LP maximizes profit, while the

    assignment problem minimizes cost. We overcome both problems by introducing an

    additional machine, labeled 0, to which we assignall unselected items and item fractions.

    Thus we add a variable x0,i and put x0,i = 1

    cW xc,i , for each item i Iw. Weset the processing time of item i on machine 0 to be the profit pi . Thus T0 becomes the

    profit loss due to unselected items and item fractions. Finally, to keep the total area of

    selected wide items from increasing, we define the cost of assigning item i to container

    c to be si , and the cost of assigning it to machine 0 to be 0 (discarding an item cannot

    increase the area). We now apply the rounding procedure of Shmoys and Tardos to x

    (more accurately, to the variables in x representing wide items and containersrecall

    that we are focusing on the wide items and containers only) and obtain a 0-1 assignment

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    17/20

    Maximizing the Total Profit of Rectangles Packed into a Rectangle 339

    x with the following properties:

    1. The total area of selected items is not greater in x than in x .2. Every item that is assigned by x is assigned to a container to which it was at least

    partially assigned by x . This ensures that every item is assigned to a container that isat least as wide as the item.

    3. At most one item needs to be removed from every container so that the remaining

    items can all be packed into it.

    4. The profit loss due to unselected items is greater in x than in x by at most the profitof one unselected item (i.e., an item assigned to machine 0).

    Thus, the items assigned by x to the containers, together with the item that is referredto in property 4 (if it exists), constitute a subset of Iw whose total profit is at least the

    total contribution of items in Iw to the value of x . By discarding at most 2k+ 2 of theseitems (one per container and one assigned to machine 0), we obtain a packing of the

    remaining items in the wide containers.

    We carry out a similar procedure with the tall items.

    To round the small items, we use the straightforward greedy knapsack algorithm,namely, we sort the items in Is by non-increasing order of pi /si , and greedily select the

    items in this order as long as the total area of the selected items does not exceed the area

    occupied by the items of Is in x (i.e.,

    iIs sixi ). By so doing, we lose the profit of atmost one item in Is.

    We thus obtain a set Y of items with the following properties:

    1. S Y.2. Y Iw is packable in the wide containers.3. Y It is packable in the tall containers.4. s(Y) C.5. p(Y) OPTCP D2, where D2 is the profit of at most 4k+ 5 distinct items whose

    profits are bounded by miniS pi .

    As we shall see, there exists a choice ofk for which D2 is negligible. Unfortunately, thisk may be different from the k required to make D1 negligible in Section 6.1. We resolve

    this problem in Section 6.5.

    6.3. Packing a Subset of the Items. At this point we have a set of items Y satisfying the

    conditions listed at the end of the previous subsection, and we can assume (by properly

    choosing k) that its profit p(Y) is nearly OPT. Let Yw and Yt denote the wide items and

    tall items, respectively, in Y (including those in S). By the above conditions, S Ywand S Yt are packable, as are any of their subsets. Create two sets of items T1 and T2,as follows. First put Yw in T1 and Yt in T2. Then distribute the remaining (small) items

    of S between the two sets arbitrarily. If the profit of one of the sets is at least p(Y)/2,

    return it. Otherwise, if the area of one of them is at least C/2, add all remaining items

    of Y (they are all small) to the other set and return it. (This set has profit greater than

    p(Y)/2, and it is packable by Lemma 2, since its area is at most C/2.) Finally, if both

    sets have area less than C/2 and profit less that p(Y)/2, distribute the remaining items

    ofY between T1 and T2 by first adding items to T1 until its area reaches or exceeds C/2,

    and then adding any remaining items to T2. If the area of T1 exceeds C/2, discard the

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    18/20

    340 K. Jansen and G. Zhang

    last item added to it (so that its area drops below C/2). By the magical choice of k, the

    profit of this item is negligible, so at least one of T1 and T2 has a profit of nearly p(Y)/2

    (or more), and both are packable by Lemma 2. Return the set with larger profit. Thus, in

    all cases we find a packing of a set of items whose total profit is nearly OPT/2 or more.

    6.4. Choice of the Constant k. In our description of the various stages of the algorithm

    we have relied on the existence of a number k (bounded by a constant) such that if I

    is a set of items containing a candidate X of size k, then any subset of I\X consistingof O(k) items has negligible profit. The following lemma is a slight modification of the

    one in [10] and provides a sufficient condition for this and nails down the parameters.

    LEMMA 11 [10]. Let p1, . . . , pl be a monotone non-increasing sequence of non-negative

    real numbers, and let P =li=1 pi .Let c 1 and d 0 be integers, and let0 < 1.If l is large enough (specifically, l > (1/d+ 1)(c + 1)1/), then there is an integerk [(c + d)(c + 1)1/1 d]/c 1 such that

    pk+

    1

    + +pk

    +ck

    +(c

    +d)

    P.

    (The precise value of k may depend on the sequence of pi s, but the bound on k depends

    only on , c, and d.)

    The condition of large l is only there to ensure that the sequence contains at least

    k+ ck + (c + d) elements (i.e., the lemma continues to hold if we drop the conditionand instead pad the sequence with sufficiently many zeros). This will come into play in

    the next subsection. For now, let us ignore this condition.

    To make use of Lemma 11, recall the analysis of the algorithm. We start out with an

    optimal solution, discard some items not in the candidate, and take (at least) half of the

    remaining profit. The items we discard can be grouped into two sets: at most 8 k + 2items that are discarded in Section 6.1, and at most 4 k + 6 additional items that arediscarded in Sections 6.2 and 6.3. Note that the items of the first set are only discarded

    conceptually (to show that OPTCP is only slightly lower than OPT), whereas the itemsof the second set are actually discarded by the algorithm. Thus, the two sets are not

    necessarily disjoint. Now, if we can ensure that total profit loss due to discarded items

    is at most (/3)OPT, then we will have that the profit of the solution found is at least12

    (1 (/3))OPT OPT/(2 + ), yielding the desired performance ratio. (We assume 1.) We thus want to bound the profit loss due to each set by (/6)OPT, so we put = /6. To bound the number of items in each set by ck+ (c + d), we put c = 8 andd = 0. Thus, the constant bounding k guaranteed by the lemma is N = 96/1.

    In the above discussion we have glossed over a potential difficulty, namely, that the

    first group of discardeditems is removed froma hypothetical optimal solution X, whereas

    the second group is removed from an actual set of items found by the algorithm. In all

    likelihood, these two sets are not the same (even though they share the same candidate),

    and therefore may require different choices ofkin order to make theprofitloss negligible.

    We deal with this problem in the next subsection.

    6.5. The Algorithm. We are now ready to tie the two remaining loose ends and present

    the final version of the algorithm. Recall from the previous subsection that the problems

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    19/20

    Maximizing the Total Profit of Rectangles Packed into a Rectangle 341

    still facing us are: (1) Lemma 11 requires the set of items to which it is applied to be

    large (i.e., more than 96/ items); and (2) Lemma 11 is applied twice, to two differentsets of items, so two different choices of k may be required. We solve both problems

    as follows. We introduce a preliminary stage in which the algorithm considers packings

    of all choices of up to 96/ items, and records the best one found. The algorithm thenproceeds on the assumption that the optimal solution is large. This takes care of the first

    problem. To deal with the second problem, we rely on the assumption that the optimal

    solution is largespecifically, that it contains at least k+ ck+ (c + d) = 9k+ 8 items(for the kwhose existence is guaranteed by Lemma 11). For each value ofk, we consider

    not only all choices of the set S consisting of the k most profitable items, but also all

    choices of a set S consisting of the next max{8k+ 2, 4k+ 6} = max{8k+ 2, 6} mostprofitable items. We then proceed with the set of items I that is the union of S, S, andthe set of all items with lesser (or equal) profit. At least one of the choices of S Sconsists of the most profitable items in an optimal solution X. For this choice, S is theset of most profitable items in X S, and thus (for the proper choice of k) the profit lossin Section 6.1 is bounded by p(S), which by Lemma 11 isbounded by (/6)OPT. Since

    S is also the set of most profitable items in I S, the profit loss due to items discardedin Sections 6.2 and 6.3 is also bounded p(S) (/6)OPT.

    We now present the algorithm in its full glory:

    (1) Try all packings with at most 96/ items.(2) FOR k = 0, . . . , 96/1 DO

    FOR each subset S of size k+ max{8k+ 2, 6} DOLet S be the set ofk items with highest profit in S,

    and let I = S {all items with profit at most miniS pi }.FOR each choice W, T of up to 2k+ 1 wide containers and up to2k+ 1 tall containers DO

    IF both S W and S T can be packed DOSolve the LP for (I, S, W, T), round the solution, and extract

    a feasible packing.(3) Return the best packing thus found.

    REMARK. The algorithm can be accelerated by testing for each choice of S = S\Swhether p(S) (/6)OPT. If not, it is not necessary to continue with this choice, andthe algorithm may skip to the next iteration. Since the value ofOPT is not known, we use

    an approximate upper bound instead. For example, we can run the (3+)-approximationalgorithmof Section 3, anduse (3+) times thevalue returned as an upper bound on OPT.

    7. Concluding Remarks. Most of thealgorithmsin this paper arebased on Steinbergs

    theorem. We first gave a simple (3 + )-approximation algorithm. Then a restrictedproblem (includingRRP and SP) was investigated by presenting a (2

    +)-approximation

    algorithm. We further designed an improved algorithm forRP and proved a performance

    ratio of at most 5/2+ . Finally a more theoretical (2 + )-approximation algorithm wasdevised. It is the best bound we can obtain by using Steinbergs theorem. To improve the

    performance ratio new strategies are required.

  • 8/3/2019 Klaus Jansen and Guochuan Zhang- Maximizing the Total Profit of Rectangles Packed into a Rectangle

    20/20

    342 K. Jansen and G. Zhang

    Acknowledgment. We are grateful to the referees for the insightful comments and the

    great help in improving the presentation of the paper.

    References

    [1] B.S. Baker, A.R. Calderbank, E.G. Coffman, and J.C. Lagarias, Approximation algorithms for maxi-

    mizing the number of squares packed intoa rectangle, SIAMJournal on Algebraic andDiscrete Methods

    4 (1983), 383397.

    [2] J.E. Beasley, An exact two-dimensional non-guillotine cutting tree search procedure, Operations Re-

    search 33 (1985), 4964.

    [3] A. Caprara and M. Monaci, On the 2-dimensional knapsack problem, Operations Research Letters 32

    (2004), 514.

    [4] E.G. Coffman, Jr., M.R. Garey, and D.S. Johnson, Approximation algorithms for bin packing: a survey,

    inApproximation Algorithmsfor NP-HardProblems (D.Hochbaum, editor),PWS, Boston, MA,pp. 46

    93, 1997.

    [5] W. Fernandez de la Vega and G.S. Lueker, Bin packing can be solved within 1 + in linear time,Combinatorica 1 (1981), 349355.

    [6] A. Freund and J. Naor, Approximating the advertisement placement problem, IPCO 2002, LNCS 2337,pp. 415424, 2002.

    [7] A.M. Frieze and M.R.B. Clarke, Approximation algorithms for the m-dimensional 0-1 knapsack prob-

    lem: worst-case and probabilistic analyses, European Journal of Operational Research 15 (1984),

    100109.

    [8] D.S. Hochbaum and W. Maass, Approximation schemes for covering and packing problems in image

    processing and VLSI, Journal of ACM 32 (1985), 130136.

    [9] O.H. Ibarraand C.E. Kim, Fast approximation algorithms forthe knapsackand sumof subsetproblems,

    Journal of ACM22 (1975), 463468.

    [10] K.Jansen andL. Porkolab, Improved approximation schemes forschedulingunrelated parallelmachines,

    Mathematics of Operations Research 26 (2001), 324338.

    [11] N. Karmarkar and R.M. Karp, An efficient approximation scheme for the one-dimensional bin-packing

    problem, Proc. 23rd Annual IEEE Symposium on the Foundations of Computer Science , pp. 312320,

    1982.

    [12] H. Kellerer and U. Pferschy, A new fully polynomial approximation scheme for the knapsack problem,

    APPROX98, LNCS 1444, pp. 123134, 1998.[13] J.Y.-T. Leung, T.W. Tam, C.S. Wong, G.H. Young, and F.Y.L. Chin, Packing squares into a square,

    Journal of Parallel and Distributed Computing 10 (1990), 271275.

    [14] E.Y.-H. Lin, A bibliographical survey on some well-known non-standard knapsack problems, INFOR

    36 (1998), 274317.

    [15] A. Lodi, S. Martello, and M. Monaci, Two-dimensional bin packing problems: a survey, European

    Journal of Operational Research 141 (2002), 241252.

    [16] A. Lodi, S. Martello, and D. Vigo, Recent advances on two-dimensional packing problems, Discrete

    Applied Mathematics 123 (2002), 379396.

    [17] R. Loulou and E. Michaelides, New greedy-like heuristics for the multidimensional 0-1 knapsack

    problem, Operations Research 27 (1979), 11011114.

    [18] M.J. Magazineand O. Oguz, A heuristic algorithmfor themultidimensionalzero-one knapsackproblem,

    European Journal of Operational Research 16 (1984), 319326.

    [19] D. Shmoys and E. Tardos, An approximation algorithm for the generalized assignment problem, Math-

    ematical Programming 62 (1993), 461474.

    [20] D. Simchi-Levi, New worst-case results for the bin packing problem, Naval Research Logistics 41(1994), 579585.

    [21] A. Steinberg, A strip-packing algorithm with absolute performance bound 2, SIAM Journal on Com-

    puting 26 (1997), 401409.