Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tori Pruim, Simone Liu, Zach Parks

Similar presentations


Presentation on theme: "Tori Pruim, Simone Liu, Zach Parks"— Presentation transcript:

1 Tori Pruim, Simone Liu, Zach Parks
iObstacle Tori Pruim, Simone Liu, Zach Parks

2 Informal Definition Find the shortest series of moves to create a path from a set start position to a set end position, for an object to travel on a square grid which contains a series of obstacles.

3

4 Formal Definition ORTHOGONAL SQUARE GRID
Two sets of evenly-spaced parallel lines at perpendicular angles to one another. Grid size = n*n START/END Start = coordinate on grid, object’s first current position End = goal coordinate, where object is attempting to find

5 Formal Definition Cont.
SQUARES S – set of ordered pairs in the grid where each ordered pair represents one square S={ (0,0), (0,1), .... (0,n-1), (1,0), (1,1), …. (n-1, 0), (n-1,1), … (n-1,n-1)} All s either have a value of 0 or 1: 0 - Obstacle Open path Except the start square (2) and the end square (3)

6 Formal Definition Cont.
Adjacent Squares Two squares are adjacent if for one square with coordinates (i,j) where both i and j are in the range (0,n) , the other square’s coordinates are (i,j+1) , (i, j-1), (i+1, j) , or (i-1,j). MOVE A move is a transition from one square to an adjacent square, represented as a tuple M= { (si, sj) | sj and sj ∈ S and si ≠ sj }

7 Formal Definition Cont.
PATH A path is a sequence of moves, such that the second square in one move is the first square of the following move P = { (s1 , s2) , (s2 , s3) , (s3, s4) , (s4 , s5) } ∃ a path, P, such that the first square in the first move is the start square and the last square in the last move is the end square. P = { M1, M2, M3, …., Mk} , k = total number of moves

8 Formal Definition Cont.
PATH LENGTHS Q is a list of the lengths of all tested paths that go from start to end. Length of a path is defined by the number of moves in the path Q = { len(P1), len(P2), ….len(Pr)} r = number of paths tested Pshortest = min(Q) a shortest path in all of those which were tested.

9 Constraints There must be a possible path from start to finish
The object can only move up, down, left, or right, NO diagonal movement

10 Algorithms Dijkstra’s Algorithm A* Search Algorithm
Breadth First Search (BFS) Algorithm

11 Dijkstra’s History Edsger Dijkstra’s “A note on two problems in connexion with graphs” Dijkstra’s main objective: choose a problem and a computational solution that non-computing people could understand. Implemented on the ARMAC to form a simplified transportation map between 64 cities in the Netherlands

12 A* History 1964 A1 Nils Nilsson invented a heuristic based approach to increase the speed of Dijkstra’s algorithm 1967 A2 Bertram Raphael made dramatic improvements upon this algorithm, but failed to show optimality 1968 A* Peter E.Hart slightly proved that A2 was optimal when using a heuristic with only minor changes

13 BFS’s History 1945 BFS was invented by Konrad Zuse and Michael Burke, but was not published until 1972 1959 BFS was reinvented by Edward F. Moore to find the shortest path out of a maze 1961 BFS was developed into a wire routing algorithm by C. Y. Lee

14 Dijkstra’s Algorithm Constructs a shortest path tree from the source node to every other node in a non-negatively weighted, directed or undirected graph (if reachable) Beginning with a start node and a set of “open” candidate nodes, at each step the node in the “open” set with the shortest distance from the start is examined. This node is then marked “closed” and adjacent nodes are added to the “open” set, given that they have not been visited yet. Shortest path nodes are examined first - the first time a node is examined and a distance assigned, the shortest path has been found.

15 Dijkstra’s Algorithm

16 Dijkstra Pseudocode 4+ 4^h

17 Complexity as a function of number of edges |E| and vertices |V|
Design and Analysis Complexity as a function of number of edges |E| and vertices |V| Loop: O(|V|) Insertion (self-balancing binary tree): O(log |V|) O(|V| log |V|) Removing minima of priority queue: O (|V|) O((|E|+|V|) log |V|) Neighbor Loop: O(|E|) Removing vertices: O(log |V|) O(|E| log |V|) Adding updated vertices: O(log |V|)

18 A* Algorithm Cost f(n) = g(n) + h(n) n = node/square on path
(0,0) Cost f(n) = g(n) + h(n) n = node/square on path g = cost of path from start to n h = heuristic/estimated cost of path from n to end For two squares (x,y) and (i,j), the h cost is calculated by |j-x| + |j-y| (n-1,n-1)

19 A* Algorithm “As A* traverses the graph, it follows a path of the lowest known cost, Keeping a sorted priority queue of alternate path segments along the way. If, at any point, a segment of the path being traversed has a higher cost than another encountered path segment, it abandons the higher-cost path segment and traverses the lower-cost path segment instead. This process continues until the goal is reached.”

