Artificial Intelligence Informed search methods
In which we see how information about the state space can prevent algorithms from blundering about in the dark. 2
Uninformed vs. Informed Search Uninformed search strategies Find solutions to problems by systematically generating new states and testing for goal Most are incredibly inefficient Informed search strategies Use problem-specific knowledge Find solutions more efficiently 3
Informed Search Informed search strategy One that uses problem-specific knowledge beyond the problem definition itself General approach is called Best First search Node selected for expansion based on an evaluation function Measuring a distance to goal Node with lowest evaluation is selected 4
Techniques Best-first search Expand minimum cost nodes first Greedy search Minimize estimated cost to reach goal A* search Estimated total costs through node n to goal: (actual cost to reach n) + (estimated cost from n to goal) Iterative improvement algorithms Continually moves in the direction of increasing value Hill climbing searches 5
Best-First Search Methods 6
Best-First Search Try to expand node that is closest to goal Use evaluation function to estimate how desirable Open set Priority queue implementation Insert expanded nodes in decreasing order of desirability (most desirable first) Special cases Greedy search: expand node closest to goal A* search: expand node on least-cost solution path 7
Greedy Search Simplest best-first search strategy Minimize estimated cost to reach goal Evaluation function h(n) (heuristic) Estimate of cost from node n to goal Require h(n) = 0 if n is goal e.g., For a road map, h SLD (n) = straight-line distance from city n to Bucharest Greedy search expands the node that appears to be closest to the goal Takes the biggest bite out of remaining cost to reach goal Each step tries to get as close to goal as possible Though, not considers if its action will be the best in the long run 8
Romania Step Costs in km 71 Oradea Neamt 87 75 Zerind 151 Iasi 118 140 Timisoara 111 70 75 Debreta 80 Sibiu Fagaras Lugoj Mehadia 120 99 Rimnicu Vilcea 97 146 138 Craiova Pitesti 211 101 85 90 Bucharest Giurgiu 92 142 98 Urziceni Vaslui Hirsova 86 Eforie 9
Straight-Line Distance to Bucharest 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 176 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 Oradea 380 Pitesti 100 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 Zerind 374 10
Greedy Search Example: Romania 366 Open = { (366) } 11
Greedy Search Example: Romania 366 Zerind Sibu Timisoara 374 253 329 Open = { Sibu(253), Timisoara(329), Zerind(374) } 12
Greedy Search Example: Romania 366 Zerind Sibu Timisoara 374 253 329 Oradea Fagaras Rimnicu Vilcea 366 380 176 193 Open = { Fagaras(176), RimnicuVilcea(193), Timisoara(329), (366), Zerind(374), Oradea(380) } 13
Greedy Search Example: Romania 366 Zerind Sibu Timisoara 374 253 329 Oradea Fagaras Rimnicu Vilcea 366 380 176 193 Sibiu Bucharest 253 0 Open = { Bucharest(0), Fagaras(176), RimnicuVilcea(193), Sibu(253), Timisoara(329), (366), Zerind(374), Oradea(380) } 14
Greedy Search Example: Romania 366 Zerind Sibu Timisoara 374 253 329 Oradea Fagaras Rimnicu Vilcea 366 380 176 193 Sibiu Bucharest 253 0 15
Properties of Greedy Search Not complete (can be bad) Can get stuck in loops Go from Iasi to Fagaras: Iasi Neamt Iasi Neamt (only 1 link) Complete if check for repeated states Time (can be bad) O(b m ), m=maximum depth (worst case, like DFS) Space (can be bad) O(b m ), keeps all nodes in memory (worst case) Not optimal (can be bad) Heuristic is an estimate But a good heuristic can give dramatic improvement! 16
A* Search Minimizes total estimated path cost Avoids expanding paths already expensive Evaluation function f(n) = g(n) + h(n) Actual cost to reach node n so far g(n) Estimated cost from n to goal h(n) Estimated total cost through n to goal f(n) = g(n) + h(n) A* search uses admissible heuristic i.e., h(n) h*(n) where h*(n) is true cost from n to goal e.g., h SLD (n) never overestimates actual distance 17
A* Search Example: Romania Open = { (366) } 366 g(n): cost so far f(n)=g(n)+h(n) = cost so far + estimated cost to goal 18
A* Search Example: Romania 75 366 140 118 Open = { Sibu(393), Timisoara(447), Zerind(449) } Zerind Sibu Timisoara 449 393 447 f(zerind)=75 + 374=449 g(n): cost so far f(n)=g(n)+h(n) = cost so far + estimated cost to goal 19
A* Search Example: Romania 75 Zerind Sibu 366 140 118 Timisoara 449 393 447 140 151 99 80 Open = { RimnicuVilcea(413), Fagaras(415), Timisoara(447), Zerind(449), (646), Oradea(671) } Oradea Fagaras Rimnicu Vilcea 646 671 415 413 f(fagaras)=(140+99) + 176=415 g(n): cost so far f(n)=g(n)+h(n) = cost so far + estimated cost to goal 20
A* Search Example: Romania 75 366 140 118 Open = { Fagaras(415), Pitesti(417), Timisoara(447), Zerind(449), Craiova(526), Sibu(553), (646), Oradea(671) } Zerind Sibu Timisoara 449 393 447 140 151 99 80 Oradea Fagaras Rimnicu Vilcea 646 671 415 413 146 97 80 Craiova Pitesti Sibiu 526 417 553 g(n): cost so far f(n)=g(n)+h(n) = cost so far + estimated cost to goal 21
A* Search Example: Romania 75 366 140 118 Open = { Pitesti(417), Timisoara(447), Bucharest(450), Zerind(449), Craiova(526), Sibu(553), Sibu(591), (646), Oradea(671) } Zerind Sibu Timisoara 449 393 447 140 151 99 80 Oradea Fagaras Rimnicu Vilcea 646 671 415 413 99 211 146 97 80 Sibiu Bucharest 591 450 Craiova Pitesti Sibiu 526 417 553 g(n): cost so far f(n)=g(n)+h(n) = cost so far + estimated cost to goal 22
A* Search Example: Romania 75 366 140 118 Open = { Bucharest(418), Timisoara(447), Bucharest(450), Zerind(449), Craiova(526), Sibu(553), Sibu(591), RimnicuVilcea(607), Craiova(615), (646), Oradea(671) } Zerind Sibu Timisoara 449 393 447 140 151 99 80 Oradea Fagaras Rimnicu Vilcea 646 671 415 413 99 211 146 97 80 Sibiu Bucharest 591 450 Craiova Pitesti Sibiu 526 417 553 97 138 101 Rimnicu Vilcea g(n): cost so far f(n)=g(n)+h(n) = cost so far + estimated cost to goal Craiova Bucharest 607 615 418 23
A* Search Example: Romania 75 366 140 118 Recall that Greedy path was [, Sibu, Fagaras, Bucharest] = 450 Zerind Sibu Timisoara 449 393 447 140 151 99 80 Oradea Fagaras Rimnicu Vilcea 646 671 415 413 99 211 146 97 80 Sibiu Bucharest 591 450 Craiova Pitesti Sibiu 526 417 553 97 138 101 Rimnicu Vilcea g(n): cost so far f(n)=g(n)+h(n) = cost so far + estimated cost to goal Craiova Bucharest 607 615 418 24
Admissible Heuristics (Not over-estimate path cost) 8-puzzle h 1 (n) = number of misplaced tiles Must move each misplaced tile at least once h 2 (n) = total Manhattan distance (city block) Number of squares from desired tile location (Horiz+Vert) 5 4 6 1 8 1 2 8 3 4 7 3 2 Start State 7 6 5 Goal State 25
Admissible Heuristics 5 4 1 2 3 6 1 8 8 4 7 3 2 Start State 7 6 5 Goal State h 1 (Start) = 7 (# tiles misplaced) h 2 (Start) = 2+3+3+2+4+2+0+2=18 (total Manhattan distance) [Typical solution about 20 steps, though varies with initial state] 26
Heuristic Dominance If h 2 (n) h 1 (n) for all n (both admissible) Then h 2 dominates h 1, and h 2 is better for search As the larger h 2 is closer to the optimal/true total cost h*, then A* using h 2 will expand fewer nodes (on average) 27
Properties of A* Complete (good) Unless infinitely many nodes Time and space (not good) Still exponential in worst case (keeps all nodes in memory) Strongly depends on choice of heuristic Optimal (good) Expands fewest nodes Gaming: Sim City traffic 28
Summary Informed search strategies Best-first search Expand minimum cost nodes first Greedy search Minimize estimated cost to reach goal A* search Estimated total costs through n to goal (actual cost to reach n) + (estimated cost from n to goal) Admissible heuristic never overestimates actual distance to goal 29