# A heuristic algorithm for solving triangle packing problem.

1. IntroductionSolving NP-hard problems is always the bottleneck task for computer science and techniques. However, in recent years, many research results have indicated that there is no a complete, accurate, and fast solving algorithm for this kind of problem at all. People tend to focus on searching for a quick and practical approximation algorithm; see, for example, [1].

Triangle packing problem is that given a known length and width of rectangle empty container and N triangles of definite size and shape; namely, the three sides of a triangle are known, and the question is whether the N triangles can be placed into the rectangle container. If we can, then give position and orientation of each triangle in the rectangle. If no, give a negative answer to this problem. Since triangle in the plane can be continuously translated and rotated, there are infinite numbers of placements which are detrimental to solve the problem. And so the placement should be limited always. The strategy in [2] is only to allow a polygon to be rotated, but not to be translated, which translates the polygon packing problem to NP-complete problem.

Triangular packing problem is a special case of a polygon packing problem but is still NP-hard. For now, there is no a quick and complete solving algorithm, and the heuristic method is still an ordinary method; see, for example, [3-7] and references therein. In this paper, a edge-conjoining and corner-occupying algorithm that is a quick and approximate method is designed based on the angle region-filling strategy. This paper has special significance for polygon packing problem, network resource optimization, and so forth, since it is a special case of a polygon packing problem; see, for example, [8-11].

In Section 2, the basic concepts such as angle region are given. The classification of angle region and the corner-occupying action are discussed, and the physical meaning has been analyzed in Section 3. In Section 4, two heuristics strategies and an approximate algorithm for solving triangle packing problem are proposed. Finally, the complexity of algorithm is also discussed and some results of the simulation example are given.

2. Formation of Angle Region

Definition 1. Triangles in a same plane are said to be intersectant, if the overlapping area of two triangles is larger than zero. Or else the two triangles are said to be non-intersectant.

Definition 2. For two non-intersectant triangles in the same plane, if there exists one intersection at least between two edges which are from each triangle, then the two triangles are said to be tangent, as shown in Figure 1.

Definition 3. For two edges from two tangent triangles, respectively, if the following conditions are satisfied:

(1) There exists only one intersection (O) for the two triangles;

(2) An angle formed by the two edges is a positive angle and less than n;

(3) In the angle of (2), there are no other edges of the two triangles except (1);

then the angle in (2) is said to be the angle region of the two tangent triangles. Its size is called the angle of the angle region. The overlapping part of the initial edge of the angle in (2) and one of the two triangles is said to be the initial edge of the angle region; similarly, the overlapping part of the terminal edge of the angle in (2) and one of the two triangles is said to be the terminal edge of the angle region; the intersection in (1) is said to be a vertex of the angle region. As shown in Figure 2, [DELTA] ABC is tangent to [DELTA] DEF at O(A), and Z BOD is an angle region of the [DELTA] ABC and [DELTA] DEF; the angle size of the region angle is denoted by Z BOD; OB and OD are the initial edge and the terminal edge of the angle region, respectively; O is said to be the vertex of the angle region.

To judge whether there is an angle region formed by two tangent triangles, it is just to take out two edges with common vertex from each of triangles and judge that whether the two triangles form a positive angle less than n and verify that there is no other edges of the two triangles on the angle. The computational procedure can be realized according to vertex coordinate of the triangle.

By the definition of angle region, whether the two edges of the tangent triangles can form angle region is unrelated to the size and shape of the triangle that will be put into the angle region.

3. The Classification of an Angle Region and the Corner-Occupying Action

Depending on the two triangles' different positions, the two tangent triangles may form zero, one or two angle region, which is shown in Figures 3 and 4(a)-4(c) and 5(a)-5(d), respectively.

These angle regions look like the scraps generated during the material machining processes. If we make use of these scraps, then the ratio of utilization of material can be increased on basis of practical production experiences. It is illustrated through practice to sufficiently increase the ratio of material, and then the position of the filter within the vessel should be stable. Whether a plane figure is precarious depends on shiftable degree of freedom and the rotatable degree of freedom. For a triangle, the rotatable degree of freedom refers to a clockwise or counterclockwise rotation of one triangle with the origin at one of its vertexes, and here the triangle is still in the rectangle container after be rotated, and the triangle cannot conflict with other triangles around it; namely, there is no overlapping part between the rotated triangle and other triangles, which means you can rotate the triangle freely; similarly, the translatable degree of freedom refers to a translation of one triangle along two opposite directions of one of the straight lines on which one edge of the triangle lies in the barycentric coordinate of the triangle as the initial point, when the triangle is still in the rectangle container after the manipulation of translating, and the triangle cannot conflict with other triangles around it; namely, there is no overlapping part between the translated triangle and other triangles, which means you can translate the triangle freely.

