download

Matakuliah
Tahun
Versi
: T0264/Inteligensia Semu
: Juli 2006
: 2/1
Pertemuan 3
Heuristic Search Techniques
Generate-and-Test
1
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa
akan mampu :
• << TIK-99 >>
• << TIK-99>>
2
Outline Materi
•
•
•
•
•
Materi 1
Materi 2
Materi 3
Materi 4
Materi 5
3
Search Strategis
A. Blind Search :
 Breadth-first search
 Depth-first search
B. Heuristic Search :
•
•
•
•
•
•
Generate-and-test
Hill climbing
Best-first search
Problem reduction
Constrain satisfaction
Means-ends analysis
4
3.1 Generate-and-Test
Algorithm : Generate-and-Test
1. Generate a possible solution.
2. Test to see if this actually a solution by
comparing the chosen point or the
endpoint of the chosen path to the set of
acceptable goal states.
3. If a solution has been found, quit.
Otherwise, return to step1.
5
Generate-and-Test
• Sales Traveling Problem
8
A
7
5
3
C
B
6
4
D
Dengan Menggunakan
Generate and test bisa
ditentukan lintasan
terpendek yang harus
ditempuh oleh sales.
6
3.2 Hill-Climbing
Algorithm : Simple Hill – Climbing
1. Evaluate the initial state. If it is also a goal
state, then return it and quit. Otherwise,
continue with the initial state as the current
state.
2. Loop until a solution is found or until there are
no new operators left to be applied in the
current state :
a. Select an operator that has not yet been applied to
the current state and apply it to produce a new state.
7
Algorithm : Simple Hill – Climbing
b.
Evaluate the new state.
i.
ii.
iii.
If it is a goal state, then return it and quit.
If it is not a goal state but it is better than
the current state, then make it the current
state.
If it is not better than the current state, then
continue in the loop.
8
Algorithm : Steepest – Ascent Hill Climbing
1. Evaluate the initial state. If it is also a goal
state, then return it and quit. Otherwise,
continue with the initial state as the current
state.
2. Loop until a solution is found or until a
complete iteration produces no change to
current state :
a. Let SUCC be a state such that any
possible sucessor of the current state will
be better than SUCC.
9
Algorithm : Steepest – Ascent Hill Climbing
b. For each operator that applies to current state
do :
i. Apply the operator and generate a new
state.
ii. Evaluate the new state. If it is goal state,
then return it and quit. If not, compare it to
SUCC. If it is better, then set SUCC to this
state. If it is not better, leave SUCC alone.
c. If the SUCC is better than current state, then
set current state to SUCC.
10
Kasus Sales Hill Climbing
Operator yang digunakan :
1.
2.
3.
4.
5.
6.
Tukar kota 1 dengan 2
Tukar kota 2 dengan 3
Tukar kota 3 dengan 4
Tukar kota 4 dengan 1
Tukar kota 2 dengan 4
Tukar kota 1 dengan 3
11
Kasus Sales dengan Hill Climbing
ABCD/19
BACD/12
ACBD/12
ABCD/19
BCAD/15
Simple H. C.
ABDC/18
BADC/12
DBCA/12
DACB/12
ADCB/18
CBAD/20
BDCA/15
CABD/16
Steepest Acsent H. C.
12
Hill - Climbing Dangers
13
A Hill Climbing Problem
A
H
H
G
G
F
F
E
E
D
D
C
C
B
B
A
Initial State
Goal State
14
Three Possible Moves
G
A
H
G
F
E
D
C
B
(a)
F
E
D
H
C
A
B
(b)
G
F
E
D
C
A
H
(c)
B
15
3.3 Best – First Search
Step 1
Step 2
A
A
B (3)
C (5)
Step 3
A
D (1)
B
(3) C
(5) D
Step 4
Step 5
A
E
(4) F (6)
A
B
C (5)
D
B
G (6) H (5)
E
C (5)
D
(4) F (6)
G (6) H (5)
I
E
F (6)
(2) J (1)
16
Algorithm : Best - First Search
1.
2.
Start with Open containing just the initial state
Until a goal is found or there are no nodes left
on Open do:
(a) Pick the best node on Open.
(b) Generate its successors.
(c) For each successor do :
i. If it has not been generate before, evaluate it,
add it to Open, and record its parent.
ii. If it has been generate before, change the parent
if this new path is better than previous one. In
that case, update the cost of getting to this node
and to any successors that this node may
already have.
17
Underestimates
A
B
E
F
(3+1)
C
(4+1)
D
(5+1)
(3+2)
(3+3)
18
Overestimates
A
B
E
F
G
(3+1)
C
(4+1)
D
(5+1)
(2+2)
(1+3)
(0+4)
19
<< CLOSING>>
End of Pertemuan 3
Good Luck
20