om
nh
Vi
en
Zo
ne
.C
Heuristic Search
Si
Chapter 3
SinhVienZone.com
/>
.C
Generate-and-test
nh
Vi
en
Best-first search
Zo
Simulated annealing
ne
Hill climbing
Means-ends analysis
Constraint satisfaction
Si
•
•
•
•
•
•
om
Outline
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
2
24 February, 2009
/>
ne
.C
Algorithm
1. Generate a possible solution.
om
Generate-and-Test
Zo
2. Test to see if this is actually a solution.
Si
nh
Vi
en
3. Quit if a solution has been found.
Otherwise, return to step 1.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
3
24 February, 2009
/>
om
Generate-and-Test
.C
• Acceptable for simple problems.
Si
nh
Vi
en
Zo
ne
• Inefficient for problems with large space.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
4
24 February, 2009
/>
.C
• Exhaustive generate-and-test.
om
Generate-and-Test
ne
• Heuristic generate-and-test: not consider paths that
nh
Vi
en
• Plan generate-test:
Zo
seem unlikely to lead to a solution.
Si
− Create a list of candidates.
− Apply generate-and-test to that list.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
5
24 February, 2009
/>
om
Generate-and-Test
Si
nh
Vi
en
Zo
ne
.C
Example: coloured blocks
“Arrange four 6-sided cubes in a row, with each side of
each cube painted one of four colours, such that on all four
sides of the row one block face of each colour is showing.”
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
6
24 February, 2009
/>
om
Generate-and-Test
ne
.C
Example: coloured blocks
Si
nh
Vi
en
Zo
Heuristic: if there are more red faces than other colours
then, when placing a block with several red faces, use few
of them as possible as outside faces.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
7
24 February, 2009
/>
om
Hill Climbing
Si
nh
Vi
en
Zo
ne
.C
• Searching for a goal state = Climbing to the top of a hill
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
8
24 February, 2009
/>
om
Hill Climbing
.C
• Generate-and-test + direction to move.
Zo
Si
nh
Vi
en
is to a goal state.
ne
• Heuristic function to estimate how close a given state
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
9
24 February, 2009
/>
.C
ne
Algorithm
1. Evaluate the initial state.
om
Simple Hill Climbing
nh
Vi
en
Zo
2. Loop until a solution is found or there are no new
operators left to be applied:
Si
− Select and apply a new operator
− Evaluate the new state:
goal → quit
better than current state → new current state
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
10
24 February, 2009
/>
.C
ne
Algorithm
1. Evaluate the initial state.
om
Simple Hill Climbing
nh
Vi
en
Zo
2. Loop until a solution is found or there are no new
operators left to be applied:
Si
− Select and apply a new operator
− Evaluate the new state:
goal → quit
better than current state → new current state
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
not try all possible new states!
11
24 February, 2009
/>
om
Simple Hill Climbing
ne
.C
Example: coloured blocks
Si
nh
Vi
en
Zo
Heuristic function: the sum of the number of different
colours on each of the four sides (solution = 16).
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
12
24 February, 2009
/>
om
Simple Hill Climbing
• Heuristic function as a way to inject task-specific
Si
nh
Vi
en
Zo
ne
.C
knowledge into the control process.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
13
24 February, 2009
/>
om
Steepest-Ascent Hill Climbing
(Gradient Search)
.C
• Considers all the moves from the current state.
Si
nh
Vi
en
Zo
ne
• Selects the best one as the next state.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
14
24 February, 2009
/>
.C
ne
Algorithm
1. Evaluate the initial state.
om
Steepest-Ascent Hill Climbing
(Gradient Search)
nh
Vi
en
Zo
2. Loop until a solution is found or a complete iteration
produces no change to current state:
Si
− Apply all the possible operators
− Evaluate the best new state:
goal → quit
better than current state → new current state
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
15
24 February, 2009
/>
.C
ne
Algorithm
1. Evaluate the initial state.
om
Steepest-Ascent Hill Climbing
(Gradient Search)
Zo
2. Loop until a solution is found or a complete iteration
produces no change to current state:
Si
nh
Vi
en
− SUCC = a state such that any possible successor of the
current state will be better than SUCC (the worst state).
− For each operator that applies to the current state, evaluate
the new state:
goal → quit
better than SUCC → set SUCC to this state
− SUCC is better than the current state → set the new current
Cao Hoang Trustate to SUCC.
16
CSE Faculty - HCMUT
SinhVienZone.com
24 February, 2009
/>
om
Hill Climbing: Disadvantages
Si
nh
Vi
en
Zo
ne
.C
Local maximum
A state that is better than all of its neighbours, but not
better than some other states far away.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
17
24 February, 2009
/>
om
Hill Climbing: Disadvantages
Si
nh
Vi
en
Zo
ne
.C
Plateau
A flat area of the search space in which all neighbouring
states have the same value.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
18
24 February, 2009
/>
om
Hill Climbing: Disadvantages
Si
nh
Vi
en
Zo
ne
.C
Ridge
The orientation of the high region, compared to the set
of available moves, makes it impossible to climb up.
However, two moves executed serially may increase
the height.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
19
24 February, 2009
/>
om
Hill Climbing: Disadvantages
.C
Ways Out
Zo
different direction.
ne
• Backtrack to some earlier node and try going in a
Si
nh
Vi
en
• Make a big jump to try to get in a new section.
• Moving in several directions at once.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
20
24 February, 2009
/>
• Hill climbing is a local method:
om
Hill Climbing: Disadvantages
ne
.C
Decides what to do next by looking only at the
“immediate” consequences of its choices.
nh
Vi
en
Si
functions.
Zo
• Global information might be encoded in heuristic
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
21
24 February, 2009
/>
Goal
nh
Vi
en
C
ne
D
.C
A
Zo
Start
D
C
B
A
Si
B
om
Hill Climbing: Blocks World
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
22
24 February, 2009
/>
D
.C
nh
Vi
en
C
4
ne
0
Goal
A
Zo
Start
B
om
Hill Climbing: Blocks World
D
C
B
A
Si
Local heuristic:
+1 for each block that is resting on the thing it is supposed to
be resting on.
−1 for each block that is resting on a wrong thing.
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
23
24 February, 2009
/>
2
nh
Vi
en
C
ne
D
.C
A
Zo
0
om
Hill Climbing: Blocks World
C
B
A
Si
B
D
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
24
24 February, 2009
/>
2
D
C
B
0
Si
A
nh
Vi
en
Zo
B
ne
C
.C
D
Cao Hoang Tru
CSE Faculty - HCMUT
SinhVienZone.com
C
B
om
Hill Climbing: Blocks World
A
0
D
A
C
B
0
A
D
25
24 February, 2009
/>