Informed Search (no corresponding text chapter). Recall: Wanted " An algorithm and associated data structure(s) that can: 1) Solve an arbitrary 8-puzzle.

Slides:



Advertisements
Similar presentations
Review: Search problem formulation
Advertisements

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
Chapter 15 Heaps. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Define a heap abstract data structure Demonstrate.
5-1 Chapter 5 Tree Searching Strategies. 5-2 Satisfiability problem Tree representation of 8 assignments. If there are n variables x 1, x 2, …,x n, then.
EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt.
Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Priority Queues. 2 Priority queue A stack is first in, last out A queue is first in, first out A priority queue is least-first-out The “smallest” element.
Advanced Data Structures Chapter 16. Priority Queues Collection of elements each of which has a priority. Does not maintain a first-in, first-out discipline.
State Space Search Algorithms CSE 472 Introduction to Artificial Intelligence Autumn 2003.
Trees Chapter 8.
SE Last time: Problem-Solving Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation:
Review: Search problem formulation
Fall 2007CS 2251 Trees Chapter 8. Fall 2007CS 2252 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Heaps and heapsort COMP171 Fall Sorting III / Slide 2 Motivating Example 3 jobs have been submitted to a printer in the order A, B, C. Sizes: Job.
Using Search in Problem Solving
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
Uninformed Search Reading: Chapter 3 by today, Chapter by Wednesday, 9/12 Homework #2 will be given out on Wednesday DID YOU TURN IN YOUR SURVEY?
Trees and Red-Black Trees Gordon College Prof. Brinton.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L12 (Chapter 20) Lists, Stacks,
Problem Solving and Search in AI Heuristic Search
1 CS211, Lecture 20 Priority queues and Heaps Readings: Weiss, sec. 6.9, secs When they've got two queues going, there's never any queue!
Source: Muangsin / Weiss1 Priority Queue (Heap) A kind of queue Dequeue gets element with the highest priority Priority is based on a comparable value.
CSC344: AI for Games Lecture 4: Informed search
1 Tree Searching Strategies. 2 The procedure of solving many problems may be represented by trees. Therefore the solving of these problems becomes a tree.
Chapter 12 Trees. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Define trees as data structures Define the terms.
Problem-solving agents
Priority Queues, Heaps & Leftist Trees
For Friday Finish chapter 3 Homework: –Chapter 3, exercise 6 –May be done in groups. –Clarification on part d: an “action” must be running the program.
State-Space Searches.
More Trees COL 106 Amit Kumar and Shweta Agrawal Most slides courtesy : Douglas Wilhelm Harder, MMath, UWaterloo
Informed Search Idea: be smart about what paths to try.
Heapsort Based off slides by: David Matuszek
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Trees. Tree Terminology Chapter 8: Trees 2 A tree consists of a collection of elements or nodes, with each node linked to its successors The node at the.
Graphs II Robin Burke GAM 376. Admin Skip the Lua topic.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Spring 2010CS 2251 Trees Chapter 6. Spring 2010CS 2252 Chapter Objectives Learn to use a tree to represent a hierarchical organization of information.
1 Trees A tree is a data structure used to represent different kinds of data and help solve a number of algorithmic problems Game trees (i.e., chess ),
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
Informed (Heuristic) Search
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
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.
WEEK 3 Leftist Heaps CE222 Dr. Senem Kumova Metin CE222_Dr. Senem Kumova Metin.
For Friday Finish reading chapter 4 Homework: –Lisp handout 4.
For Monday Read chapter 4, section 1 No homework..
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
1 Heaps and Priority Queues v2 Starring: Min Heap Co-Starring: Max Heap.
Artificial Intelligence for Games Informed Search (2) Patrick Olivier
For Friday Read chapter 4, sections 1 and 2 Homework –Chapter 3, exercise 7 –May be done in groups.
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
Heaps & Priority Queues
Informed Search CSE 473 University of Washington.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
CS 367 Introduction to Data Structures Lecture 8.
Artificial Intelligence Lecture No. 8 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
For Monday Read chapter 4 exercise 1 No homework.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Chapter 8 – Binary Search Tree
CSE 473 University of Washington
HW 1: Warmup Missionaries and Cannibals
Informed Search Idea: be smart about what paths to try.
HW 1: Warmup Missionaries and Cannibals
Reading: Chapter 4.5 HW#2 out today, due Oct 5th
Informed Search Idea: be smart about what paths to try.
Presentation transcript:

Informed Search (no corresponding text chapter)

Recall: Wanted " An algorithm and associated data structure(s) that can: 1) Solve an arbitrary 8-puzzle problem (or problem like it), 2) Do it in a reasonable amount of time and space-- efficiency, 3) Be guaranteed to first find the solution with the minimum number of actions--optimality.

Available Algorithms " Breadth-first state space search (BFS) ➢ Pro: optimal ➢ Con: memory inefficient " Depth-first state space search (DFS) ➢ Pro: memory efficient ➢ Con: non-optimal " Solution: A* search, a kind of "informed'' search

Informed and Uninformed Search " If a search algorithm makes an attempt to evaluate an item's children by comparing their "goodness'' with respect to the goal, it is informed. " If a search algorithm is not informed, it is uninformed or blind. " BFS and DFS are uninformed " Informed search requires the concept of an evaluation function

