SlideShare a Scribd company logo
1 of 26
Download to read offline
Route/Path Planning
Bagian 2: Algoritma A*
IF221 Strategi Algoritma
Program Studi Informatika
STEI-ITB
IF2211/NUM/RIN/19Mar2020 1
Referensi
1. Materi kuliah IF3170 Inteligensi Buatan Teknik Informatika ITB,
Course Website:
http://kuliah.itb.ac.id → STEI → Teknik Informatika → IF3170
2. Stuart J Russell & Peter Norvig, Artificial Intelligence: A Modern
Approach, 3rd Edition, Prentice-Hall International, Inc, 2010,
Textbook
Site: http://aima.cs.berkeley.edu/ (2nd edition)
3. Free online course materials | MIT OpenCourseWare Website:
Site: http://ocw.mit.edu/courses/electrical-engineering-and-
computer-science/
4. Lecture Notes in Informed Heuristic Search, ICS 271 Fall 2008,
http://www.ics.uci.edu/~dechter/courses/ics-271/fall-08/lecture-
notes/4.InformedHeuristicSearch.ppt
2
IF2211/NUM/RIN/19Mar2020
Route
Planning
3
IF2211/NUM/RIN/19Mar2020
4
Search
Source: Russell’s book
S: set of cities
i.s: A (Arad)
g.s: B (Bucharest)
Goal test: s = B ?
Path cost: time ~ distance
A
118
T
S
O
Z
R
P
F
B
C
L
M
D
111
75
71 151 99
97
120
146 138
101
211
75
70
140 80
IF2211/NUM/RIN/19Mar2020
Persoalan: Carilah lintasan terpendek dari Arad (A) ke Bucharest (B)!
Heuristic Search
➢Heuristic estimates value of a node
• promise of a node
• difficulty of solving the subproblem
• quality of solution represented by node
• the amount of information gained
➢f(n)- heuristic evaluation function.
• depends on n, goal, search so far, domain
5
IF2211/NUM/RIN/19Mar2020
A* Search
➢ Idea: avoid expanding paths that are already expensive
➢ Evaluation function f(n) = g(n) + h(n)
• g(n) = cost so far to reach n
• h(n) = estimated cost from n to goal
• f(n) = estimated total cost of path through n to goal
➢ if f(n) = g(n) → Uniform Cost Search (UCS)
if f(n) = h(n) → Greedy Best First Search
if f(n) = g(n) + h(n) → A*
6
IF2211/NUM/RIN/19Mar2020
n
root
goal
g(n)
h(n)
A* search example
7
IF2211/NUM/RIN/19Mar2020
f(n) = g(n) + h(n)
g(n) = distance from Arad to n
h(n) = straight-line distance from n to Bucharest
8
IF2211/NUM/RIN/19Mar2020
f(n) = g(n) + h(n)
g(n) = distance from Arad to n
h(n) = straight-line distance from n to Bucharest
A* search example
9
IF2211/NUM/RIN/19Mar2020
f(n) = g(n) + h(n)
g(n) = distance from Arad to n
h(n) = straight-line distance from n to Bucharest
A* search example
10
IF2211/NUM/RIN/19Mar2020
f(n) = g(n) + h(n)
g(n) = distance from Arad to n
h(n) = straight-line distance from n to Bucharest
A* search example
11
IF2211/NUM/RIN/19Mar2020
f(n) = g(n) + h(n)
g(n) = distance from Arad to n
h(n) = straight-line distance from n to Bucharest
A* search example
12
IF2211/NUM/RIN/19Mar2020
f(n) = g(n) + h(n)
g(n) = distance from Arad to n
h(n) = straight-line distance from n to Bucharest
A* search example
A* Special
➢Goal: find a minimum sum-cost path
➢Notation:
• c(n,n’) - cost of arc (n,n’)
• g(n) = cost of current path from start to node n in the search tree.
• h(n) = estimate of the cheapest cost of a path from n to a goal.
• Special evaluation function: f = g+h
➢f(n) estimates the cheapest cost solution path that goes through n.
• h*(n) is the true cheapest cost from n to a goal.
• g*(n) is the true shortest path from the start s, to n.
➢If the heuristic function, h always underestimate the true cost (h(n) is
smaller than h*(n)), then A* is guaranteed to find an optimal solution
→ admissible; and also has to be consistent
13
IF2211/NUM/RIN/19Mar2020
f(n) = g(n) + h(n)
n
root
goal
g(n)
h(n)
Properties of A*
• Complete? Yes, unless there are infinitely many nodes
with f ≤ f(G)
• Time? Exponential: O(bm)
• Space? Keep all the nodes in memory: O(bm)
• Optimal? Yes
14
IF2211/NUM/RIN/19Mar2020
Branch-and-Bound vs A*
• As in A*, look for a bound which is guaranteed lower than the true
cost
• Search the branching tree in any way you like
• e.g. depth first (no guarantee), best first
• Cut off search if cost + bound > best solution found
• If heuristic is cost + bound, search = best first
• then B&B = A*
• Bounds often much more sophisticated
• e.g. using mathematical programming optimisations
15
IF2211/NUM/RIN/19Mar2020
Admissible heuristics
➢A heuristic h(n) is admissible if for every node n, h(n) ≤ h*(n), where
h*(n) is the true cost to reach the goal state from n.
➢An admissible heuristic never overestimates the cost to reach the
goal, i.e., it is optimistic
➢Example: hSLD(n) (never overestimates the actual road distance)
Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal
IF2211/NUM/RIN/19Mar2020 16
IF2211/NUM/RIN/19Mar2020
Admissibility
• What must be true about h
for A* to find optimal path?
• A* finds optimal path if h is
admissable; h is admissible
when it never overestimates.
• In this example, h is not
admissible.
• In route finding problems,
straight-line distance to goal
is admissible heuristic.
g(X)+h(X)=2+100=102
G(Y)+h(Y)=73+1=74
Optimal path is not found!
Because we choose Y, rather than X
which is in the optimal path.
17
Latihan soal A*
Terdapat persoalan 8-puzzle seperti pada Gambar 1. Gambar 1(a) adalah start state
persoalan, dan gambar 1(b) adalah goal state. Ubin yang dapat bergerak adalah
ubin kosong, dengan urutan pergerakan (jika diperlukan) adalah kiri, kanan, atas,
bawah. Selesaikan persoalan 8-puzzle tersebut dengan teknik A*. Biaya suatu state
dari start state adalah banyaknya langkah ubin kosong yang telah dilakukan. Jika
diperlukan heuristik, maka digunakan jumlah manhattan distance semua ubin
selain ubin kosong. Manhattan distance sebuah ubin adalah banyaknya ubin secara
horisontal dan vertikal terdekat untuk menuju posisi ubin yang sesuai
IF2211/NUM/RIN/19Mar2020 18
Tuliskan langkah-langkah penyelesaiannya dengan menggambarkan pohon ruang
pencarian, dan di setiap simpul pohon tunjukkan perhitungan nilai fungsi
evaluasinya (yang menjadi penentu state berikutnya yang harus diperiksa).
State yang sudah pernah dilalui tidak perlu diperiksa kembali. Setelah pencarian
selesai, tuliskan langkah pergeseran ubin kosong dari start state hingga goal state.
Asumsi: status tujuan selalu dapat dicapai dari status awal.
Penyelesaian:
f(n) = g(n) + h(n)
g(n) = jumlah langkah ubin kosong yang telah dilakukan
h(n) = jumlah manhattan distance semua ubin selain ubin kosong.
IF2211/NUM/RIN/19Mar2020 19
(Manhattan distance sebuah ubin adalah banyaknya ubin secara horisontal dan vertikal terdekat
untuk menuju posisi ubin yang sesuai)
IF2211/NUM/RIN/19Mar2020 20
Goal state
Initial state
Contoh Soal UAS Sem 2 2014/2015
Dalam permainan video game, adakalanya entitas bergerak dalam video
game perlu berpindah dari satu posisi ke posisi lain. Seringkali proses
perpindahan perlu mengutamakan jalur terdekat atau biaya minimal
karena berhubungan dengan poin yang diperoleh. Gambar di bawah ini
menunjukkan contoh jalur yang mungkin dilewati oleh entitas bergerak
dalam suatu video game. Suatu entitas akan berpindah dari posisi titik A
menuju ke posisi titik F. Jika diperlukan informasi heuristik, nilai heuristik
dari suatu simpul adalah banyaknya busur minimal yang
menghubungkan titik tersebut ke titik tujuan.
IF2211/NUM/RIN/19Mar2020 21
Contoh Soal UAS Sem 2 2014/2015 (2)
22
Pencarian solusi dengan:
a. UCS
b. Greedy Best First
c. A Star
Untuk masing-masing pendekatan tuliskan:
- Formula
- Iterasi
- Simpul yang diekspansi
- Simpul hidup & nilai f(n)
Urut abjad, simpul ekspan tidak mengulang,
tidak membentuk sirkuit, berhenti saat satu
solusi ditemukan
IF2211/NUM/RIN/19Mar2020
Solusi:
IF2211/NUM/RIN/19Mar2020 23
Jawaban:
Iterasi
UCS Greedy Best First Search A Star
Formula: f(n) = g(n) Formula: f(n) = h(n) Formula: f(n) = g(n) + h(n)
Simpul - Ekspan Simpu lHidup Simpul–Ekspan Simpul Hidup Simpul - Ekspan Simpul Hidup
1 A
Ba
f(B) = 2
A
Ea
f(Ea) = 1
A
Ba
f(Ba) = 2+2 =
4
Ca
f(C) = 4
Ba
f(Ba) = 2
Ca
f(Ca) = 4 + 2 =
6
Ea
f(E) = 5
Ca
f(Ca) = 2
Ea
f(Ea) = 5 + 1 =
6
2
Ba
Eba
f(Eba) = 3
Ea
De
f(De) = 1
Ba
Eba
f(Eba) = 3 + 1
= 4
Ca
f(C) = 4
Fea
f(Fea) = 0
Ca
f(Ca) = 4 + 2 =
6
Ea
f(E) = 5
Bea
f(Bea) = 2
Ea
f(Ea) = 5 + 1 =
6
Ba
f(Ba) = 2
Ca
f(Ca) = 2
IF2211/NUM/RIN/19Mar2020 24
3
Eba
Ca
f(C) = 4
Fea
Sudah sampai
solusi
Eba
Feba
f(Feba) = 5 +
0 = 5
Ea
f(E) = 5
Ca
f(Ca) = 4 + 2 =
6
Feba
f(Feba) = 5
Ea
f(Ea) = 5 + 1 =
6
Deba
f(Deba) = 6
Deba
f(Deba) = 6+1
= 7
4
Ca
Ea
f(E) = 5
Feba
Sudah
sampai solusi
Feba
f(Feba) = 5
Deba
f(Deba) = 6
Dca
f(Dca) = 7
5
Ea
Feba
f(Feba) = 5
Deba
f(Deba) = 6
Dca
f(Dca) = 7
Fea
f(Fea) = 7
Dea
f(Dea) = 8
IF2211/NUM/RIN/19Mar2020 25
6 Feba
Solusi sudah
ditemukan
Hasil
Jalur: A-B-E-F Jalur: A-E-F Jalur: A-B-E-F
Jarak: 5 Jarak: 7 Jarak: 5
Banyaknya iterasi: 6 Banyaknya iterasi: 3 Banyaknya iterasi: 4
Selamat Belajar
IF2211/NUM/RIN/19Mar2020 26

