Tori Pruim, Simone Liu, Zach Parks

Slides:



Advertisements
Similar presentations
Problem solving with graph search
Advertisements

IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
State Space Search Algorithms CSE 472 Introduction to Artificial Intelligence Autumn 2003.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Graphs & Graph Algorithms 2 Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Graphs. Graphs Many interesting situations can be modeled by a graph. Many interesting situations can be modeled by a graph. Ex. Mass transportation system,
CSE 421 Algorithms Richard Anderson Lecture 4. What does it mean for an algorithm to be efficient?
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
1 Shortest Path Calculations in Graphs Prof. S. M. Lee Department of Computer Science.
Dijkstra's algorithm.
Informed Search Idea: be smart about what paths to try.
Shortest Path Algorithms. Kruskal’s Algorithm We construct a set of edges A satisfying the following invariant:  A is a subset of some MST We start with.
1 GRAPHS - ADVANCED APPLICATIONS Minimim Spanning Trees Shortest Path Transitive Closure.
Graphs II Robin Burke GAM 376. Admin Skip the Lua topic.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Dijkstras Algorithm Named after its discoverer, Dutch computer scientist Edsger Dijkstra, is an algorithm that solves the single-source shortest path problem.
Representing and Using Graphs
Graph Algorithms. Definitions and Representation An undirected graph G is a pair (V,E), where V is a finite set of points called vertices and E is a finite.
P ROBLEM Write an algorithm that calculates the most efficient route between two points as quickly as possible.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Spanning Trees CSIT 402 Data Structures II 1. 2 Two Algorithms Prim: (build tree incrementally) – Pick lower cost edge connected to known (incomplete)
Michael Walker. From Maps to Graphs  Make Intersections Vertices  Make Roads Edges  Result is Weighted Directed Graph  Weights: Speed Limit Length.
Ricochet Robots Mitch Powell Daniel Tilgner. Abstract Ricochet robots is a board game created in Germany in A player is given 30 seconds to find.
State space representations and search strategies - 2 Spring 2007, Juris Vīksna.
Graph Algorithms GAM 376 Robin Burke Fall Outline Graphs Theory Data structures Graph search Algorithms DFS BFS Project #1 Soccer Break Lab.
A* Path Finding Ref: A-star tutorial.
Union By Rank Ackermann’s Function Graph Algorithms Rajee S Ramanikanthan Kavya Reddy Musani.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
CSE 373: Data Structures and Algorithms Lecture 21: Graphs V 1.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
CSG3F3/ Desain dan Analisis Algoritma
Review: Tree search Initialize the frontier using the starting state
Greedy Algorithms.
Programming Abstractions
CSC317 Shortest path algorithms
Last time: Problem-Solving
Spanning Trees Lecture 21 CS2110 – Fall 2016.
Introduction to Graphs
Artificial Intelligence Problem solving by searching CSC 361
Maze Implementation, Analysis and Design to find Shortest Paths
I206: Lecture 15: Graphs Marti Hearst Spring 2012.
Programming Abstractions
Motion Planning for a Point Robot (2/2)
CSE 421: Introduction to Algorithms
Graphs & Graph Algorithms 2
Greedy Algorithms / Dijkstra’s Algorithm Yin Tat Lee
Graphs Chapter 13.
Graphs Chapter 11 Objectives Upon completion you will be able to:
CSE 373 Data Structures and Algorithms
A* Path Finding Ref: A-star tutorial.
Graphs.
Shortest Path Algorithms
Team 17c ****** Pathfinding
Yan Shi CS/SE 2630 Lecture Notes
The Rock Boxers: Tabitha Greenwood Cameron Meade Noah Cahan
CSE 373: Data Structures and Algorithms
CO Games Development 1 Week 8 Depth-first search, Combinatorial Explosion, Heuristics, Hill-Climbing Gareth Bellaby.
Troposphere (sic) Fliers
Minimum Spanning Tree.
Minimum Spanning Trees
HW 1: Warmup Missionaries and Cannibals
CSE 373 Data Structures and Algorithms
Informed Search Idea: be smart about what paths to try.
CSC 380: Design and Analysis of Algorithms
CSE 417: Algorithms and Computational Complexity
CSE 373: Data Structures and Algorithms
Spanning Trees Lecture 20 CS2110 – Spring 2015.
HW 1: Warmup Missionaries and Cannibals
Informed Search Idea: be smart about what paths to try.
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

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

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.

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

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 1 - Open path Except the start square (2) and the end square (3) 2 1 1 1 0 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3

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 }

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

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.

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

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

Dijkstra’s History 1959 - 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

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

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

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.

Dijkstra’s Algorithm

Dijkstra Pseudocode 4+ 4^h

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|)

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)

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.” http://cs.indstate.edu/hgopireddy/algor.pdf

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.

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()+1 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)

A* versus Dijkstra’s https://en.wikipedia.org/wiki/A*_search_algorithm#/media/File:Astar _progress_animation.gif

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. (https://en.wikipedia.org/wiki/Breadth-first_search) BFS will look at all nodes in a given depth in the search tree before considering any nodes beneath that point

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

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|*(1 + 1 + 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)

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

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% 20% 30% 40% Statement and implementation of algorithms? What evidence is presented? What holes exist in the work?

Dijkstra slowest by far

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

Dijkstra

Dijkstra

A Star

A Star

BFS

BFS

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

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.

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

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

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

Citations http://cs.indstate.edu/hgopireddy/algor.pdf https://courses.cs.washington.edu/courses/cse473/14au/slides/03-hsearch.pdf https://en.wikipedia.org/wiki/Breadth-first_search https://en.wikipedia.org/wiki/A*_search_algorithm#/media/File:Astar_progress_animation.gif https://github.com/gajduk/maze-generator-and-solver-applet