CS 416 Artificial Intelligence Lecture 4 Finish Uninformed Searches Begin Informed Searches Lecture 4 Finish Uninformed Searches Begin Informed Searches.

Slides:



Advertisements
Similar presentations
Review: Search problem formulation
Advertisements

Informed search algorithms
An Introduction to Artificial Intelligence
A* Search. 2 Tree search algorithms Basic idea: Exploration of state space by generating successors of already-explored states (a.k.a.~expanding states).
Problem Solving: Informed Search Algorithms Edmondo Trentin, DIISM.
Informed Search Methods Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 4 Spring 2004.
Solving Problem by Searching
Artificial Intelligence Chapter 9 Heuristic Search Biointelligence Lab School of Computer Sci. & Eng. Seoul National University.
1 Heuristic Search Chapter 4. 2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*
Problem-solving as search. History Problem-solving as search – early insight of AI. Newell and Simon’s theory of human intelligence and problem-solving.
CSC 423 ARTIFICIAL INTELLIGENCE
Review: Search problem formulation
CS 460 Spring 2011 Lecture 3 Heuristic Search / Local Search.
ITCS 3153 Artificial Intelligence Lecture 5 Informed Searches Lecture 5 Informed Searches.
CSC344: AI for Games Lecture 4: Informed search
ITCS 3153 Artificial Intelligence Lecture 4 Uninformed Searches (cont) Lecture 4 Uninformed Searches (cont)
Informed Search Idea: be smart about what paths to try.
Graphs II Robin Burke GAM 376. Admin Skip the Lua topic.
Vilalta&Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
CS 416 Artificial Intelligence Lecture 5 Finish Uninformed Searches Begin Informed Searches Lecture 5 Finish Uninformed Searches Begin Informed Searches.
CS 416 Artificial Intelligence Lecture 4 Uninformed Searches (cont) Lecture 4 Uninformed Searches (cont)
Informed search algorithms
Informed search algorithms
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
CHAPTER 4: INFORMED SEARCH & EXPLORATION Prepared by: Ece UYKUR.
1 Shanghai Jiao Tong University Informed Search and Exploration.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
Informed search algorithms Chapter 4. Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most.
ISC 4322/6300 – GAM 4322 Artificial Intelligence Lecture 3 Informed Search and Exploration Instructor: Alireza Tavakkoli September 10, 2009 University.
Informed search strategies Idea: give the algorithm “hints” about the desirability of different states – Use an evaluation function to rank nodes and select.
Informed searching. Informed search Blind search algorithms do not consider any information about the states and the goals Often there is extra knowledge.
For Friday Finish reading chapter 4 Homework: –Lisp handout 4.
For Monday Read chapter 4, section 1 No homework..
CS344: Introduction to Artificial Intelligence (associated lab: CS386)
Chapter 4 Informed/Heuristic Search
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
Advanced Artificial Intelligence Lecture 2: Search.
CSC3203: AI for Games Informed search (1) Patrick Olivier
CS621: Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 3 - Search.
Informed Search and Heuristics Chapter 3.5~7. Outline Best-first search Greedy best-first search A * search Heuristics.
4/11/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 4, 4/11/2005 University of Washington, Department of Electrical Engineering Spring 2005.
A General Introduction to Artificial Intelligence.
Feng Zhiyong Tianjin University Fall  Best-first search  Greedy best-first search  A * search  Heuristics  Local search algorithms  Hill-climbing.
Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most desirable unexpanded node Implementation:
Informed Search II CIS 391 Fall CIS Intro to AI 2 Outline PART I  Informed = use problem-specific knowledge  Best-first search and its variants.
Informed Search CSE 473 University of Washington.
Searching for Solutions
A* optimality proof, cycle checking CPSC 322 – Search 5 Textbook § 3.6 and January 21, 2011 Taught by Mike Chiang.
3.5 Informed (Heuristic) Searches This section show how an informed search strategy can find solution more efficiently than uninformed strategy. Best-first.
Chapter 3.5 and 3.6 Heuristic Search Continued. Review:Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
Artificial Intelligence Lecture No. 8 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
CPSC 420 – Artificial Intelligence Texas A & M University Lecture 5 Lecturer: Laurie webster II, M.S.S.E., M.S.E.e., M.S.BME, Ph.D., P.E.
For Monday Read chapter 4 exercise 1 No homework.
Chapter 3.5 Heuristic Search. Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
Review: Tree search Initialize the frontier using the starting state
Last time: Problem-Solving
Artificial Intelligence Problem solving by searching CSC 361
HW #1 Due 29/9/2008 Write Java Applet to solve Goats and Cabbage “Missionaries and cannibals” problem with the following search algorithms: Breadth first.
The A* Algorithm Héctor Muñoz-Avila.
Discussion on Greedy Search and A*
Discussion on Greedy Search and A*
CS 4100 Artificial Intelligence
EA C461 – Artificial Intelligence
Informed search algorithms
Informed search algorithms
Artificial Intelligence
CSE 473 University of Washington
Artificial Intelligence
CS 416 Artificial Intelligence
Informed Search.
Presentation transcript:

