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 10 Jan.

Similar presentations


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

1 1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Search Algorithms Winter Semester 2004/2005 10 Jan 2005 11th 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 –Searching without help –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 Searching with some Help From “Searching with Uncertainty”, Kranakis, Krizanc, SIROCCO, 1999, 194-203  Problem: –In Manhattan you are looking for a restaurant –You ask a policeman at every crossing for directions –This policeman stays at his crossing –There is a constant error probability p<1/2 that this information is wrong  Task: –Find the restaurant as fast as possible –with respect to the start distance d ???

4 Search Algorithms, WS 2004/05 4 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Main Problem  If you rely all policemen there is a constant probability that you get stuck  If you ignore the advice of the policemen you need much more time –Then you can use a spiral approach taking O(d 2 ) steps target start

5 Search Algorithms, WS 2004/05 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Solution for the 1-Dimensional Case  Consider a ring of length n Search-Ring(k) 1.dir  direction at start position 2.for i  1 to n or target is reached do 3. move in direction dir 4. od 5.if the majority of the policeman met so far agree then 6. continue in direction dir until target is found 7.else 8. reverse direction dir and continue until target is found 9.fi Observation: The probability that Search-Ring continues in the correct direction after k steps is

6 Search Algorithms, WS 2004/05 6 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer  The probability to make a wrong decision is given by  Observe  To describe X m  m/2 we set  This leads to  Let m = c log n and c’=min( ,  2 ) then the error probability is Analysis of the Ring Case Theorem Search-Ring(k) for k=  (log n) solves the search problem within d+O(log n) steps with high probability, i.e. 1-n -O(1). Proof  Consider Bernoulli experiment of X i of choosing direction with probability p for outcome 1 and probability 1-p for outcome 0.  Chernoff bound: –For independent Bernoulli variable X i and with

7 Search Algorithms, WS 2004/05 7 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The 2-Dimensional Case  Assumptions –Torus street map –Policemen point to east/west bound direction before showing to north/south bound direction (if their advice is correct).

8 Search Algorithms, WS 2004/05 8 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Block-Wise Approach  Consider Blocks of size  (log n) x  (log n)  Properties (with high probability) –West/east bound directions can be decided correctly with high probability –If the target is north/south bound from a block this can be decided correctly by scanning all the columns of a block Kranakis-Krizanc-Search 1.Apply horizontal Search-Ring(c log n) to find the west/east bound direction 2.Follow this direction until a majority of policemen in a block advises to go into the opposite direction 3.Find the correct vertical column in the current block and the block visited before 4.Move along the vertical direction until the target is found or the majority of policemen points backwards 5.If the target has not been found by now, perform a spiral search

9 Search Algorithms, WS 2004/05 9 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Performance of Kranakis-Krizanc-Search Theorem With high probability the Kranakis-Krizanc-Search finds the target in d + O(log 2 n) steps. Proof: Follows by applying Chernoff bounds Discusssion:  Prefering horizontal directions over vertical ones is an (unnecessary) simplification  The block-wise approach can solve this problem as well, since either the horizontal or the vertical direction can be detected by a walk through a block –This results in an algorithm with same performance (exercise!!)  Policemen help a lot

10 Search Algorithms, WS 2004/05 10 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 ???

11 Search Algorithms, WS 2004/05 11 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  =

12 Search Algorithms, WS 2004/05 12 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer The Rental Ski Problem Problem –Buying a pair of skis costs 100 Euro –Renting a pair of skis one day costs 10 Euro  How many days do we have snow?  Shall we buy or rent? 1st Solution: Buy on the first snow day  Buy one the first day of snow –Cost Buy (1) = 100  Worst case = 1 day of snow –Cost offline (1) = 10 (1 day renting) 2nd Solution: Always rent  Rent every day –For x snow days –Cost Buy (x) = 10 x  Worst case = always snow –best strategy: buy on the first day –Cost offline (1) = 100

13 Search Algorithms, WS 2004/05 13 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer A Better Solution for the Rental Ski Problem Rent&Buy 1.Rent for 10 days 2.Then Buy on the 11th day  Cost for x<11 days of snow: –Cost Rent&Buy (x) = 10x  Cost for x>10 days of snow: –Cost Rent&Buy (x) = 200  Best strategy for x<11 days of snow: –Rent for x days –Cost offline (x) = 10x  Best strategy for x>10 days of snow: –Buy on the first day –Cost offline (x) = 100

14 Search Algorithms, WS 2004/05 14 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.

15 Search Algorithms, WS 2004/05 15 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...

16 Search Algorithms, WS 2004/05 16 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 ?

17 Search Algorithms, WS 2004/05 17 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

18 Search Algorithms, WS 2004/05 18 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 Hamming 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.

19 19 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Christian Schindelhauer Thanks for your attention End of 11th lecture Next lecture:Mo 17 Jan 2005, 11.15 am, FU 116 Next exercise class:Mo 10 Jan 2005, 1.15 pm, F0.530 or We 12 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 10 Jan."

Similar presentations


Ads by Google