Lecture 5a Heuristic Functions
Lecture 5a Heuristic Functions
Lecture 5a Heuristic Functions
Heuristic function
A function which applies an algorithm to
the nodes and assigns a value to them that
indicates how close the evaluated node is
to the goal node.
Difficulty however is in determining the
heuristics
Given a heuristic guidance is still required
as to how to use the heuristic values
2
search
Finding Heuristics
Tic - Tac - Toe
which one to choose? X
X
X
Heuristic:
calculate winning lines and move to state with most wining lines.
Note that here we have a maximizing heuristic, maximum is
chosen, otherwise minimum is chosen for minimizing heuristic
3
search
Maximizing Minimizing
4
search
X X
X
5
search
Example TSP
8 Queen Problem
Min-conflicts Example 1
Score)
8-puzzle
Avg. solution cost is about 22 steps (branching factor
+/- 3)
Exhaustive search to depth 22: 3.1 x 1010 states.
A good heuristic function can reduce the search process.
CAN YOU THINK OF A HEURISTIC ?
10
search
8 Puzzle
11
search
Heuristic quality
12
search
h1 h2 h1 h2
14
search
Admissibility: 8 Puzzle
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.
16
search
17
search
BOTH
18
search
3 1 1 3
3 1 1 3
3 1 3
1
3 1 3
1
3 1 3
1
1 3 1 3
1 3 1 3
B
Consider the state-space on the
1 5
Figure.
S G
S A B G
h1: 0 0 0 0
h2: 2 3 5 0
h3: 3 4 3 0
h4: 4 0 0 0
5 8 1 2 3
4 2 1 x x x
7 3 6 x x
5 8 1 2 3
4 2 1 4 5 6 8
7 3 6 7 8
5 6
6
h = h8 + h5 + h6 +…
29
search
Complex: Relaxed Problem
Consider two more complex relaxed problems:
5 8 1 2 3
4 2 1 4 5 6
7 3 6 7 8
1 2 3 5 8
4 2 1 4 5 6
3 7 6 7 8