Computer Science CPSC 322 Lecture 6 Iterative Deepening and Search with Costs (Ch: 3.7.3, 3.5.3)

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
Uninformed search strategies
Artificial Intelligence By Mr. Ejaz CIIT Sahiwal.
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 §
ICS-171:Notes 4: 1 Notes 4: Optimal Search ICS 171 Summer 1999.
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
1 Lecture 3 Uninformed Search. 2 Uninformed search strategies Uninformed: While searching you have no clue whether one non-goal state is better than any.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
CS 480 Lec 3 Sept 11, 09 Goals: Chapter 3 (uninformed search) project # 1 and # 2 Chapter 4 (heuristic search)
Blind Search1 Solving problems by searching Chapter 3.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.4) January, 14, 2009.
Artificial Intelligence (CS 461D)
Uninformed Search Jim Little UBC CS 322 – Search 2 September 12, 2014
Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Slide 1 Heuristic Search: BestFS and A * Jim Little UBC CS 322 – Search 5 September 19, 2014 Textbook § 3.6.
Slide 1 Search: Advanced Topics Jim Little UBC CS 322 – Search 5 September 22, 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 Introduction to Artificial Intelligence October 27, 2004.
CPSC 322, Lecture 9Slide 1 Search: Advanced Topics Computer Science cpsc322, Lecture 9 (Textbook Chpt 3.6) January, 22, 2010.
Review: Search problem formulation
UnInformed Search What to do when you don’t know anything.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 580 Artificial Intelligence Ch.3 [P]: Searching Fall 2009 Marco Valtorta.
Artificial Intelligence Chapter 3: Solving Problems by Searching
1 Solving Problems by Searching. 2 Terminology State State Space Initial State Goal Test Action Step Cost Path Cost State Change Function State-Space.
1 Lecture 3 Uninformed Search. 2 Complexity Recap (app.A) We often want to characterize algorithms independent of their implementation. “This algorithm.
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
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.)
1 Lecture 3 Uninformed Search
Multiple Path Pruning, Iterative Deepening CPSC 322 – Search 7 Textbook § January 26, 2011.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
1 Problem Solving and Searching CS 171/271 (Chapter 3) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Problem Solving and Search Andrea Danyluk September 11, 2013.
Uninformed Search Strategies CPSC 322 – Search 2 January 14, 2011 Textbook §3.5 1.
Computer Science CPSC 322 Lecture Heuristic Search (Ch: 3.6, 3.6.1) Slide 1.
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)
How are things going? Core AI Problem Mobile robot path planning: identifying a trajectory that, when executed, will enable the robot to reach the goal.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l all learning algorithms,
Computer Science CPSC 322 Lecture 9 (Ch , 3.7.6) Slide 1.
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.
Lecture 3: Uninformed Search
Heuristic Search: A* 1 CPSC 322 – Search 4 January 19, 2011 Textbook §3.6 Taught by: Vasanth.
Goal-based Problem Solving Goal formation Based upon the current situation and performance measures. Result is moving into a desirable state (goal state).
Uninformed search strategies A search strategy is defined by picking the order of node expansion Uninformed search strategies use only the information.
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.
Fahiem Bacchus © 2005 University of Toronto 1 CSC384: Intro to Artificial Intelligence Search II ● Announcements.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
Artificial Intelligence Lecture No. 8 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
CPSC 322, Lecture 10Slide 1 Finish Search Computer Science cpsc322, Lecture 10 (Textbook Chpt 3.6) Sep, 26, 2010.
Brian Williams, Fall 041 Analysis of Uninformed Search Methods Brian C. Williams Sep 21 st, 2004 Slides adapted from: Tomas Lozano Perez,
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.
Artificial Intelligence Solving problems by searching.
Computer Science CPSC 322 Lecture 5 Heuristic Search and A* (Ch: 3.6, 3.6.1) Slide 1.
Computer Science cpsc322, Lecture 7
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
Computer Science cpsc322, Lecture 2
Iterative Deepening CPSC 322 – Search 6 Textbook § 3.7.3
Iterative Deepening and Branch & Bound
Presentation transcript:

Computer Science CPSC 322 Lecture 6 Iterative Deepening and Search with Costs (Ch: 3.7.3, 3.5.3)

Lecture Overview Recap of last class: Uninformed search Iterative Deepening Search (IDS) Search with Costs Intro to Heuristic Search (time permitting)

A. Check what node on a path is the goal B. Initialize the frontier C. Add/remove paths from the frontier D. Check if a state is a goal Search Strategies are different with respect to how they:

A. Check what node on a path is the goal B. Initialize the frontier C. Add/remove paths from the frontier D. Check if a state is a goal Search Strategies are different with respect to how they:

DFS Depth-First Search, DFS explores each path on the frontier until its end (or until a goal is found) before considering any other path. the frontier is a last-in-first-out stack

Breadth-first search (BFS) BFS explores all paths of length l on the frontier, before looking at path of length l + 1 The frontier is a first-in-first-out queue

Comparing DFS and BFS CompleteOptimalTimeSpace DFSNO O(b m ) BFSYES O(b m )

When to use BFS vs. DFS? 8 The search graph has cycles or is infinite We need the shortest path to a solution There are only solutions at great depth There are some solutions at shallow depth and others deeper No way the search graph will fit into memory DFS BFS DFS

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 DFSNO O(b m ) BFSYES O(b m ) Comparing DFS and BFS

