Professional Documents
Culture Documents
Solving Problems by Searching
Solving Problems by Searching
Solving Problems by Searching
CHAPTER 3
Outline
2
Problem-solving agents
Problem types
Problem formulation
Example problems
Basic search algorithms
3
Asymptotic complexity
O() notation
NP-completeness
Problem Solving Agents
6
Formulate goal:
be in Bucharest
Formulate problem:
states: various cities
actions: drive between cities
Find solution:
sequence of cities, e.g., Arad, Sibiu, Fagaras,
Bucharest
The process of looking for a sequence of actions that
reaches the goal is called search.
A search algorithm takes a problem as input and
returns a solution in the form of an action
sequence.
Once a solution is found, the actions it recommends
can be carried out. This is called the execution
phase
Well-defined problems and solutions
31
Example: vacuum world
32
Sensorless, start in
{1,2,3,4,5,6,7,8} e.g.,
Right goes to {2,4,6,8}
Solution?
[Right,Suck,Left,Suck]
Example: vacuum world
33
Contingency
Nondeterministic: Suck may
dirty a clean carpet
Partially observable:
location, dirt at current location.
Percept: [L, Clean],
i.e., start in #5 or #7
Solution?
[Right, if dirt then Suck]
Single-state problem formulation
34
states?
actions?
goal test?
path cost?
Vacuum world state space graph
37
states?
actions?
goal test?
path cost?
Example: The 8-puzzle
39
Basic idea:
exploration of state space by generating successors of
already-explored states (expanding)
Tree search example
48
Tree search example
49
Tree search example
50
Loopy path
Breadth-first search
64
Breadth-first search
65
Breadth-first search
66
Properties of breadth-first search
67
Depth-first search
72
Depth-first search
73
Depth-first search
74
Depth-first search
75
Depth-first search
76
Depth-first search
77
Depth-first search
78
Depth-first search
79
Depth-first search
80
Depth-first search
81
Properties of depth-first search
83
For b = 10, d = 5,
NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111
NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456
Properties of iterative deepening search
92
Complete? Yes
Time? (d)b + (d-1)b2 + … + (1)bd = O(bd)
the nodes on the bottom level (depth d) are
generated once, those on the next-to-bottom level
are generated twice, and so on, up to the children of
the root, which are generated d times
Space? O(bd)
Optimal? Yes, if step cost = 1
In general, iterative deepening is the preferred
uninformed search method when the search
space is large and the depth of the solution is not
known.
Summary of algorithms
93
INFORMED (HEURISTIC)
SEARCH STRATEGIES
• G EN ER I C B EST FI R S T SEA R C H
• G R EEDY B EST FI R ST SEA R C H
• A * SEA R C H
Informed Search
h1(S) = ?
h2(S) = ?
Admissible heuristics
h1(S) = ? 8
h2(S) = ? 3+1+2+2+2+3+3+2 = 18
Dominance