20 A* Complexity The time complexity of the A* algorithm depends on how accurate the heuristic function is at estimating the cost from any node to the end node. The worst case complexity for a maze with no obstacles is exponential with respect to the number of squares total and the number of nodes expanded for each square. The time complexity is polynomial when the maze has a single end state and “the heuristic function meets |h(x)-h*(x)| = O(log h*(x)), where h* is the optimal heuristic” ( the exact cost to get from square x to the end goal). Accurately estimating a heuristic cost, or at least not overestimating the heuristic is a crucial element of A* search.

21 A* Pseudo Code O(eh) O(1) O(1) O(h) O(1) O(e)
op = new priority queue op.add( start ) closed = [ ] done = False while not done expanded = op.pop() if ( expanded = end ) done = True closed.append( expanded ) neighbors = expanded.getNeighbors() for n in neighbors if ( ! n.isObstacle() ) estimate = expanded.getGcost() if ( n.getGcost() > estimate ) n.setGcost( estimate ) if ( ! op.contains(n) ) op.add( n ) O(eh) e - average number of neighbors expanded h - avg number of squares searched O(1) O(1) O(h) O(1) O(e)

22

23 A* versus Dijkstra’s _progress_animation.gif

24 Breadth First Search Algorithm
Breadth First Search (BFS) is an algorithm for traversing or search tree or graph data structures. BFS is complete and is guaranteed to find the best solution (if one exists) within a finite amount of time. It starts at the tree root and explodes the neighbor nodes first, before moving to the next level neighbors. ( BFS will look at all nodes in a given depth in the search tree before considering any nodes beneath that point

25 Breadth First Search Algorithm
1 S E 2 1 10 3 4 2 4 6 8 11 5 6 7 8 3 13 9 10 11 5 14 15 16 12 13 7 9 12 14 15 16 We need to keep the reference to all the children nodes using queue

26 BFS Pseudo Code O(|V|+|E|) BFS(start,end): queue = empty new queue
queue.add(start) //mark visited O(1) visiting= new list visiting.add(start,none) while (!queue.empty()){ current = queue.pop(front) O(1) if (current == end) { return the path }else{ for each of 4 adjacent vertices of current and if the vertex is not obstacle{ if (vertex was visited== false){ queue.add(vertex) O(1) visiting.add(current, vertex) } 1 + |V|*( A*1) = |V| + |V| + |V|*A = 2|V| + |E| = |V| + |E| O(|V|+|E|) where |V|: number of vertices A: number of adjacent vertices to current vertex |E|: total number of edges O(1) O(|V|) O(A)

27 BFS Analysis V0 V1 V3 V2 V4 V5 V6 V7 |V| + |E|
= |V| + |E0| + |E1| + |E2| + |E3| + |E4| + |E5| + |E6| + |E7| = = = 17

28 Experimental Procedure
For each density in set d = {10%, 20%, 30%, 40%} Create mazes with size n2 for n in range 10 to 100 incrementing by 10 Time how long it takes Dijkstra, A*, and BFS to solve each maze 10% % % % Statement and implementation of algorithms? What evidence is presented? What holes exist in the work?

29 Dijkstra slowest by far

30 A. and BFS very close to each other
A* and BFS very close to each other. BFS starts faster for smaller mazes but then A* becomes faster for bigger mazes. This trend was true for all sets of mazes of all densities

31 Dijkstra

32 Dijkstra

33 A Star

34 A Star

35 BFS

36 BFS

37 Conclusions The time complexities of these three algorithms are all functions of the number of edges and the number of vertices that represent a given maze Running time Maze Size Maze Density Running time

38 Holes Dijkstra and A* are both greedy algorithms. They perform more efficiently than BFS when the cost per move is not constant. In this case with each step having a cost of 1, Dijkstra’s and A*’s performances were both decreased.

39 Future Work 3D mazes Robotics Self learning navigation Gaming
Routing protocols Hardwire Wiring City / Transportation Planning 3D mazes

40 Questions What is the name of the estimated cost from any square to the end square? Heuristic cost What is one fatal error for A* Search? Overestimating the heuristic cost Why are A* and Dijkstra’s considered “greedy” algorithms? They both search for the shortest traversal path through a graph based on making the locally optimum choice with the goal of finding a global optimum The complexity of graph search algorithms such as BFS, Dijkstra’s, and A* is a based on a function of what? The complexity is a function of the graph’s number of edges and vertices Add 3 more questions and answers

41 Questions 5. Solve for |V| and |E| of the map below, where |V| is the number of vertices and |E|is the number of edges, using BFS. (V0: start point, V6: end point) V E V0 → {V1, V2} |E0| = 2 V1 → {V3, V4} |E1| = 2 V2 → {V3} |E2| = 1 V3 → {V5} |E3| = 1 V4 → {V5} |E4| = 1 V5 → {V6} |E5| = 1 V6 → { } |E6| = 0 V0 V1 V4 V2 V3 V5 V6 |V| = 7 |E| = |E0| + |E1| + |E2| + |E3| + |E4| + |E5| + |E6| = 8 Add 3 more questions and answers

42 Citations http://cs.indstate.edu/hgopireddy/algor.pdf


Download ppt "Tori Pruim, Simone Liu, Zach Parks"

Similar presentations


Ads by Google