Evaluation Functions " An evaluation function takes a search space item as an argument and returns a numerical value as its "goodness'' " One type evaluates the strength of a state (as in chess playing programs)--the higher the better " Another type estimates the number of actions required to get to the goal. " Such an evaluation function is also called a "heuristic'' " The smaller an item's heuristic, the better

Heuristic for the 8-puzzle " If n is an item in the 8-puzzle state space, consider: ➢ h(n) = m, where m is the number of tiles out of place " h estimates, but does not overestimate, the number of actions required to get to the goal g " Note that h(g) = 0

8-puzzle Heuristic Function: Number of Misplaced Tiles up left down right left right up left right

Recall General Search Algorithm Suppose we added children to the waiting collection on the basis of their heuristic values. Q: What kind of collection should be used? search(root) returns Node or null { waiting.add(root) while (waiting is not empty) { node = waiting.remove() state = node.getState() if (problem.success(state)) return node else { children = expand(node) for each child in children waiting.add(child) } return null }

Priority Queues A (regular) queue has first-in, first-out (FIFO) behavior, where items must enter at the rear and leave from the front. In a priority queue items must leave from the front, but they enter on the basis of a priority (key) value. The queue is kept sorted by this value. Examples of priority queues: - CPU process queues - Print queues - Event-driven simulation (traffic flows) - VLSI design (channel routing, pin layout) - Artificial intelligence search algorithms

Implementations of Priority Queues Priority Queue Linked ListArrayBinary Heap Implemented as:

Array Implementation of Priority Queues Suppose items with keys 1, 3, 4, 7, 8, 9, 10, 14, 16 are to be stored in a priority queue. Array: A 1 NMax Suppose an item with key 2 is added: A 1 Max 2 Thus inserting takes O(N) time: linear

Linked List Implementation of Priority Queues L Suppose an item with key 15 is to be added: L 15 Only O(1) (constant) pointer changes required, but it takes O(N) pointer traversals to find the location for insertion.

Binary Heap Implementation of Priority Queues A binary heap is a "nearly full" binary tree: A binary heap has the property that, for every node other than a leaf, its key value is less than or equal to that of its children (called the Heap Property). Adds and removes: O(log 2 N) time (see java.util.PriorityQueue)

Example State Space With Heuristics Goal State

"Best-First'' State Space Search ● If the general search algorithm is used on a priority queue where the key value is a heuristic, it is called a "best-first'' search ● "Best-first'' search, despite its name, is not optimal

Trace of Best-First Search PQ: ( 1 ) PQ: ( ) PQ: ( 32 ) PQ: ( 32 ) PQ: ( 32 ) PQ: ( 32 ) These links are pointers back to parent created at expansion time

Notes On Best-First Search ● Solution path found in the example: – 1  4  10  17  18  28 ● Shortest possible solution: – 1   12  18  28 ● Therefore best-first search is not optimal ● The problem: the heuristic function rates state 4 better than state 5 ● Moral: heuristic functions are not perfect

Recall 8-puzzle Heuristic up left right up left right This state leads to the shortest solution This state may not lead to the shortest solution

Forcing an Optimal Solution In Previous Example ● The problem is that 18 is created as a result of expanding 17 instead of 12 ● 12 is preferred to 17 because it is shallower in the state space ● We can force 12 to precede 17 in the PQ by adding a state's depth to its heuristic value before adding it. ● When we order the PQ by key = heuristic + depth, then the search is called A*.

Taking Heuristics and Depth Into Account Goal State

A* Search PQ: ( )

Notes on A* Search ● Q: What is the solution path? – descended from ● A: 1 → 5 → 12 → 18 → 28 (optimal) ● If A* is used, and the heuristic never overestimates the number of moves required, a shortest solution is guaranteed (theorem). ● The number-of-misplaced-tiles heuristic never overestimates

BFS As A Special Case of A* ● Suppose the heuristic function is h(n) = 0 ● Then the priority queue key will be: ➢ h(n) + depth(n) = 0 + depth(n) = depth(n) ● If the children of an item at depth k are added to a priority queue they will go to the end (since they are at depth k+1) ● Therefore all items at depth k will be examined before items at depth k+1= the definition of BFS

Some Heuristics Are Better Than Others ● Although the number-of-misplaced-tiles heuristic never overestimates, we could do better without overestimating up left right This state is better because the 8 is closer to its destination. A more informed heuristic is the sum of the "Manhattan distances'' that the tiles are out of place

8-puzzle Heuristic Function: Sum of Manhattan Distances up left down right left right up left right

Comparing Heuristic Functions ● A heuristic h 1 is more informed than another heuristic h 2 if: – For all items n in the search space, h 1 (n)  h 2 (n)  The more informed the heuristic, the fewer items will be expanded  If a heuristic is more informed without overestimating, then it is more efficient as well as optimal  The sum-of-Manhattan-distances heuristic does not overestimate

Implementing Heuristics ● Need to add depth and heuristic to Node class as instance variables ● Abstract computeHeuristic(State) method can be added to Problem class; overridden in subclasses ● Depth and heuristic can be computed at expand time (depth of child = 1 + depth of parent) ● Use key = depth + heuristic to insert into priority queue