1 / 19

Search Algorithms Winter Semester 2004/2005 10 Jan 2005 11th Lecture

Search Algorithms Winter Semester 2004/2005 10 Jan 2005 11th Lecture. Christian Schindelhauer schindel@upb.de. Spatial Searching. Prolog: Searching with some help Searching with total Uncertainty Nearsighted Search The Cow Path Problem The Concept of Competitive Analysis

Download Presentation

Search Algorithms Winter Semester 2004/2005 10 Jan 2005 11th Lecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Search AlgorithmsWinter Semester 2004/200510 Jan 200511th Lecture Christian Schindelhauer schindel@upb.de

  2. 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. 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. The Main Problem start • 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(d2) steps target

  5. The Solution for the 1-Dimensional Case • Consider a ring of length n Search-Ring(k) • dir direction at start position • for i1 to n or target is reached do • move in direction dir • od • if the majority of the policeman met so far agree then • continue in direction dir until target is found • else • reverse direction dir and continue until target is found • fi Observation: The probability that Search-Ring continues in the correct direction after k steps is

  6. The probability to make a wrong decision is given by Observe To describe Xm 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 Xi of choosing direction with probability p for outcome 1 and probability 1-p for outcome 0. Chernoff bound: For independent Bernoulli variable Xi and with

  7. 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. 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 • Apply horizontal Search-Ring(c log n) to find the west/east bound direction • Follow this direction until a majority of policemen in a block advises to go into the opposite direction • Find the correct vertical column in the current block and the block visited before • Move along the vertical direction until the target is found or the majority of policemen points backwards • If the target has not been found by now, perform a spiral search

  9. Performance of Kranakis-Krizanc-Search Theorem With high probability the Kranakis-Krizanc-Search finds the target in d + O(log2 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. 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. 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 • CostAlg(x) • to the best possible offline solution (unknown to the cow) • Costoffline(x) • Minimize the competitive ratio  =

  12. 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 • CostBuy(1) = 100 • Worst case = 1 day of snow • Costoffline(1) = 10 (1 day renting) 2nd Solution: Always rent • Rent every day • For x snow days • CostBuy(x) = 10 x • Worst case = always snow • best strategy: buy on the first day • Costoffline(1) = 100

  13. A Better Solution for the Rental Ski Problem Rent&Buy • Rent for 10 days • Then Buy on the 11th day • Cost for x<11 days of snow: • CostRent&Buy (x) = 10x • Cost for x>10 days of snow: • CostRent&Buy (x) = 200 • Best strategy for x<11 days of snow: • Rent for x days • Costoffline (x) = 10x • Best strategy for x>10 days of snow: • Buy on the first day • Costoffline (x) = 100 !!!!!!!!!!!

  14. Solution of the Cow Fence Problem Deterministic Cow-Path • dir  left • for i  0 to log n do • go 2i steps to direction dir • go 2i steps back to the origin • revert direction dir • od Theorem [Baeza-Yates, Culberson, Rawlins, 1993] The deterministic Cow-Path algorithm has a competitive ratio of 9. This competitive ratio is optimal.

  15. 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 = 2x+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’/4 d’/2 Exit d’ 2d’ d’ 2d’ d’+1

  16. 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. The Spiral Solution for the Shoreline ProblemBaeza-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... k2 1

  18. 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. Thanks for your attentionEnd of 11th lectureNext lecture: Mo 17 Jan 2005, 11.15 am, FU 116Next exercise class: Mo 10 Jan 2005, 1.15 pm, F0.530 or We 12 Jan 2005, 1.00 pm, E2.316

More Related