Heuristic (Informed) Search (Where we try to choose smartly)

Similar documents
AI: A Modern Approach, Chpts. 3-4 Russell and Norvig

Informed search algorithms. Chapter 4, Sections 1 2 1

Smart Graphics: Methoden 3 Suche, Constraints

Measuring the Performance of an Agent

Approximation Algorithms

CS MidTerm Exam 4/1/2004 Name: KEY. Page Max Score Total 139

Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

2. Length and distance in hyperbolic geometry

Search methods motivation 1

An Introduction to The A* Algorithm

Applied Algorithm Design Lecture 5

The Graphical Method: An Example

CMPSCI611: Approximating MAX-CUT Lecture 20

Graph Theory Problems and Solutions

SIMS 255 Foundations of Software Design. Complexity and NP-completeness

(Refer Slide Time: 2:03)

CSC2420 Fall 2012: Algorithm Design, Analysis and Theory

1 The Brownian bridge construction

6.3 Conditional Probability and Independence

Data Mining Practical Machine Learning Tools and Techniques

ECON 459 Game Theory. Lecture Notes Auctions. Luca Anderlini Spring 2015

Offline sorting buffers on Line

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 313]

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Modern Optimization Methods for Big Data Problems MATH11146 The University of Edinburgh

Problem solving and search

Branch-and-Price Approach to the Vehicle Routing Problem with Time Windows

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

Testing LTL Formula Translation into Büchi Automata

From Last Time: Remove (Delete) Operation

Load Balancing. Load Balancing 1 / 24

DEVELOPMENT OF A VULNERABILITY ASSESSMENT CODE FOR A PHYSICAL PROTECTION SYSTEM: SYSTEMATIC ANALYSIS OF PHYSICAL PROTECTION EFFECTIVENESS (SAPE)

Mathematical Induction

Lecture 3: Finding integer solutions to systems of linear equations

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

Clock Arithmetic and Modular Systems Clock Arithmetic The introduction to Chapter 4 described a mathematical system

Special Situations in the Simplex Algorithm

Y. Xiang, Constraint Satisfaction Problems

Information Retrieval and Web Search Engines

Introduction to Scheduling Theory

Enumerating possible Sudoku grids

Programming Using Python

Decision Trees from large Databases: SLIQ

Lecture. Simulation and optimization

Network (Tree) Topology Inference Based on Prüfer Sequence

7 Gaussian Elimination and LU Factorization

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

Analysis of Algorithms, I

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

Lecture 4 Online and streaming algorithms for clustering

1 Solving LPs: The Simplex Algorithm of George Dantzig

3 Some Integer Functions

The Taxman Game. Robert K. Moniot September 5, 2003

Follow the Perturbed Leader

Self Organizing Maps: Fundamentals

Linear Programming. March 14, 2014

1 if 1 x 0 1 if 0 x 1

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Big Data - Lecture 1 Optimization reminders

Analysis of Micromouse Maze Solving Algorithms

Problem Set 7 Solutions

LEARNING OBJECTIVES FOR THIS CHAPTER

Scenario: Optimization of Conference Schedule.

Introduction Solvability Rules Computer Solution Implementation. Connect Four. March 9, Connect Four

Dynamic Programming. Lecture Overview Introduction

Three Effective Top-Down Clustering Algorithms for Location Database Systems

Notes from Week 1: Algorithms for sequential prediction

Kenken For Teachers. Tom Davis June 27, Abstract

Metric Spaces. Chapter 1

Cpt S 223. School of EECS, WSU

Complete Solution of the Eight-Puzzle and the Benefit of Node Ordering in IDA*

M. Sugumaran / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 2 (3), 2011,

Lecture 5 - CPA security, Pseudorandom functions

APP INVENTOR. Test Review

Chapter 13: Binary and Mixed-Integer Programming

Practical Guide to the Simplex Method of Linear Programming

Concurrency Control. Chapter 17. Comp 521 Files and Databases Fall

Data Structures Fibonacci Heaps, Amortized Analysis

Roulette Wheel Selection Game Player

Robot Navigation. Johannes Maurer, Institute for Software Technology TEDUSAR Summerschool u

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Classification - Examples

Dynamic programming formulation

A hierarchical multicriteria routing model with traffic splitting for MPLS networks

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Introduction to Markov Chain Monte Carlo

Methods for Solving Sudoku Puzzles

Part 2: Community Detection

Outline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb

The vehicle routing problem with time windows is a hard combinatorial optimization problem that has

B490 Mining the Big Data. 2 Clustering

Transcription:

Heuristic (Informed) Search (Where we try to choose smartly) R&: Chap., Sect.. Recall that the ordering of FRIGE defines the search strategy Search Algorithm # SEARCH#. ISERT(initial-node,FRIGE). Repeat: a. If empty(frige) then return failure b. REMOVE(FRIGE) c. s STATE() d. If GOAL?(s) then return path or goal state e. For every state s in SUCCESSORS(s) i. Create a node as a successor of ii. ISERT(,FRIGE) Best-First Search It exploits state description to estimate how good each search node is An evaluation function f maps each node of the search tree to a real number f() 0 [Traditionally, f() is an estimated cost; so, the smaller f(), the more promising ] Best-first search sorts the FRIGE in increasing f [Arbitrary order is assumed among nodes with equal f] Best-First Search It exploits state description to estimate how good each search node is An evaluation function f maps each node of the search tree to a real number Best does not refer to the quality f() 0 of the generated path [Traditionally, f() is an estimated cost; so, the smaller f(), the more promising Best-first ] search does not generate optimal paths in general Best-first search sorts the FRIGE in increasing f [Arbitrary order is assumed among nodes with equal f] How to construct f? Typically, f() estimates: either the cost of a solution path through Then, where g() is the cost of the path from the initial node to h() is an estimate of the cost of a path from to a goal node or the cost of a path from to a goal node Then f() = h() Greedy best-search But there are no limitations on f. Any function of your choice is acceptable. But will it help the search algorithm? How to construct f? Typically, f() estimates: either the cost of a solution path through Then, where g() is the cost of the path from the initial node to h() is an estimate of the cost of a path from to a goal node or the cost of a path from to a goal node Then f() = h() Heuristic function But there are no limitations on f. Any function of your choice is acceptable. But will it help the search algorithm?

Heuristic Function The heuristic function h() 0 estimates the cost to go from STATE() to a goal state Its value is independent of the current search tree; it depends only on STATE() and the goal test GOAL? Example: STATE() h () = number of misplaced numbered tiles = [Why is it an estimate of the distance to the goal?] Goal state Other Examples STATE() Goal state h () = number of misplaced numbered tiles = h () = sum of the (Manhattan) distance of every numbered tile to its goal position = + + 0 + + + 0 + + = h () = sum of permutation inversions = n + n + n + n + n + n + n + n = + + + + 0 + + 0 + 0 = -Puzzle f() = h() = number of misplaced numbered tiles -Puzzle with h() = number of misplaced numbered tiles + + + + + 0 0+ + + + + + +0 + + The white tile is the empty tile 9 0 -Puzzle f() = h() = Σ distances of numbered tiles to their goals Robot avigation y 0 y g h () = (x -x ) +(y -y ) (L or Euclidean distance) g g h () = x -x g + y -y g x x g (L or Manhattan distance)

Best-First Efficiency Local-minimum problem Can we prove anything? If the state space is infinite, in general the search is not complete If the state space is finite and we do not discard nodes that revisit states, in general the search is not complete If the state space is finite and we discard nodes that revisit states, the search is complete, but in general is not optimal f() = h() = straight distance to the goal Admissible Heuristic Admissible Heuristic Let h*() be the cost of the optimal path from to a goal node The heuristic function h() is admissible if: 0 h() h*() An admissible heuristic function is always optimistic! Let h*() be the cost of the optimal path from to a goal node The heuristic function h() is admissible if: 0 h() h*() An admissible heuristic function is always optimistic! G is a goal node h(g) = 0 -Puzzle Heuristics -Puzzle Heuristics STATE() Goal state STATE() Goal state h () = number of misplaced tiles = is??? h () = sum of the (Manhattan) distances of every tile to its goal position = + + 0 + + + 0 + + = is admissible h () = sum of permutation inversions = + + + + 0 + + 0 + 0 = is not admissible h () = number of misplaced tiles = is admissible h () = sum of the (Manhattan) distances of every tile to its goal position = + + 0 + + + 0 + + = is??? h () = sum of permutation inversions = + + + + 0 + + 0 + 0 = is not admissible