More Related Content

Similar to Route-Planning other sesion for Universal

Branch and bound method
Branch and bound methodBranch and bound method
Branch and bound methodVidhyaSenthil
 
Pathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic searchPathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic searchStavros Vassos
 
09 heuristic search
09 heuristic search09 heuristic search
09 heuristic searchTianlu Wang
 
Branch and bound.ppt
Branch and bound.pptBranch and bound.ppt
Branch and bound.pptumairshams6
 
AI_Session 8 A searching algorithm .pptx
AI_Session 8 A searching algorithm .pptxAI_Session 8 A searching algorithm .pptx
AI_Session 8 A searching algorithm .pptxAsst.prof M.Gokilavani
 
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)Omkar Rane
 
WEEK 4- DLD-GateLvelMinimization.pptx
WEEK 4- DLD-GateLvelMinimization.pptxWEEK 4- DLD-GateLvelMinimization.pptx
WEEK 4- DLD-GateLvelMinimization.pptxTaoqeerRajput
 
Mathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxMathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxgbikorno
 
Mathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxMathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxgbikorno
 
Informed-search TECHNIQUES IN ai ml data science
Informed-search TECHNIQUES IN ai ml data scienceInformed-search TECHNIQUES IN ai ml data science
Informed-search TECHNIQUES IN ai ml data sciencedevvpillpersonal
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsSigSegVSquad
 