CS 416 Artificial Intelligence Lecture 4 Finish Uninformed Searches Begin Informed Searches Lecture 4 Finish Uninformed Searches Begin Informed Searches

Administrivia There is an ACM meeting after class (OLS 011). I’ll end early. Getting you registered for license of VisualStudio There is an ACM meeting after class (OLS 011). I’ll end early. Getting you registered for license of VisualStudio

Uniform-Cost Search (review) Always expand the lowest-path-cost node Don’t evaluate the node until it is “expanded”… not when it is the result of expansion Always expand the lowest-path-cost node Don’t evaluate the node until it is “expanded”… not when it is the result of expansion

Uniform-Cost Search (review) Fringe = [S 0 ] Expand(S)  {A 1, B 5, C 15 } Fringe = [S 0 ] Expand(S)  {A 1, B 5, C 15 }

Uniform-Cost Search (review) Fringe = [A 1, B 5, C 15 ] Expand(A) = {G 11 } Fringe = [A 1, B 5, C 15 ] Expand(A) = {G 11 }

Uniform-Cost Search (review) Fringe = [B 5, G 11, C 15 ] Expand(B)  {G 10 } Fringe = [B 5, G 11, C 15 ] Expand(B)  {G 10 }

Uniform-Cost Search (review) Fringe = [G 10, C 15 ] Expand(G)  Goal Fringe = [G 10, C 15 ] Expand(G)  Goal

Bidirectional Search Search from goal to start Search from start to goal Search from goal to start Search from start to goal Two b d/2 searches instead of one b d

Bidirectional Search Implementation Each search checks nodes before expansion to see if they are on the fringe of the other searchEach search checks nodes before expansion to see if they are on the fringe of the other search Example: Bidirectional BFS search with d=6 & b=10Example: Bidirectional BFS search with d=6 & b=10 –Worst case: both search trees must expand all but one element of the third level of the tree  2* ( ) node expansions  Versus 1 * ( … ) epansions Implementation Each search checks nodes before expansion to see if they are on the fringe of the other searchEach search checks nodes before expansion to see if they are on the fringe of the other search Example: Bidirectional BFS search with d=6 & b=10Example: Bidirectional BFS search with d=6 & b=10 –Worst case: both search trees must expand all but one element of the third level of the tree  2* ( ) node expansions  Versus 1 * ( … ) epansions

Bidirectional Search Implementation Checking fringe of other treeChecking fringe of other tree –At least one search tree must be kept in memory –Checking can be done in constant time (hash table) Searching back from goalSearching back from goal –Must be able to compute predecessors to node n: Pred (n) –Easy with 15-puzzle, but how about chess? Implementation Checking fringe of other treeChecking fringe of other tree –At least one search tree must be kept in memory –Checking can be done in constant time (hash table) Searching back from goalSearching back from goal –Must be able to compute predecessors to node n: Pred (n) –Easy with 15-puzzle, but how about chess?

Avoid Repeated States Search algorithms that forget their history are doomed to repeat it. Russell and Norvig So remember where you’ve been… on a listSo remember where you’ve been… on a list If you come upon a node you’ve visited before, don’t expand itIf you come upon a node you’ve visited before, don’t expand it Let’s call this GRAPH-SEARCHLet’s call this GRAPH-SEARCH Search algorithms that forget their history are doomed to repeat it. Russell and Norvig So remember where you’ve been… on a listSo remember where you’ve been… on a list If you come upon a node you’ve visited before, don’t expand itIf you come upon a node you’ve visited before, don’t expand it Let’s call this GRAPH-SEARCHLet’s call this GRAPH-SEARCH