-Puzzle Heuristics -Puzzle Heuristics STATE() Goal state STATE() Goal state h () = number of misplaced tiles = is admissible h () = sum of the (Manhattan) distances of every tile to its goal position = + + 0 + + + 0 + + = is admissible h () = sum of permutation inversions = + + + + 0 + + 0 + 0 = is??? 9 h () = number of misplaced tiles = is admissible h () = sum of the (Manhattan) distances of every tile to its goal position = + + 0 + + + 0 + + = is admissible h () = sum of permutation inversions = + + + + 0 + + 0 + 0 = is not admissible 0 Robot avigation Heuristics Robot avigation Heuristics Cost of one horizontal/vertical step = Cost of one diagonal step = Cost of one horizontal/vertical step = Cost of one diagonal step = h () = (x -x ) +(y -y ) is admissible g g h () = x -x g + y -y g is??? Robot avigation Heuristics How to create an admissible h? Cost of one horizontal/vertical step = Cost of one diagonal step = h () = x -x g + y -y g h*(i) = h (I) = is admissible if moving along diagonals is not allowed, and not admissible otherwise An admissible heuristic can usually be seen as the cost of an optimal solution to a relaxed problem (one obtained by removing constraints) In robot navigation: The Manhattan distance corresponds to removing the obstacles The Euclidean distance corresponds to removing both the obstacles and the constraint that the robot moves on a grid More on this topic later

A* Search (most popular algorithm in AI) ), where: g() = cost of best path found so far to h() = admissible heuristic function ) for all arcs: c(, ) ε > 0 Result # A* is complete and optimal [This result holds if nodes revisiting states are not discarded] ) SEARCH# algorithm is used Best-first search is then called A* search Proof (/) ) If a solution exists, A* terminates and returns a solution Proof (/) ) If a solution exists, A* terminates and returns a solution - For each node on the fringe, f() = g()+h() g() d() ε, where d() is the depth of in the tree K - For each node on the fringe, f() = g()+h() g() d() ε, where d() is the depth of in the tree - As long as A* hasn t terminated, a node K on the fringe lies on a solution path Proof (/) ) If a solution exists, A* terminates and returns a solution K - For each node on the fringe, f() = g()+h() g() d() ε, where d() is the depth of in the tree - As long as A* hasn t terminated, a node K on the fringe lies on a solution path - Since each node expansion increases the length of one path, K will eventually be selected for expansion, unless a solution is found along another path 9 Proof (/) ) Whenever A* chooses to expand a goal node, the path to this node is optimal - C*= cost of the optimal solution path - G : non-optimal goal node in the fringe f(g ) = g(g ) + h(g ) = g(g ) > C* G K - A node K in the fringe lies on an optimal path: f(k) = g(k) + h(k) C* - So, G will not be selected for expansion 0

Time Limit Issue When a problem has no solution, A* runs for ever if the state space is infinite. In other cases, it may take a huge amount of time to terminate So, in practice, A* is given a time limit. If it has not found a solution within this limit, it stops. Then there is no way to know if the problem has no solution, or if more time was needed to find it When AI systems are small and solving a single search problem at a time, this is not too much of a concern. When AI systems become larger, they solve many search problems concurrently, some with no solution. What should be the time limit for each of them? More on this in the lecture on Motion Planning... + -Puzzle 0+ + + + + + + + + + + + +0 Robot avigation Robot avigation f() = h(), with h() = Manhattan distance to the goal (not A*) 0 Robot avigation Robot avigation f() = h(), with h() = Manhattan distance to the goal (not A*) 0 f() = g()+h(), with h() = Manhattan distance to goal (A*) + + + + + + + +9 +0 + + + + + +9 +0 0+ 0 +0 + + + + + + + + +

Best-First Search An evaluation function f maps each node of the search tree to a real number f() 0 Best-first search sorts the FRIGE in increasing f A* Search ), where: g() = cost of best path found so far to h() = admissible heuristic function ) for all arcs: c(, ) ε > 0 ) SEARCH# algorithm is used Best-first search is then called A* search Result # What to do with revisited states? A* is complete and optimal [This result holds if nodes revisiting states are not discarded] c = h = 00 The heuristic h is clearly admissible 90 00 0 9 0 What to do with revisited states? What to do with revisited states? c = h = 00 f = +00 + 90 00 0? +90 0 If we discard this new node, then the search algorithm expands the goal node next and returns a non-optimal solution 00 +00 + 90 00 0 +90 0 +90 0 Instead, if we do not discard nodes revisiting states, the search terminates with an optimal solution

But... If we do not discard nodes revisiting states, the size of the search tree can be exponential in the number of visited states But... If we do not discard nodes revisiting states, the size of the search tree can be exponential in the number of visited states + + + + + + + + + + + + n+ states O( n ) nodes It is not harmful to discard a node revisiting a state if the cost of the new path to this state is cost of the previous path [so, in particular, one can discard a node if it re-visits a state already visited by one of its ancestors] A* remains optimal, but states can still be re- visited multiple times [the size of the search tree can still be exponential in the number of visited states] Fortunately, for a large family of admissible heuristics consistent heuristics there is a much more efficient way to handle revisited states Consistent Heuristic An admissible heuristic h is consistent (or monotone) if for each node and each child of : c(, ) h() c(, ) + h( ) h() h( ) (triangle inequality) Intuition: a consistent heuristics becomes more precise as we get deeper in the search tree Consistency Violation If h tells that is 00 units from the goal, then moving from along an arc costing 0 units should not lead to a node that h estimates to be 0 units away from the goal c(, ) =0 h() =00 h( ) =0 (triangle inequality) Consistent Heuristic (alternative definition) A heuristic h is consistent (or monotone) if ) for each node and each child of : h() c(, ) + h( ) c(, ) ) for each goal node G: h() h(g) = 0 h( ) A consistent heuristic (triangle inequality) is also admissible

