Professional Documents
Culture Documents
AI Chap4 Heur
AI Chap4 Heur
Heuristic Functions
Hill climbing
Beam search
Hill climbing (2)
Greedy search
Heuristic Search
“the study of the methods and rules of discovery
and invention” [Polya 1945]
In state space search, heuristics are formalized as
rules for choosing those branches in a state space
that are most likely to lead to an acceptable
problem solution.
2
Heuristic Functions
To further improve the quality of the previous
methods, we need to include problem-specific
knowledge on the problem.
How to do this in such a way that the algorithms
remain generally applicable ???
HEURISTIC FUNCTIONS:
f: States --> Numbers
f(T) : expresses the quality of the state T
– allow to express problem-specific knowledge,
BUT: can be imported in a generic way in the
algorithms.
3
Examples (1):
Imagine the problem of finding a route on a road map and
that the NET below is the road map:
A 4 B 4 C
3
S 5 5
G
4 D E F 3
2 4
A 10.4 B 6.7 C 4
The estimate
S 11
G can be wrong!
8.9
D E 6.9 F 3
4
Examples (2): 8-puzzle
f1(T) = the number correctly placed tiles on the
board: 1 3 2
f1 8 4 =4
5 6 7
1 5 2
f3 8 4 = 1 + 4 + 2 + 3 = 10
3 6 7
6
Examples (4):
Chess:
F(T) = (Value count of black pieces) - (Value count
of white pieces)
f = v( ) + v( )
+ v( ) + v( )
- v( ) - v( )
7
Hill climbing
S
Perform depth-first,
A 10.4 D 8.9 BUT:
instead of left-to-
right selection,
A 10.4 6.9
E FIRST select the child
with the best heuristic
value
6.7 B F 3.0
9
Hill climbing_1 algorithm:
1. QUEUE <-- path only containing the root;
3. IF goal reached
THEN success;
ELSE failure;
10
Beam search
A D
A D Optimi-
zation:
B D A E
4.0 6.9 6.7 B ignore
_C E X X F 3.0
X leafs
end
ignore that are
not goal
Depth 4) S nodes
(see C)
A D
B D A E
_C E X X B F
X
10.4 A 0.0
_C G
13
Beam search algorithm:
See exercises!
Properties:
Completeness:
Hill climbing: YES (backtracking), Beam search: NO
Speed/Memory:
Hill climbing:
same as Depth-first (in worst case)
Beam search:
QUEUE always has length WIDTH, so memory
usage is constant = WIDTH, time is of the order
of WIDTH*m*b or WIDTH*d*b if no solution is
14
found
Hill climbing_2
== Beam search with a width of 1.
15
Problems with
Hill climbing_2:
Foothills: Plateaus
Local
maximum
Ridges
16
Comments:
Foothills are local minima: hill climbing_2 can’t
detect the difference.
Plateaus don’t allow you to progress in any direction.
17
Local search
Hill climbing_2 is an example of local S
search. A
In local search, we only keep track of 1
path and use it to compute a new path in B
the next step. C
QUEUE is always of the form: D
( p)
Another example:
MINIMAL COST search: A
3 4
If p is the current path:
B C
the next path extends p by adding the
2 3 5
node with the smallest cost from the
endpoint of p D E F
18
Greedy search
S 30
10 40
1 20 At each step,
3 select the
node with the
35 15 best (in this
case: lowest)
2 27 18
heuristic
value.
25 45 The ‘open’
nodes
20
Greedy search algorithm:
1. QUEUE <-- path only containing the root;