A* and Min-Max Searching Algorithms in AI , DSA.pdf
A* and Min-Max Searching Algorithms in AI , DSA.pdfA* and Min-Max Searching Algorithms in AI , DSA.pdf
A* and Min-Max Searching Algorithms in AI , DSA.pdfCS With Logic
 
AstarAlgorithm_v5_TeamFlash
AstarAlgorithm_v5_TeamFlashAstarAlgorithm_v5_TeamFlash
AstarAlgorithm_v5_TeamFlashShuqing Zhang
 
Optimal L-shaped matrix reordering, aka graph's core-periphery
Optimal L-shaped matrix reordering, aka graph's core-peripheryOptimal L-shaped matrix reordering, aka graph's core-periphery
Optimal L-shaped matrix reordering, aka graph's core-peripheryFrancesco Tudisco
 
Combinatorial optimization CO-2
Combinatorial optimization CO-2Combinatorial optimization CO-2
Combinatorial optimization CO-2man003
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 

Similar to Route-Planning other sesion for Universal (20)

Branch and bound method
Branch and bound methodBranch and bound method
Branch and bound method
 
Pathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic searchPathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic search
 
09 heuristic search
09 heuristic search09 heuristic search
09 heuristic search
 
Branch and bound.ppt
Branch and bound.pptBranch and bound.ppt
Branch and bound.ppt
 
