Introduction to Artificial Intelligence Problem Solving through - - PowerPoint PPT Presentation
Introduction to Artificial Intelligence Problem Solving through - - PowerPoint PPT Presentation
Introduction to Artificial Intelligence Problem Solving through Search (Goal-based agents) BFS, DFS, Greedy Search Janyl Jumadinova September 12-16, 2016 Example: Romania On holiday in Romania; currently in Arad. Flight leaves tomorrow from
Example: Romania
On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest Formulate goal: be in Bucharest Formulate problem: states: various cities actions: drive between cities Find solution: sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest
2/38
Example: Romania
3/38
Tree search algorithms
Basic idea:
- ffline, simulated exploration of state space
by generating successors of already-explored states (a.k.a. expanding states)
4/38
Tree search example
5/38
Tree search example
6/38
Tree search example
7/38
Implementation: states vs. nodes
A state is a (representation of) a physical configuration A node is a data structure constituting part of a search tree includes parent, children, depth, path cost g(x) States do not have parents, children, depth, or path cost!
8/38
Breadth-first search
Expand shallowest unexpanded node
◮ FIFO queue, i.e., new successors go at end
A B C D E F G
9/38
Breadth-first search
Expand shallowest unexpanded node
◮ FIFO queue, i.e., new successors go at end
A B C D E F G
10/38
Breadth-first search
Expand shallowest unexpanded node
◮ FIFO queue, i.e., new successors go at end
A B C D E F G
11/38
Breadth-first search
Expand shallowest unexpanded node
◮ FIFO queue, i.e., new successors go at end
A B C D E F G
12/38
Breadth-first search
Arad
13/38
Breadth-first search
Zerind Sibiu Timisoara Arad
14/38
Breadth-first search
Arad Oradea Zerind Sibiu Timisoara Arad
15/38
Breadth-first search
Arad Oradea Rimnicu Vilcea Fagaras Arad Lugoj Arad Oradea Zerind Sibiu Timisoara Arad
16/38
Breadth-first search
17/38
Depth-first search
Expand deepest unexpanded node
◮ LIFO queue, i.e., put successors at front
Arad
18/38
Depth-first search
Expand deepest unexpanded node
◮ LIFO queue, i.e., put successors at front
Zerind Sibiu Timisoara Arad
19/38
Depth-first search
Expand deepest unexpanded node
◮ LIFO queue, i.e., put successors at front
Arad Oradea Zerind Sibiu Timisoara Arad
20/38
Depth-first search
Expand deepest unexpanded node
◮ LIFO queue, i.e., put successors at front
Zerind Sibiu Timisoara Arad Oradea Zerind Sibiu Timisoara Arad
21/38
Best-first search
Idea: use an evaluation function for each node – estimate of “desirability”
22/38
Best-first search
Idea: use an evaluation function for each node – estimate of “desirability” ⇒ Expand most desirable unexpanded node
22/38
Best-first search
Idea: use an evaluation function for each node – estimate of “desirability” ⇒ Expand most desirable unexpanded node Implementation: a queue sorted in decreasing order of desirability
22/38
Best-first search
Idea: use an evaluation function for each node – estimate of “desirability” ⇒ Expand most desirable unexpanded node Implementation: a queue sorted in decreasing order of desirability Special cases: greedy search, A∗ search
22/38
Romania with step costs in km
Bucharest Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Rimnicu Vilcea Vaslui Iasi Straight−line distance to Bucharest 160 242 161 77 151 241 366 193 178 253 329 80 199 244 380 226 234 374 98
Giurgiu Urziceni Hirsova Eforie Neamt Oradea Zerind Arad Timisoara Lugoj Mehadia Dobreta Craiova Sibiu Fagaras Pitesti Vaslui Iasi Rimnicu Vilcea Bucharest
71 75 118 111 70 75 120 151 140 99 80 97 101 211 138 146 85 90 98 142 92 87 86
A* slide
23/38
Greedy search
Evaluation function h(n) (heuristic) = estimate of cost from n to the closest goal Example: h(n) = straight-line distance from n to Bucharest
24/38
Greedy search
Evaluation function h(n) (heuristic) = estimate of cost from n to the closest goal Example: h(n) = straight-line distance from n to Bucharest
◮ Greedy search expands the node that appears to be closest to
goal
24/38
Greedy Search
Arad 366
25/38
Greedy Search
Zerind Arad Sibiu Timisoara 253 329 374
26/38
Greedy Search
Rimnicu Vilcea
Zerind Arad Sibiu Arad Fagaras Oradea Timisoara 329 374 366 176 380 193
27/38
Greedy Search
Rimnicu Vilcea
Zerind Arad Sibiu Arad Fagaras Oradea Timisoara Sibiu Bucharest 329 374 366 380 193 253
28/38
Greedy search
◮ Can get stuck in loops, e.g.,
Iasi → Neamt → Iasi → Neamt → Complete in finite space with repeated-state checking
◮ A good heuristic can give dramatic improvement in search cost 29/38
http://aispace.org/search/
Explore Best first search (explanation from AIspace: http://www.aispace.org/deduction/help/tut3.shtml)
30/38
A* search
Idea:
avoid expanding paths that are already expensive
31/38
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
Romania with step costs
31/38
Example: Romania
32/38
A* Search
Arad 366=0+366
33/38
A* Search
Zerind Arad Sibiu Timisoara 447=118+329 449=75+374 393=140+253
34/38
A* Search
Zerind Arad Sibiu Arad Timisoara
Rimnicu Vilcea
Fagaras Oradea 447=118+329 449=75+374 646=280+366 413=220+193 415=239+176 671=291+380
35/38
A* Search
Zerind Arad Sibiu Arad Timisoara Fagaras Oradea 447=118+329 449=75+374 646=280+366 415=239+176
Rimnicu Vilcea
Craiova Pitesti Sibiu 526=366+160 553=300+253 417=317+100 671=291+380
36/38
A* Search
Zerind Arad Sibiu Arad Timisoara Sibiu Bucharest
Rimnicu Vilcea
Fagaras Oradea Craiova Pitesti Sibiu 447=118+329 449=75+374 646=280+366 591=338+253 450=450+0 526=366+160 553=300+253 417=317+100 671=291+380
37/38
A* Search
Zerind Arad Sibiu Arad Timisoara Sibiu Bucharest
Rimnicu Vilcea
Fagaras Oradea Craiova Pitesti Sibiu Bucharest Craiova
Rimnicu Vilcea
418=418+0 447=118+329 449=75+374 646=280+366 591=338+253 450=450+0 526=366+160 553=300+253 615=455+160 607=414+193 671=291+380
38/38