Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.

Slides:



Advertisements
Similar presentations
Informed search algorithms
Advertisements

Heuristic Search Russell and Norvig: Chapter 4 Slides adapted from:
Informed search algorithms
Review: Search problem formulation
Heuristic Search. Best First Search A* Heuristic Search Heuristic search exploits additional knowledge about the problem that helps direct search to.
Informed search algorithms
An Introduction to Artificial Intelligence
Solving Problem by Searching
1 Heuristic Search Chapter 4. 2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*
Problem Solving by Searching
Review: Search problem formulation
Informed Search Methods Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 4 Spring 2005.
CS 460 Spring 2011 Lecture 3 Heuristic Search / Local Search.
Informed Search CSE 473 University of Washington.
Problem Solving and Search in AI Heuristic Search
CSC344: AI for Games Lecture 4: Informed search
Informed Search Chapter 4 Adapted from materials by Tim Finin, Marie desJardins, and Charles R. Dyer CS 63.
Heuristic (Informed) Search (Where we try to be smarter in how we choose among alternatives) R&N III: Chapter 3.5 R&N II: Chap. 4, Sect. 4.1–3.
Russell and Norvig: Chapter 4 CSMSC 421 – Fall 2005
Rutgers CS440, Fall 2003 Heuristic search Reading: AIMA 2 nd ed., Ch
1 Midterm Review cmsc421 Fall Outline Review the material covered by the midterm Questions?
Informed Search Idea: be smart about what paths to try.
Informed search algorithms
Vilalta&Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
Informed Search Chapter 4 (b)
INTRODUÇÃO AOS SISTEMAS INTELIGENTES Prof. Dr. Celso A.A. Kaestner PPGEE-CP / UTFPR Agosto de 2011.
CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #3 Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam.
Informed State Space Search Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
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.
1 Artificial Intelligence CS 165A Tuesday, October 16, 2007  Informed (heuristic) search methods (Ch 4) 1.
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 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.
Informed Search Include specific knowledge to efficiently conduct the search and find the solution.
For Wednesday Read chapter 6, sections 1-3 Homework: –Chapter 4, exercise 1.
For Wednesday Read chapter 5, sections 1-4 Homework: –Chapter 3, exercise 23. Then do the exercise again, but use greedy heuristic search instead of A*
Princess Nora University Artificial Intelligence Chapter (4) Informed search algorithms 1.
CSC3203: AI for Games Informed search (1) Patrick Olivier
1 Heuristic (Informed) Search (Where we try to choose smartly) R&N: Chap. 4, Sect. 4.1–3.
1 CS B551: Elements of Artificial Intelligence Instructor: Kris Hauser
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 algorithms Chapter 4 Slides derived in part from converted to powerpoint by Min-Yen.
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.
Heuristic Search Foundations of Artificial Intelligence.
Searching for Solutions
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.
Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 CS121 – Winter 2003.
Informed Search. S B AD E C F G straight-line distances h(S-G)=10 h(A-G)=7 h(D-G)=1 h(F-G)=1 h(B-G)=10 h(E-G)=8 h(C-G)=20 The graph above.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
Informed Search Chapter 4 (b)
Informed Search Chapter 4 (b)
Artificial Intelligence Problem solving by searching CSC 361
Discussion on Greedy Search and A*
Discussion on Greedy Search and A*
CS 4100 Artificial Intelligence
Artificial Intelligence Informed Search Algorithms
Informed Search Chapter 4 (b)
Artificial Intelligence
Heuristic (Informed) Search (Where we try to choose smartly) R&N: Chap
Artificial Intelligence
Presentation transcript:

Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #4

When to Use Search Techniques? The search space is small, and –There is no other available techniques, or –It is not worth the effort to develop a more efficient technique The search space is large, and –There is no other available techniques, and –There exist “good” heuristics

Models, |=, math proofs Alpha |= Beta –Alpha, Beta – propositional formulas –M |= Alpha “M models Alpha” means “Alpha evaluated to TRUE in model M” Math. Proofs: example –A  B |= A –(another one later in today’s class)

Search Algorithms Blind search – BFS, DFS, ID, uniform cost –no notion concept of the “right direction” –can only recognize goal once it’s achieved Heuristic search – we have rough idea of how good various states are, and use this knowledge to guide our search