GRAPH-SEARCH Faster and smaller space requirements if many repeating states Time-space requirements are a function of state space not depth/branhing of tree to goalTime-space requirements are a function of state space not depth/branhing of tree to goal Completeness and Optimality of search techniques change when used in GRAPH-SEARCHCompleteness and Optimality of search techniques change when used in GRAPH-SEARCH –Uniform-cost search and BFS only optimal w/ constant step costs –DFS requires update node costs and descendent node costs Faster and smaller space requirements if many repeating states Time-space requirements are a function of state space not depth/branhing of tree to goalTime-space requirements are a function of state space not depth/branhing of tree to goal Completeness and Optimality of search techniques change when used in GRAPH-SEARCHCompleteness and Optimality of search techniques change when used in GRAPH-SEARCH –Uniform-cost search and BFS only optimal w/ constant step costs –DFS requires update node costs and descendent node costs

Interesting problems Exercise 3.9: 3 cannibals and 3 missionaries and a boat that can hold one or two people are on one side of the river. Get everyone across the river (early AI problem, 1968)3 cannibals and 3 missionaries and a boat that can hold one or two people are on one side of the river. Get everyone across the river (early AI problem, 1968) 8-puzzle and 15-puzzle, invented by Sam Loyd in good ol’ USA in 1870s. Think about search space.8-puzzle and 15-puzzle, invented by Sam Loyd in good ol’ USA in 1870s. Think about search space. Rubik’s cubeRubik’s cube Traveling Salesman Problem (TSP)Traveling Salesman Problem (TSP) Exercise 3.9: 3 cannibals and 3 missionaries and a boat that can hold one or two people are on one side of the river. Get everyone across the river (early AI problem, 1968)3 cannibals and 3 missionaries and a boat that can hold one or two people are on one side of the river. Get everyone across the river (early AI problem, 1968) 8-puzzle and 15-puzzle, invented by Sam Loyd in good ol’ USA in 1870s. Think about search space.8-puzzle and 15-puzzle, invented by Sam Loyd in good ol’ USA in 1870s. Think about search space. Rubik’s cubeRubik’s cube Traveling Salesman Problem (TSP)Traveling Salesman Problem (TSP)

Chapter 4 – Informed Search INFORMED? Uses problem-specific knowledge beyond the definition of the problem itselfUses problem-specific knowledge beyond the definition of the problem itself –selecting best lane in traffic –playing a sport  what’s the heuristic (or evaluation function)? INFORMED? Uses problem-specific knowledge beyond the definition of the problem itselfUses problem-specific knowledge beyond the definition of the problem itself –selecting best lane in traffic –playing a sport  what’s the heuristic (or evaluation function)?

Best-first Search BFS/DFS/UCS differ in how they select a node to pull off the fringe We want to pull the node that’s on the optimal path off the fringeWe want to pull the node that’s on the optimal path off the fringe –But if we know the “best” node to explore, we don’t have to search!!! Use an evaluation function to select node to expand f(n) = evaluation function = expected “cost” for a path from root to goal that goes through node nf(n) = evaluation function = expected “cost” for a path from root to goal that goes through node n Select the node n that minimizes f(n)Select the node n that minimizes f(n) How do we build f(n)?How do we build f(n)? BFS/DFS/UCS differ in how they select a node to pull off the fringe We want to pull the node that’s on the optimal path off the fringeWe want to pull the node that’s on the optimal path off the fringe –But if we know the “best” node to explore, we don’t have to search!!! Use an evaluation function to select node to expand f(n) = evaluation function = expected “cost” for a path from root to goal that goes through node nf(n) = evaluation function = expected “cost” for a path from root to goal that goes through node n Select the node n that minimizes f(n)Select the node n that minimizes f(n) How do we build f(n)?How do we build f(n)?

Evaluation function: f(n) Combine two costs f(n) = g(n) + h(n)f(n) = g(n) + h(n) –g(n) = cost to get to n from start –h(n) = cost to get to from n to goal Combine two costs f(n) = g(n) + h(n)f(n) = g(n) + h(n) –g(n) = cost to get to n from start –h(n) = cost to get to from n to goal

Heuristics A function, h(n), that estimates cost of cheapest path from node n to the goal h(n) = 0 if n == goal nodeh(n) = 0 if n == goal node A function, h(n), that estimates cost of cheapest path from node n to the goal h(n) = 0 if n == goal nodeh(n) = 0 if n == goal node

Greedy Best-first Search Trust your heuristic evaluate node that minimizes h(n)evaluate node that minimizes h(n) f(n) = h(n)f(n) = h(n) Example: getting from A to B Explore nodes with shortest straight distance to BExplore nodes with shortest straight distance to B Shortcomings of heuristic?Shortcomings of heuristic? –Greedy can be bad… Climbing K2 accomplishes a goal, but the cost of getting there is prohibitive Trust your heuristic evaluate node that minimizes h(n)evaluate node that minimizes h(n) f(n) = h(n)f(n) = h(n) Example: getting from A to B Explore nodes with shortest straight distance to BExplore nodes with shortest straight distance to B Shortcomings of heuristic?Shortcomings of heuristic? –Greedy can be bad… Climbing K2 accomplishes a goal, but the cost of getting there is prohibitive

