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

searching
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

  • f finding logical consequence to a search problem of

finding derivations.

☞ ☞

slide-2
SLIDE 2

Search Graphs

➤ A graph consists of a set N of nodes and a set A of

  • rdered pairs of nodes, called arcs .

➤ Node n2 is a neighbor of n1 if there is an arc from n1 to

  • n2. That is, if n1, n2 ∈ A.

➤ A path is a sequence of nodes n0, n1, . . . , nk such that

ni−1, ni ∈ A.

➤ Given a set of start nodes and goal nodes, a solution

is a path from a start node to a goal node.

☞ ☞ ☞

slide-3
SLIDE 3

Example Graph for the Delivery Robot

  • 109
  • 103

ts mail

  • 111

l2d3 l2d4 l3d2 l3d1 l3d3 l2d2 l2d1

  • 119

storage

  • 125

r123

  • 123

☞ ☞ ☞

slide-4
SLIDE 4

Search Graph for SLD Resolution

a ← b ∧ c. a ← g. a ← h. b ← j. b ← k. d ← m. d ← p. f ← m. f ← p. g ← m. g ← f . k ← m. h ← m. p. ?a ∧ d

yes←a∧d yes←j∧c∧d yes←k∧c∧d yes←m∧c∧d yes←g∧d yes←b∧c∧d yes←m∧d yes←m∧d yes←f∧d yes←p∧d yes←d yes←m yes←p yes←h∧d yes←m∧d yes←

☞ ☞ ☞

slide-5
SLIDE 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.

☞ ☞ ☞

slide-6
SLIDE 6

Problem Solving by Graph Searching

frontier explored nodes unexplored nodes start node

☞ ☞ ☞

slide-7
SLIDE 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 n0, . . . , nk from frontier; if goal(nk) return n0, . . . , nk; for every neighbor n of nk add n0, . . . , nk, n to frontier; end while

☞ ☞ ☞

slide-8
SLIDE 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.

☞ ☞