Types of heuristic search Best First –A* is a special case –BFS is a special case ID A* –ID is a special case Hill climbing Simulated Annealing

A* Example: 8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

ID A*: 8-Puzzle Example 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=4

ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 4 6 Cutoff=4 6 5 ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 4 6 Cutoff= ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 4 6 Cutoff= ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 6 Cutoff=5 ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 4 6 Cutoff=5 6 ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 4 6 Cutoff=5 6 5 ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 4 6 Cutoff= ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 4 6 Cutoff= ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 4 6 Cutoff= ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

4 4 6 Cutoff= ID A*: 8-Puzzle Example f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

Hill climbing example start goal -5 h = -3 h = -2 h = -1 h = 0 h = f(n) = -(number of tiles out of place)

Best-first search Idea: use an evaluation function f(n) for each node n Expand unexpanded node n with min f(n) Implementation: FRINGE is queue sorted by decreasing order of desirability –Greedy search –A* search

Greedy Search h(n) – a ‘heuristic’ function estimating the distance to the goal Greedy Best First: expand argmin_n h(n) thus,f(v) = h(v)

Informed Search Add domain-specific information to select the best path along which to continue searching h(n) = estimated cost (or distance) of minimal cost path from n to a goal state. The heuristic function is an estimate, based on domain-specific information that is computable from the current state description, of how close we are to a goal

Robot Navigation

f(N) = h(N), with h(N) = Manhattan distance to the goal

Robot Navigation f(N) = h(N), with h(N) = Manhattan distance to the goal 7 0 What happened???

Greedy Search f(N) = h(N)  greedy best-first Is it complete? If we eliminate endless loops, yes Is it optimal?

More informed search Our goal is not to minimize the distance from the current head of our path to the goal, we want to minimize the overall length of the path to the goal! Let g(N) be the cost of the best path found so far between the initial node and N f(N) = g(N) + h(N)

Robot Navigation f(N) = g(N)+h(N), with h(N) = Manhattan distance to goal

Can we Prove Anything? If the state space is finite and we avoid repeated states, the search is complete, but in general is not optimal Proof: ? If the state space is finite and we do not avoid repeated states, the search is in general not complete

Admissible heuristic Let h*(N) be the true cost of the optimal path from N to a goal node Heuristic h(N) is admissible if: 0  h(N)  h*(N) An admissible heuristic is always optimistic

A* Search Evaluation function: f(N) = g(N) + h(N) where: –g(N) is the cost of the best path found so far to N –h(N) is an admissible heuristic Then, best-first search with this evaluation function is called A* search Important AI algorithm developed by Fikes and Nilsson in early 70s. Originally used in Shakey robot.

Completeness & Optimality of A* Claim 1: If there is a path from the initial to a goal node, A* (with no removal of repeated states) terminates by finding the best path, hence is: –complete –optimal requirements: –0 <   c(N,N’) - c(N,N’) – cost of going from N to N’

Completeness of A* Theorem: If there is a finite path from the initial state to a goal node, A* will find it.

Proof of Completeness Intuition (not math. Proof): Let g be the cost of a best path to a goal node No path in search tree can get longer than g/ , before the goal node is expanded

Optimality of A* Theorem: If h(n) is admissable, then A* is optimal (finds an optimal path).

Proof of Optimality G1G1 N G2G2 f(G 1 ) = g(G 1 ) f(N) = g(N) + h(N)  g(N) + h*(N) f(G 1 )  g(N) + h(N)  g(N) + h*(N) Cost of best path to a goal thru N

Example of Evaluation Function f(N) = (sum of distances of each tile to its goal) + 3 x (sum of score functions for each tile) where score function for a non-central tile is 2 if it is not followed by the correct tile in clockwise order and 0 otherwise N goal f(N) = x( ) = 49

Heuristic Function Function h(N) that estimates the cost of the cheapest path from node N to goal node. Example: 8-puzzle N goal h(N) = number of misplaced tiles = 6

Heuristic Function Function h(N) that estimate the cost of the cheapest path from node N to goal node. Example: 8-puzzle N goal h(N) = sum of the distances of every tile to its goal position = = 13

8-Puzzle f(N) = h(N) = number of misplaced tiles

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

8-Puzzle f(N) = h(N) =  distances of tiles to goal

8-Puzzle Ngoal h 1 (N) = number of misplaced tiles = 6 is admissible h 2 (N) = sum of distances of each tile to goal = 13 is admissible h 3 (N) = (sum of distances of each tile to goal) + 3 x (sum of score functions for each tile) = 49 is not admissible

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

Robot navigation Cost of one horizontal/vertical step = 1 Cost of one diagonal step =  2 f(N) = g(N) + h(N), with h(N) = straight-line distance from N to goal

About Repeated States NN1N1 SS1S1 f(N)=g(N)+h(N) f(N 1 )=g(N 1 )+h(N 1 ) g(N 1 ) < g(N) h(N) < h(N 1 ) f(N) < f(N 1 ) N2N2 f(N 2 )=g(N 2 )+h(N) g(N 2 ) < g(N)

Consistent Heuristic The admissible heuristic h is consistent (or satisfies the monotone restriction) if for every node N and every successor N’ of N: h(N)  c(N,N’) + h(N’) (triangle inequality) N N’ h(N) h(N’) c(N,N’)

8-Puzzle Ngoal h 1 (N) = number of misplaced tiles h 2 (N) = sum of distances of each tile to goal are both consistent

Robot navigation Cost of one horizontal/vertical step = 1 Cost of one diagonal step =  2 h(N) = straight-line distance to the goal is consistent

Claims If h is consistent, then the function f along any path is non-decreasing: f(N) = g(N) + h(N) f(N’) = g(N) +c(N,N’) + h(N’) N N’ h(N) h(N’) c(N,N’)

Claims If h is consistent, then the function f along any path is non-decreasing: f(N) = g(N) + h(N) f(N’) = g(N) +c(N,N’) + h(N’) h(N)  c(N,N’) + h(N’) f(N)  f(N’) N N’ h(N) h(N’) c(N,N’)

Claims If h is consistent, then the function f along any path is non-decreasing: f(N) = g(N) + h(N) f(N’) = g(N) +c(N,N’) + h(N’) h(N)  c(N,N’) + h(N’) f(N)  f(N’) If h is consistent, then whenever A* expands a node it has already found an optimal path to the state associated with this node N N’ h(N) h(N’) c(N,N’)

Avoiding Repeated States in A* If the heuristic h is consistent, then: Let CLOSED be the list of states associated with expanded nodes When a new node N is generated: –If its state is in CLOSED, then discard N –If it has the same state as another node in the fringe, then discard the node with the largest f

Complexity of Consistent A* Let s be the size of the state space Let r be the maximal number of states that can be attained in one step from any state Assume that the time needed to test if a state is in CLOSED is O(1) The time complexity of A* is O(s r log s)

Heuristic Accuracy h(N) = 0 for all nodes is admissible and consistent. Hence, breadth-first is a special case of A* !!! Let h 1 and h 2 be two admissible and consistent heuristics such that for all nodes N: h 1 (N)  h 2 (N). Then, every node expanded by A* using h 2 is also expanded by A* using h 1. h 2 is more informed than h 1

Iterative Deepening A* (IDA*) Use f(N) = g(N) + h(N) with admissible and consistent h Each iteration is depth-first with cutoff on the value of f of expanded nodes

8-Puzzle 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=4

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=4 6

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=4 6 5

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=

4 8-Puzzle 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=

8-Puzzle 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5 6

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5 6 5

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5 6 57

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=

8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=

About Heuristics Heuristics are intended to orient the search along promising paths The time spent computing heuristics must be recovered by a better search After all, a heuristic function could consist of solving the problem; then it would perfectly guide the search Deciding which node to expand is sometimes called meta-reasoning Heuristics may not always look like numbers and may involve large amount of knowledge

What’s the Issue? Search is an iterative local procedure Good heuristics should provide some global look-ahead (at low computational cost)

Another approach… for optimization problems –rather than constructing an optimal solution from scratch, start with a suboptimal solution and iteratively improve it Local Search Algorithms –Hill-climbing or Gradient descent –Potential Fields –Simulated Annealing –Genetic Algorithms, others…

Hill-climbing search If there exists a successor s for the current state n such that –h(s) < h(n) –h(s) <= h(t) for all the successors t of n, then move from n to s. Otherwise, halt at n. Looks one step ahead to determine if any successor is better than the current state; if there is, move to the best successor. Similar to Greedy search in that it uses h, but does not allow backtracking or jumping to an alternative path since it doesn’t “remember” where it has been. Not complete since the search will terminate at "local minima," "plateaus," and "ridges."

Hill climbing on a surface of states Height Defined by Evaluation Function

Hill climbing Steepest descent (~ greedy best-first with no search)  may get stuck into local minimum

Robot Navigation f(N) = h(N) = straight distance to the goal Local-minimum problem

Examples of problems with HC applet

Drawbacks of hill climbing Problems: –Local Maxima: peaks that aren’t the highest point in the space –Plateaus: the space has a broad flat region that gives the search algorithm no direction (random walk) –Ridges: flat like a plateau, but with dropoffs to the sides; steps to the North, East, South and West may go down, but a step to the NW may go up. Remedy: –Introduce randomness Random restart. Some problem spaces are great for hill climbing and others are terrible.

What’s the Issue? Search is an iterative local procedure Good heuristics should provide some global look-ahead (at low computational cost)

Hill climbing example start goal -5 h = -3 h = -2 h = -1 h = 0 h = f(n) = -(number of tiles out of place)

Example of a local maximum startgoal

Potential Fields Idea: modify the heuristic function Goal is gravity well, drawing the robot toward it Obstacles have repelling fields, pushing the robot away from them This causes robot to “slide” around obstacles Potential field defined as sum of attractor field which get higher as you get closer to the goal and the indivual obstacle repelling field (often fixed radius that increases exponentially closer to the obstacle)

Does it always work? No. But, it often works very well in practice Advantage #1: can search a very large search space without maintaining fringe of possiblities Scales well to high dimensions, where no other methods work Example: motion planning Advantage #2: local method. Can be done online

Example: RoboSoccer All robots have same field: attracted to the ball Repulsive potential to other players Kicking field: attractive potential to the ball and local repulsive potential if clase to the ball, but not facing the direction of the opponent’s goal. Result is tangent, player goes around the ball. Single team: kicking field + repulsive field to avoid hitting other players + player position fields (paraboilic if outside your area of the field, 0 inside). Player nearest to the ball has the largest attractive coefficient, avoids all players crowding the ball. Two teams: identical potential fields.

Simulated annealing Simulated annealing (SA) exploits an analogy between the way in which a metal cools and freezes into a minimum-energy crystalline structure (the annealing process) and the search for a minimum [or maximum] in a more general system. SA can avoid becoming trapped at local minima. SA uses a random search that accepts changes that increase objective function f, as well as some that decrease it. SA uses a control parameter T, which by analogy with the original application is known as the system “temperature.” T starts out high and gradually decreases toward 0.

Simulated annealing (cont.) A “bad” move from A to B is accepted with a probability (f(B)-f(A)/T) e The higher the temperature, the more likely it is that a bad move can be made. As T tends to zero, this probability tends to zero, and SA becomes more like hill climbing If T is lowered slowly enough, SA is complete and admissible.

The simulated annealing algorithm

Summary: Local Search Algorithms Steepest descent (~ greedy best-first with no search)  may get stuck into local minimum Better Heuristics: Potential Fields Simulated annealing Genetic algorithms

When to Use Search Techniques? The search space is small, and –There is no other available techniques, or –It is not worth the effort to develop a more efficient technique The search space is large, and –There is no other available techniques, and –There exist “good” heuristics

Summary Heuristic function Best-first search Admissible heuristic and A* A* is complete and optimal Consistent heuristic and repeated states Heuristic accuracy IDA*

Modified Search Algorithm 1.INSERT(initial-node,FRINGE) 2.Repeat: If FRINGE is empty then return failure n  REMOVE(FRINGE) s  STATE(n) If GOAL?(s) then return path or goal state For every state s’ in SUCCESSORS(s)  Create a node n’  INSERT(n’,FRINGE)