A* (A-star) Search Don’t simply minimize the cost to goal… minimize the cost from start to goal… f(n) = g(n) + h(n)f(n) = g(n) + h(n) –g(n) = cost to get to n from start –h(n) = cost to get from n to goal Select node from fringe that minimizes f(n) Don’t simply minimize the cost to goal… minimize the cost from start to goal… f(n) = g(n) + h(n)f(n) = g(n) + h(n) –g(n) = cost to get to n from start –h(n) = cost to get from n to goal Select node from fringe that minimizes f(n)

A* is Optimal? A* can be optimal if h(n) satisfies conditions h(n) never overestimates cost to reach the goalh(n) never overestimates cost to reach the goal –it is eternally optimisic –called an admissible heurisitic –f(n) never overestimates cost of a solution through n Proof of optimality?Proof of optimality? A* can be optimal if h(n) satisfies conditions h(n) never overestimates cost to reach the goalh(n) never overestimates cost to reach the goal –it is eternally optimisic –called an admissible heurisitic –f(n) never overestimates cost of a solution through n Proof of optimality?Proof of optimality?

A* is Optimal We must prove that A* will not return a suboptimal goal or a suboptimal path to a goal Let G be a suboptimal goal nodeLet G be a suboptimal goal node –f(G) = g(G) + h(G) –h(G) = 0 because G is a goal node –f(G) = g(G) > C* (because G is suboptimal) We must prove that A* will not return a suboptimal goal or a suboptimal path to a goal Let G be a suboptimal goal nodeLet G be a suboptimal goal node –f(G) = g(G) + h(G) –h(G) = 0 because G is a goal node –f(G) = g(G) > C* (because G is suboptimal)

A* is Optimal We must prove that A* will not return a suboptimal goal or a suboptimal path to a goal Let G be a suboptimal goal nodeLet G be a suboptimal goal node –f(G) = g(G) + h(G) –h(G) = 0 because G is a goal node –f(G) = g(G) > C* (because G is suboptimal) We must prove that A* will not return a suboptimal goal or a suboptimal path to a goal Let G be a suboptimal goal nodeLet G be a suboptimal goal node –f(G) = g(G) + h(G) –h(G) = 0 because G is a goal node –f(G) = g(G) > C* (because G is suboptimal) Let n be a node on the optimal pathLet n be a node on the optimal path –because h(n) does not overestimate –f(n) = g(n) + h(n) <= C* Therefore f(n) <= C* < f(G)Therefore f(n) <= C* < f(G) –node n will be selected before node G Let n be a node on the optimal pathLet n be a node on the optimal path –because h(n) does not overestimate –f(n) = g(n) + h(n) <= C* Therefore f(n) <= C* < f(G)Therefore f(n) <= C* < f(G) –node n will be selected before node G

Repeated States and GRAPH-SEARCH GRAPH-SEARCH always ignores all but the first occurrence of a state during search Lower cost path may be tossedLower cost path may be tossed –So, don’t throw away subsequent occurrences –Or, ensure that the optimal path to any repeated state is always the first one followed Additional constraint on heurisitic, consistencyAdditional constraint on heurisitic, consistency GRAPH-SEARCH always ignores all but the first occurrence of a state during search Lower cost path may be tossedLower cost path may be tossed –So, don’t throw away subsequent occurrences –Or, ensure that the optimal path to any repeated state is always the first one followed Additional constraint on heurisitic, consistencyAdditional constraint on heurisitic, consistency

Consistent heuristic: h(n) Heuristic function must be monotonic for every node, n, and successor, n’, obtained with action afor every node, n, and successor, n’, obtained with action a –estimated cost of reaching goal from n is no greater than cost of getting to n’ plus estimated cost of reaching goal from n’ –h(n) <= c(n, a, n’) + h(n’) This implies f(n) along any path are nondecreasingThis implies f(n) along any path are nondecreasing Heuristic function must be monotonic for every node, n, and successor, n’, obtained with action afor every node, n, and successor, n’, obtained with action a –estimated cost of reaching goal from n is no greater than cost of getting to n’ plus estimated cost of reaching goal from n’ –h(n) <= c(n, a, n’) + h(n’) This implies f(n) along any path are nondecreasingThis implies f(n) along any path are nondecreasing

