Professional Documents
Culture Documents
Oradea
71 Neamt
Zerind 87
75 151
Arad Iasi
140 92
Sibiu Faragas
118 99
Vaslui
80
Timisoara Rimnicu Vilcea
142
111 Pitesi 211
Lugoj 97
70 98
Hirsova
Mehadia 146 85
101 Urziceni
75 138 Bucharest 86
Dobreta 120 90
Craiova Eforie
Giurhiu
Dijkstra
140 92
Sibiu Faragas
118 99
Vaslui
80
Timisoara Rimnicu Vilcea
End 142
111 Pitesi 211
Lugoj 97 Node
70 98
Hirsova
Mehadia 146 85
101 Urziceni
75 138 Bucharest 86
Dobreta 120 90
Craiova Eforie
Giurhiu
Dijkstra
End 142
111 Pitesi 211
Lugoj 97 Node
70 98
Hirsova
Mehadia 146 85
101 Urziceni
75 138 Bucharest 86
Dobreta 120 90
Craiova Eforie
Giurhiu
Dijkstra
End 142
111 Pitesi 211
Lugoj 97 Node
70 98
Hirsova
Mehadia 146 85
101 Urziceni
75 138 Bucharest 86
Dobreta 120 90
Craiova Eforie
Giurhiu
Dijkstra
End 142
111 Pitesi 211
Lugoj 97 Node
70 98
Hirsova
Mehadia 146 85
101 Urziceni
75 138 Bucharest 86
Dobreta 120 90
Craiova Eforie
Giurhiu
Dijkstra
End 142
111 Pitesi 211
Lugoj 97 Node
70 98
Hirsova
Mehadia 146 85
101 Urziceni
75 138 Bucharest 86
Dobreta 120 90
Craiova Eforie
Giurhiu
Dijkstra
End 142
111 Pitesi 211
Lugoj 97 Node
70 98
Hirsova
Mehadia 146 85
101 Urziceni
75 138 Bucharest 86
Dobreta 120 90
Craiova Eforie
Giurhiu
Dijkstra
End 142
111 Pitesi 211
Lugoj 97 Node
70 98
Hirsova
Mehadia 146 85
101 Urziceni
75 138 Bucharest 86
Dobreta 120 90
Craiova Eforie
Giurhiu
Dijkstra
●
● Guided Search Use a heuristic
○ estimation of how to search for a solution
● Updated Evaluation Function
● Search Algorithm
A*
○ Use of heuristic to guide the search
● Dijkstra Algorithm
Arad
Arad
Arad
Rimnicu
Arad Faragas Oradea Vilcia
Zerind: f(n) = g(n) + h(n) = 75 + 374 = 449
A* Search Timisoara: f(n) = g(n) + h(n) = 118 + 329 = 447
Faragas: f(n) = g(n) + h(n) = (140 + 99) + 176 = 415
Rimnicu Vilcea: f(n) = g(n) + h(n) = (140 + 80) + 193 = 413
Oradea: f(n) = g(n) + h(n) = (140 + 151) + 380 = 671
Arad: f(n) = g(n) + h(n) = (140 + 140) + 366 = 646
Oradea Straight Line distance to Bucharest
Arad
Rimnicu
Arad Faragas Oradea Vilcia
280 + 366 = 646 239 + 176 = 415 291 + 380 = 671 220 + 193 = 413
A* Search
Arad
Rimnicu
Arad Faragas Oradea Vilcia
280 + 366 = 646 239 + 176 = 415 291 + 380 = 671
Arad
Rimnicu
Arad Faragas Oradea Vilcia
280 + 366 = 646 239 + 176 = 415 291 + 380 = 671
Arad
Rimnicu
Arad Faragas Oradea Vilcia
280 + 366 = 646 291 + 380 = 671
Arad
Rimnicu
Arad Faragas Oradea Vilcia
280 + 366 = 646 291 + 380 = 671
Arad
Rimnicu
Arad Faragas Oradea Vilcia
280 + 366 = 646 291 + 380 = 671
Rimnicu
Bucharest Craiova Vilcia
Zerind: f(n) = g(n) + h(n) = 75 + 374 = 449
A* Search Timisoara: f(n) = g(n) + h(n) = 118 + 329 = 447
Oradea: f(n) = g(n) + h(n) = (140 + 151) + 380 = 671
Arad: f(n) = g(n) + h(n) = (140 + 140) + 366 = 646 Through Faragas
Craiova: f(n) = g(n) + h(n) = (140 + 80 + 146) + 160 = 526 Through Pitesi
Bucharest: f(n) = g(n) + h(n) = (140 + 99 + 211) + 0 = 450
Straight Line distance to Bucharest
Oradea Bucharest: f(n) = g(n) + h(n) = (140 + 80 + 97+101) + 0 = 418
Start 71 Craiova: Neamt Arad 366
Node Rimnicu Vilcea: Bucharest 0
Zerind 87 Craiova 160
75 151
Dobreta 242
Arad Iasi
Eforie 161
140 92 Faragas 176
Sibiu Faragas Giurhiu 77
118 99 Hirsova 151
Vaslui Iasi 226
80
Rimnicu Vilcea Lugoj 244
Timisoara
Mehadia 241
End 142 Neamt 234
111 Pitesi 211
Lugoj 97 Node Oradea 380
Pitesi 100
70 98
Hirsova Rimnicu Vilcea 193
Mehadia 146 85
101 Urziceni Sibiu 253
75 138 Bucharest 86 Timisoara 329
Dobreta Urziceni 80
120 90 Vaslui 199
Craiova Eforie
Giurhiu Zerind 374
Zerind: f(n) = g(n) + h(n) = 75 + 374 = 449
A* Search Timisoara: f(n) = g(n) + h(n) = 118 + 329 = 447
Oradea: f(n) = g(n) + h(n) = (140 + 151) + 380 = 671
Arad: f(n) = g(n) + h(n) = (140 + 140) + 366 = 646 Through Faragas
Craiova: f(n) = g(n) + h(n) = (140 + 80 + 146) + 160 = 526 Through Pitesi
Bucharest: f(n) = g(n) + h(n) = (140 + 99 + 211) + 0 = 450
Straight Line distance to Bucharest
Oradea Bucharest: f(n) = g(n) + h(n) = (140 + 80 + 97+101) + 0 = 418
Start 71 Craiova: Neamt Arad 366
Node Rimnicu Vilcea: Bucharest 0
Zerind 87 Craiova 160
75 151
Dobreta 242
Arad Iasi
Eforie 161
140 92 Faragas 176
Sibiu Faragas Giurhiu 77
118 99 Hirsova 151
Vaslui Iasi 226
80
Rimnicu Vilcea Lugoj 244
Timisoara
Mehadia 241
End 142 Neamt 234
111 Pitesi 211
Lugoj 97 Node Oradea 380
Pitesi 100
70 98
Hirsova Rimnicu Vilcea 193
Mehadia 146 85
101 Urziceni Sibiu 253
75 138 Bucharest 86 Timisoara 329
Dobreta Urziceni 80
120 90 Vaslui 199
Craiova Eforie
Giurhiu Zerind 374
A* Search
Arad
Rimnicu
Arad Faragas Oradea Vilcia
280 + 366 = 646 291 + 380 = 671
Rimnicu
Bucharest Craiova Vilcia
418 + 0 = 418 455 + 160 = 615 414 + 193 = 607
A* Search
4 intermediate nodes expanded 😄
●
● When
○ Only Nodes on the shortest path are expanded
○ Optimal solution is found
● When
○ Additional nodes are expanded
○ Optimal solution is found
● When
○ Optimal solution is overlooked
Admissible Heuristic and Dominance
●
● A heuristic is admissible if for every node , , where is the true cost to reach the goal state
from .
● An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic.
● If is admissible, A* using TREE-SEARCH is optimal
● are both admissible and , then dominates
● If dominates , then is better for A* search
○ Expands less or equal number of nodes
Consistent Heuristic
h(𝑛)
𝑑
𝑛
′
′
h(𝑛
)
𝑐 ( 𝑛 ,𝑛 )
𝑛 ′
Consistent Heuristic
●
● If
is consistent then is admissible
● Frequently when is admissible, it is also consistent
● A* generates an optimal solution if is a consistent heuristic and the search space is a
graph
Performance
● Complete
○ Yes, unless there are infinitely many nodes
● Time
○ Exponential
○ The better the heuristic, the better the time
○ Best case: is perfect,
○ Worst case: , same as BFS
● Space
○ Keeps all nodes in memory and save in case of repetition
○ This is or worse
○ A* usually runs out of space before it runs out of time
● Optimal
○ Yes, cannot expand unless is finished
Thank You !