Télécharger la présentation

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

2. Today • Look at one version of Breadth-first search on a grid • Develop Matlab version of BFS

3. Wavefront planner • Use BFS on a grid • Label cells with values • Zero means unchecked • 1 is obstacle • Set start cell to 2 • Expand from start • Add +1 to neighbors of current wavefront • Use gradient descent to search from goal to start

4. Representations: A Grid • Distance is reduced to discrete steps • For simplicity, we’ll assume distance is uniform • Direction is now limited from one adjacent cell to another

5. Representations: Connectivity • 8-Point Connectivity • (chessboard metric) • 4-Point Connectivity • (Manhattan metric)

6. The Wavefront Planner: Setup

7. The Wavefront in Action (Part 1) • Starting with the goal, set all adjacent cells with “0” to the current cell + 1 • 4-Point Connectivity or 8-Point Connectivity? • Your Choice. We’ll use 8-Point Connectivity in our example

8. The Wavefront in Action (Part 2) • Now repeat with the modified cells • This will be repeated until goal is reached • 0’s will only remain when regions are unreachable

9. The Wavefront in Action (Part 3) • Repeat again...

10. The Wavefront in Action (Part 4) • And again...

11. The Wavefront in Action (Part 5) • And again until...

12. The Wavefront in Action (Done) • You’re done

13. The Wavefront • To find the shortest path simply always move toward a cell with a lower number • The numbers generated by the Wavefront planner are roughly proportional to their distance from the goal Two possible shortest paths shown

14. Developing the Breadth-First Search Algorithm • Store the list of graph vertices under consideration (the wavefront). • Store indices rather than the whole vertex • Look for successors of the wavefront • Put the successors back on the wavefront • Where should they go? 1st gen 2nd gen 3rd gen

15. Queue • A queue is a datastructure where you can • Add elements to the back • Take an element off the front • First in the queue is first out • FIFO

16. Queue • Matlab can easily make a queue • Pop element from front element = wavefront(1) wavefront = wavefront(2:end) • Add to end wavefront = [wavefrontnewelement]

17. Matlab • Develop BFS in Matlab