Computer Science CPSC 322 Lecture Heuristic Search (Ch: 3.6, 3.6.1) Slide 1.

Slides:



Advertisements
Similar presentations
CPSC 322, Lecture 7Slide 1 Heuristic Search Computer Science cpsc322, Lecture 7 (Textbook Chpt 3.5) January, 19, 2009.
Advertisements

Review: Search problem formulation
Notes Dijstra’s Algorithm Corrected syllabus.
Informed search strategies
Informed search algorithms
Problem Solving: Informed Search Algorithms Edmondo Trentin, DIISM.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 14, 2012.
Heuristic Search Jim Little UBC CS 322 – Search 4 September 17, 2014 Textbook §
Greedy best-first search Use the heuristic function to rank the nodes Search strategy –Expand node with lowest h-value Greedily trying to find the least-cost.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 4 Jim Martin.
Solving Problem by Searching
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.4) January, 14, 2009.
Uninformed Search Jim Little UBC CS 322 – Search 2 September 12, 2014
Slide 1 Heuristic Search: BestFS and A * Jim Little UBC CS 322 – Search 5 September 19, 2014 Textbook § 3.6.
CPSC 322, Lecture 9Slide 1 Search: Advanced Topics Computer Science cpsc322, Lecture 9 (Textbook Chpt 3.6) January, 23, 2009.
CPSC 322, Lecture 9Slide 1 Search: Advanced Topics Computer Science cpsc322, Lecture 9 (Textbook Chpt 3.6) January, 22, 2010.
Review: Search problem formulation
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 580 Artificial Intelligence Ch.3 [P]: Searching Fall 2009 Marco Valtorta.
CS 460 Spring 2011 Lecture 3 Heuristic Search / Local Search.
Informed Search Methods How can we make use of other knowledge about the problem to improve searching strategy? Map example: Heuristic: Expand those nodes.
Problem Solving and Search in AI Heuristic Search
CPSC 322, Lecture 8Slide 1 Heuristic Search: BestFS and A * Computer Science cpsc322, Lecture 8 (Textbook Chpt 3.5) January, 21, 2009.
CS 188: Artificial Intelligence Spring 2006 Lecture 2: Queue-Based Search 8/31/2006 Dan Klein – UC Berkeley Many slides over the course adapted from either.
Uninformed Search (cont.)
Multiple Path Pruning, Iterative Deepening CPSC 322 – Search 7 Textbook § January 26, 2011.
CMU Snake Robot
Dijkstra’s Algorithm and Heuristic Graph Search David Johnson.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Problem Solving and Search Andrea Danyluk September 11, 2013.
Dr.Abeer Mahmoud ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information.
CPSC 322, Lecture 8Slide 1 Heuristic Search: BestFS and A * Computer Science cpsc322, Lecture 8 (Textbook Chpt 3.6) Sept, 23, 2013.
Computer Science CPSC 322 Lecture A* and Search Refinements (Ch 3.6.1, 3.7.1, 3.7.2) Slide 1.
Lecture 2 Search (textbook Ch: 3)
Informed search algorithms
CHAPTER 4: INFORMED SEARCH & EXPLORATION Prepared by: Ece UYKUR.
Computer Science CPSC 322 Lecture 9 (Ch , 3.7.6) Slide 1.
Informed search algorithms Chapter 4. Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most.
Informed search strategies Idea: give the algorithm “hints” about the desirability of different states – Use an evaluation function to rank nodes and select.
Search (cont) & CSP Intro Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Dan Klein, Stuart Russell, Andrew Moore,
Informed searching. Informed search Blind search algorithms do not consider any information about the states and the goals Often there is extra knowledge.
Informed Search Strategies Lecture # 8 & 9. Outline 2 Best-first search Greedy best-first search A * search Heuristics.
For Friday Finish reading chapter 4 Homework: –Lisp handout 4.
For Monday Read chapter 4, section 1 No homework..
Search with Costs and Heuristic Search 1 CPSC 322 – Search 3 January 17, 2011 Textbook §3.5.3, Taught by: Mike Chiang.
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.
Heuristic Search: A* 1 CPSC 322 – Search 4 January 19, 2011 Textbook §3.6 Taught by: Vasanth.
Computer Science CPSC 322 Lecture 6 Iterative Deepening and Search with Costs (Ch: 3.7.3, 3.5.3)
1 Kuliah 4 : Informed Search. 2 Outline Best-First Search Greedy Search A* Search.
Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most desirable unexpanded node Implementation:
CPSC 322, Lecture 8Slide 1 Heuristic Search: BestFS and A * Computer Science cpsc322, Lecture 8 (Textbook Chpt 3.6) Sept, 21, 2010.
CPSC 322, Lecture 6Slide 1 Uniformed Search (cont.) Computer Science cpsc322, Lecture 6 (Textbook finish 3.5) Sept, 17, 2012.
A* optimality proof, cycle checking CPSC 322 – Search 5 Textbook § 3.6 and January 21, 2011 Taught by Mike Chiang.
CHAPTER 2 SEARCH HEURISTIC. QUESTION ???? What is Artificial Intelligence? The study of systems that act rationally What does rational mean? Given its.
Chapter 3.5 and 3.6 Heuristic Search Continued. Review:Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
For Monday Read chapter 4 exercise 1 No homework.
CPSC 322, Lecture 7Slide 1 Heuristic Search Computer Science cpsc322, Lecture 7 (Textbook Chpt 3.6) Sept, 20, 2013.
Computer Science CPSC 322 Lecture 6 Analysis of A*, Search Refinements (Ch ) Slide 1.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Computer Science CPSC 322 Lecture 5 Heuristic Search and A* (Ch: 3.6, 3.6.1) Slide 1.
Computer Science cpsc322, Lecture 7
Review: Tree search Initialize the frontier using the starting state
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
Heuristic Search Introduction to Artificial Intelligence
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
Informed search algorithms
Iterative Deepening CPSC 322 – Search 6 Textbook § 3.7.3
Announcements This Friday Project 1 due Talk by Jeniya Tabassum
Iterative Deepening and Branch & Bound
Informed Search.
Presentation transcript:

Computer Science CPSC 322 Lecture Heuristic Search (Ch: 3.6, 3.6.1) Slide 1

Announcements Assignment 1 posted in Connect Due Monday Feb 2, 2pm Assignment 0 will be marked and returned by Wed. class 2

Lecture Overview Recap of Lecture 6 Best First Search A* Admissible heuristic Slide 3

DFS vs. BFS How can we achieve an acceptable (linear) space complexity while maintaining completeness and optimality? Key Idea: re-compute elements of the frontier rather than saving them. CompleteOptimalTimeSpace DFS NO O(b m ) BFS YES O(b m ) ????? YES O(b m ) 4

depth = 1 depth = 2 depth = 3... Iterative Deepening DFS (IDS) in a Nutshell Use DFS to look for solutions at depth 1, then 2, then 3, etc – For depth D, ignore any paths with longer length – Depth-bounded depth-first search If no goal re-start from scratch and get to depth 2 If no goal re-start from scratch and get to depth 3 If no goal re-start from scratch and get to depth 4 5

DFS vs. BFS But what if we have costs associated with search actions (arcs in the search space? CompleteOptimalTimeSpace DFS NO O(b m ) BFS YES O(b m ) IDS YES O(b m ) 6

Search with Costs In this setting we usually want to find the solution that minimizes cost Def.: The cost of a path is the sum of the costs of its arcs Def.: A search algorithm is optimal if when it finds a solution, it is the best one: it has the lowest path cost Slide 7

Lowest-cost-first search finds the path with the lowest cost to a goal node At each stage, it selects the path with the lowest cost on the frontier. The frontier is implemented as a priority queue ordered by path cost. Lowest-Cost-First Search (LCFS) 8

Summary of Uninformed Search CompleteOptimalTimeSpace DFSNNO(b m )O(mb) BFSYY (shortest) O(b m ) IDSYY (shortest) O(b m )O(mb) LCFSY Costs > 0 Y (Least Cost) Costs >=0 O(b m ) Slide 9

How to Make Search More Informed? Def.: A search heuristic h(n) is an estimate of the cost of the optimal (cheapest) path from node n to a goal node. Estimate: h(n1) Estimate: h(n2) Estimate: h(n3) n3 n2 n1 h can be extended to paths: h(  n 0,…,n k  )=h(n k ) h(n) should leverage readily obtainable information (easy to compute) about a node. Slide 10

Example: finding routes Possible h(n)? the straight-line (Euclidian) distance between source and goal node (here Bucharest) 11

Lecture Overview Recap of Lecture 6 Best First Search A* Admissible heuristic Slide 12

Idea: always choose the path on the frontier with the smallest h value. BestFS treats the frontier as a priority queue ordered by h. Greedy approach: expand path whose last node seems closest to the goal - chose the solution that is locally the best. Best First Search (BestFS) Let’s see how this works in AIspace: in the Search Applet toolbar select the “Vancouver Neighborhood Graph” problem set “Search Options -> Search Algorithms” to “Best-First ”. select “Show Node Heuristics” under “View” compare number of nodes expanded by BestFS and LCFS 13

Complete? See the “misleading heuristics demo” example in AISPACE Optimal? Try AISPACE example “ex-best.txt” from schedule page (save it and then load using “load from file” option) Time Complexity: O(b m ) - Worst case: has to explore all nodes Space Complexity: O(b m ) Analysis of BestFS Why would one want to use Best Search then? Because if the heuristics is good if can find the solution very fast. For another example, see Aispace, Delivery problem graph with C1 linked to o123 (cost 3.0) 14

Always choose the path on the frontier with the smallest h value. BestFS treats the frontier as a priority queue ordered by h. Can get to the goal pretty fast if it has a good h but… It is not complete, nor optimal still has time and space worst-case complexity of O(b m ) Best First Search (BestFS) 15

Thus, having estimates of the distance to the goal can speed things up a lot, but by itself it can also mislead the search (i.e. Best First Search) On the other hand, taking only path costs into account allows LCSF to find the optimal solution, but the search process is still uniformed as far as distance to the goal goes. What’s Next? 16

How can we more effectively use h(p) and cost(p)? Shall we select from the frontier the path p with: A.Lowest cost(p) – h(p) B.Highest cost(p) – h(p) C.Highest cost(p)+h(p) D. Lowest cost(p)+h(p) 17

How can we more effectively use h(p) and cost(p)? Shall we select from the frontier the path p with: A.Lowest cost(p) – h(p) B.Highest cost(p) – h(p) C.Highest cost(p)+h(p) D. Lowest cost(p)+h(p) 18

Lecture Overview Recap of Lecture 6 Best First Search A* Admissible heuristic Slide 19

A * search takes into account both the cost of the path to a node c(p) the heuristic value of that path h(p). Let f(p) = c(p) + h(p). f(p) is an estimate of the cost of a path from the start to a goal via p. A* Search c(p) h(p) f(p ) A* always chooses the path on the frontier with the lowest estimated distance from the start to a goal node constrained to go via that path. 20

F-value of ubc  kd  jb? A.6 C.10 D. 11 B. 9 Computing f-valeues 21

F-value of ubc  kd  jb? C.10 Computing f-valeues 22

23

Compare A* and LCFS on the Vancouver graph A * search takes into account both the cost of the path to a node c(p) the heuristic value of that path h(p). Let f(p) = c(p) + h(p). f(p) is an estimate of the cost of a path from the start to a goal via p. A* Search c(p) h(p) f(p ) A* always chooses the path on the frontier with the lowest estimated distance from the start to a goal node constrained to go via that path. 24

A* is complete (finds a solution, if one exists) and optimal (finds the optimal path to a goal) if the branching factor is finite arc costs are > 0 h(n) is admissible Optimality of A* 25

Admissibility of a heuristic Def.: Let c(n) denote the cost of the optimal path from node n to any goal node. A search heuristic h(n) is called admissible if h(n) ≤ c(n) for all nodes n, i.e. if for all nodes it is an underestimate of the cost to any goal. Example: is the straight- line distance (SLD) admissible? 26

Admissibility of a heuristic Def.: Let c(n) denote the cost of the optimal path from node n to any goal node. A search heuristic h(n) is called admissible if h(n) ≤ c(n) for all nodes n, i.e. if for all nodes it is an underestimate of the cost to any goal. Example: is the straight- line distance admissible? - The shortest distance between two points is a line. YES 27

Admissibility of a heuristic Def.: Let c(n) denote the cost of the optimal path from node n to any goal node. A search heuristic h(n) is called admissible if h(n) ≤ c(n) for all nodes n, i.e. if for all nodes it is an underestimate of the cost to any goal. example: the goal is Urzizeni (red box), but all we know is the straight- line distances to Bucharest (green box) Possible h(n) = sld(n, Bucharest) + cost(Bucharest, Urzineni) Admissible? A. Yes C. It depends B. No 28

Admissibility of a heuristic Def.: Let c(n) denote the cost of the optimal path from node n to any goal node. A search heuristic h(n) is called admissible if h(n) ≤ c(n) for all nodes n, i.e. if for all nodes it is an underestimate of the cost to any goal. example: the goal is Urzizeni (red box), but all we know is the straight- line distances to Bucharest (green box) NO Possible h(n) = sld(n, Bucharest) + cost(Bucharest, Urzineni) Admissible? 29 Cost of going from Vastul to Urzineni is shorter than this estimate

Example 2: grid world Search problem: robot has to find a route from start to goal location G on a grid with obstacles Actions: move up, down, left, right from tile to tile Cost : number of moves Possible h(n)? -Manhattan distance (L 1 distance) to the goal G: sum of the (absolute) difference of their coordinates -Admissible? G Slide 30

Example 2: grid world Search problem: robot has to find a route from start to goal location G on a grid with obstacles Actions: move up, down, left, right from tile to tile Cost : number of moves Possible h(n)? -Manhattan distance (L 1 distance) to the goal G: sum of the (absolute) difference of their coordinates -Admissible? Yes. Manhattan distance is the shortest path between any two tiles of the grid given the actions available and no walls. Including the walls will force the agent to take some extra steps to avoid them G Slide 31

Heuristic Function for 8-puzzle An admissible heuristics for the 8-puzzle is? A.Number of misplaced tiles plus number of correctly place tiles B.Number of misplaced tiles C.Number of correctly placed tiles D.None of the above 32

Example 3: Eight Puzzle Admissible h(n): Number of Misplaced Tiles: One needs at least that many moves to get the board in the goal state Slide 33

How to Construct an Admissible Heuristic Identify relaxed version of the problem: -where one or more constraints have been dropped -problem with fewer restrictions on the actions Grid world: the agent can move through walls Driver: the agent can move straight 8 puzzle: -“number of misplaced tiles”: tiles can move everywhere and occupy same spot as others -“sum of moves between current and goal position”: tiles can occupy same spot as others Why does this lead to an admissible heuristic? -The problem only gets easier! -Less costly to solve it 34

How to Construct a Heuristic (cont.) You should identify constraints which, when dropped, make the problem easy to solve important because heuristics are not useful if they're as hard to solve as the original problem! This was the case in our examples Robot: allowing the agent to move through walls. Optimal solution to this relaxed problem is Manhattan distance Driver: allowing the agent to move straight. Optimal solution to this relaxed problem is straight-line distance 8puzzle: tiles can move anywhere. Optimal solution to this relaxed problem is number of misplaced tiles 35

Apply basic properties of search algorithms: completeness, optimality time and space complexity Select the most appropriate search algorithms for specific problems. Depth-First Search vs. Bredth-First Search vs. Iterative Deepening vs. Least-Cost-First Search, Best First Search, A* Define/read/write/trace/debug different search algorithms Construct heuristic functions and discuss their admissibility for specific search problems Learning Goals for Search (up to today) Slide 36

A*: Ch 6.1 Practice Excercises 3C and 3D TODO Start working on Assignment 1! You can already do - several subquestions in Q1 - Q2 and most of Q3 37