If a triangle with the barycentric coordinate as the initial point can translate freely along any straight line where a edge of the triangle lies, then the triangle is deemed to be impending. Apparently, the position of this kind of triangle is unstable, such as the triangle 1 shown in Figure 6.

If a triangle can translate freely along one straight line only or rotate freely around a certain vertex, this kind of position is pushable and swingable, and also it is unstable, such as the triangles 2 and 3 shown in Figure 6.

Generally speaking, the position where a triangle cannot translate freely along one straight line only or rotate freely around a certain vertex is stable, such as the triangles 4, 5, 6, and 7 shown in Figure 6.

If one edge of the triangle 1 is conjoined with a edge of another triangle 2, namely, the length of the overlapping part is more than zero and the triangle 1 can only translate along the edge of the triangle 2, then the position of the triangle 1 is pushable. Pushing the triangle 1 along the edge of the triangle 2, if the triangle 1 is just tangent to a third triangle and the edge of the triangle 1 is still conjoined with the edge of the triangle 2, then the position of the triangle 1 is stable.

In general, compared with the positions of triangles 4 and 7, the positions of triangles of 5 and 6 can easily divide the space, which is bad for making use of space. It is reasonable to assume that the positions of triangles 4 and 7 are better than those of triangles 5 and 6. For this reason, we have the following definitions.

Definition 4. Corner-occupying action: If one edge of a triangle is conjoined with a initial or terminal edge of a angle region, namely, the length of the overlapping part is more than zero and another edge of the triangle is conjoined with a terminal or initial edge of the region, then the process of putting the triangle into the angle region is called a corner-occupying action. In the case, the angle opposite to the third edge is called the cut-in angle.

It can find a corner-occupying action in this way: pushing a edge which is conjoined with a initial or terminal edge of the triangle region of a triangle outside a rectangle container into the rectangle container, if when the triangle cannot be put away anymore (when the triangle is tangent to the terminal or initial edge), the edge of the triangle is still conjoined with the initial or terminal edge of the angle region, then the process of putting the triangle into the position is called corner-occupying action. Therefore, the problem of putting a triangle into an angle region formed by two tangent triangles can be transformed to a issue of position relation between the edge of triangle and the line segment. Thereby, the search space can be confined in a limited number of points from a continuous Euclidean space.

Definition 5. The conjoint degree of a corner-occupying action: If one edge (the length is [a.sub.1]) of a triangle and one edge (the length is [b.sub.1]) of an angle region are conjoint and let the length of the overlapping part be [c.sub.1], then the conjoint degree of corner-occupying action is [c.sub.1]/max([a.sub.1], [b.sub.1]). Specially, if another edge (the length is [a.sub.2]) of the triangle and another edge (the length is [b.sub.2]) of the angel region are conjoint and the length of the overlapping part is [c.sub.2], then the conjoint degree of corner-occupying action is [c.sub.1]/max([a.sub.1],[b.sub.1]) + [c.sub.2]/max([a.sub.2], [b.sub.2]).

Definition 6. For two edges of an angle region, if the angle between a edge which is conjoined with a triangle and another edge which is tangent to the triangle is [alpha] and the size of the cutin angle is [beta], then the conformity degree of the corner-occupying action is min(a, p)/max([alpha], [beta]).

The conjoint degree and the conformity degree are used to measure the adjacent degree between the filling triangle and the position where the filling triangle will be placed. The bigger the conjoint degree and the conformity degree of a corner-occupying action are, the higher the adjacent degree is.

4. An Algorithm of Edge-Conjoining and Corner-Occupying

As shown in Figure 7, a rectangle container can be deemed as a plane figure encircled by four triangles.

Definition 7. Pattern: A pattern refers to a kind of ordered pair <P, Q, R>, where P is the set of four triangles forming the rectangle container which some triangles have been put in (each element in the set is denoted by three vertices coordinates of the triangle), Q is the set of triangles out of the rectangle container (each element in the set is denoted by three edges of the triangle), and R is a set of angle region formed by triangles in P.