AI_Session 8 A searching algorithm .pptx
AI_Session 8 A searching algorithm .pptxAI_Session 8 A searching algorithm .pptx
AI_Session 8 A searching algorithm .pptx
 
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
 
Heuristic search
Heuristic searchHeuristic search
Heuristic search
 
WEEK 4- DLD-GateLvelMinimization.pptx
WEEK 4- DLD-GateLvelMinimization.pptxWEEK 4- DLD-GateLvelMinimization.pptx
WEEK 4- DLD-GateLvelMinimization.pptx
 
Mathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxMathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptx
 
Mathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxMathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptx
 
Informed-search TECHNIQUES IN ai ml data science
Informed-search TECHNIQUES IN ai ml data scienceInformed-search TECHNIQUES IN ai ml data science
Informed-search TECHNIQUES IN ai ml data science
 
A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
 
2 funda.ppt
2 funda.ppt2 funda.ppt
2 funda.ppt
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 
A* and Min-Max Searching Algorithms in AI , DSA.pdf
A* and Min-Max Searching Algorithms in AI , DSA.pdfA* and Min-Max Searching Algorithms in AI , DSA.pdf
A* and Min-Max Searching Algorithms in AI , DSA.pdf
 
Astar algorithm
Astar algorithmAstar algorithm
Astar algorithm
 
