Metode Pencarian
Terdapat banyak metode yang telah diusulkan.
Semua metode yang ada dapat dibedakan ke dalam 2 jenis :
1. Pencarian buta / tanpa informasi (
blind / un-informed search
)
2. Pencarian heuristik / dengan informasi (
heuristic
atau
informed search
)
4 Kriteria mengukur performansi
1. Completeness :
Apakah metode tersebut menjamin penemuan solusi jika
solusinya memang ada?
2. Time complexity :
Berapa lama waktu yang diperlukan ?
3. Space complexity :
Berapa banyak memori yang diperlukan ?
4. Optimality :
Apakah metode tersebut menjamin menemukan solusi
Heuristic Searching
Sebagai Dasar dari Kecerdasan Buatan
Para peneliti awal kecerdasan buatan menitik beratkan pada
penyelesaian masalah yang tidak menggunakan metoda
komputasi konvensional.
Hal ini disebabkan metoda pemecahan masalah konvensional
tidak dapat lagi digunakan.
Permasalahan pada sistem Kecerdasan Buatan tidak memiliki
algoritma tertentu. Kalaupun ada tentulah sangat kompleks.
Karena itu haruslah ditemukan sebuah teknik baru yang mirip
dengan cara yang digunakan oleh manusia untuk
Salah satu metoda yang cukup terkenal adalah metoda
searching
.
Searching dalam sebuah struktur data telah menjadi
dasar bagi algoritma komputer, tetapi proses searching
pada KB memiliki perbedaan.
Metoda searching pada KB merupakan searching
Proses searching ini berupa jalur yang menggambarkan
keadaan awal sebuah masalah menuju kepada
penyelesaian masalah yang diinginkan.
Jalur-jalur ini mengambarkan langkah-langkah
penyelesaian masalah.
Perhatikan contoh penyelesaian masalah komputer
pada slide diatas.
Langkah pertama untuk mengetahui apakah komputer
dapat digunakan atau tidak adalah men-switch ON.
Selanjutnya dengan melakukan inspeksi terhadap
kondisi lampu indikator kita dapat menentukan langkah
berikutnya.
Misalnya kondisi lampu OFF.
Dengan melakukan searching terhadap problem space
BLIND / UN-INFORMED SEARCH
Istilah
blind
atau buta digunakan karena memang tidak ada
informasi awal yang digunakan dalam proses pencarian.
Berikut ini, sekilas 6 metode yang tergolong blind search
a.
Breadth-First Search (BFS)
b.
Depth-First Search (DFS)
c.
Depth-Limited Search (DLS)
d.
Uniform Cost Search (UCS)
e.
Iterative-Deepening Search (IDS)
1. Breadth-frst Search
Breadth-frst search (BFS)
melakukan proses searching
pada semua node yang berada pada level atau hirarki
yang sama terlebih dahulu sebelum melanjutkan
proses searching pada node di level berikutnya.
Urutan proses searching BFS ditunjukkan dalam
Pada metode Breadth-First Search, semua node pada
level n akan dikunjungi terlebih dahulu sebelum
mengunjungi node-node pada level n+1
Pencarian dimulai dari node akar terus ke level ke-1
dari kiri ke kanan, kemudian berpindah ke level
Example:
Keuntungan
Tidak akan menemui jalan buntu (solusi lebih optimal)
Kelemahan
Membutuhkan memori yang cukup banyak, karena
menyimpan semua node dalam satu pohon
(membutuhkan simpul yam umumnya relatif banyak)
Membutuhkan waktu yang cukup lama, karena akan
2. Depth-frst Search
Depth-frst search (DFS)
adalah proses searching sistematis
buta yang melakukan ekpansi sebuah path (jalur) menuju
penyelesaian masalah sebelum melakukan ekplorasi terhadap
path yang lain.
Proses searching mengikuti sebuah path tunggal sampai
menemukan goal atau dead end.
Apabila proses searching menemukan dead-end, DFS akan
melakukan penelusuran balik ke node terakhir untuk melihat
apakah node tersebut memiliki path cabang yang belum
Apabila cabang ditemukan, DFS akan melakukan ekplorasi ke
cabang tersebut.
Apabila sudah tidak ada lagi cabang yang dapat dieksplorasi,
DFS akan kembali ke node parent dan melakukan proses
searching terhadap cabang yang belum dieksplorasi dari node
parent sampai menemukan penyelesaian masalah.
Urutan proses searching DFS ditunjukkan dalam Gambar 1.5
Kelebihan DFS adalah:
Pemakaian memori hanya sedikit, berbeda jauh
dengan BFS yang harus menyimpan semua node yang
pernah dibangkitkan.
Jika solusi yang dicari berada pada level yang dalam
Kelemahan DFS adalah:
Jika pohon yang dibangkitkan mempunyai level yang
dalam (tak terhingga), maka tidak ada jaminan untuk
menemukan solusi (
Tidak
Complete
).
Jika terdapat lebih dari satu solusi yang sama tetapi
3. Depth-Limited Search (DLS)
Metode ini berusaha mengatasi kelemahan DFS (tidak
complete) dengan membatasi kelemahan maksimum dari
suatu jalur solusi.
www.themegallery.com
Defnisi
Algoritma Depth-Limited Search (DLS), adalah salah satu jenis
algoritma pencarian solusi. Algoritma ini dijalankan dengan
cara membangkitkan pohon pencarian secara dinamis.
Pencarian solusi dilakukan secara mendalam.
Pada dasarnya, algoritma DLS sama dengan algoritma DFS,
hanya saja dalam permasalahan penelusuran graf, sebelumnya
ditentukan terlebih dahulu batas maksimum level yang
www.themegallery.com
Algoritma
1.
Tentukan batas kedalaman pohon yang akan dikunjungi.2.
Kunjungi simpul v.3.
Kunjungi simpul w yang bertetangga dengan simpul v, yang berada di kedalaman pohon <= batas.
Misalkan terdapat graf/pohon dengan n buah simpul dan v merupakan simpul
www.themegallery.com
4.
Ulangi DLS mulai dari simpul w.5.
Ketika mencapai simpul semua simpul yang bertetangga dengannya telah u sedemikian sehingga dikunjungi, pencarian dirunut-balik (backtrack) ke simpul terakhir yang dikunjungi sebelumnya dan mempunyai simpul w yang belum dikunjungi.6.
Kelebihan dan Kekurangan
DLS lahir untuk mengatasi kelemahan DFS(tidak
complete) dengan membatasi kedalaman maksimum
dari suatu jalur solusi. Tetapi harus diketahui atau ada
batasan dari sistem tentang level maksimum. Jika
batasan kedalaman terlalu kecil, DLS tidak complete.
www.themegallery.com
Contoh 1
www.themegallery.com
Contoh 2
4. Uniform Cost Search (UCS)
Konsepnya hampir sama dengan BFS, bedanya adalah bahwa
BFS menggunakan urutan level yang paling rendah sampai
yang paling tinggi, sedangkan UCS menggunakan urutan
biaya dari yang paling kecil sampai yang terbesar.
UCS berusaha menemukan solusi dengan total biaya
5. Iterative-Deepening Search (IDS)
IDS merupakan metode yang menggabungkan
kelebihan BFS (Complete dan Optimal) dengan
kelebihan DFS (space complexity rendah atau
membutuhkan sedikit memori)
Tetapi konsekwensinya adalah time complexitynya
Iterative deepening search
The problem with depth-limited search is deciding on a suitable depth
parameter. To avoid this problem there is another search called iterative
deepening search (IDS).
This search method tries all possible depth limits; frst 0, then 1, then 2 etc.,
until a solution is found.
IDS may seem wasteful as it is expanding nodes multiple times. But the
overhead is small in comparison to the growth of an exponential search tree
For large search spaces where is the depth of the solution is not known IDS is
normally the preferred search method.
The following slide illustrates an iterative deepening search of 26 nodes
A
C
D
E
F
B
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
The example node set
Initial state
Goal state
A
L
A
A
We begin with our initial state: the node labeled A. This node is added to thequeue. Press space to continue
Size of Queue: 0
Nodes expanded: 0 Current Action: Expanding Current level: n/a
Queue: Empty Queue: A
Size of Queue: 1
Current level: 0 Nodes expanded: 1
Queue: Empty Size of Queue: 0
Press space to begin the search
As this is the 0th iteration of the search, we cannot search past any level greater than zero.
This iteration now ends, and we begin the 1st iteration.
ITERATIVE DEEPENING SEARCH PATTERN (0th ITERATION)
A
C
D
E
F
B
A
B
C
D
We again begin with our initial state: the
node labeled A. Note that the 1st iteration
carries on from the 0th, and therefore the
‘nodes expanded’ value is already set to 1. Press space to continue
Node A is expanded, then removed from the queue, and the revealed nodes are added to the front . Press space.
The search now moves to level one of the node set. Press space to continue
Node B is expanded and removed from the queue. Press space.
Size of Queue: 0
Nodes expanded: 1 Current Action: Current level: n/a
Queue: Empty Queue: A
Size of Queue: 1
Nodes expanded: 2
Queue: B, C, D, E, F
Press space to begin the search
Size of Queue: 5
Current level: 0 Current Action: Expanding
Queue: C, D, E, F Size of Queue: 4
Nodes expanded: 3 Current Action: Backtracking Current level: 1Current level: 0Current level: 1
Queue: D, E, F Size of Queue: 3
Nodes expanded: 4 Current Action: ExpandingCurrent Action: Backtracking Current level: 0Current level: 1 Queue: E, F
Size of Queue: 2
Nodes expanded: 5 Current Action: ExpandingCurrent Action: BacktrackingCurrent Action: Expanding Current level: 0Current level: 1 Queue: F
E
Current Action: Backtracking Current level: 0
Current Action: Expanding Current level: 1
Queue: Empty
F
Current level: 0 Current level: 1 Press space to continue the search
Press space to continue the search Press space to continue the search
ITERATIVE DEEPENING SEARCH PATTERN (1st ITERATION)
Size of Queue: 1 Size of Queue: 0
As this is the 1st iteration of the search, we cannot search past any level greater than level
one. This iteration now ends, and we begin a 2nd iteration.
Nodes expanded: 6 Nodes expanded: 7
A
We again begin with our initial state: the
node labeled A. Note that the 2nd
iteration carries on from the 1st, and
therefore the ‘nodes expanded’ value is already set to 7 (1+6). Press space to continue the search
Again, we expand node A to reveal the level one nodes. Press space.
Node A is removed from the queue and
each revealed node is added to the front of the queue. Press space.
The search then moves to level one of the node set. Press space to continue Node B is expanded and the revealed nodes added to the front of the queue. Press space to continue.
Size of Queue: 0
Nodes expanded: 7 Current Action: Current level: n/a
Queue: Empty Queue: A
Size of Queue: 1
Current level: 0 Nodes expanded: 8
Queue: B, C, D, E, F
Current level: 1 Queue: G, H, C, D, E, F
Nodes expanded: 9 Current level: 2
ITERATIVE DEEPENING SEARCH PATTERN (2nd ITERATION)
Size of Queue: 5
Current Action: Expanding We now move to level two of the node
set. Press space to continue.
After expanding node G we backtrack to expand node H. The process then continues until goal state. Press space
Queue: H, C, D, E, F
Nodes expanded: 10 Current Action: BacktrackingCurrent Action: Expanding Queue: C, D, E, F
Size of Queue: 6
Nodes expanded: 11
H
Press space to continue the search
Size of Queue: 5 Size of Queue: 4
Current Action: Backtracking Current Action: Expanding Queue: I, J, D, E, F
Size of Queue: 5
Nodes expanded: 12
Press space to continue the search
C
Size of Queue: 4
Nodes expanded: 13
I
Press space to continue the search
Current Action: Backtracking Current level: 1Current level: 2
Queue: D, E, F
Current Action: Expanding Size of Queue: 3
Nodes expanded: 14
J
Press space to continue the search
Current Action: Backtracking Current level: 1Current level: 0Current level: 1 Current Action: Expanding
Queue: K, L, E, F Size of Queue: 4
Nodes expanded: 15
D
Press space to continue the search
Current level: 2 Queue: L, E, F
Size of Queue: 3
Nodes expanded: 16
K
Press space to continue the search
Current Action: Expanding Current level: 1Current level: 2
LLLLL
Current Action: Backtracking Queue: Empty
Size of Queue: 0
Node L is located on the second level and the search returns a solution on its second iteration. Press space to end.
6. Bi-Directional Search (BDS)
Pencarian dilakukan dari dua arah : pencarian maju
(dari start ke goal) dan pencarian mundur (dari goal
ke start). Ketika dua arah pencarian telah
membangkitkan simpul yang sama, maka solusi
telah ditemukan, yaitu dengan cara
Perbandingan Strategi Pencarian
www.themegallery.com
Keterangan
b : faktor percabangan
d : kedalaman solusi
M : kedalaman maksimum pohon pencarian