Admissibility and Consistency A consistent heuristic is also admissible An admissible heuristic may not be consistent, nt but many admissible heuristics s are consistent c(, ) h() h( ) h() c(, ) + h( ) -Puzzle STATE() goal h () = number of misplaced tiles h () = sum of the (Manhattan) distances of every tile to its goal position are both consistent (why?) 9 0 c(, ) h() h( ) Robot avigation Result # If h is consistent, then whenever A* expands a node, it has already found an optimal path to this node s state h() c(, ) + h( ) Cost of one horizontal/vertical step = Cost of one diagonal step = h () = (x -x ) +(y -y ) h () = x -x g + y -y g g g is consistent is consistent if moving along diagonals is not allowed, and not consistent otherwise Proof (/) ) Consider a node and its child Since h is consistent: h() c(, )+h( ) f() = g()+h() g()+c(, )+h( ) = f( ) So, f is non-decreasing along any path Proof (/) ) If a node K is selected for expansion, then any other node in the fringe verifies f() f(k) K S If one node lies on another path to the state of K, the cost of this other path is no smaller than that of the path to K: f( ) f() f(k) and h( ) = h(k) So, g( ) g(k) 9

Proof (/) Result # If h is consistent, then whenever A* expands a ) If node, a node it K has is already selected found for expansion, optimal then path any to this other node node s in state the fringe verifies f() f(k) K S If one node lies on another path to the state of K, the cost of this other path is no smaller than that of the path to K: f( ) f() f(k) and h( ) = h(k) So, g( ) g(k) The path to is the optimal path to S Implication of Result # S S can be discarded Revisited States with Consistent Heuristic When a node is expanded, store its state into CLOSED When a new node is generated: If STATE() is in CLOSED, discard If there exists a node in the fringe such that STATE( ) = STATE(), discard the node or with the largest f (or, equivalently, g) Is A* with some consistent heuristic all that we need? o! There are very dumb consistent heuristic functions For example: h 0 It is consistent (hence, admissible)! A* with h 0 is uniform-cost search Breadth-first t and uniform-cost are particular cases of A* Heuristic Accuracy Let h and h be two consistent heuristics such that for all nodes : h () h () h is said to be more accurate (or more informed) than h STATE() Goal state h () = number of misplaced tiles h () = sum of distances of every tile to its goal position 9 h is more accurate than h 0 0

Result # Let h be more accurate than h Let A * be A* using h and A * be A* using h Whenever a solution exists, all the nodes expanded by A *, except possibly for some nodes such that f () = f () = C* (cost of optimal solution) are also expanded by A * Proof C* = h*(initial-node) [cost of optimal solution] Every node such that f() < C* is eventually expanded. o node such that f() > C* is ever expanded Every node such that h() < C* g() is eventually expanded. So, every node such that h () < C* g() is expanded by A *. Since h () h (), is also expanded by A * If there are several nodes such that f () = f () = C* (such nodes include the optimal goal nodes, if there exists a solution), A * and A * may or may not expand them in the same order (until one goal node is expanded) Effective Branching Factor It is used as a measure the effectiveness of a heuristic Let n be the total number of nodes expanded by A* for a particular problem and d the depth of the solution The effective branching factor b* is defined by n = + b* + (b*) +...+ (b*) d Experimental Results (see R& for details) -puzzle with: h = number of misplaced tiles h = sum of distances of tiles to their goal positions Random generation of many problem instances Average effective branching factors (number of expanded d nodes): d IDS A * A *..9.9...0. (,,0). (). () --.. 0 --.. --. (9,). (,) How to create good heuristics? By solving relaxed problems at each node In the -puzzle, the sum of the distances of each tile to its goal position (h ) corresponds to solving simple problems: d i is the length of the shortest path to move tile i to its goal position, ignoring the other tiles, e.g., d = h = Σ i=,... d i Can we do better? For example, we could consider two more complex relaxed problems: d = length of the shortest path to move tiles,,, and to their goal positions, ignoring the other tiles h = d + d [disjoint pattern heuristic] d It ignores negative interactions among tiles

