searching
play

Searching Often we are not given an algorithm to solve a problem, - PowerPoint PPT Presentation

Searching Often we are not given an algorithm to solve a problem, but only a specification of what is a solution we have to search for a solution. Search is a way to implement dont know nondeterminism. So far we have seen how


  1. Searching ➤ Often we are not given an algorithm to solve a problem, but only a specification of what is a solution — we have to search for a solution. ➤ Search is a way to implement don’t know nondeterminism. ➤ So far we have seen how to convert a semantic problem of finding logical consequence to a search problem of finding derivations. ☞ ☞

  2. Search Graphs ➤ A graph consists of a set N of nodes and a set A of ordered pairs of nodes, called arcs . ➤ Node n 2 is a neighbor of n 1 if there is an arc from n 1 to n 2 . That is, if � n 1 , n 2 � ∈ A . ➤ A path is a sequence of nodes � n 0 , n 1 , . . . , n k � such that � n i − 1 , n i � ∈ A . ➤ Given a set of start nodes and goal nodes, a solution is a path from a start node to a goal node. ☞ ☞ ☞

  3. Example Graph for the Delivery Robot r123 storage o125 o123 o119 l3d1 l3d2 l3d3 l2d1 l2d2 l2d4 l2d3 o109 mail ts o103 o111 ☞ ☞ ☞

  4. Search Graph for SLD Resolution yes ← a ∧ d yes ← h ∧ d a ← b ∧ c . a ← g . yes ← b ∧ c ∧ d yes ← g ∧ d yes ← m ∧ d a ← h . b ← j . yes ← m ∧ d yes ← j ∧ c ∧ d b ← k . d ← m . yes ← f ∧ d yes ← k ∧ c ∧ d d ← p . f ← m . yes ← m ∧ d yes ← p ∧ d f ← p . g ← m . yes ← m ∧ c ∧ d yes ← d g ← f . k ← m . yes ← p yes ← m h ← m . p . yes ← ? a ∧ d ☞ ☞ ☞

  5. Graph Searching ➤ Generic search algorithm: given a graph, start nodes, and goal nodes, incrementally explore paths from the start nodes. ➤ Maintain a frontier of paths from the start node that have been explored. ➤ As search proceeds, the frontier expands into the unexplored nodes until a goal node is encountered. ➤ The way in which the frontier is expanded defines the search strategy. ☞ ☞ ☞

  6. Problem Solving by Graph Searching frontier start node explored nodes unexplored nodes ☞ ☞ ☞

  7. Graph Search Algorithm Input: a graph, a set of start nodes, Boolean procedure goal ( n ) that tests if n is a goal node. frontier := {� s � : s is a start node } ; while frontier is not empty: select and remove path � n 0 , . . . , n k � from frontier ; if goal ( n k ) return � n 0 , . . . , n k � ; for every neighbor n of n k add � n 0 , . . . , n k , n � to frontier ; end while ☞ ☞ ☞

  8. ➤ We assume that after the search algorithm returns an answer, it can be asked for more answers and the procedure continues. ➤ Which value is selected from the frontier at each stage defines the search strategy. ➤ The neighbors defines the graph. ➤ is _ goal defines what is a solution. ☞ ☞

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