Examples of consistent h(n) h(n) <= c(n, a, n succ ) + h(n succ ) recall h(n) is admissiblerecall h(n) is admissible –The quickest you can get there from here is 10 minutes  It may take more than 10 minutes, but not fewer After taking an action and learning the costAfter taking an action and learning the cost –It took you two minutes to get here and you still have nine minutes to go –We cannot learn… it took you two minutes to get here and you have seven minutes to go h(n) <= c(n, a, n succ ) + h(n succ ) recall h(n) is admissiblerecall h(n) is admissible –The quickest you can get there from here is 10 minutes  It may take more than 10 minutes, but not fewer After taking an action and learning the costAfter taking an action and learning the cost –It took you two minutes to get here and you still have nine minutes to go –We cannot learn… it took you two minutes to get here and you have seven minutes to go

Example of inconsistent h(n) As a thought exercise for after class Consider what happens when a heuristic is inconsistentConsider what happens when a heuristic is inconsistent Consider how one could have a consistent but non- admissible heuristicConsider how one could have a consistent but non- admissible heuristic As a thought exercise for after class Consider what happens when a heuristic is inconsistentConsider what happens when a heuristic is inconsistent Consider how one could have a consistent but non- admissible heuristicConsider how one could have a consistent but non- admissible heuristic

Proof of monotonicity of f(n) If h(n) is consistent (monotonic) then f(n) along any path is nondecreasing then f(n) along any path is nondecreasing let n’ be a successor of nlet n’ be a successor of n –g(n’) = g(n) + c (n, a, n’) for some a –f(n’) = g(n’) + h(n’) = g(n) + c(n, a, n’) + h(n’) >= g(n) + h(n) = f(n) If h(n) is consistent (monotonic) then f(n) along any path is nondecreasing then f(n) along any path is nondecreasing let n’ be a successor of nlet n’ be a successor of n –g(n’) = g(n) + c (n, a, n’) for some a –f(n’) = g(n’) + h(n’) = g(n) + c(n, a, n’) + h(n’) >= g(n) + h(n) = f(n) monotonicity implies h(n) <= c(n, a, n’) + h(n’)

Contours Because f(n) is nondecreasing we can draw contours If we know C*If we know C* We only need to explore contours less than C*We only need to explore contours less than C* Because f(n) is nondecreasing we can draw contours If we know C*If we know C* We only need to explore contours less than C*We only need to explore contours less than C*

Properties of A* A* expands all nodes with f(n) < C*A* expands all nodes with f(n) < C* A* expands some (at least one) of the nodes on the C* contour before finding the goalA* expands some (at least one) of the nodes on the C* contour before finding the goal A* expands no nodes with f(n) > C*A* expands no nodes with f(n) > C* –these unexpanded nodes can be pruned A* expands all nodes with f(n) < C*A* expands all nodes with f(n) < C* A* expands some (at least one) of the nodes on the C* contour before finding the goalA* expands some (at least one) of the nodes on the C* contour before finding the goal A* expands no nodes with f(n) > C*A* expands no nodes with f(n) > C* –these unexpanded nodes can be pruned

A* is Optimally Efficient Compared to other algorithms that search from root Compared to other algorithms using same heuristic No other optimal algorithm is guaranteed to expand fewer nodes than A* (except perhaps eliminating consideration of ties at f(n) = C*) Compared to other algorithms that search from root Compared to other algorithms using same heuristic No other optimal algorithm is guaranteed to expand fewer nodes than A* (except perhaps eliminating consideration of ties at f(n) = C*)

Pros and Cons of A* A* is optimal and optimally efficient A* is still slow and bulky (space kills first) Number of nodes grows exponentially with the length to goalNumber of nodes grows exponentially with the length to goal –This is actually a function of heuristic, but they all have errors A* must search all nodes within this goal contourA* must search all nodes within this goal contour Finding suboptimal goals is sometimes only feasible solutionFinding suboptimal goals is sometimes only feasible solution Sometimes, better heuristics are non-admissibleSometimes, better heuristics are non-admissible A* is optimal and optimally efficient A* is still slow and bulky (space kills first) Number of nodes grows exponentially with the length to goalNumber of nodes grows exponentially with the length to goal –This is actually a function of heuristic, but they all have errors A* must search all nodes within this goal contourA* must search all nodes within this goal contour Finding suboptimal goals is sometimes only feasible solutionFinding suboptimal goals is sometimes only feasible solution Sometimes, better heuristics are non-admissibleSometimes, better heuristics are non-admissible

End for ACM meeting?