Upload
ishan
View
214
Download
0
Embed Size (px)
Citation preview
Folding Links Is Hard
Ishan BehooraDepartment of Manufacturing and Automation Engineering
Netaji Subhas Institute of TechnologyDwarka, New Delhi, [email protected]
Abstract—The ruler folding problem asks: Given a set of nline segment links attached at their end points with rotatingjoints. Find a minimum length folding of this chain of linksalong a line.
In this paper, we provide an improved approximation forthe problem if the longest link is significantly larger thanthe rest. We then consider generalizations to trees of linksand instances containing cycles of links. We provide the firstfully polynomial time approximation scheme (FPTAS) for thetree variant and prove the inapproximability of cycle variants.Lastly, we consider the area optimizaton problem, of foldingthe links to achieve minimum area within minimum width.We prove the problem and any multiplicative approximationto be NP-hard and also prove the impossibility of any additivepolynomial time approximation schemes (PTAS).
Keywords-folding; approximation; FPTAS; PTAS; hardness;
I. INTRODUCTION
The ruler folding problem is a famous problem fromcomputational geometry which can be stated as follows:Given a chain of n links, line segments l1, l2, l3..ln. Theselinks are attached end to end about joints which can rotatefreely forming a chain. Fold the links turning each jointeither 0◦ or 180◦ with respect to the previous one, so as toachieve minimum length.
The problem can be stated formally as: Determinee1, e2, e3..en where ei ∈ {−1, 1} such that max{∀j
∑ji=0 li ∗ ei} - min {∀j
∑ji=0 li ∗ ei} is minimized.
An example of a 3 link chain with lengths 6,3 and 6 isshown below in Fig. 1.
Figure 1. 3-Link chain minimum length
This problem has many applications. One of the mostnatural ones stems from robotics where a robot’s base andarms can be modelled as links. This is depicted in Fig.2.
Folding for minimum length lets us calculate propertiessuch as the smaller radius of the work envelope and alsohelps us figure out the best way to pack the robot as shownbelow in Fig. 3.
Another application is in computational biology whereprotein folding can be analyzed a problem of folding links.
It was in the context of robotic arm movement thatthe question was studied by Hopcroft, Joseph and White-sides [1], who proved the problem to be NP-completeand provided a 2 factor approximation algorithm forit. Subsequently this was improved to max{2m1 −m1−m2
2k−2 ,∑k−1i=0
m12i }, where m1 and m2 are the two largest
links respectively and k is the number of occurences of m1 inthe chain, by Norullah and Razazzi [2]. Our paper improvesupon this bound for large k if m1 > 2m2.
Figure 2. Modelling Robot arms
Figure 3. Folded arms
2010 International Conference of Computational Science and Its Applications
978-0-7695-3999-7/10 $26.00 © 2010 IEEE
DOI 10.1109/ICCSA.2010.36
68
2010 International Conference on Computational Science and Its Applications
978-0-7695-3999-7/10 $26.00 © 2010 IEEE
DOI 10.1109/ICCSA.2010.36
68
Calinescu and Dumitrescu [3] also studied the problemand provided the first FPTAS for it. In our paper we alsolook at generalizations of the problem from a path of linksto trees of links and graphs with cyles. We provide the firstFPTAS for the trees case and prove the inapproximiabilityof cases involving cycles.
Later in their paper, Calinescu and Dumitrescu [3] intro-duced an area variant of the problem, in which the aim isto fold the links such that no two joints are more than L (=max {l1, l2..ln}) distance away and the area of the convexhull of the joints is minimized. An example using the same3 link chain is shown in Fig. 4.
The problem can be stated formally as :Determine θ1, θ2, θ3..θn where xj =
∑ji=0 li ∗ cosθi and
yj =∑ji=0 li ∗ sinθi under the constraint that ∀i, j
distance((xi, yi), (xj , yj)) ≤ L , such that the area of theconvex hull of (x0, y0), (x1, y1)..(xn, yn) is minimized.
In our paper we study this problem and prove it andany multiplicative approximation to be NP-hard. We alsoconsider additive approximations and prove the impossibilityof any additive FPTAS or PTAS.
As with the line case, results here can be used to determinethe best way to pack a robot. This is illustrated below in Fig.5.
Figure 4. 3-Link chain minimum area
Figure 5. Packing arms
II. OUR WORK
A. Length minimization
Since we already know the ruler folding problem is NP-complete the question is can the approximation algorithmgiven in [2] be improved? It turns out that an improvementcan be made to the second term in the bound.
Theorem 1: An improved upper bound for a ruler foldingis max(2m1 − m1−m2
2k−2 ,∑min(k−1,k2)i=0
m12i ) where k2 is the
smallest integer such that∑k2i=0
m12i >= m1 + 2m2.
Proof:Notice, that under the condition m1 > 2m2, there is no
need to go beyond m1+2m2. We can follow the algorithmprovided in [2] till the length is ≥ m1+2m2 and thenconsider a partitioning from the end point reached as shownin Fig. 6 and use the FOLD algorithm given below.
Figure 6. Partitioning the folding so far
Algorithm II.1: FOLD(linkIndex, currentPosition)
if currentPosition <= P
then
if linkLength[linkIndex] = m1
then{currentPosition←currentPosition+m1
else if linkLength[linkIndex] < m1
then{currentPosition←HOPCROFT(currentPosition,AP )
else
if linkLength[linkIndex] = m1
then{currentPosition←currentPosition−m1
else if linkLength[linkIndex] < m1
then{currentPosition←HOPCROFT(currentPosition,QB)
FOLD(linkIndex+ 1, currentPosition)
Once we reach the limit m1+2m2 we use the algorithmgiven in [1] to stay within AP or QB if the link is not m1
otherwise we hop between them.In the algorithm by [2] they fold the smaller links into
2m2 intervals about the first m1 and after this for everyadditional m1 they increase the length by at most half thecurrent length by folding it to towards the appropriate side.If m1 > 2m2 the length needed for k = 1 is m1 hence theirexpression reduces to
∑k−1i=0
m12i . This coupled with our limit
of m1+2m2 explained above results in the improved bound.Our upper bound is an improvement because if k is largeusing [2] we get
∑k−1i=0
m12i which tends to 2m1 whereas our
result shows we can stop once we reach m1 + 2m2.
6969
Now, we consider the natural extention of the problemfrom a chain of links, which is a path, to trees of links. Weobviously want to know if the already known algorithms forpaths are applicable for trees. The linear time approximationalgorithms for paths given by [1] and [2] can also be usedfor trees by considering them as a collection of paths. (kbecomes the number of instances of m1 in the whole tree).However, the new bound we have found and the FPTASfrom [3] can not be applied.
This asks the question: Does there exist a fully polynomialtime approximation scheme (FPTAS) or polynomial timeapproximation scheme (PTAS) for folding trees?
The obstacle one faces with trees is that at nodes whichbrach out the posibilities to consider are exponential in thedegree of the node. Fortunately we can overcome this usingthe following lemma.
Lemma 2: If there exits an FPTAS/PTAS for binary trees,we can have an FPTAS/PTAS for trees having any degree.
Proof: Given any general tree, for each node ni havingdegree d > 2, we can add d-1 additional nodes such that theoriginal ni node and the newly added nodes have degree 2.This can be done by reducing the degree of n1 incrementallyby 1 by replacing any two braches of ni by one brach of 0length attached to the orignal two branches. To convert tobinary tree it will take at most n additional nodes and O(n2)operations and so we can use the FPTAS/PTAS to find thefolding for this new modified tree and use the same foldingon the old tree as the new links are all of length 0.
This process is illustrated in Fig. 7.
Figure 7. Partitioning the folding so far
Thus, turning out attention to binary trees.Lemma 3: There exists an FPTAS for determining the
folding for a binary tree.Proof:
From [1] we know that a optimal folding will not belonger than 2L, where L is the longest link. Hence for anyoptimal folding, if we start the first link from origin, wenever need to go beyond 2L in either direction. Thus allpossible optimal foldings will start at O and are containedwithin [−2L, 2L].
Starting with the base case of no links, we can generateall possible foldings till a node nk iteratively. Each link lkcan be attached in one of two directions to the foldingspossible using the links till node nk−1. If we denote afolding starting at 0 and ranging from a to b by (a, b), thenthe only two possible foldings after using the link lk are(min(a+lk, 0), b+lk) and (a−lk,max(0, b−lk)) as shownbelow in Fig. 8.
In this way we can generate foldings for paths. For trees,we start at the leaves and work our way backwards updatingall nodes at a particular depth from the root, before movingto a lower depth. If we come across a node having one child,i.e. one link attached to it, we can proceed as in the pathcase.
However, if we come across a node n having two children,links li and lj attached to it, we split the node into twonodes. Create temporary nodes n1 connected to link li andn2 connected to lj and determine all possible foldings for n1
and n2. After that we can combine them back into n because∀a1, a2, b1, b2 such that (a1, b1) is possible for n1 and(a2, b2) is possible for n2 then (min(a1, a2),max(b1, b2))is possible for n.
Using this we can determine all possible foldings for asubtree rooted at a particular node. Once we work our wayback and reach the root, we have all possible foldings andwe can pick the best one.
Figure 8. Update process
7070
If we store the exact values of (a,b) for each foldingsthe possibitilies are exponential and so as done in [3] wepartition of the sample space into intervals. We use 4n
εintervals, where n is the number of nodes in the tree, andwe will store 2-tuples for each node (ai,bi) indicating ifa folding starting from exactly 0 and spanning from ai tobi intervals is possible or not for the subtree starting fromthat node. This is illustrated in Fig. 9. Since, the startingpoint is maintained as exactly 0 we can still do the split andcombination for nodes having two children. The error dueto considering intervals instead of actual foldings spans canbe bounded as follows.
Lemma 4: For a subtree rooted at ni an actual foldingstarting at 0 and ranging from ar to br exists then an intervalfolding (av, bv) exists such thatar − av ≤ kδbr − bv ≤ kδwhere k is the length of the path to the furthest leaf in thesubtree and δ = interval length = Lε
n .Proof: We prove this using induction. For the base case
a single node, the actual folding (0, 0) is the folding we storehence ar − av = 0 ≤ 0δ and br − bv = 0 ≤ 0δ.
Now assume for a particular node nk for every actualfolding (ar, br) we have an interval folding (av, bv) suchthat ar − av ≤ kδ and br − bv ≤ kδ where k is the lengthof the path to the furthest leaf in the subtree. If this node isjoined by link lk to node nk+1, the foldings possible at nk+1
are (min(ar + lk, 0), br + lk) and (ar− lk,max(0, br− lk))for every (ar, br) at nk.• For the possibility (min(ar + lk, 0), br + lk):
Assuming av + lk lies in interval av2 and bv + lk liesin interval bv2.⇒ bv + lk − bv2 ≤ δusing the induction hypothesis br − bv ≤ kδ⇒ br + lk − (bv + lk) ≤ kδAdding br + lk − bv2 ≤ (k + 1)δ
If av + lk ≤ ar + lk ≤ 0(min(av + lk, 0), bv + lk) = (av + lk, bv + lk)(min(ar + lk, 0), br + lk) = (ar + lk, br + lk)Similarly as with br+ lk−bv2, ar+ lk−av2 ≤ (k+1)δ
If av + lk ≤ ar + lk ≤ 0(min(av + lk, 0), bv + lk) = (0, bv + lk)(min(ar + lk, 0), br + lk) = (0, br + lk)0− 0 ≤ (k + 1)δ
If av + lk ≤ 0 ≤ ar + lk(min(av + lk, 0), bv + lk) = (av + lk, bv + lk)(min(ar + lk, 0), br + lk) = (0, br + lk)0− av2 ≤ ar + lk − av2 ≤ (k + 1)δ
Thus in all cases min(ar + lk, 0)−min(av + lk, 0) ≤(k + 1)δ
Figure 9. partitioning into intervals
• For the possibility (ar − lk,max(0, br − lk)):Assuming av − lk lies in interval av2 and bv − lk liesin interval bv2.
⇒ av − lk − av2 ≤ δusing the induction hypothesis ar − av ≤ kδ⇒ ar − lk − (av − lk) ≤ kδAdding ar − lk − av2 ≤ (k + 1)δ
If br − lk ≥ bv − lk ≥ 0(ar − lk,max(0, br − lk)) = (ar − lk, br − lk)(av − lk,max(0, bv − lk)) = (av − lk, bv − lk)Similarly as with ar− lk−av2, br− lk−bv2 ≤ (k+1)δ
If 0 ≥ br − lk ≥ bv − lk(ar − lk,max(0, br − lk)) = (ar − lk, 0)(av − lk,max(0, bv − lk)) = (av − lk, 0)0− 0 ≤ (k + 1)δ
If br − lk ≥ 0 ≥ bv − lk(ar − lk,max(0, br − lk)) = (ar − lk, br − lk)(av − lk,max(0, bv − lk)) = (av − lk, 0)br − lk − 0 ≤ br − lk − bv − lk ≤ (k + 1)δ
Thus in all cases min(br − lk, 0)−min(bv − lk, 0) ≤(k + 1)δ
Hence the subtree rooted at nk+1 having degree 1, forevery actual folding (ar, br) we have an interval folding(av, bv) such that ar−av ≤ (k+1)δ and br−bv ≤ (k+1)δ.For nodes which have two children, splitting the node nk+1
into n1 and n2.
At n1 for every actual folding (ar1, br1) we have aninterval folding (av1, bv1) such that ar1 − av1 ≤ (k1 + 1)δand br1 − bv1 ≤ (k1 + 1)δ.At n2 for every actual folding (ar2, br2) we have an intervalfolding (av2, bv2) such that ar2 − av2 ≤ (k2 + 1)δ andbr2 − bv2 ≤ (k2 + 1)δ.
If k = max(k1, k2) ⇒ar1 − av1 ≤ (k + 1)δ, br1 − bv1 ≤ (k + 1)δand ar2 − av2 ≤ (k + 1)δ,br2 − bv2 ≤ (k + 1)δ.
7171
After the recombination at nk+1 for every actual folding(ar, br) we have an interval folding (av, bv) such thatar − av ≤ (k + 1)δ and br − bv ≤ (k + 1)δ.
Hence for the subtree rooted at nk+1 having degree 2,for every actual folding (ar, br) we have an interval folding(av, bv) such that ar−av ≤ (k+1)δ and br−bv ≤ (k+1)δ.Thus the lemma is proved.
Also note from the proof, that the (av, bv)s generated arealways associated with a corresponding (ar, br) and hencesuperfluous additional interval foldings are not generated.
Suppose the optimal folding is (ar, br) from the abovelemma 4 we get that there exists an interval foldings (av, bv)such that ar − av ≤ nδ and br − bv ≤ nδ⇒ (bv − av)− (br − ar) ≤ nδ. since δ = Lε
n⇒ (bv − av)− (br − ar) ≤ Lε.⇒ (bv − av) ≤ (br − ar) + Lε ≤ (1 + ε)OPT
The algorithm takes O(n5
ε4 ) time and O(n3
ε2 ) space andhence is a FPTAS.
Note that using this approach we reduce the running timeand space of the FPTAS based on trimming the solutionspace from [3] to O(n
3
ε2 ) time and O(n2
ε2 ) space and hencebring it on par with the FPTAS based on rounding andscaling given later in the same paper.
Thus, combining lemma 2 and lemma 3 we can answer thequestion of whether a FPTAS exists for trees in the positive.
Theorem 5: There exists an FPTAS for determining thefolding for a tree.
Next we turn to graphs with cycles. Determining iffolding a cycle onto a line is possible is NP-complete.However, given that a folding exists is it possible to findan approximation to the optimal?
Theorem 6: Any approximation to optimally folding agraph with cycles is NP hard.
Proof: Assume we have an algorithm which gives anapproximate to the optimal folding given that at least onefolding exists. We run the same algorithm on a general case,i.e. one for which a folding may or may not exist. If thealgorithm exits with a valid folding we can say a foldingexists but if the algorithm exits with an invalid folding orerror state eg. divide by zero, more steps than it should useetc. then we can say no folding exists as one would havebeen found if it existed. Hence, we can resolve the NP-complete problem of if a folding is possible.
Although the general problem is hard, if we simply theproblem and consider graphs with identical links it is easilysolvable. For general graphs with identical link lengths, L,if the graph is bipartite we can label each node and fold intotwo halfs and achieve a folding of size L which is optimalotherwise the graph contains an odd cycle and can not befolded onto a line.
B. Area minimization
Now, we consider the area variant introduced by Cali-nescu and Dumitrescu [3] and the question arises: Can areaminimization within maximum link width (L) be achievedexactly and if not is there a FPTAS/PTAS for it.
Theorem 7: Finding the optimal area folding within aconstant width is NP hard as is any multiplicative approxi-mation.
Proof: Given a set of links with maximum length L.If we have an algorithm which obtains the optimal foldingor any multiplicative approxmation, we can use it to checkif the optimal area is 0. And if so the original chain canbe folded within length L, if not it can not. Hence we havesolved a NP complete question.
And so we turn our focus to additive approximations andto whether area minimization within maximum link width(L) has an additive FPTAS/PTAS.
When folding within width L, in a sense we are com-pressing a line folding and so for foldings which are longerthan L this results in positive area. We now try to quantifythis area.
Lemma 8: If a folding with n integer length links andmaximum link length L has optimal area Area > 0 thenArea ≥
√2nL−14n .
Proof: Consider the flattening of any folding by rotatinglinks to the nearest horizontal. This is illustrated below inFig. 10. Notice that each flattening should translate but doesnot rotate the remaining links.
Figure 10. Flattening the folding
Now consider the flattening of an n integer length linkswith maximum length link L (AB) and optimal folding > 0as shown in Fig. 11
7272
Figure 11. Positive area example
Start at A and flatten the links following A till a joint,say J, falls outside AB. If J falls beyond B chose the chainA to J, otherwise chose the chain B to A to J.
If you reach the end before a joint falls outside AB, startfrom B and flatten the links before B. Similarly if the jointJ falls beyond A chose the chain B to J otherwise chose thechain A to B to J. At least one has to occur otherwise afolding within AB is possible which has 0 area.
By the above procedure we have chosen a flattened chainwhich begins at one of the end points A or B and thencrosses the other end point. Since each link is an integerlength this chain has to have length at least L+1.
Note that each of this chain’s links are rotated ≤ 90◦ toreach the original configuration in which the chain fits withinlength L. As shown in the above Fig. 12, consider the jointJ which has to be moved at least one unit (L+1 to L). Themaximum joint J can be moved backward the maximum ifall links in the backward direction remain horizontal and alllinks in the forward direction are bent as much as possible.
If h is the maximum height reached on either side of ABthen, since the smallest link is 1, the maximum angle anylink can make with the horizontal is sin−12h. As there aren links each with length ≤ L, we can move back by at most(1-cos(sin−12h))nL. Since it is possible to move J back towithin length L⇒ nL(1 - cos(sin−12h)) ≥ 1⇒ 2h ≥
√2nL−1nL .
⇒ Area ≥ 12Lh =
√2nL−14n .
Figure 12. Folding within height bounds
This area is large enough to discount the possibility of aFPTAS/PTAS.
Theorem 9: There is no additive FPTAS or PTAS for areaminimization.
Proof: Using a construction similar to the one in[1], we consider a set partition problem n elements withmaximum element L. This is equivalent to the ruler foldingproblem with n+4 elements and links nL nL
2 l1l2..lnnL2 nL.
If a FPTAS/PTAS was possible we can call it with
an ε <
√2(n+4)(nL)−1
4(n+4) and if a folding within length L ispossible for the given chain the algorithm will produce itotherwise no such folding is possible.
Now, 1ε = 4(n+4)√
2nL(n+4)−1≤ 4(n+4)√
2n(n+4)−1≤ 20
3 and
hence we can use the FPTAS/PTAS to answer question ofwhether a folding within length nL is possible and hencesolve the NP-complete set partition problem. This is notpossible assuming P!=NP and thus no FPTAS/PTAS exists.
III. ACKNOWLEDGMENTS
Part of the research was conducted while the author wasa research intern in the Algorithms Group at MicrosoftResearch India. Amit Deshpande of Microsoft ResearchIndia provided invaluable guidance and feedback during thecourse of the research. We express our gratitute to both Amitand Microsoft Research.
REFERENCES
[1] J. Hopcroft, D. Joseph, S. Whitesides, On the movement ofrobot arms in 2-dimensional bounded regions, SIAM Journalon Computing Vol. 14, No. 2, 315-333, 1985.
[2] A. Nourollah and M. Razzazi, A Linear Time ApproximationAlgorithm for Ruler Folding Problem, Journal of UniversalComputer Science. Vol. 14, No. 4, 566-574, 2008.
[3] G. Calinescu and A. Dumitrescu, The Carpenter’s RulerFolding Problem, Combinatorial and Computational Geome-try Mathematical Sciences Research Institute Publications,Cambridge University Press, 155-166, 2005.
[4] N. Karmarkar and R. Karp, The Differencing Method of SetPartitioning, Technical Report. CSD-83-113, 1983.
7373