Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Search Algorithms Winter Semester 2004/2005 17 Jan.

Similar presentations


Presentation on theme: "1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Search Algorithms Winter Semester 2004/2005 17 Jan."— Presentation transcript:

1 1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Search Algorithms Winter Semester 2004/2005 17 Jan 2005 12th Lecture Christian Schindelhauer schindel@upb.de

2 Search Algorithms, WS 2004/05 2 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Spatial Searching  Prolog: Searching with some help  Searching with total Uncertainty  Nearsighted Search –The Cow Path Problem –The Concept of Competitive Analysis –Deterministic Solution –Finding a Shoreline –Probabilistic Solution –The Wall Problem  Farsighted Search –The Watchman Problem –How to Learn your Environment

3 Search Algorithms, WS 2004/05 3 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Cow-Path Problem  Given –A near-sighted cow –A fence with a gate –The cow does not know the direction  Task –Find the exit as fast as possible ???

4 Search Algorithms, WS 2004/05 4 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Competitive Analysis  How to evaluate the online solution  Classical approach: –Worst-case time This is always n for a fence of length n –Average case This is not better  Competitive Analysis –Compare the cost of the solution of an instance x Cost Alg (x) –to the best possible offline solution (unknown to the cow) Cost offline (x)  Minimize the competitive ratio  =

5 Search Algorithms, WS 2004/05 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Solution of the Cow Fence Problem Deterministic Cow-Path 1.dir  left 2.for i  0 to log n do 3. go 2 i steps to direction dir 4. go 2 i steps back to the origin 5. revert direction dir 6.od Theorem [Baeza-Yates, Culberson, Rawlins, 1993] The deterministic Cow-Path algorithm has a competitive ratio of 9. This competitive ratio is optimal.

6 Search Algorithms, WS 2004/05 6 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Exit Performance of the Cow-Path Algorithm  Performance of the best (offline) strategy: d –where d is the shortest way to the exit  Worst case of the Cow-Path Algorithm –d = 2 x +1 –Let d’=d-1  Number of steps before finding the exit: 1+1+2+2+4+4+...+d’/2+d’/2+d’+d’+2d’+2d’+d’+1 = 9 d’-1 = 9 d - 10 d’ 2d’ d’ 2d’ d’+1 d’/2 d’/4...

7 Search Algorithms, WS 2004/05 7 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Shoreline Problem Problem description  A boat is lost in a half ocean with a linear shoreline  No compass on board  No sight because of dense fog  The distance to the shoreline is unknown Task  Find the coast as fast as possible ?

8 Search Algorithms, WS 2004/05 8 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Spiral Solution for the Shoreline Problem Baeza-Yates, Culberson, Rawlins, 1993 Solution:  Use logarithmic spiral obeying –where r is the polar radius from the starting point –and  is the polar angle  Numerical optimization leads to a competitive optimal ratio for k=1.250...  The shoreline problem can be solved using the logarithmic spiral method with competitive ratio 13.81... 1 k2k2

9 Search Algorithms, WS 2004/05 9 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Searching for a point in a Grid  Problem: –Find a spot in a grid without knowing the coordinates –(finding the restaurant in New York without policemen)  Solution: –Use a spiral covering all points in Manhattan distance 1,2,3,4,...  Theorem [Baeza-Yates, Culberson, Rawlins, 1993] –Using the spiral method this problem can be solved with competitive ratio 2d, where d is the Hamming distance between start and target. –This competitive ratio is optimal.

10 Search Algorithms, WS 2004/05 10 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Search for a point in m Concurrent Rays Problem:  A robot is at the meeting point of m rays  It has to find a point on one of the rays  Find the shortest path Variants 1.Variant: the distance n is known: Then a (2m-1) competitive (deterministic) algorithm optimally solves the case 2.Variant: distance is not known  Visit in round i, i+m, i+2m,.. ray i –no other ordering can improve the ratio  Perform in each ray test –such that ray 1+(i mod m) is searched f(i) steps deep.  Observe for all i>m for all reasonable algorithms:

11 Search Algorithms, WS 2004/05 11 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Spiral Search Cow Spiral-Search-Cow 1.i  0 2.while bull not found do 3. i  i+1 4. 5. explore f(i) steps of ray (i mod m)+1 6. return to the starting point 7. od Theorem The spiral search cow algorithm has a competitive ratio of Proof: Worst case: bull in depth f(i)+1