At the first moment, P contains only four triangles forming the rectangle container, and Q is the set of all triangles to be put in the rectangle container, and R is a set of four angle regions formed by four triangles in P, and then the pattern at this moment is called the initial pattern, which is denoted by <[P.sub.0], [Q.sub.0], [R.sub.0]). Starting with the initial pattern, the pattern formed by putting the kth triangle taken out from Q into the rectangle container is called kth pattern, which is denoted by <[P.sub.k], [Q.sub.k], [R.sub.k]). In the kth pattern, if [N.sub.k] = 0, then it is called the terminal pattern.

In the kth pattern before the terminal pattern, let a triangle perform corner-occupying action, if the triangle is still in the rectangle container and do not intersect with other triangle in [P.sub.k], then the corner-occupying action is called a reasonable corner-occupying action.

Corner-Occupying Strategy. For two reasonable corner-occupying actions [a.sub.1] and [a.sub.2], let the conformity degree of both be [p.sub.1] and [p.sub.2], respectively. If [p.sub.1] > [p.sub.2], then [a.sub.1] is said to have a higher priority than [a.sub.2].

Edge-Conjoining Strategy. For two reasonable corner-occupying actions [a.sub.1] and [a.sub.2], let the conjoint degree of both be [q.sub.1] and [q.sub.2], respectively. If [q.sub.1] > [q.sub.2], then [a.sub.1] is said to have a higher priority than [a.sub.2].

Based on the edge-conjoining strategy and the corner-occupying strategy, a heuristic algorithm for solving triangle packing problem is provided below.

Given the initial pattern <[P.sub.0], [Q.sub.0], [R.sub.0]>, where [P.SUB.0] is the set of four triangles forming the rectangle container, [Q.sub.0] is the set of all triangles to be put in the rectangle container, and [R.sub.0] is a set of four angle regions formed by four triangles in [P.sub.0]. Arrange the angle region and the reasonable corner-occupying action in time order.

Step 1. Set t = 0, and the current pattern S is [S.sub.t].

Step 2. If [Q.sub.0] = 0, then it is reported that all triangles have been put into the rectangle container, and stop; if [Q.sub.0] [not equal to] 0 and there is no reasonable corner-occupying action to perform in St, then the failure of algorithm is reported, and go to Step 3; if [Q.sub.0] = 0 and in St, there exists a reasonable corner-occupying action to perform, and then go to Step 3.

Step 3. Choose a reasonable corner-occupying action with the highest priority to perform according to corner-occupying strategy. If there exists only one reasonable corner-occupying action according to corner-occupying strategy, then fill the triangle according to this corner-occupying action, and go to Step 5; if not, choose a reasonable corner-occupying action with the highest priority to perform according to conjoining-occupying strategy, and go to Step 4.

Step 4. Choose a reasonable corner-occupying action with the highest priority to perform according to conjoining-occupying strategy. If there exists only one reasonable corner-occupying action according to conjoining-occupying strategy, then fill the triangle according to this corner-occupying action; if not, fill the triangle according to the first corner-occupying action.

Step 5. Add three vertical coordinates of the triangle performing the corner-occupying action to the [P.sub.t], and remove three edges of the triangle performing the corner-occupying action from the [Q.sub.t]. Change [P.sub.t] to [P.sub.t+1], [Q.sub.t] to [Q.sub.t+1], and [P.sub.t+1] to [R.sub.t+1] which is the set of angle regions formed by triangles in [P.sub.t+1]. Switch to a new pattern ([P.sub.t+1], [Q.sub.t+1], [R.sub.t+1]), and go to Step 2.

5. Time Complexity Analysis of the Algorithm of Edge-Conjoining and Corner-Occupying

For the initial pattern (P, Q, R) if there are m triangles in P and n triangles in Q without generality, find out the reasonable corner-occupying action with the highest priority and calculate out the f(m, n) time units (step number of calculating) spent on performing the action.

Firstly, calculate the time complexity of all the angle regions formed by m triangles in P.

Given two triangles, take out one edge from each of them, if it will take a time units to judge whether the two edges can form an angle region. Then, it will take C(3,1) * C(3,1) * a = 9a time units at most to find out all the angle regions formed by two given triangles.

It will take C(m, 2)*9*a time units to find out all the angle regions formed by m triangles in P. By the definition of angle region, two triangles can form two angle regions at most. Therefore, there are 2 * C(m, 2) angle regions in R at most. In fact, there is little chance that a triangle is tangent to every triangle, where all the triangles are in the same rectangle container. Generally speaking, the total angle regions formed by m triangles are far less than 2 * C(m, 2). This is the root cause of the high speed of the proposed algorithm.

Secondly, calculate the time complexity of all the corner-occupying actions of putting n triangles which are in the Q into the angle regions in R.

