Algoritma Pencarian dalam Kecerdasan Artifisial
Algoritma Pencarian dalam Kecerdasan Artifisial
Searching
Chastine Fatichah
Departemen Teknik Informatika
September 2025
• Goal-based agent →
mempertimbangkan aksi-aksi yang akan
datang dan hasil yang ingin dicapai
• Agent problem solving → Menemukan
rangkaian aksi (sequence action) untuk
mencapai tujuannya
• Algoritma Uninformed → Tidak ada
informasi, hanya deskripsi pada masalah
tersebut
Action First(seq)
Seq Rest(seq)
Return action
• State : ?
• Initial State : ?
• Successor Function : ?
• Goal Test : ?
• Path Cost : ?
• State : ?
• Initial State : ?
• Successor Function : ?
• Goal Test : ?
“N”, 1.0
• Successor function
(with actions, costs)
“E”, 1.0
• Solusi adalah urutan aksi (rencana) yang akan dilakukan dari start
state ke goal state
Sumber: Sergey Levine & Stuart Russell, University of California, Berkeley
• Sebuah “what if” tree pada rencana dan luaran yang dihasilkan
• Start state adalah root node
• Anak merefer pada successors
• Nodes menunjukkan states
• Pada banyak problem, sebenarnya tidak pernah membangun tree
secara utuh Sumber: Sergey Levine & Stuart Russell, University of California, Berkeley
a G d e p
b c
b c e h r q
e
d f a a h r p q f
S h
p r p q f q c G
q
q c G a
Consider this 4-state graph: How big is its search tree (from S)?
a s
a b
S G
b G a G
b a G b G
… …
Important: Lots of repeated structure in the search tree!
Sumber: Sergey Levine & Stuart Russell, University of California, Berkeley
• Search:
• Ekspansi potensi (tree nodes)
• Mencoba untuk ekspansi sedikit
mungkin node pada tree
• Fringe → kumpulan node hasil
generate yang belum diekspansi
S s
s→d
d e p s→e
s→p
b c e h r q s→d→b
s→d→c
a a h r p q f s→d→e
s→d→e→h
p q f q c G
s→d→e→r
a s→d→e→r→f
q c G
s→d→e→r→f→c
a s→d→e→r→f→G
Sumber: Sergey Levine & Stuart Russell, University of California, Berkeley
[Link]/informatika Konsep Kecerdasan Artifisial EK234201
Search Strategies
• Strategy → memilih node yang akan diekspansi:
• Completeness →Menemukan solusi jika ada
• Optimality → Optimal solution (cost terkecil)
• Time Complexity → berapa lama menemukan solusinya ?
• Space Complexity → berapa banyak memory yang
dibutuhkan ?
• Time dan Space Complexity bisa dilihat dari:
• b → maks branch factor
• d → depth dari solusi terkecil
• m → maks depth dari state space
• Depth-first search
• Breadth-first search
• Depth-limited search
• Iterative deepening search
• Uniform-cost search
• Bidirectional search
• Time ? O(bm)
• Bermasalah jika m jauh lebih besar dari d
• Space ? O(bm), linier space
• Optimal ? Tidak
ee
d f
S h
p q r
d e p
b c e h r q
a a h r p q f
p q f q c G
q c G
a
1 2 1 2 3
4 5 3 4 5
7 8 6 7 8 6
b=3 b=3
1, L 2, R 5, U 3, D 5, R 6, U
Goal
[Link]/informatika Konsep Kecerdasan Artifisial EK234201
Breadth-first Search
• Ekspand node ke samping
• Fringe → FIFO queue
• Complete ? Ya, jika b terbatas
• Time ? 1 + b + b2 + b3 + … + bd = O(bd)
d+1
• Space ? O(b ) A
D E F G
d e p
Search
b c e h r q
Tiers
a a h r p q f
p q f q c G
q c G
a
Sumber: Sergey Levine & Stuart Russell, University of California, Berkeley
1 2 1 2 3
4 5 3 4 5
7 8 6 7 8 6
b=3 b=3
1, L 2, R 5, U 3, D 5, R 6, U
Goal
S 0
d 3 e 9 p 1
b 4 c e 5 h 17 r 11 q 16
11
Cost a 6 a h 13 r 7 p q f
contours
p q f 8 q c G
q 11 c G 10
a
Sumber: Sergey Levine & Stuart Russell, University of California, Berkeley
a
[Link]/informatika Konsep Kecerdasan Artifisial EK234201
Bidirectional Search
• Mencari dari 2 arah secara simultan
• Motivasi → bd/2 + bd/2 jauh lebih kecil dari bd
• Misal d = 6, masing2 menggunakan BFS → depth=3, b=10; dengan
bidirectional hanya 22.200 node sedangkan BFS standar mencapai
11.111.000 node
Evaluation of search algorithms. b is the branching factor; m is the maximum depth of the search tree; d is the depth of the
shallowest solution, or m is when there is no solution; ℓ is the depth limit.
Superscript caveats are as follows: 1complete if b is finite, and the state space either has a solution or is finite.
2
complete if all action costs are ≥ ε > 0; 3cost-optimal if action costs are all identical; 4if both directions are breadth-first or
uniform-cost.
Pada permainan 8-puzzles dengan informasi state awal dan goal sebagai
berikut: