CS 415 – A.I. Slide Set 6. Chapter 4 – Heuristic Search Heuristic – the study of the methods and rules of discovery and invention State Space Heuristics.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Informed search algorithms
Review: Search problem formulation
Informed search algorithms
Ch 4. Heuristic Search 4.0 Introduction(Heuristic)
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.
Traveling Salesperson Problem
Solving Problem by Searching
Artificial Intelligence Chapter 9 Heuristic Search Biointelligence Lab School of Computer Sci. & Eng. Seoul National University.
Artificial Intelligence
CS 484 – Artificial Intelligence1 Announcements Department Picnic: today, after class Lab 0 due today Homework 2 due Tuesday, 9/18 Lab 1 due Thursday,
Chapter 4 Search Methodologies.
HEURISTIC SEARCH ARTIFICIAL INTELLIGENCE 5th edition George F Luger
Mahgul Gulzai Moomal Umer Rabail Hafeez
Problem Solving by Searching
CPSC 322 Introduction to Artificial Intelligence October 27, 2004.
SE Last time: Problem-Solving Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation:
Review: Search problem formulation
Cooperating Intelligent Systems Informed search Chapter 4, AIMA.
Problem Solving and Search in AI Heuristic Search
HEURISTIC SEARCH. Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005 Portion of the state space for tic-tac-toe.
1 Heuristic Search 4 4.0Introduction 4.1An Algorithm for Heuristic Search 4.2Admissibility, Monotonicity, and Informedness 4.3Using Heuristics in Games.
CS 561, Session 6 1 Last time: Problem-Solving Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation:
Heuristic Search Heuristic - a “rule of thumb” used to help guide search often, something learned experientially and recalled when needed Heuristic Function.
Informed Search Idea: be smart about what paths to try.
Informed Search Strategies
Vilalta&Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
Heuristic Search In addition to depth-first search, breadth-first search, bound depth-first search, and iterative deepening, we can also use informed or.
Informed search algorithms
Informed search algorithms
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
1 Shanghai Jiao Tong University Informed Search and Exploration.
CS 415 – A.I. Slide Set 5. Chapter 3 Structures and Strategies for State Space Search – Predicate Calculus: provides a means of describing objects and.
George F Luger ARTIFICIAL INTELLIGENCE 5th edition Structures and Strategies for Complex Problem Solving HEURISTIC SEARCH Luger: Artificial Intelligence,
George F Luger ARTIFICIAL INTELLIGENCE 6th edition Structures and Strategies for Complex Problem Solving HEURISTIC SEARCH Luger: Artificial Intelligence,
Informed search algorithms Chapter 4. Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most.
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.
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
1 Branch and Bound Searching Strategies Updated: 12/27/2010.
Ch4 Heuristic Search Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011.
Informed Search and Heuristics Chapter 3.5~7. Outline Best-first search Greedy best-first search A * search Heuristics.
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:
State space representations and search strategies - 2 Spring 2007, Juris Vīksna.
Heuristic Search Foundations of Artificial Intelligence.
Searching for Solutions
A* optimality proof, cycle checking CPSC 322 – Search 5 Textbook § 3.6 and January 21, 2011 Taught by Mike Chiang.
George F Luger ARTIFICIAL INTELLIGENCE 5th edition Structures and Strategies for Complex Problem Solving HEURISTIC SEARCH Luger: Artificial Intelligence,
Chapter 3.5 and 3.6 Heuristic Search Continued. Review:Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
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 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Review: Tree search Initialize the frontier using the starting state
AI Classnotes #5, John Shieh, 2012
Last time: Problem-Solving
Heuristic Search A heuristic is a rule for choosing a branch in a state space search that will most likely lead to a problem solution Heuristics are used.
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.
CS 4100 Artificial Intelligence
BEST FIRST SEARCH -OR Graph -A* Search -Agenda Search CSE 402
A General Backtracking Algorithm
HW 1: Warmup Missionaries and Cannibals
Informed Search Idea: be smart about what paths to try.
HW 1: Warmup Missionaries and Cannibals
CS 416 Artificial Intelligence
Reading: Chapter 4.5 HW#2 out today, due Oct 5th
Informed Search Idea: be smart about what paths to try.
Lecture 4: Tree Search Strategies
Presentation transcript:

CS 415 – A.I. Slide Set 6

Chapter 4 – Heuristic Search Heuristic – the study of the methods and rules of discovery and invention State Space Heuristics –  Formalized as rules for choosing those branches in a state space that are most likely to lead to an acceptable problem solution Apply Heuristics When: 1. A problem is ambiguous and may not have an EXACT solution 2. The computational cost of finding an exact solution is prohibitive

Simplifying Tic-Tac-Toe Brute Force – 9! total states  First use symmetry to reduce the number of states (see next slide)‏  7x12 states  Simple Heuristic  Put X where it has the most winning possibilities  See Figure 4.2 and Figure 4.3  This “prunes” the search space  In the first level, pick one of three, ignore the subtrees for the other two  Approx. 25 total states to consider

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005 Fig 4.1First three levels of the tic-tac-toe state space reduced by symmetry 2

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005 Fig 4.2The “most wins” heuristic applied to the first children in tic-tac-toe. 3

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005 Fig 4.3Heuristically reduced state space for tic-tac-toe. 4

Hill-Climbing and Dynamic Programming Hill-Climbing  Expand the current state and evaluate its children  Pick the best child Mountain climbing  Go as steep as you can for as long as you can. Problem:  Keeps no backtracking info  Becomes stuck at “local maxima”  Example:  8-square problem

Dynamic Programming  Don’t solve subproblems multiple times  Instead, keep track of the solutions to these subproblems  Memoizing – subproblem solution caching Two Examples 1. Finding an optimal global alignment 2. Finding the minimum edit distance between two strings

Optimal Global Alignment Small Example  String #1  BAADDCABDDA  String #2  BBADCBA Rules  Cannot change order of respective elements  Can have spaces between elements Possible solutions  How do we figure out optimal solution?

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005 Fig 4.5The initialization stage and first step in completing the array for character alignment using dynamic programming. 6 Let’s create a matrix The value of each element reflects the global alignment success to that point in the matching process Our “cost” scheme 1 – if an element has to be shifted along the shorter string for better alignment Cost recorded in col 1 – if a new character is inserted Cost recorded in row 2 – different characters, shift and insert cost 2 0 – if elements are identical

The forward stage Fill the array from the upper left corner  The value of (x,y) is a function (min cost) of either  (x-1,y), (x-1,y-1), or (x, y-1)‏  If there is a match  Add 0 to (x-1,y-1)‏  If there is no match  Add 2 to (x-1,y-1)‏  If we shift  Add 1 to the previous column  If we insert a character  Add 1 to the previous row

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005 Fig 4.6The completed array reflecting the maximum alignment information for the strings. 7

The backward stage Once the matrix is filled  From the best alignment count, we produce a specific alignment of characters  Begin at the lower right-hand corner  Move back through the matrix  Each step, select one of the immediate state’s predecessors  (previous diagonal, row, or column)‏  Choose the minimum

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005 Fig 4.7A completed backward component of the dynamic programming example giving one (of several possible) string alignments. 8

Example #2 – Min Edit Distance Spell Checker  What words from our dictionary best approximate a word we do not recognize (misspelled word)‏  We need to know the “distance” between two words Minimum edit distance  The number of insertions, deletions and replacements to turn the source word into the target word

intention – source word execution – target word Our “cost”  1 for a character insertion or deletion  2 for a replacement (deletion + insertion)‏

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005 Fig 4.8Initialization of minimum edit difference matrix between intention and execution (adapted from Jurafsky and Martin, 2000). 9 Beginning state a sequence of insertions is needed beginning at null to make either word look like the other (2,2) is cost 2 because a replacement is required to make an i be an e

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005 Intention ntentiondelete I, cost 1 etentionreplace n with e, cost 2 exentionreplace t with x, cost 2 exenution insert u, cost 1 execution replace n with c, cost 2 Complete array of minimum edit difference between intention and execution (adapted from Jurafsky and Martin, 2000) (of several possible) string alignments. 11 The value at each (x,y) is the cost of minimum editing to that point, plus the minimum cost of either an insertion, deletion, or replacement In other words, cost of (x,y) is the minimum of Cost of (x-1,y) + insertion Cost of (x-1,y-1) + replacement Cost of (x, y-1) + deletion Finally, the backward part will select a list of optimal changes Bold text near the diagonal Not strictly required for spell-check case