12 Search Algorithms, WS 2004/05 12 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The spiral search cow algorithm has a competitive ratio of Theorem Proof: Worst case: bull in depth f(i)+1 Steps of spiral-search-cow: Competitive ratio:

13 Search Algorithms, WS 2004/05 13 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Theorem: The Spiral-Search-Cow is optimal up to a constant term o(1). Proof:  Visit in round i, i+m, i+2m,.. ray i –no other ordering can improve the ratio  Perform in each ray test –such that ray 1+(i mod m) is searched f(i) steps deep.  Observe for all i>m for all reasonable algorithms:  Compute the competitive ratio by  Consider the constant c upper bounding  Some (involved) analysis shows that this constant is minimal for  which matches exactly the behavior of the spiral search cow

14 Search Algorithms, WS 2004/05 14 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Deterministic and Probabilistic Competitive Ratio  Deterministic Competitive Analysis –Compare the cost of the solution of an instance x Cost Alg (x) –to the best possible offline solution (unknown to the cow) Cost offline (x)  Minimize the competitive ratio  =  Probabilistic (Randomized) Competitive Analysis –Allow the algorithm to use random input –Compare the cost of the expected solution of an instance x E[Cost Alg (x)] –to the best possible offline solution independent from the random numbers unknown to the algorithm Cost offline (x)  Minimize

15 Search Algorithms, WS 2004/05 15 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Why Randomness Helps - 1:1= 1 3:1= 3 4:2= 2 8:2= 4 9:3= 3 10:4= 2.5 11:5= 2.2 19:3= 6.3.. 20:4= 5 21:6= 3.5 22:7= 3.1.. 23:8= 2.8..... 42:6= 7 43:7= 6.1.. 11:5= 2.2 Expected probabilistic competitive ratio: 6 Optimal deterministic ratio:9

16 Search Algorithms, WS 2004/05 16 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Smart Cow [Kao, Reif, Tate] 5. repeat 6. Explore path  (p) up to distance d 7. d  d r 8. p  p mod m +1 9.until target found Theorem For any r>1 Smart Cow has a competitive ratio of Let c:= min r>1 (1+r)/ln r and let r* be r minimizing this term Theorem Smart Cow is the optimizes the randomized competitive ratio of the cow and the fence problem for r=r* with ratio 1+c = 4.59112..

17 Search Algorithms, WS 2004/05 17 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Probabilism versus Determinism m Randomized Competitive Ratio of Smart-Cow Optimal Deterministic Ratio of Spiral-Search-Cow 24.59112...9 37.73232...14.5 410.84181...19.96296... 513.94159...25.41406... 617.03709...30.85984... 720.13033...36.30277...

18 Search Algorithms, WS 2004/05 18 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Wall Problem  Instance: –A set of non-overlapping oriented rectangles multiples of the unit size in a d x d - square –Player is nearsighted –If we hit a wall we immediately know its geometry  Problem: –Minimize the path to an infinite line parallel to the rectangles  Question: –What is the competitive ratio? –i.e. ratio of found path / shortest path

19 Search Algorithms, WS 2004/05 19 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Lower Bound for the Wall Problem [Papadimitriou, Yannakakis, 1991] Theorem No deterministic algorithm can achieve a competitive ratio of o(n 1/2 ) Proof –Place n obstacles of size 1xn into the deterministic path of the player –such that the middle of each obstacle –Then, the length of the path of the algorithm is n x n/2 = n 2 /2 –There exists a horizontal line –which is at most n 3/2 steps upwards –and hits at most n 1/2 rectangles –If such a line would not exist then the total area covered by the rectange would be larger than n 2 –Hence, the offline solution is at most n 3/2 –This leads to the ratio n 1/2

20 Search Algorithms, WS 2004/05 20 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Upper Bounds for the Wall Problem Theorem [Blum, Raghavan, Schieber 1991] The Wall problem can be solved with the sweep algorithm with competitive ratio O(n 1/2 ) Theorem [Fiat, Karloff, Rosen, Berman, Blum, Saks 1996] There is a O(n 4/9 log n) competitive randomized algorithm for the wall problem.

