artificial intelligence pathfinding and search
play

ARTIFICIAL INTELLIGENCE Pathfinding and search Lecturer: Silja - PowerPoint PPT Presentation

Utrecht University INFOB2KI 2019-2020 The Netherlands ARTIFICIAL INTELLIGENCE Pathfinding and search Lecturer: Silja Renooij These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html


  1. Utrecht University INFOB2KI 2019-2020 The Netherlands ARTIFICIAL INTELLIGENCE Pathfinding and search Lecturer: Silja Renooij These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html

  2. Pathfinding `Physical’ world: open space or structured? 2

  3. Contents  Dijkstra, BFS, DFS, DLS, IDS  Differences with elective course ‘Algoritmiek’: – Theory all by example: Dijkstra in detail, others more superficial. Some more in- depth in Project B – Emphasis on difference tree-search / graph-search – Emphasis on comparison of properties rather than proofs of properties. 3

  4. Pathfinding in Romania 4

  5. Requirements for search 1. States S: abstract represention of (set of) real state(s) – E.g. all cities on a map, or all possible paths in a grid or (waypoint) graph – A problem typically assigns an initial state (e.g "in Arad“) and a goal state (e.g. "in Zerind“) 2. Actions (operators/production rules) S  S’: abstract representation of combination of real actions – E.g. change from one path to another by change of links – Each abstract action should be "easier" than the original problem; e.g., "Arad  Zerind" represents a complex set of possible routes, detours, rest stops, etc. 5

  6. State space for search The state space represents all states reachable from the initial state by any sequence of actions. A tree or graph with nodes S and (un)directed edges S  S’ is used as state space representation. A search algorithm is applied to the state space representation to find a solution (abstract representation of solution in the real world) – for guaranteed realizability, a sequence of actions maps initial state to goal state – e.g. list of connections = real path 6

  7. Searching the state space 3. Strategy – Defines how to search through state space – E.g. Systematic (desirable, not always possible): • All states are visited • No state is visited more than once Search algorithms: • differ in employed strategy • build a search tree to explore state space • often “create” state space while searching (space often too large to represent all solutions • create (portions of) all paths while finding a good path between two points 7

  8. Different representations  Real world is absurdly complex  We often represent the world in a simplified way  In addition, the search space is abstracted for problem solving in the world An abstract representation of the world is not the same as a state space representation suitable for problem solving! The map of Romania is represented as a graph with cities as nodes, and edges representing existing connections between cities. We can also use grids or waypoint graphs to represent the real world. As state space representation for path finding we can use, e.g.  the same structure as the domain representation (nodes in the grid / (waypoint) graph), or  nodes to represent entire paths (lists of connections) on this grid/graph,… 8

  9. Dijkstra’s algorithm  Solves the single‐source shortest path problem using G RAPH ‐ SEARCH Edsger W. Dijkstra 1930‐2002  Source state  start node of search  Each connection is associated with a cost, often called step‐cost  The cost‐so‐far is the cost to reach a node n along a given path from the start node (often called path‐cost, denoted g(n) )  Result: to each n , a path with minimal g(n) 9

  10. Dijkstra’s algorithm Bookkeeping:  open list (seen, but not processed)  closed list (completely processed)  cost‐so‐far & connections (path) followed to get here Init: open list  (start node, cost‐so‐far=0) Iteration: Process node from open list with smallest cost‐so‐far Terminate:  When open list is empty  Follow back connections to retrieve path 10

  11. Dijkstra’s algorithm: example Open: (Arad,0) Closed: 11

  12. Dijkstra’s algorithm: example Open: (Z,75) Arad , (S,140) A , (T,118) A Closed: (Arad,0) 12

  13. Dijkstra’s algorithm: example Closed: (Arad,0), (Z,75) A Open: (S,140) A , (T,118) A , (O,146) Z 13

  14. Dijkstra’s algorithm: example Open: (S,140) A , (O,146) Z , (L,229) T Closed: (Arad,0), (Z,75) A , (T,118) A 14

  15. Dijkstra’s algorithm: example  140 + 151 > 146 Open: (O,146) Z , (L,229) T , (R,220) S , Closed: (Arad,0), (Z,75) A , (T,118) A , (S,140) A (F,239) S 15

  16. Dijkstra’s algorithm: example Open: (L,229) T , (R,220) S , (F,239) S Closed: (Arad,0), (Z,75) A , (T,118) A , (S,140) A , (O,146) Z 16

  17. Dijkstra’s algorithm: example Open: (L,229) T , (F,239) S , (C,366) R , Closed: (Arad,0), (Z,75) A , (T,118) A , (S,140) A , (P,317) R (O,146) Z , (R,220) S 17

  18. Dijkstra’s algorithm: example Open: (F,239) S , (C,366) R , (P,317) R , Closed: (Arad,0), (Z,75) A , (T,118) A , (S,140) A , (M,299) L (O,146) Z , (R,220) S , (L,229) T 18

  19. Dijkstra’s algorithm: example Open: (C,366) R , (P,317) R , (M,299) L , Closed: (Arad,0), (Z,75) A , (T,118) A , (S,140) A , (B,450) F (O,146) Z , (R,220) S , (L,229) T , (F,239) S 19

  20. Dijkstra’s algorithm: example Closed: (Arad,0), (Z,75) A , (T,118) A , (S,140) A , Open: (C,366) R , (P,317) R , (B,450) F , (O,146) Z , (R,220) S , (L,229) T , (F,239) S , (D,374) M (M,299) L 20

  21. Dijkstra’s algorithm: example  317+138>366 Open: (C,366) R , (B,450) F , (D,374) M , Closed:(Arad,0), (Z,75) A , (T,118) A , (S,140) A , (B,418) P (O,146) Z , (R,220) S , (L,229) T , (F,239) S , (M,299) L , (P,317) R 21

  22. Dijkstra’s algorithm: example 366+120>374 Closed:(Arad,0), (Z,75) A , (T,118) A , (S,140) A , Open: (D,374) M , (B,418) P (O,146) Z , (R,220) S , (L,229) T , (F,239) S , (M,299) L , (P,317) R , (C,366) R 22

  23. Dijkstra’s algorithm: example Closed: (Arad,0), (Z,75) A , (T,118) A , (S,140) A (O,146) Z , Open: (B,418) P (R,220) S , (L,229) T , (F,239) S , (M,299) L , (P,317) R , (C,366) R , Etc…. (D,374) M (Dijkstra continues, we stop…) 23

  24. Dijkstra’s algorithm: example (Arad,0), (Z,75) A , (T,118) A , (S,140) A , (O,146) Z , Retrieve path to (R,220) S , (L,229) T , (F,239) S , (M,299) L , (P,317) R , … Bucharest (C,366) R , (D,374) M ,(B,418) P 24

  25. Dijkstra’s algorithm: summary  Start with paths of length 1 and expand the one with lowest (non‐negative !) cost first  All paths will be found (and no path will be found more than once)  G RAPH ‐ SEARCH algorithm: i.e. uses closed list concept to avoid loops  Recall: solves the single‐source shortest path problem  Not aimed at finding path to one specific goal… 25

  26. T REE - SEARCH algorithms Simulated exploration of state space by generating successors of already‐explored states (a.k.a. expanding) – initial state  start node of tree – expand: function that generates leafs for successors  fringe (= frontier = open list) with all leafs – goal state: used in goal test Note: goal‐test only when node is considered for expansion, not already upon generation! 26

  27. Pseudocode general T REE - SEARCH # fringe = frontier = open list Note: goal‐test upon expansion; sometimes more efficient upon generation! 27

  28. Implementation: states vs. nodes  (As before) State S is abstract representation of physical configuration in problem domain; it corresponds to a node in the state space representation  A node x in a search tree constructed upon exploring the state space is a data structure containing info on: – state S – parent node – action – path cost g(x) , – depth,…  Expand: function that – creates new nodes – fills in the various node fields – uses problem‐associated Successor‐Fn to generate successors 28

  29. T REE - SEARCH example Node for initial state “Arad” in fringe 29

  30. T REE - SEARCH example  Node related to state “Arad” is expanded and removed from fringe  Nodes related to states “Sibiu” (~path from Arad to Sibiu), “Timisoara” and “Zerind” are generated and added to the fringe 30

  31. T REE - SEARCH example Suppose strategy selects node related to state “Sibiu” for expansion:  a.o. node related to state “Arad” is generated  and added to the fringe  oops….there’s a loop….! 31

  32. Repeated states Failure to detect repeated states can turn a linear problem into an exponential one! 32

  33. Avoiding loops Method 1: • Don’t add node to the fringe if we generated a node for the associated state before  What if there are multiple paths to a node and we want to be sure to get the shortest ? (like e.g. to Oradea) Method 2: G RAPH SEARCH • Don’t add node to the fringe if we expanded a node for the associated state before  Keep a closed (=explored=visited) list of expanded states (c.f. Dijkstra)  This is not for free: takes up time and memory! 33

  34. G RAPH - SEARCH 34

  35. T REE - SEARCH vs G RAPH - SEARCH G RAPH ‐ SEARCH = T REE ‐ SEARCH + a closed list of explored states G RAPH ‐ SEARCH is used to prevent searching redundant paths; search algorithms can be implemented as either one. NB tree vs graph in this context refers to:  structure underlying the state space It does not refer to:  structure built during search (a tree in both cases)  simplified representation of problem domain – e.g. the road map 35

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend