Professional Documents
Culture Documents
Search 4 PDF
Search 4 PDF
1 2
•Given:
-An initial state of the world •Path cost: a function that assigns a cost to a path, typically
by summing the cost of the individual operators in the path.
-A set of possible possible actions or operators that can May want to find minimum cost solution.
be performed.
-A goal test that can be applied to a single state of the
world to determine if it is a goal state.
•Search cost: The computational time and space (memory)
•Find: required to find the solution.
3 4
Sample Route Finding Problem Sample “Toy” Problems
Zerind
5 4 5
1 4
2 3
Iasi
Arad
Sibiu Fagaras
6 1 88 6
8 84
Vaslui
Rimnicu Vilcea
Timisoara
Pitesti
7 3 22 7 6 25
Lugoj
Hirsova
Mehadia Urziceni Start State Goal State
Bucharest
Dobreta
Craiova Eforie
Giurgiu •Peg Puzzle (Hi-Q)
Initial state: Arad
Goal state: Bucharest •Cryptarithmetic
FORTY 29786 F=2, O=9, R=7, T=8,...
Path cost: Number of intermediate cities, distance traveled, + TEN + 850
expected travel time + TEN + 850
---------- ---------
SIXTY 31486
5 6
•VLSI layout
•Robot navigation
•Web searching
•Missionaries and cannibals
Identity of individuals irrelevant,best to represent state as
7 8
Searching Concepts Expanding Nodes and Search
•A search node in the tree can contain Arad Fagaras Oradea Rimnicu Vilcea
-Corresponding state
-Parent node
function GENERAL-SEARCH( problem,strategy) returns a solution, or failure
-Operator applied to reach this node initialize the search tree using the initial state of problem
-Length of path from root to node (depth) loop do
if there are no candidates for expansion then return failure
-Path cost of path from initial state to node
choose a leaf node for expansion according to strategy
if the node contains a goal state then return the corresponding solution
else expand the node and add the resulting nodes to the search tree
end
9 10
nodes MAKE-QUEUE(MAKE-NODE(INITIAL-STATE[problem]))
•Uniformed search strategies (blind, exhaustive, brute-
force) do not guide the search with any additional
loop do
information about the problem.
if nodes is empty then return failure
node REMOVE-FRONT(nodes)
if GOAL-TEST[problem] applied to STATE(node) succeeds then return node •Informed search strategies (heuristic, intelligent) use
nodes QUEUING-FN(nodes,EXPAND(node,OPERATORS[problem])) information about the problem (estimated distance from a
end state to the goal) to guide the search.
11 12
Breadth-First Search Breadth-First Complexity
•Expands search nodes level by level, all nodes at level d •Assume there are an average of b successors to each
are expanded before expanding nodes at level d+1 node, called the branching factor.
nodes.
•Implemented by adding new nodes to the end of the queue •Assuming can expand and check 1000 nodes/sec and need
(FIFO queue): 100 bytes/node storage , b=10
13 14
•Like breadth-first except always expand node of least cost •Always expand node at deepest level of the tree, i.e. one of
instead of of least depth (i.e. sort new queue by path cost). the most recently generated nodes. When hit a dead-end,
backtrack to last choice.
S
0
S
A B C
1 5 15
S
A
A B C
1 10 5 15
B G
5 5 S
S G 11
15 5
A B C
C 15
G G
11 10
(a) (b)
•Do not recognize goal until it is the least cost node on the
queue and removed for goal testing.
15 16
Depth-First Properties Iterative Deepening
•Not guaranteed to be complete since might get lost •Conduct a series of depth-limited searches, increasing
following infinite path. depth-limit each time.
17 18
A A
B B B
C C C C C
19