Download presentation
Presentation is loading. Please wait.
1
2D Rectangular Packing with LFF and LFF/T Presented by Y. T. Wu
2
Overview Introduction The Problem LFF Algorithm LFF/T Algorithm – An Improvement Experimental Results Conclusion Future Direction
3
Introduction 2D rectangular packing is to pack a set of rectangles into a bounding rectangle There are many practical applications: VLSI floor-planning VLSI placement Job-scheduling
4
Introduction It is a NP-complete problem Heuristics are proposed for solving these kind of problems Existing algorithms: Simulated Annealing Genetic algorithms
5
The Problem To determine whether a set of rectangles(r 1, r 2, r 3,…, r n ) with given length l and width w can be packed into a bounded rectangular container R Goal: Minimize total area for packing these rectangles Maximize packing density
6
LFF Algorithm What is LFF? A quasi-human (cognitive) based heuristic A deterministic algorithm inspired by Chinese ancient professionals for polygon- shape stone plates Based on the concept of flexibility
7
LFF Algorithm Two types of flexibility: Flexibility of empty space follows this order: a corner < a side < a central void area a corner < a side < a central void area Flexibility of objects to be packed cannot be calculated, but follow this order in general: larger objects < smaller objects larger objects < smaller objects
8
LFF Algorithm What is a corner? It is a point which is bounded in two directions Corner bounded on top and left Corner bounded on bottom and left Corner bounded on top and right As the packed object are all rectangles, all corners are 90º Corner bounded on bottom and right
9
LFF Algorithm Basic rules of LFF: Objects must be packed to at least one corner There must not be any overlapping of objects Due to flexibilities, larger objects should be packed to corners first If more than one available corner (i.e. a corner to which the packing does not overlap with other objects), use fitness cost function to choose the best one Fitness cost function = total area of rectangle packed
10
LFF Algorithm As mentioned in previous slide, overlapping of objects is not allowed “Region query” is the process for detecting whether the region for insertion of new object is already occupied In LFF, region query is operated by K-D tree, with K = 4
11
LFF Algorithm What is K-D tree? A “Multi-dimensional Binary Tree” struct kdtree{ kdkey_t kd_keys[4]; kdkey_t kd_lo_min_bound, kd_hi_max_bound,kd_other_bound; struct kdtree *kd_father; struct kdtree * kd_sons[2]; }; The packing is considered to be performed on a coordinate- plane on which all keys are representing points on that coordinate-plane
12
LFF Algorithm The 4 kd_keys are: K 0 (p) = x 1 K 1 (p) = y 1 K 2 (p) = x 2 K 3 (p) = y 2 (x 1, y 1 ) (x 2, y 2 )
13
LFF Algorithm The two sons are LOSON and HISON To determine whether a child q is LOSON or HISON of its parent p, compare their corresponding kdkey Discriminator j is introduced to control the use kdkey for comparison. Compare K j (p) and K j (q) For example, when j=0, if K 0 (p)>K 0 (q), q is LOSON; if K 0 (p)<K 0 (q), q is HISON j increments as it goes down the tree, and reset to 0 when it reaches maximum, then repeat to increment again
14
LFF Algorithm An example Fig. 1a) 16 labelled rectangles on a grid 0 x 13 in size Fig. 1b) Placement of these 16 labelled rectangles in a 4-d binary tree a (6, 1, 7, 3) b (2, 6, 4, 9) c (9, 7, 12, 8) d (1, 4, 3, 7) e (1, 10, 3, 13)
15
LFF Algorithm Procedures for manipulating K-D Tree in LFF 2D rectangular packing: KD-INSERT KD-REGION-SEARCH KD-SUCCESSOR KD-INTERSECT-REGION
16
LFF Algorithm KD-INSERT It takes in a kd-node as parameter Insert this node into the existing KD-TREE by calling the KD-SUCCESSOR to find out where should the node be inserted KD-SUCCESSOR It compares the jth kdkey of q and p to determine whether LOSON or HISON should be the next node
17
LFF Algorithm KD-REGION-SEARCH For each kd_node in the KD-TREE, call KD-INTERSECT- REGION to check whether that kd-node intersects with o if o is packed at the corner being evaluated, report overlapping, if any and quit checking KD-INTERSECT-REGION Test, based on a set of conditions, whether p intersects or touches with o if o is packed at the corner being examined If yes, check whether they are touching If yes, add p to the touches list to indicate that p touches with o If no, return TRUE to indicate intersection
18
LFF Algorithm The relationship between the KD-TREE operations and LFF Before packing any objects, call KD-REGION- SEARCH to detect overlapping If no overlapping is reported, call KD-INSERT to update the KD-TREE, indicating that the object is packed at the specific position and occupy there
19
LFF Algorithm The algorithm: Starting with an empty work space (bounding rectangle) 1.Based on the current packing configuration, find all possible COPMs for each unpacked rectangle, represent each COPM b a quinary-tuple 1.Based on the current packing configuration, find all possible COPMs for each unpacked rectangle, represent each COPM b a quinary-tuple 2.Sort all these quinary-tuples in lexicographical order 3.For each candidate COPM, do a) to c) to find its fitness function value (FFV). a)Pseudo-pack this COPM b)Pseudo-pack all the remaining rectangles based on the current COPM list and with a greedy approach, until no more COPM can be packed c)Calculate FFV of this candidate COPM as the occupied area. Note: Before the pseudo-packing for the next candidate COPM is tried, one needs to remove the previous pseudo-packed COPM 4.Pick the candidate COPM with the highest FFB and really pack the corresponding rectangle according to the COPM 5.Mark the rectangle as packed 6.Return to step 1 until no more packing can be done
20
LFF Algorithm A sample case: Suppose rectangles A(2x5), B(4x4) and C(6x4) are to be packed in a work space (8x8) and a rectangle P(6x3) at (0, 8) is already packed in previous iteration COPM is represented as COPM is represented as As P is packed, one of the container’s corner is occupied, the available corners are: (0, 0), (0, 2), (3, 8), (8, 0), (8, 8)
21
LFF algorithm The COPM list generated stores all feasible packing (no overlapping and within the bounding rectangle) (6, 4, 1, 4, 2) – rectangle C vertically packed at (8, 8) (6, 4, 1, 3, 2) – rectangle C vertically packed at (8, 0) (6, 4, 1, 4, 0) – rectangle C vertically packed at (3, 8) (5, 2, 0, 3, 6) – rectangle A horizontally packed at (8, 8) or (3, 8) (5, 2, 1, 6, 3) – rectangle A vertically packed at (8, 8) (5, 2, 0, 3, 0) – rectangle A vertically packed at (8, 0) (5, 2, 1, 6, 0) – rectangle A vertically packed at (8, 0) (5, 2, 1, 3, 3) – rectangle A vertically packed at (3, 8) (5, 2, 0, 0, 0) – rectangle A vertically packed at (0, 2) or (0, 0) For rectangle B, the generation is by checking all orientation against all corners, if feasible in location, it will shorten itself by deleting not feasible solutions
22
LFF Algorithm Consider rectangle C is pseudo-packed to (8, 8) vertically, i.e., COPM (6, 4, 1, 4, 2) The COPM list for next pseudo-packing step is shortened by removing all entries related to rectangle C as well as all entries packing rectangles to corner (8, 8) since it is already occupied The list becomes: (5, 2, 0, 3, 0) – rectangle A vertically packed at (8, 0) (5, 2, 1, 6, 0) – rectangle A vertically packed at (8, 0) (5, 2, 1, 3, 3) – rectangle A vertically packed at (3, 8) (5, 2, 0, 0, 0) – rectangle A vertically packed at (0, 2) or (0, 0) (4, 4, 0, 4, 0) – rectangle B horizontally or vertically packed at (8, 0) (4, 4, 0, 3, 4) – rectangle B horizontally or vertically packed at (3, 8) Packing continues until all rectangles are packed or no more available space for packing. Remove all rectangles and pseudo-pack C to another corner.
23
LFF/T – An Improvement of LFF Introduce two new concepts: Tightness For each candidate rectangle placement location, we look at the points that are immediate adjacent to each corner of the candidate rectangle (There are 8 points for measurement) The 8 corner-adjacent ptsB has a larger tightness value (4) than A(3) A parameter q Greedy Search done for the COPMs of the q longest rectangles only AB
24
LFF/T – An Improvement of LFF The LFF/T algorithm: Starting with an empty work space (bounding rectangle) 1.Based on the current packing configuration, find all possible COPMs for each unpacked rectangle, represent each COPM b a quinary-tuple <longer side, shorter side, orientation, x1, y1) 2.Sort all these quinary-tuples in lexicographical order 3.For each candidate COPM, do a) to c) to find its fitness function value (FFV). a)Pseudo-pack this COPM b)While there are rectangles remaining and there are spaces in the box, If there is a location that the next rectangle in the sorted list can fit, then, For each legal corner moves of the rectangle, calculate the tightness values as described above Choose the corner move with the highest tightness values and pseudo-pack this rectangle there Update the corner lists and move to the next rectangle in the list Else Skip this rectangle Calculate FFV of this candidate COPM as the occupied area. Note: Before the pseudo-packing for the next candidate COPM is tried, one needs to remove the previous pseudo-packed COPM 4.Pick the candidate COPM with the highest FFB and really pack the corresponding rectangle according to the COPM 5.Mark the rectangle as packed 6.Return to step 1 until no more packing can be done
25
Experimental Results Problem No. of Rects Box Size Original LFF LFF/T (q=n) PackingDensity Packing Density ami33331076*107694.09%95.84% ami49495954*595496.31%97.12% playout629397*939798.83%99.26%
26
Conclusion LFF/T can really improve the packing density of LFF Reasons: In LFF, there may be several corners result in the same FFV (fitness value). The algorithm will just arbitrary take one Tightness value ensures that less gaps or spaces exist between any pair of rectangles, which in turn gives smaller dead space LFF/T takes longer processing time Both algorithms have their own advantages
27
Future Direction Extension of LFF or LFF/T to 3D applications Experiments will be carried out to see which one is more suitable
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.