• Nie Znaleziono Wyników

Search Graphs

N/A
N/A
Protected

Academic year: 2021

Share "Search Graphs"

Copied!
8
0
0

Pełen tekst

(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 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.

(3)

o103 o109

mail ts o111

l2d3 l2d4

l3d2 l3d1

l3d3 l2d2 l2d1

o119

storage

o125

r123

o123

(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.

∧ 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

(5)

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

explored nodes

unexplored nodes start

node

(7)

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

(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.

Cytaty

Powiązane dokumenty

Total cost of multicast tree versus paths to each receiving node the genetic algorithm has to choose from (number of network nodes n = 50, number of receiving nodes m = 10,

This phenomenon is referred to as the indirect land use change (ILUC) and it should be also considered when approving raw materials for biofuels production. To take into account

Na prośbę proboszcza parafi i Najświętszego Serca Pana Jezusa na Grajew- skim Przedmieściu w Brześciu z dnia 16 IX 1935 roku ordynariusz piński erygo- wał Stowarzyszenie

The performance of an indoor positioning system is highly related to the placement of the transmitting nodes that are used as references for the positioning estimations. In this

Niezaprzeczalnym  walorem  książki  jest  rów- nież fakt, iż jest to jedyna (nie licząc poprzed- niej  publikacji  tej  samej  autorki: 

E.K.]: możliwie wielka oszczędność pobudek użytych; możliwie bezpośrednie (własne) ich wyrażenie; sumowanie się ich, czyli tworzenie celowej całości. [...] Rola autora

Często dzieje się tak, że tekst literacki jest zatytułowany tak samo jak dzieło sztuki (jest to przypadek obydwu cytowanych powyżej wierszy) lub tytuł tego dzieła pojawia się

Verify inductively that T k is ‘contained’ (can be extended) to some optimal spanning tree...