21 Search Algorithms, WS 2004/05 21 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Deterministic Optimal Solution for the Wall Problem  Techniques –Move upwards, downwards or right But never to the left –Algorithm works in phases Guess distance n by W If something fails we proceed with the next phase at the end W f = O(n) –Use a window to prevent drifting apart In each phase this window size doubles –If payable use a full sweep Circumvent a rectangle on the shortest route and switch back to the original height if it costs at most n 1/2  indicated by T = W/n 1/2 –If it is too expensive perform at most n 1/2 sweeps in the window A Sweep is a monotone path upwards or downwards (indicated by dir) Use a counter (count) that avoids too many sweeps more than n 1/2

22 Search Algorithms, WS 2004/05 22 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Case 4 Case 3 Case 2 The Wall Algorithm 1.dir  downwards 2.count  1 3.W  n 4.T  n 1/2 5.while wall not reached do (phase starts) 6. walk to the right to the next obstacle O 7. If the distance to the nearest corner of O is at most T then 8. perform full sweep 9. else if O spans the entire window then 10. Go to the nearest corner 11. W  2 W 12. T  W/n 1/2 13. count  1 14. reverse dir 15. else if the corner of O in direction dir is inside the window then 16. go to the corner in direction dir of O else 17. count  count+1 18. reverse dir 19. if count > n 1/2 then 20. W  2 W 21. T  W/n 1/2 22. count  1 23. fi 24. fi 25. od Case 1 TT TT W dir TT TT TT TT

23 Search Algorithms, WS 2004/05 23 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Wall Algorithm needs O(W f n 1/2 ) steps where W f is the final window size  We bound the number of steps in each phase by c W n 1/2 for a constant c –Then the over-all number of steps is O(W f n 1/2 )  Case 1: –Each full sweep costs T = W/n 1/2 –The number of full sweeps is bounded by n This leads to O(W n 1/2 ) steps  Case 2: –ends a phase without moving, no cost  Case 3 and 4: –each sweep costs at most n vertical steps –The number of sweeps is bounded O(n 1/2 ) by the count mechanism This leads to O(W n 1/2 ) steps TT 1st sweep 2nd sweep 3rd sweep

24 Search Algorithms, WS 2004/05 24 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The shortest path has at least length  (W f )  We need to prove that the increase of window size is justified  Case 2: An obstacle spans the complete window –Then the shortest path cannot lie within the window and therefore it is at least W/2  Case 4: The number of sweeps is larger than n 1/2 –After each sweep we have collected a number of rectangles that obstruct each path by at least T=W/ n 1/2 –So all paths inside this window have minimum length n 1/2 W/ n 1/2 = W TT W TT TT

25 Search Algorithms, WS 2004/05 25 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Competitive Ratio of the Wall Algorithm  The Wall Algorithm needs O(W f n 1/2 ) steps where W f is the final window size  The shortest path has at least length  (W f )  The competitive ratio is  = O(W f n 1/2 )  (W f ) = O(n 1/2 )

26 Search Algorithms, WS 2004/05 26 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Room Problem  Instance: –A set of non-overlapping oriented rectangles multiples of the unit size in a d x d - square –Starting point in the corner –Player is nearsighted  Problem: –Minimize the path to the middle of the square  Observation: –shortest path has length of at most d Theorem [Blum, Raghavan, Schieber 1991] The room problem can be solved with competitive ratio of O(n 1/2 ) Theorem Fiat, Bar-Eli, Berman, Yan [94] 1.The room problem can be solved with competitive ratio of O(log n) 2.There is no better algorithm.

27 Search Algorithms, WS 2004/05 27 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer s-t-Problem  Instance: –A set of non-overlapping oriented possible unbounded rectangles multiples of the unit size –Starting point s –Target t  Known –coordinates of s and t are known –barriers in distance 1  Problem: –Minimize the path from s to t  Theorem –There is a O(n 1/2 ) competitive algorithm for the s-t-problem

28 28 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Thanks for your attention End of 12th lecture Next lecture:Mo 24 Jan 2005, 11.15 am, FU 116 Next exercise class:Mo 17 Jan 2005, 1.15 pm, F0.530 or We 19 Jan 2005, 1.00 pm, E2.316


Download ppt "1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Search Algorithms Winter Semester 2004/2005 17 Jan."

Similar presentations


Ads by Google