Lecture4 (Search)
Lecture4 (Search)
Example: 8 Puzzle
1 2 3
7 8 4
6
5
1 2 3
8
4
7 6 5
3
1 2 3
8
GOAL
1 2 3
7 8 4
7 6 5
left
right
up
1 2 3
1 2 3
1 2 3
7 8 4
7 8 4
6 5
6 8 5
6 5
8 Puzzle Heuristics
Blind search techniques used an arbitrary
ordering (priority) of operations.
Heuristic search techniques make use of
domain specific information - a heuristic.
What heurisitic(s) can we use to decide
which 8-puzzle move is best (worth
considering first).
1 2 3
8
GOAL
1 2 3
7 8 4
7 6 5
left
right
up
1 2 3
1 2 3
1 2 3
7 8 4
7 8 4
6 5
6 8 5
6 5
h=2
h=4
4
h=3
1 2 3
8
GOAL
1 2 3
7 8 4
7 6 5
left
right
up
1 2 3
1 2 3
1 2 3
7 8 4
7 8 4
6 5
6 8 5
6 5
h=2
h=4
4
h=4
Best-first search
Idea: use an evaluation function f(n) for each node
estimate of "desirability
Expand most desirable unexpanded node
Special cases:
greedy best-first search
A* search
A search
*
A search example
*
A search example
*
A search example
*
A search example
*
A search example
*
A search example
*
Admissible heuristics
A heuristic h(n) is admissible if for every node n,
h(n) h*(n), where h*(n) is the true cost to reach
the goal state from n.
An admissible heuristic never overestimates the
cost to reach the goal, i.e., it is optimistic
Example: hSLD(n) (never overestimates the actual
road distance)
Theorem: If h(n) is admissible, A* using TREESEARCH is optimal
Example: n-queens
Put n queens on an n n board with no
two queens on the same row, column, or
diagonal
Hill-climbing search
"Like climbing Everest in thick fog with
amnesia"
Hill-climbing search
Problem: depending on initial state, can
get stuck in local maxima
TSP Example
A
1
2
3
C
31
ABCD
ABCD
Swap 1,2
BACD
BACD
Swap 2,3
Swap 3,4
ACBD
ACBD
Swap 1,2
ABCD
ABCD
ABDC
ABDC
DBCA
DBCA
Swap 3,4
Swap 2,3
CABD
CABD
Swap 4,1
Swap 4,1
ACDB
ACDB
DCBA
DCBA
32