If it will take b time units to put one triangle into the angle region along one of the edges of the triangle which is conjoined with a edge of the angle region, and 22* b time units at most to put one triangle into a given angle region with 22 different corner-occupying actions at most, then it will take 2 * C(m, 2) *22*b time units at most to put one triangle in Q into all the angle regions in R, and 2 *C(m, 2)*22*b*n time units at most to complete the corner-occupying actions of putting n triangles in Q into all the angle regions in R.

Thirdly, calculate the time complexity of judging whether each corner-occupying action is a reasonable corner-occupying action.

If it will take [c.sub.1] time units to judge whether two triangles are intersecting and [c.sub.2] time units to judge whether a triangle is in the rectangle container, then it will take 2 * C(m, 2) *22 * (m *[c.sub.1] + [c.sub.2]) time units to find out all reasonable corner-occupying actions.

Finally, calculate the time complexity of finding out the corner-occupying action with the highest priority from all the reasonable corner-occupying actions.

If it will take d time units to compare the priorities of two corner-occupying action, then it will take 2*C(m,2)*22*n* d time units at most to find out a reasonable corner-occupying action with the highest priority. From the analysis above, the time spent on taking out the triangle corresponding to the corner-occupying action with the highest priority from Q is at most

[MATHEMATICAL EXPRESSION NOT REPRODUCIBLE IN ASCII]. (1)

At this moment, a triangle has been put in the rectangle container, and then switch to a new pattern. it will take k * [m.sup.2] *(m - 1) * n time units at most for each step. In other words,

f (m, n) [less than or equal to] k * [m.sup.2] * (m - 1) * n. (2)

Similarly,

f (m + 1, n - 1) [less than or equal to] k * [(m + 1).sup.2] * (m) * (n - 1); (3)

f (m + i, n - i) [less than or equal to] k * [(m + i).sup.2] * (m + i - 1) * (n - i),

where f(m + n,0) = 0. From the initial pattern, it will reach the end of the algorithm after n steps at most. By the analysis above, the time complexity analysis of the proposed algorithm is

[MATHEMATICAL EXPRESSION NOT REPRODUCIBLE IN ASCII]. (4)

In the initial pattern, m = 4, n is the number of the triangles to be put in the rectangle container. So

[n-1.summation over (i=0)] f (m + i, n - i) [less than or equal to] k * [(n + 4).sup.3] * [n.sup.2] = O ([n.sup.5]). (5)

That is to say, the time complexity of the proposed algorithm is O([n.sup.5]). If there is no reasonable corner-occupying action to perform, then stop. Thus, the order of magnitude of the total computing time is not more than 0([n.sup.5]).

6. Some Illustrative Examples

In this section, we have developed a program to verify the effectiveness of the proposed algorithm, and the experimental data is included in Table 1. This program is developed by using Visual C++6.0, which is realized on a computer with Pentium 2.8 GHz processor and 512 MB of RAM.

Input is the following:

the length and width of rectangle container (error is 0.1),

the edge length of each triangle to be put into (error is 0.000001).

Output is the following:

the utilization (error is 0.1%),

computing time (error is 0.01 second),

the sequence to put the triangles into the rectangle container,

the vertex coordinates of triangles to be put,

the calculating error is 0.000001; the display unit is pixels.

http://dx.doi.org/10.1155/2013/686845

Conflict of Interests

The authors declare that there is no conflict of interests regarding the publication of this paper.

Acknowledgments

This work was supported in part by the Key Project of Technology Department of Henan Province of China under Grant 122102210042, the Scientific and Technological Brainstorm Project of Henan Province of China under Grant 12B520054 and the 863 Program of China under Grant 2011AA01A201.

References

[1] B. Xia and Z. Tan, "Tighter bounds of the First Fit algorithm for the bin-packing problem," Discrete Applied Mathematics, vol. 158, no. 15, pp. 1668-1675, 2010.

[2] K. M. Daniels and V. J. Milenkovic, "Multiple translational containment: approximate and exact algorithms," in Proceedings of the 6th Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 205-214, San Francisco, Calif, USA, January 1995.

[3] J. Brandao, "A tabu search algorithm for the heterogeneous fixed fleet vehicle routing problem," Computers and Operations Research, vol. 38, no. 1, pp. 140-151, 2011.

[4] C. Duhamel, P. Lacomme, A. Quilliot, and H. Toussaint, "A multi-start evolutionary local search for the two-dimensional loading capacitated vehicle routing problem," Computers and Operations Research, vol. 38, no. 3, pp. 617-640, 2011.