Can we do better? For example, we could consider two more complex relaxed problems: Can we do better? For example, we could consider two more complex relaxed problems: d = length of the shortest path to move tiles,,, and to their goal positions, ignoring the other tiles d d = length of the shortest path to move tiles,,, and to their goal positions, ignoring the other tiles d h = d + d [disjoint pattern heuristic] How to compute d and d? h = d + d [disjoint pattern heuristic] These distances are pre-computed and stored [Each requires generating a tree of,0 nodes/states (breadth-first search)] Can we do better? For example, we could consider two more complex relaxed problems: d = length of the shortest path to move tiles,,, and to their goal positions, ignoring the other tiles Several order-of-magnitude speedups d for the - and -puzzle (see R&) h = d + d [disjoint pattern heuristic] These distances are pre-computed and stored [Each requires generating a tree of,0 nodes/states (breadth-first search)] On Completeness and Optimality A* with a consistent heuristic function has nice properties: completeness, optimality, no need to revisit states Theoretical completeness does not mean practical completeness if you must wait too long to get a solution (remember the time limit issue) So, if one can t design an accurate consistent heuristic, it may be better to settle for a non-admissible heuristic that works well in practice, even through completeness and optimality are no longer guaranteed 0 Iterative Deepening A* (IDA*) Idea: Reduce memory requirement of A* by applying cutoff on values of f Consistent heuristic function h Algorithm IDA*:. Initialize cutoff to f(initial-node). Repeat: a. Perform depth-first search by expanding all nodes such that f() cutoff b. Reset cutoff to smallest value f of nonexpanded (leaf) nodes -Puzzle Cutoff=

-Puzzle -Puzzle Cutoff= Cutoff= -Puzzle -Puzzle Cutoff= Cutoff= -Puzzle -Puzzle Cutoff= Cutoff=

-Puzzle -Puzzle Cutoff= Cutoff= 9 0 -Puzzle -Puzzle Cutoff= Cutoff= -Puzzle Cutoff= Advantages/Drawbacks of IDA* Advantages: Still complete and optimal Requires less memory than A* Avoid the overhead to sort the fringe Drawbacks: Can t avoid revisiting states not on the current path Available memory is poorly used ( memory-bounded search, see R& p. 0-0)

Local Search Light-memory search method o search tree; only the current state is represented! Only applicable to problems where the path is irrelevant (e.g., -queen), unless the path is encoded in the state Many similarities with optimization techniques Steepest Descent ) S initial state ) Repeat: a) S arg min S SUCCESSORS(S) {h(s )} b) if GOAL?(S ) return S c) if h(s ) < h(s) then S S else return failure Similar to: - hill climbing with h - gradient descent over continuous space Application: -Queen Repeat n times: ) Pick an initial state S at random with one queen in each column ) Repeat k times: a) If GOAL?(S) then return S b) Pick an attacked queen Q at random c) Move Q in its column to minimize the number of attacking queens new S [min-conflicts heuristic] ) Return failure 0 Application: -Queen Why does it work??? Repeat n times: ) ) Pick There an initial are state many S at random goal states with one that queen in are each column ) Repeat k times: well-distributed over the state space a) If GOAL?(S) then return S ) If no solution has been found after a few b) Pick an attacked queen Q at random c) steps, Move Qit s in its better column to minimize start it the all number over of again. attacking queens is minimum new S Building a search tree would be much less efficient because of the high branching factor ) Running time almost independent 0 of the number of queens Steepest Descent ) S initial state ) Repeat: a) S arg min S SUCCESSORS(S) {h(s )} b) if GOAL?(S ) return S c) if h(s ) < h(s) then S S else return failure may easily get stuck in local minima Random restart (as in n-queen example) Monte Carlo descent 9 Monte Carlo Descent ) S initial state ) Repeat k times: a) If GOAL?(S) then return S b) S successor of S picked at random c) if h(s ) h(s) then S S d) else - Δh = h(s )-h(s) - with probability ~ exp( Δh/T), where T is called the temperature, do: S S [Metropolis criterion] ) Return failure Simulated annealing lowers T over the k iterations. It starts with a large T and slowly decreases T 90

Parallel Local Search Techniques They perform several local searches concurrently, but not independently: Beam search Genetic algorithms Search problems Blind search Heuristic search: best-first and A* See R&, pages -9 Construction of heuristics Variants of A* Local search 9 9 When to Use Search Techniques? ) The search space is small, and o other technique is available, or Developing a more efficient technique is not worth the effort ) The search space is large, and o other available technique is available, and There exist good heuristics 9