Pertemuan 3 Heuristic Search Techniques Generate-and-Test

Post on 21-Jan-2016

41 views 0 download

description

Pertemuan 3 Heuristic Search Techniques Generate-and-Test. Matakuliah: T0264/Inteligensia Semu Tahun: Juli 2006 Versi: 2/1. Learning Outcomes. Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : > >. Outline Materi. Materi 1 Materi 2 Materi 3 - PowerPoint PPT Presentation

Transcript of Pertemuan 3 Heuristic Search Techniques Generate-and-Test

1

Pertemuan 3 Heuristic Search Techniques

Generate-and-Test

Matakuliah : T0264/Inteligensia Semu

Tahun : Juli 2006

Versi : 2/1

2

Learning Outcomes

Pada akhir pertemuan ini, diharapkan mahasiswa

akan mampu :

• << TIK-99 >>

• << TIK-99>>

3

Outline Materi

• Materi 1

• Materi 2

• Materi 3

• Materi 4

• Materi 5

4

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

5

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.

6

Generate-and-Test

• Sales Traveling Problem

Dengan Menggunakan Generate and test bisa ditentukan lintasan terpendek yang harus ditempuh oleh sales.

A

C D

B8

7 53 4

6

7

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.

8

Algorithm : Simple Hill – Climbing

b. Evaluate the new state.

i. If it is a goal state, then return it and quit.

ii. If it is not a goal state but it is better than the current state, then make it the current state.

iii. If it is not better than the current state, then continue in the loop.

9

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.

10

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.

11

Kasus Sales Hill Climbing

Operator yang digunakan :

1. Tukar kota 1 dengan 2

2. Tukar kota 2 dengan 3

3. Tukar kota 3 dengan 4

4. Tukar kota 4 dengan 1

5. Tukar kota 2 dengan 4

6. Tukar kota 1 dengan 3

12

Kasus Sales dengan Hill Climbing

ABCD/19

ABDC/18BACD/12 DBCA/12 ADCB/18 CBAD/20ACBD/12

BCAD/15 BADC/12 DACB/12 BDCA/15 CABD/16ABCD/19

Simple H. C. Steepest Acsent H. C.

13

Hill - Climbing Dangers

14

A Hill Climbing Problem

A

H

G

F

E

D

C

B

Initial State

H

G

F

E

D

C

B

A

Goal State

15

Three Possible Moves

A

H

G

F

E

D

C

B

(a)

A

H

G

F

E

D

C

B

(b)

A H

G

F

E

D

C

B

(c)

16

3.3 Best – First Search

Step 1 Step 2 Step 3

Step 4

Step 5

A A

B (3) C (5) D (1)

A

B (3) C (5) D

E (4) F (6)A

B C (5) D

E (4) F (6)G (6) H (5)

A

B C (5) D

E F (6)G (6) H (5)

I (2) J (1)

17

Algorithm : Best - First Search

1. Start with Open containing just the initial state

2. 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.

18

Underestimates

A

B C D

E

F

(3+1) (4+1) (5+1)

(3+2)

(3+3)

19

Overestimates

A

B C D

E

F

(3+1) (4+1) (5+1)

(2+2)

(1+3)

G (0+4)

20

<< CLOSING>>

End of Pertemuan 3

Good Luck