Artificial Intelligence Chapter 3: Problem Solving and Searching
Artificial Intelligence Chapter 3: Problem Solving and Searching
Informed search
Search strategies: best-first, A*
Heuristic functions
9l
3l
5l
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
3
0
3
0
3
0
3
1
0
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
0
3
0
3
0
3
1
0
0
0
0
0
3
3
5
5
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
0
3
0
3
0
3
0
3
1
0
5
2
0
0
0
0
3
3
5
5
0
0
3
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
0
3
3
3
0
3
0
3
1
0
5
2
0
0
0
0
3
3
5
5
0
0
2
3
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
0
3
3
3
0
3
0
3
1
0
5
2
0
5
0
0
3
3
5
5
0
0
2
2
6
6
6
6
6
7
start
goal
9l
3l
a
5l
b
b
0
c
0
0
3
3
3
3
5
2
0
5
0
0
0
2
2
7
3
0
3
1
0
0
3
3
5
5
6
6
6
6
7
start
goal
goal
9l
3l
a
5l
b
Solution 2:
0
3
3
3
3
5
2
0
5
0
0
0
2
2
7
start
start
3
0
3
0
3
0
3
1
0
goal
0
0
0
0
0
3
3
5
5
0
3
3
6
6
6
6
6
7
goal
DZB1
Slide 21
DZB1
Example: Romania
Example: Romania
Problem-Solving Agent
Restricted form of general agent:
action
Example: Buckets
Measure 7 liters of water using a 3-liter, a 5-liter, and a 9liter buckets.
Formulate goal: Have 7 liters of water
in 9-liter bucket
Formulate problem:
States:
amount of water in the buckets
Operators:
Fill bucket from source, empty bucket
Find solution:
state
Problem types
Problem types
Single-state problem:
deterministic, accessible
Multiple-state problem:
deterministic, inaccessible
Contingency problem:
nondeterministic, inaccessible
Exploration problem:
Problem types
Single-state problem:
deterministic, accessible
Problem types
Multiple-state problem:
deterministic, inaccessible
Agent does not know the exact state (could be in any of the
possible states)
May not have sensor at all
Problem types
Contingency problem: nondeterministic, inaccessible
Must use sensors during execution
Solution is a tree or policy
Often interleave search and execution
Problem types
Exploration problem: unknown state space
34
35
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]
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?
36
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]
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
38
For guaranteed realizability, any real state "in Arad must get to some
real state "in Zerind"
(Abstract) solution =
set of real paths that are solutions in the real world
39
states?
actions?
goal test?
path cost?
40
states?
actions?
goal test?
path cost?
42
43
[Note: optimal solution of n-Puzzle family is NP-hard]
44
45
Example: Romania
In Romania, on vacation. Currently in Arad.
Flight leaves tomorrow from Bucharest.
Formulate goal:
be in Bucharest
Formulate problem:
states: various cities
operators: drive between cities
Find solution:
sequence of cities, such that total driving distance is
minimized.
48
49
50
51
Search strategies
A search strategy is defined by picking the order of node
expansion
Strategies are evaluated along the following dimensions:
53
Depth = 0
root
Depth = 1
Depth = 2
N1
N3
N2
N4
N5
N6
Breadth-first search
Uniform-cost search
Depth-first search
Depth-limited search
By: Dr. Zeeshan Bhatti
55
Breadth-first search
Expand shallowest unexpanded node
Implementation:
fringe is a FIFO queue, i.e., new successors go at end
56
Breadth-first search
Expand shallowest unexpanded node
Implementation:
fringe is a FIFO queue, i.e., new successors go at end
57
Breadth-first search
Expand shallowest unexpanded node
Implementation:
fringe is a FIFO queue, i.e., new successors go at end
58
Breadth-first search
Expand shallowest unexpanded node
Implementation:
fringe is a FIFO queue, i.e., new successors go at end
59
Uniform-cost search
Expand least-cost unexpanded node
Implementation:
fringe = queue ordered by path cost
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
62
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
63
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
64
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
65
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
66
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
67
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
68
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
69
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
70
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
71
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
72
Depth-first search
Expand deepest unexpanded node
Implementation:
fringe = LIFO queue, i.e., put successors at front
73
74
Depth-limited search
= depth-first search with depth limit l,
i.e., nodes at depth l have no successors
Recursive implementation:
75
76
77
78
79
80
Properties of iterative
deepening search
Complete? Yes
Space? O(bd)
82
Summary of algorithms
83
Repeated states
Failure to detect repeated states can turn a linear
problem into an exponential one!
84
Graph search
85
Summary
Problem formulation usually requires abstracting away realworld details to define a state space that can feasibly be
explored
Variety of uninformed search strategies
Iterative deepening search uses only linear space and not
much more time than other uninformed algorithms
86
Complexity
Why worry about complexity of algorithms?
because a problem may be solvable in principle but may
take too long to solve in practice
Complexity
So