Revised by Hankui Zhuo, March 15, 2019 Informed search algorithms & Hill-climbing & Simulated annealing Chapter 4 Chapter 4 1
Outline ♦ Best-first search ♦ A ∗ search ♦ Heuristics ♦ Hill-climbing ♦ Simulated annealing ♦ Genetic algorithms (briefly) ♦ Local search in continuous spaces (very briefly) Chapter 4 2
Review: Tree search function Tree-Search ( problem, fringe ) returns a solution, or failure fringe ← Insert ( Make-Node ( Initial-State [ problem ]), fringe ) loop do if fringe is empty then return failure node ← Remove-Front ( fringe ) if Goal-Test [ problem ] applied to State ( node ) succeeds return node fringe ← InsertAll ( Expand ( node , problem ), fringe ) A strategy is defined by picking the order of node expansion Chapter 4 3
Best-first search Idea: use an evaluation function for each node – estimate of “desirability” ⇒ Expand most desirable unexpanded node Implementation: fringe is a queue sorted in decreasing order of desirability Special cases: greedy search A ∗ search Chapter 4 4
Romania with step costs in km Straight − line distance Oradea to Bucharest 71 Neamt Arad 366 Bucharest 0 87 Zerind 151 Craiova 160 75 Dobreta Iasi 242 Arad Eforie 161 140 92 Fagaras 178 Sibiu Fagaras 99 Giurgiu 77 118 Hirsova 151 Vaslui 80 Iasi 226 Rimnicu Vilcea Lugoj 244 Timisoara Mehadia 241 142 211 111 Neamt 234 Pitesti 97 Lugoj Oradea 380 70 98 Pitesti 98 85 Hirsova 146 101 Rimnicu Vilcea 193 Mehadia Urziceni 86 Sibiu 253 75 138 Bucharest Timisoara 329 120 Dobreta Urziceni 80 90 Vaslui 199 Craiova Eforie Giurgiu Zerind 374 Chapter 4 5
Greedy search Evaluation function h ( n ) ( h euristic) = estimate of cost from n to the closest goal E.g., h SLD ( n ) = straight-line distance from n to Bucharest Greedy search expands the node that appears to be closest to goal Chapter 4 6
Greedy search example Arad 366 Straight − line distance Oradea to Bucharest 71 Neamt Arad 366 Bucharest 0 87 Zerind 151 Craiova 75 160 Iasi Dobreta 242 Arad Eforie 140 161 92 Fagaras 178 Sibiu Fagaras 99 Giurgiu 77 118 Hirsova 151 Vaslui 80 Iasi 226 Rimnicu Vilcea Timisoara Lugoj 244 Mehadia 142 241 211 111 Neamt 234 Pitesti 97 Lugoj Oradea 380 70 98 Pitesti 98 85 Hirsova 146 101 Rimnicu Vilcea 193 Mehadia Urziceni Sibiu 86 253 75 138 Bucharest Timisoara 329 120 Dobreta Urziceni 80 90 Vaslui 199 Craiova Eforie Giurgiu Zerind 374 Chapter 4 7
Greedy search example Arad Sibiu Timisoara Zerind 253 329 374 Straight − line distance Oradea to Bucharest 71 Neamt Arad 366 Bucharest 0 87 Zerind 151 Craiova 75 160 Iasi Dobreta 242 Arad Eforie 140 161 92 Fagaras 178 Sibiu Fagaras 99 Giurgiu 77 118 Hirsova 151 Vaslui 80 Iasi 226 Rimnicu Vilcea Timisoara Lugoj 244 Mehadia 142 241 211 111 Neamt 234 Pitesti 97 Lugoj Oradea 380 70 98 Pitesti 98 85 Hirsova 146 101 Rimnicu Vilcea 193 Mehadia Urziceni Sibiu 86 253 75 138 Bucharest Timisoara 329 120 Dobreta Urziceni 80 90 Vaslui 199 Craiova Eforie Giurgiu Zerind 374 Chapter 4 8
Greedy search example Arad Sibiu Timisoara Zerind 329 374 Arad Fagaras Oradea Rimnicu Vilcea 366 176 380 193 Straight − line distance Oradea to Bucharest 71 Neamt Arad 366 Bucharest 0 87 Zerind 151 Craiova 75 160 Iasi Dobreta 242 Arad Eforie 140 161 92 Fagaras 178 Sibiu Fagaras 99 Giurgiu 77 118 Hirsova 151 Vaslui 80 Iasi 226 Rimnicu Vilcea Timisoara Lugoj 244 Mehadia 142 241 211 111 Neamt 234 Pitesti 97 Lugoj Oradea 380 70 98 Pitesti 98 85 Hirsova 146 101 Rimnicu Vilcea 193 Mehadia Urziceni Sibiu 86 253 75 138 Bucharest Timisoara 329 120 Dobreta Urziceni 80 90 Vaslui 199 Craiova Eforie Giurgiu Zerind 374 Chapter 4 9
Greedy search example Arad Sibiu Timisoara Zerind 329 374 Arad Fagaras Oradea Rimnicu Vilcea 366 380 193 Sibiu Bucharest 253 0 Straight − line distance Oradea to Bucharest 71 Neamt Arad 366 Bucharest 0 87 Zerind 151 Craiova 75 160 Iasi Dobreta 242 Arad Eforie 140 161 92 Fagaras 178 Sibiu Fagaras 99 Giurgiu 77 118 Hirsova 151 Vaslui 80 Iasi 226 Rimnicu Vilcea Timisoara Lugoj 244 Mehadia 142 241 211 111 Neamt 234 Pitesti 97 Lugoj Oradea 380 70 98 Pitesti 98 85 Hirsova 146 101 Rimnicu Vilcea 193 Mehadia Urziceni Sibiu 86 253 75 138 Bucharest Timisoara 329 120 Dobreta Urziceni 80 90 Vaslui 199 Craiova Eforie Giurgiu Zerind 374 Chapter 4 10
Properties of greedy search Complete?? Chapter 4 11
Properties of greedy search Complete?? No–can get stuck in loops, e.g., with Oradea as goal, Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking Time?? Chapter 4 12
Properties of greedy search Complete?? No–can get stuck in loops, e.g., Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking Time?? O ( b m ) , but a good heuristic can give dramatic improvement Space?? Chapter 4 13
Properties of greedy search Complete?? No–can get stuck in loops, e.g., Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking Time?? O ( b m ) , but a good heuristic can give dramatic improvement Space?? O ( b m ) —keeps all nodes in memory Optimal?? Chapter 4 14
Properties of greedy search Complete?? No–can get stuck in loops, e.g., Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking Time?? O ( b m ) , but a good heuristic can give dramatic improvement Space?? O ( b m ) —keeps all nodes in memory Optimal?? No Chapter 4 15
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 to goal from n f ( n ) = estimated total cost of path through n to goal A ∗ search uses an admissible heuristic i.e., h ( n ) ≤ h ∗ ( n ) where h ∗ ( n ) is the true cost from n . (Also require h ( n ) ≥ 0 , so h ( G ) = 0 for any goal G .) E.g., h SLD ( n ) never overestimates the actual road distance Theorem: A ∗ search is optimal Chapter 4 16
A ∗ search example Arad 366=0+366 Straight − line distance Oradea to Bucharest 71 Neamt Arad 366 Bucharest 0 87 Zerind 151 Craiova 160 75 Dobreta Iasi 242 Arad 140 Eforie 161 92 Fagaras 178 Sibiu 99 Fagaras Giurgiu 77 118 Hirsova 151 Vaslui 80 Iasi 226 Rimnicu Vilcea Timisoara Lugoj 244 Mehadia 142 241 211 111 Neamt 234 Pitesti 97 Lugoj Oradea 380 70 98 Pitesti 98 85 Hirsova 146 101 Rimnicu Vilcea 193 Mehadia Urziceni 86 Sibiu 253 75 138 Bucharest Timisoara 329 120 Dobreta Urziceni 80 90 Vaslui 199 Craiova Eforie Giurgiu Zerind 374 Chapter 4 17
A ∗ search example Arad Sibiu Timisoara Zerind 393=140+253 447=118+329 449=75+374 Straight − line distance Oradea to Bucharest 71 Neamt Arad 366 Bucharest 0 87 Zerind 151 Craiova 160 75 Dobreta Iasi 242 Arad 140 Eforie 161 92 Fagaras 178 Sibiu 99 Fagaras Giurgiu 77 118 Hirsova 151 Vaslui 80 Iasi 226 Rimnicu Vilcea Timisoara Lugoj 244 Mehadia 142 241 211 111 Neamt 234 Pitesti 97 Lugoj Oradea 380 70 98 Pitesti 98 85 Hirsova 146 101 Rimnicu Vilcea 193 Mehadia Urziceni 86 Sibiu 253 75 138 Bucharest Timisoara 329 120 Dobreta Urziceni 80 90 Vaslui 199 Craiova Eforie Giurgiu Zerind 374 Chapter 4 18
A ∗ search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras Oradea Rimnicu Vilcea 646=280+366 415=239+176 671=291+380 413=220+193 Straight − line distance Oradea to Bucharest 71 Neamt Arad 366 Bucharest 0 87 Zerind 151 Craiova 160 75 Dobreta Iasi 242 Arad 140 Eforie 161 92 Fagaras 178 Sibiu 99 Fagaras Giurgiu 77 118 Hirsova 151 Vaslui 80 Iasi 226 Rimnicu Vilcea Timisoara Lugoj 244 Mehadia 142 241 211 111 Neamt 234 Pitesti 97 Lugoj Oradea 380 70 98 Pitesti 98 85 Hirsova 146 101 Rimnicu Vilcea 193 Mehadia Urziceni 86 Sibiu 253 75 138 Bucharest Timisoara 329 120 Dobreta Urziceni 80 90 Vaslui 199 Craiova Eforie Giurgiu Zerind 374 Chapter 4 19
A ∗ search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras Oradea Rimnicu Vilcea 646=280+366 415=239+176 671=291+380 Craiova Pitesti Sibiu 526=366+160 417=317+100 553=300+253 Straight − line distance Oradea to Bucharest 71 Neamt Arad 366 Bucharest 0 87 Zerind 151 Craiova 160 75 Dobreta Iasi 242 Arad 140 Eforie 161 92 Fagaras 178 Sibiu 99 Fagaras Giurgiu 77 118 Hirsova 151 Vaslui 80 Iasi 226 Rimnicu Vilcea Timisoara Lugoj 244 Mehadia 142 241 211 111 Neamt 234 Pitesti 97 Lugoj Oradea 380 70 98 Pitesti 98 85 Hirsova 146 101 Rimnicu Vilcea 193 Mehadia Urziceni 86 Sibiu 253 75 138 Bucharest Timisoara 329 120 Dobreta Urziceni 80 90 Vaslui 199 Craiova Eforie Giurgiu Zerind 374 Chapter 4 20
Recommend
More recommend