[5] G. Fuellerer, K. F. Doerner, R. F. Hartl, and M. Iori, "Metaheuristics for vehicle routing problems with three-dimensional loading constraints," European Journal of Operational Research, vol. 201, no. 3, pp. 751-759, 2010.

[6] S. C. H. Leung, X. Y. Zhou, D. F. Zhang, and J. M. Zheng, "Extended guided tabu search and a new packing algorithm for the two-dimensional loading vehicle routing problem," Computers and Operations Research, vol. 38, no. 1, pp. 205-215, 2011.

[7] C. H. L. Stephen, Z. Zhang, D. Zhang, X. Hua, and M. K. Lim, "A meta-heuristic algorithm for heterogeneous fleet vehicle routing problems with two-dimensional loading constraints," European Journal of Operational Research, vol. 225, no. 2,pp. 199-210, 2013.

[8] G. Dosa and J. Sgall, "First Fit bin packing: a tight analysis," in Proceedings of the 30th International Symposium on Theoretical Aspects of Computer Science, 2013.

[9] Z. Li and V. Milenkovic, "Compaction and separation algorithms for non-convex polygons and their applications," European Journal of Operational Research, vol. 84, no. 3, pp. 539-561, 1995.

[10] V. J. Milenkovic and K. M. Daniels, "Translational polygon containment and minimal enclosure using linear programming based restriction," in Proceedings of the 28th Annual ACM Symposium on the Theory of Computing, pp. 109-118, New York, NY, USA, May 1996.

[11] M. Sindelar, R. K. Sitaraman, and P. Shenoy, "Sharing-aware algorithms for virtual machine colocation," in Proceedings of the 23rd ACM Symposium on Parallelism in Algorithms and Architectures (SPAA '11), pp. 367-377, San Jose, Calif, USA, June 2011.

Ruimin Wang, (1) Yuqiang Luo, (2) Jianqiang Dong, (3) Shuai Liu, (4) and Xiaozhuo Qi (5)

(1) School of Information Engineering, Zhengzhou University, Zhengzhou 450001, China

(2) Informatization Office, University of Shanghai for Science and Technology, Shanghai 200093, China

(3) Zhengzhou Xinda Jiean Information Technology Co., Ltd., Zhengzhou 450002, China

(4) College of Science, University of Shanghai for Science and Technology, Shanghai 200093, China

(5) 95107 Troops, Guangzhou 510500, China

Correspondence should be addressed to Ruimin Wang; iermwang@zzu.edu.cn and Yuqiang Luo; abel.luo.me@gmail.com

Received 20 September 2013; Accepted 24 October 2013

Academic Editor: Guoliang Wei

TABLE 1: Experimental data. Example Edge lengths Edge lengths of Graphic no. of rectangle triangles outputs containers 1 80, 80 (80.0, 56.6, 56.6) x 2 Figure 8(a) (40.0, 40.0, 56.7) x 4 2 700, 400 225.0, 275.5, 160.0 Figure 8(b) 166.0, 174.9, 55.0 278.9, 134.0, 245.0 229.0, 190.0, 299.0 108.0, 260.0, 279.7 296.0, 278.2, 300.4 167.6, 293.2, 273.5 3 200, 200 (100.0, 100.0, 100.0) x 6 Figure 8(c) 4 400, 300 166.0,174.9, 55.0 Figure 8(d) 278.9, 134.0, 245.0 229.0, 190.0, 299.0 108.0, 260.0, 279.7 296.0, 278.2, 300.4 1676, 293.2, 273. Example Algorithm results no. 1 two triangles left Utilization: 75.0% Computing time: 0.008 sec 2 one triangle left Utilization: 71.4% Computing time: 0.006 sec 3 Success! Utilization: 65.0% Computing time: 0.005 sec 4 Success! Utilization: 96.7% Computing time: 0.007 sec

Printer friendly Cite/link Email Feedback | |

Title Annotation: | Research Article |
---|---|

Author: | Wang, Ruimin; Luo, Yuqiang; Dong, Jianqiang; Liu, Shuai; Qi, Xiaozhuo |

Publication: | Discrete Dynamics in Nature and Society |

Article Type: | Report |

Date: | Jan 1, 2014 |

Words: | 4209 |

Previous Article: | Note on the persistence of a nonautonomous Lotka-Volterra competitive system with infinite delay and feedback controls. |

Next Article: | Dynamic pricing based on strategic consumers and substitutes in a duopoly setting. |

Topics: |