Why Dynamic Programming? What’s the cost of DP?  n 2 where n is the size of the longest string  n 3 in the worst case if we need to consider other row/col values to determine the current state  What is the cost of exhaustive search?  Between 2 n and 3 n  Useful heuristics for DP  Usually the solution lies near the horizontal  Prune the considerations if the cost passes a predetermined threshold

Best-First Search Algorithm Need to have a good evaluation function  Avoid  Local maxima  Dead-ends  Anomalies in search space Return to general form of state space search algorithm  Lists  open – states we haven’t explored  closed – states we have explored  Now, order states in open according to some heuristic  Thus, each loop considers the most “promising” state first

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, Keeps track of ancestor information to ensure that we can check to see if state already reached and so we can return the chosen path at the end Can make use of a “priority queue”

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005 Fig 4.10Heuristic search of a hypothetical state space. 13 Notice how states are selected for next examination.

A trace of the execution of best_first_search for Figure 4.4 Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited,

Implementing Heuristic Evaluation Functions Evaluate the performance of heuristics for solving 8-puzzle. Ideas? 1. Count number of tiles out of place  Doesn’t consider how far out of place they are 2. Get a total distance out of place  But what if tiles are right next to each other but out of order  Very difficult to switch tiles

Examining these Heuristics Fig 4.12The start state, first moves, and goal state for an example-8 puzzle. Which seems closest?

What the Heuristics Give Us Fig 4.14Three heuristics applied to states in the 8-puzzle.

What if two states have (nearly) the same heuristic evaluation? The heuristic f applied to states in the 8-puzzle.

How Good is a Heuristic? Evaluated along several dimensions  Goals?  Guaranteed Solution?  Shortest Path?  Shortest path heuristics are said to be admissible  Better heuristics  Concept of informedness  When a state is found is there a guarantee that a better state won’t be found later in the search?  Concept of monotonicity

Admissibility Measures Admissible – guaranteed to find a minimal path to a solution if it exists  Example: BFS Use the function f(n) = g(n) + h(n)‏  f(n) = evaluation function  g(n) = actual length from any state n to the start state  h(n) = heuristic estimate from any state n to the goal

Using f(n) to discuss admissibility  f(n) estimates the total cost of the path from the start state through n to the goal state Define f*(n) = g*(n) + h*(n)‏  All the same, but now only dealing with the shortest path from start to n and from n to goal  f*(n) is often called an oracle  Often do not exist for most real problems  Still we want f to be a close estimate to f*

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited,

Examples BFS is an A* algorithm in which  f(n) = g(n) + 0  The decision for considering a state is based solely on the distance from the start state Several Heuristics from 8-Puzzle are A*  Can’t always compute value of h*(n), but we can bound a heuristic cost above by the actual shortest-path cost

A* Examples for 8-puzzle Counting the number of tiles out of place is always less than or equal to the number of moves to move them to their goal  Thus: heuristic is admissible The sum of the direct distances of tiles out of place is also less than or equal to the minimum actual path  Thus: heuristic is admissible

Monotonicity The definition of A* does not require that g(n) = g*(n)‏  So, A* algorithms may initially reach non-goal states along sub-optimal paths before eventually finding an optimal path Monotonicity – property that guarantees that the heuristic is “locally optimal”  Consistently follows only the optimal path

Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited,

Monotonicity is possible when:  Search space is everywhere locally consistent with the heuristic employed  The difference between a heuristic measure of a state and any of its successors is bound by the actual cost of moving from predecessor to successor states As the path is followed when using a monotone heuristic  value of f is monotonically nondecreasing (hence the name)‏

Monotonicity and Admissibility All monotone heuristics are admissible  In fact, monotonicity is a refinement of admissibility Not all admissible heuristics are monotone

Relatively Better Heuristics Informedness

Example BFS is equivalent to A* with heuristic h1 such that h1(x)=0 for all states x  This is always less than h*(x)‏ Lets call the number of tiles out of place, h2  This is also less than h* But, we have h1<=h2<=h*  Thus, h2 is “more informed” than h1 Additionally, we can argue that calculation of direct distance of out of place tiles is more informed than h2