Polygons and Database Driven Marker Making
5.1 Denition and Complexity
Given a set of overlapping polygons, the separation problem is the problem of nding a set of translations of the polygons such that, after the translations, the polygons are in non- overlapping positions and such that the total translation of all the polygons is minimized.
First we show that nding a global minimum for the total translation is NP-complete.
Theorem 5.1
The separation of overlapping polygons is NP-complete even for rectangles.Proof:
Since rotation is not allowed, we can use the same argument as in [MDL91] to show that the problem is in NP. To show it is NP-hard we again reduce PARTITION to the problem. Figure 5.1 shows the construction of the reduction. Let (a
1;a
2;:::;a
n)be the integers in an instance of PARTITION. Let
B
= Pni=1
a
i=
2. Placen
rectangularin overlapping positions. The rectangular space is then surrounded by many additional rectangular \blocks" to make sure its size is not easily enlarged. For one piece to move from one position to another position inside the rectangular space, it needs to move no more than 1 unit vertically and
B
units horizontally. The total motion of the pieces is therefore less thanB
+B
2. The surrounding blocks are built in such a way that to increase thelength or the width of the rectangular space, they have to move a total of
B
+B
2 unitsdistance. Therefore, PARTITION has a solution if and only if the total displacement in the separation is less than
B
+B
2. The construction can be done in polynomial time.2
In applications of the algorithm, namely the database driven automated marker making and correcting overlaps caused by rounding error, the polygons are not grossly overlapped. They tend to overlap slightly on their boundaries since the polygons being substituted are matched for similar shape and size or vertices and the position of a polygon has been rounded to the nearest integer. Next, we show that even with the additional restriction that the polygons only slightly overlap each other, the separation problem is no easier than the general case, that is, it remains NP-complete.
We dene the degree of overlap
r
for two overlapping polygonsP
andQ
as the minimum translation needed forP
to be in a non-overlapping position withQ
. We say that two polygons are slightly overlapping if their degree of overlapr
1
c
minfW
P;H
P;W
Q;H
Qgfor a constant
c >
1, whereW
P;H
P;W
Q;H
Q are the widths and heights of the boundingboxes of
P
andQ
.Theorem 5.2
The separation of overlapping polygons is NP-complete even if the polygons just slightly overlap each other.Proof:
We reduce the NP-hard 2-PARTITION problem to this problem. The 2-PARTITION problem is the same as PARTITION except that it requires that the two subsets each con- tain the same number of integers. Each piece still has height 1 but width 2Bc
+a
i. Therectangular space in the middle now has size 2(2
Bnc
+B
). We divide then
pieces intotwo rows each containing
n=
2 pieces within the middle space. The two rows do not overlap vertically. Within each row, the pieces are spread out evenly. The degree of overlap between two adjacent pieces in each row is at most2
B
because 2
B
is the total overlap. If there is a solution to 2-PARTITION, the moves needed to make the pieces non-overlapping are as follows: exchange two vertically adjacent pieces when necessary and do horizontal adjustment within each row. The vertical exchanges have a total displacement of at most 2n
. The total horizontal displacement within each row is at mostnB
because each piece has at mostB
horizontal displacement. So with<
2n
(B
+ 1) total displacement, we can solve the separation problem. We put 2n
(B
+ 1) surrounding blocks on each side to restrict the movement of the pieces within the middle space. 2It is easy to see that the constant
c
can be replaced by a polynomialF
(B;n
) and the proof still works.Remark 5.1
In the proofs of Theorem 5.1 and Theorem 5.2, we assumed that the distance used is the usual Euclidean distance. We observe that the proofs are also valid usingL
1distance. The
L
1 distance between the two pointsp
1 = (x
1;y
1) andp
2 = (x
2;y
2) is denedas follows.
d
L1(p
1;p
2) = jx
1x
2 j+jy
1y
2 jRemark 5.2
We mentioned in Section 1.2.3 that we will prove the compaction problem to be PSPACE-hard in Chapter 9. The gap in complexity between the compaction problem and the separation problem is accounted for by the fact that the compaction problem is dened as a motion planning problem in which the polygons cannot pass through (or jump over) each other, while in the separation problem there is no such restriction. We would like to point out that if we eliminate the above mentioned restriction in the compaction problem, then compaction, separation and packing all become equivalent. The NP-complete layout problem can be reduced to separation through essentially the same reduction as the on in the proof of Theorem 5.1 : In Chapter 8, we will develop a mixed integer programming (MIP) formulation of compaction. Under the MIP formulation, the polygons are permitted to pass through each other. The formulation gives a direct reduction of compaction to MIP which shows compaction is in NP. Thus, we establish the NP-completeness of compaction when the polygons can pass through each other. The same MIP formulation also gives a direct reduction of the strip packing problem to mixed integer programming. In fact, compaction and strip packing become equivalent under the formulation.c
Q −
c
P(0, 0)
Figure 5.2: Minkowski sum of two slightly overlapped polygons.