Search 4
Search 4
Search 4
-Such a table or policy is difcult to build -All contingencies must be anticipated A more general approach is for the agent to have
knowledge of the world and how its actions affect it and be able to simulate execution of actions in an internal model of the world in order to determine a sequence of actions that will accomplish its goals.
Problem Solving Task Given: -An initial state of the world -A set of possible possible actions or operators that can
be performed.
Measuring Performance
4 1 3
Start State
5 1 8 8 2 2 6 8 7
4 2
3 8 4
Lugoj
Pitesti
6
Goal State
2 5
Mehadia
Urziceni Bucharest
Initial state: Arad Goal state: Bucharest Path cost: Number of intermediate cities, distance traveled, expected travel time
More Realistic Problems Route nding Travelling salesman problem VLSI layout Robot navigation Web searching
Searching Concepts A state can be expanded by generating all states that can
be reached by applying a legal operator to the state.
Arad
Arad
Timisoara
Zerind
A search node in the tree can contain -Corresponding state -Parent node -Operator applied to reach this node -Length of path from root to node (depth) -Path cost of path from initial state to node
Arad
Fagaras
Oradea
Rimnicu Vilcea
function GENERAL-SEARCH( problem,strategy) returns a solution, or failure initialize the search tree using the initial state of problem loop do if there are no candidates for expansion then return failure 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
10
Search Strategies Properties of search strategies -Completeness -Time Complexity -Space Complexity -Optimality Uniformed search strategies (blind, exhaustive, bruteforce) do not guide the search with any additional information about the problem.
11
12
Breadth-First Search Expands search nodes level by level, all nodes at level d
are expanded before expanding nodes at level d+1
nodes.
Plus need bd Implemented by adding new nodes to the end of the queue
(FIFO queue): GENERAL-SEARCH(problem, ENQUEUE-AT-END)
13
14
Uniform Cost Search Like breadth-rst except always expand node of least cost
instead of of least depth (i.e. sort new queue by path cost).
S 0 S
Depth-First Search Always expand node at deepest level of the tree, i.e. one of
the most recently generated nodes. When hit a dead-end, backtrack to last choice.
A 1
B 5
C 15 S
A A 1 S 15 C G 11 (a) (b) G 10 5 B 5 5 A B C 15 10 G G 11 B 5 C 15 S
15
16
1+b+b ++b
2
d2
+b
d1
+b
Iterative deepening:
( d + 1 )1 + db + ( d 1 )b + + 3b
2
d2
+ 2b
d1
+ 1b
17
18
Avoiding Repeated States Basic search methods may repeatedly search the same
state if it can be reached via multiple paths.
A B C D C A
B C C
B C
Requires storing all generated states (O(bd) space) and searching them (usually using a hash-table for efciency).
19