Lecture Overview Recap of last class: Uninformed search Iterative Deepening Search (IDS) Search with Costs Intro to Heuristic Search (time permitting)

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

(Time) Complexity of IDS DepthTotal # of paths at that level #times created by BFS (or DFS) #times created by IDS Total #paths for IDS 1b1 2b2b m-1b m-1 1 mbmbm 1 12 m m mb (m-1) b 2 2 b m-1 bmbm That sounds wasteful! Let’s analyze the time complexity For a solution at depth m with branching factor b

Solution at depth m, branching factor b Total # of paths generated: b m + 2 b m b m mb = b m (1 b b b m b 1-m ) (Time) Complexity of IDS converges to Overhead factor  For b= 10, m = 5. BSF 111,111 and ID = 123,456 (only 11% more nodes)  The larger b the better, but even with b = 2 the search ID will take only 2 times as much as BFS

Lecture Overview Recap of last class: Uninformed search Iterative Deepening Search (IDS) Search with Costs Intro to Heuristic Search (time permitting)

Search with Costs Sometimes there are costs associated with arcs. Def.: The cost of a path is the sum of the costs of its arcs Slide 15

Example: Traveling in Romania

Search with Costs Sometimes there are costs associated with arcs. In this setting we often don't just want to find any solution 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 17

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) 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 “Lowest-Cost-First ”. select “Show Edge Costs” under “View” Create a new arc from UBC to SP with cost 20 and run LCFS Slide 18

Example of one step for LCFS: Let’s use (p i, c i ) to indicate a path p i and its cost the frontier is [(p 2, 5),  p 3, 7 ,  p 1, 11 , ] p 2 is the lowest-cost node in the frontier: Paths obtained by adding neighbor nodes to the end node of p 2 are: {  p 9, 10 ,  p 10, 15  } What happens? p 2 is selected, and tested for being a goal: false Neighbor paths of p 2 are inserted into the frontier, which is then sorted by cost Thus, the frontier is now [  p 3, 7 ,  p 9, 10 ,  p 1, 11 ,  p 10, 15  ].  p 3, 7  is selected next.

When arc costs are equal LCFS is equivalent to.. A.DFS B.BFS C.IDS D.None of the Above

When arc costs are equal LCFS is equivalent to.. A.DFS B.BFS C.IDS D.None of the Above

Analysis of Lowest-Cost Search (1) Is LCFS complete? not in general: for instance, a cycle with zero or negative arc costs could be followed forever. yes, as long as arc costs are strictly positive Is LCFS optimal? see how this works in AIspace: e.g, add arc with cost -20 to the simple search graph from N4 to S

Analysis of Lowest-Cost Search (1) Is LCFS complete? not in general: for instance, a cycle with zero or negative arc costs could be followed forever. yes, as long as arc costs c are strictly positive Is LCFS optimal? Not in general. Arc costs could be negative: a path that initially looks high-cost could end up getting a ``refund''. However, LCFS is optimal if arc costs are guaranteed to be see how this works in AIspace: e.g, add arc with cost -20 to the simple search graph from N4 to S

Analysis of LCFS What is the time complexity, if the maximum path length is m and the maximum branching factor is b ? What is the space complexity?

Analysis of Lowest-Cost Search Time complexity, if the maximum path length is m and the maximum branching factor is b The time complexity is O(b m ) In worst case, must examine every node in the tree because it generates all paths from the start that cost less than the cost of the solution Space complexity Space complexity is O(b m ): E.g. uniform cost: just like BFS, in worst case frontier has to store all nodes m-1 steps from the start node

Summary of Uninformed Search CompleteOptimalTimeSpace DFSNNO(b m )O(mb) BFSYY (shortest) O(b m ) IDS LCFS Slide 26

Summary of Uninformed Search CompleteOptimalTimeSpace DFSNNO(b m )O(mb) BFSYY (shortest) O(b m ) IDSYY (shortest) O(b m )O(mb) LCFS Slide 27

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 28

Select the most appropriate search algorithms for specific problems. Depth-First Search vs. Bredth-First Search vs. Iterative Deepening vs. Least-Cost-First Search Define/read/write/trace/debug different search algorithms Learning Goals for Search (cont’) (up to today)

Continue Heuristic Search: Ch 6 TODO Assign 1 will be available early next week Due Monday Feb 2 30

Summary of Uninformed Search (cont.) Why are all the search strategies seen so far are called uninformed? Because they do not consider any information about the states and the goals to decide which path to expand first on the frontier They are blind to the goal In other words, they are general and do not take into account the specific nature of the problem.

Lecture Overview Recap of last class: Uninformed search Iterative Deepening Search (IDS) Search with Costs Intro to Heuristic Search (time permitting)

Blind search algorithms do not take into account the goal until they are at a goal node. Often there is extra knowledge that can be used to guide the search: -an estimate of the distance/cost from node n to a goal node. This estimate is called a search heuristic. Heuristic Search Slide 33

More formally 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 Slide 34

Example: finding routes 35 What could we use as h(n)?

Example: finding routes 36 What could we use as h(n)? E.g., the straight-line (Euclidian) distance between source and goal node

Example 2 Search problem: robot has to find a route from start to goal location on a grid with obstacles Actions: move up, down, left, right from tile to tile Cost : number of moves Possible h(n)? G S

Example 2 Search problem: robot has to find a route from start to goal location 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) between two points: sum of the (absolute) difference of their coordinates G