AstarAlgorithm_v5_TeamFlash
AstarAlgorithm_v5_TeamFlashAstarAlgorithm_v5_TeamFlash
AstarAlgorithm_v5_TeamFlash
 
Optimal L-shaped matrix reordering, aka graph's core-periphery
Optimal L-shaped matrix reordering, aka graph's core-peripheryOptimal L-shaped matrix reordering, aka graph's core-periphery
Optimal L-shaped matrix reordering, aka graph's core-periphery
 
Combinatorial optimization CO-2
Combinatorial optimization CO-2Combinatorial optimization CO-2
Combinatorial optimization CO-2
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 

Recently uploaded (20)

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

Route-Planning other sesion for Universal

  • 1. Route/Path Planning Bagian 2: Algoritma A* IF221 Strategi Algoritma Program Studi Informatika STEI-ITB IF2211/NUM/RIN/19Mar2020 1
  • 2. Referensi 1. Materi kuliah IF3170 Inteligensi Buatan Teknik Informatika ITB, Course Website: http://kuliah.itb.ac.id → STEI → Teknik Informatika → IF3170 2. Stuart J Russell & Peter Norvig, Artificial Intelligence: A Modern Approach, 3rd Edition, Prentice-Hall International, Inc, 2010, Textbook Site: http://aima.cs.berkeley.edu/ (2nd edition) 3. Free online course materials | MIT OpenCourseWare Website: Site: http://ocw.mit.edu/courses/electrical-engineering-and- computer-science/ 4. Lecture Notes in Informed Heuristic Search, ICS 271 Fall 2008, http://www.ics.uci.edu/~dechter/courses/ics-271/fall-08/lecture- notes/4.InformedHeuristicSearch.ppt 2 IF2211/NUM/RIN/19Mar2020
  • 4. 4 Search Source: Russell’s book S: set of cities i.s: A (Arad) g.s: B (Bucharest) Goal test: s = B ? Path cost: time ~ distance A 118 T S O Z R P F B C L M D 111 75 71 151 99 97 120 146 138 101 211 75 70 140 80 IF2211/NUM/RIN/19Mar2020 Persoalan: Carilah lintasan terpendek dari Arad (A) ke Bucharest (B)!
  • 5. Heuristic Search ➢Heuristic estimates value of a node • promise of a node • difficulty of solving the subproblem • quality of solution represented by node • the amount of information gained ➢f(n)- heuristic evaluation function. • depends on n, goal, search so far, domain 5 IF2211/NUM/RIN/19Mar2020
  • 6. A* Search ➢ Idea: avoid expanding paths that are already expensive ➢ Evaluation function f(n) = g(n) + h(n) • g(n) = cost so far to reach n • h(n) = estimated cost from n to goal • f(n) = estimated total cost of path through n to goal ➢ if f(n) = g(n) → Uniform Cost Search (UCS) if f(n) = h(n) → Greedy Best First Search if f(n) = g(n) + h(n) → A* 6 IF2211/NUM/RIN/19Mar2020 n root goal g(n) h(n)
  • 7. A* search example 7 IF2211/NUM/RIN/19Mar2020 f(n) = g(n) + h(n) g(n) = distance from Arad to n h(n) = straight-line distance from n to Bucharest
  • 8. 8 IF2211/NUM/RIN/19Mar2020 f(n) = g(n) + h(n) g(n) = distance from Arad to n h(n) = straight-line distance from n to Bucharest A* search example
  • 9. 9 IF2211/NUM/RIN/19Mar2020 f(n) = g(n) + h(n) g(n) = distance from Arad to n h(n) = straight-line distance from n to Bucharest A* search example
  • 10. 10 IF2211/NUM/RIN/19Mar2020 f(n) = g(n) + h(n) g(n) = distance from Arad to n h(n) = straight-line distance from n to Bucharest A* search example
  • 11. 11 IF2211/NUM/RIN/19Mar2020 f(n) = g(n) + h(n) g(n) = distance from Arad to n h(n) = straight-line distance from n to Bucharest A* search example
  • 12. 12 IF2211/NUM/RIN/19Mar2020 f(n) = g(n) + h(n) g(n) = distance from Arad to n h(n) = straight-line distance from n to Bucharest A* search example
  • 13. A* Special ➢Goal: find a minimum sum-cost path ➢Notation: • c(n,n’) - cost of arc (n,n’) • g(n) = cost of current path from start to node n in the search tree. • h(n) = estimate of the cheapest cost of a path from n to a goal. • Special evaluation function: f = g+h ➢f(n) estimates the cheapest cost solution path that goes through n. • h*(n) is the true cheapest cost from n to a goal. • g*(n) is the true shortest path from the start s, to n. ➢If the heuristic function, h always underestimate the true cost (h(n) is smaller than h*(n)), then A* is guaranteed to find an optimal solution → admissible; and also has to be consistent 13 IF2211/NUM/RIN/19Mar2020 f(n) = g(n) + h(n) n root goal g(n) h(n)
  • 14. Properties of A* • Complete? Yes, unless there are infinitely many nodes with f ≤ f(G) • Time? Exponential: O(bm) • Space? Keep all the nodes in memory: O(bm) • Optimal? Yes 14 IF2211/NUM/RIN/19Mar2020
  • 15. Branch-and-Bound vs A* • As in A*, look for a bound which is guaranteed lower than the true cost • Search the branching tree in any way you like • e.g. depth first (no guarantee), best first • Cut off search if cost + bound > best solution found • If heuristic is cost + bound, search = best first • then B&B = A* • Bounds often much more sophisticated • e.g. using mathematical programming optimisations 15 IF2211/NUM/RIN/19Mar2020
  • 16. Admissible heuristics ➢A heuristic h(n) is admissible if for every node n, h(n) ≤ h*(n), where h*(n) is the true cost to reach the goal state from n. ➢An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic ➢Example: hSLD(n) (never overestimates the actual road distance) Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal IF2211/NUM/RIN/19Mar2020 16
  • 17. IF2211/NUM/RIN/19Mar2020 Admissibility • What must be true about h for A* to find optimal path? • A* finds optimal path if h is admissable; h is admissible when it never overestimates. • In this example, h is not admissible. • In route finding problems, straight-line distance to goal is admissible heuristic. g(X)+h(X)=2+100=102 G(Y)+h(Y)=73+1=74 Optimal path is not found! Because we choose Y, rather than X which is in the optimal path. 17
  • 18. Latihan soal A* Terdapat persoalan 8-puzzle seperti pada Gambar 1. Gambar 1(a) adalah start state persoalan, dan gambar 1(b) adalah goal state. Ubin yang dapat bergerak adalah ubin kosong, dengan urutan pergerakan (jika diperlukan) adalah kiri, kanan, atas, bawah. Selesaikan persoalan 8-puzzle tersebut dengan teknik A*. Biaya suatu state dari start state adalah banyaknya langkah ubin kosong yang telah dilakukan. Jika diperlukan heuristik, maka digunakan jumlah manhattan distance semua ubin selain ubin kosong. Manhattan distance sebuah ubin adalah banyaknya ubin secara horisontal dan vertikal terdekat untuk menuju posisi ubin yang sesuai IF2211/NUM/RIN/19Mar2020 18
  • 19. Tuliskan langkah-langkah penyelesaiannya dengan menggambarkan pohon ruang pencarian, dan di setiap simpul pohon tunjukkan perhitungan nilai fungsi evaluasinya (yang menjadi penentu state berikutnya yang harus diperiksa). State yang sudah pernah dilalui tidak perlu diperiksa kembali. Setelah pencarian selesai, tuliskan langkah pergeseran ubin kosong dari start state hingga goal state. Asumsi: status tujuan selalu dapat dicapai dari status awal. Penyelesaian: f(n) = g(n) + h(n) g(n) = jumlah langkah ubin kosong yang telah dilakukan h(n) = jumlah manhattan distance semua ubin selain ubin kosong. IF2211/NUM/RIN/19Mar2020 19 (Manhattan distance sebuah ubin adalah banyaknya ubin secara horisontal dan vertikal terdekat untuk menuju posisi ubin yang sesuai)
  • 21. Contoh Soal UAS Sem 2 2014/2015 Dalam permainan video game, adakalanya entitas bergerak dalam video game perlu berpindah dari satu posisi ke posisi lain. Seringkali proses perpindahan perlu mengutamakan jalur terdekat atau biaya minimal karena berhubungan dengan poin yang diperoleh. Gambar di bawah ini menunjukkan contoh jalur yang mungkin dilewati oleh entitas bergerak dalam suatu video game. Suatu entitas akan berpindah dari posisi titik A menuju ke posisi titik F. Jika diperlukan informasi heuristik, nilai heuristik dari suatu simpul adalah banyaknya busur minimal yang menghubungkan titik tersebut ke titik tujuan. IF2211/NUM/RIN/19Mar2020 21
  • 22. Contoh Soal UAS Sem 2 2014/2015 (2) 22 Pencarian solusi dengan: a. UCS b. Greedy Best First c. A Star Untuk masing-masing pendekatan tuliskan: - Formula - Iterasi - Simpul yang diekspansi - Simpul hidup & nilai f(n) Urut abjad, simpul ekspan tidak mengulang, tidak membentuk sirkuit, berhenti saat satu solusi ditemukan IF2211/NUM/RIN/19Mar2020
  • 23. Solusi: IF2211/NUM/RIN/19Mar2020 23 Jawaban: Iterasi UCS Greedy Best First Search A Star Formula: f(n) = g(n) Formula: f(n) = h(n) Formula: f(n) = g(n) + h(n) Simpul - Ekspan Simpu lHidup Simpul–Ekspan Simpul Hidup Simpul - Ekspan Simpul Hidup 1 A Ba f(B) = 2 A Ea f(Ea) = 1 A Ba f(Ba) = 2+2 = 4 Ca f(C) = 4 Ba f(Ba) = 2 Ca f(Ca) = 4 + 2 = 6 Ea f(E) = 5 Ca f(Ca) = 2 Ea f(Ea) = 5 + 1 = 6 2 Ba Eba f(Eba) = 3 Ea De f(De) = 1 Ba Eba f(Eba) = 3 + 1 = 4 Ca f(C) = 4 Fea f(Fea) = 0 Ca f(Ca) = 4 + 2 = 6 Ea f(E) = 5 Bea f(Bea) = 2 Ea f(Ea) = 5 + 1 = 6 Ba f(Ba) = 2 Ca f(Ca) = 2
  • 24. IF2211/NUM/RIN/19Mar2020 24 3 Eba Ca f(C) = 4 Fea Sudah sampai solusi Eba Feba f(Feba) = 5 + 0 = 5 Ea f(E) = 5 Ca f(Ca) = 4 + 2 = 6 Feba f(Feba) = 5 Ea f(Ea) = 5 + 1 = 6 Deba f(Deba) = 6 Deba f(Deba) = 6+1 = 7 4 Ca Ea f(E) = 5 Feba Sudah sampai solusi Feba f(Feba) = 5 Deba f(Deba) = 6 Dca f(Dca) = 7 5 Ea Feba f(Feba) = 5 Deba f(Deba) = 6 Dca f(Dca) = 7 Fea f(Fea) = 7 Dea f(Dea) = 8
  • 25. IF2211/NUM/RIN/19Mar2020 25 6 Feba Solusi sudah ditemukan Hasil Jalur: A-B-E-F Jalur: A-E-F Jalur: A-B-E-F Jarak: 5 Jarak: 7 Jarak: 5 Banyaknya iterasi: 6 Banyaknya iterasi: 3 Banyaknya iterasi: 4