Heuristic search
This presentation is the property of its rightful owner.
Sponsored Links
1 / 71

Heuristic Search PowerPoint PPT Presentation


  • 44 Views
  • Uploaded on
  • Presentation posted in: General

Heuristic Search. Russell and Norvig: Chapter 4 CSMSC 421 – Fall 2005. Modified Search Algorithm. INSERT( initial-node,FRINGE) Repeat: If FRINGE is empty then return failure n  REMOVE(FRINGE) s  STATE( n ) If GOAL?( s ) then return path or goal state

Download Presentation

Heuristic Search

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Heuristic search

Heuristic Search

Russell and Norvig: Chapter 4

CSMSC 421 – Fall 2005


Modified search algorithm

Modified Search Algorithm

  • INSERT(initial-node,FRINGE)

  • 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)


Search algorithms

Search Algorithms

  • Blind search – BFS, DFS, 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


Best first search

Best-first search

  • Idea: use an evaluation function f(n) for each node

    • Estimate of desirability

  • Expand most desirable unexpanded node

  • Implementation: fringe is queue sorted by descreasing order of desirability

    • Greedy search

    • A* search


Heuristic

Heuristic

Webster's Revised Unabridged Dictionary (1913) (web1913)

Heuristic \Heu*ris"tic\, a. [Greek. to discover.] Serving to discover or find out.

The Free On-line Dictionary of Computing (15Feb98)

heuristic 1. <programming> A rule of thumb, simplification or educated guess that reduces or limits the search for solutions in domains that are difficult and poorly understood. Unlike algorithms, heuristics do not guarantee feasible solutions and are often used with no theoretical guarantee. 2. <algorithm> approximation algorithm.

From WordNet (r) 1.6

heuristic adj 1: (computer science) relating to or using a heuristic rule 2: of or relating to a general formulation that serves to guide investigation [ant: algorithmic] n : a commonsense rule (or set of rules) intended to increase the probability of solving some problem [syn: heuristic rule, heuristic program]


Informed search

Informed Search

  • Add domain-specific information to select the best path along which to continue searching

  • Define a heuristic function, h(n), that estimates the “goodness” of a node n.

  • Specifically, 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


Greedy search

Greedy Search

  • f(N) = h(N) greedy best-first


Robot navigation

Robot Navigation


Robot navigation1

8

7

6

5

4

3

2

3

4

5

6

7

5

4

3

5

6

3

2

1

0

1

2

4

7

6

5

8

7

6

5

4

3

2

3

4

5

6

Robot Navigation

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


Robot navigation2

Robot Navigation

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

8

7

6

5

4

3

2

3

4

5

6

7

5

4

3

5

0

6

3

2

1

0

1

2

4

What happened???

7

7

6

5

8

7

6

5

4

3

2

3

4

5

6


Greedy search1

Greedy Search

  • f(N) = h(N) greedy best-first

  • Is it complete?

    If we eliminate endless loops, yes

  • Is it optimal?


More informed search

More informed search

  • We kept looking at nodes closer and closer to the goal, but were accumulating costs as we got further from the initial state

  • 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 navigation3

3+8

2+9

4+7

5+6

3+8

8

7

6

5

4

3

2

3

4

5

6

7+2

7

5

4

3

5

6+1

8+3

6+1

6

3

2

1

0

1

2

4

7+2

7+0

6+1

7

6

5

8+1

6+1

8

7

6

5

4

3

2

3

4

5

6

2+9

3+8

7+2

2+9

3+10

4+5

1+10

4+7

5+4

3+6

2+7

8+3

7+4

5+6

6+3

2+9

3+8

4+5

3+6

2+7

6+5

7+4

0+11

1+10

4+7

3+8

5+6

6+3

7+2

5+4

6+3

Robot Navigation

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

7+0

8+1


Can we prove anything

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

  • If the state space is finite and we do not avoid repeated states, the search is in general not complete

  • If the state space is infinite, the search is in general not complete


Admissible heuristic

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

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

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’)

    • Each node has a finite number of successors


Completeness of a

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

Proof of Completeness

  • 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

Optimality of A*

  • Theorem: If h(n) is admissable, then A* is optimal.


Proof of optimality

Cost of best path

to a goal thru N

N

G1

G2

Proof of Optimality

f(G1) = g(G1)

f(N) = g(N) + h(N)  g(N) + h*(N)

f(G1)  g(N) + h(N)  g(N) + h*(N)


Heuristic function

1

2

3

4

5

6

7

8

5

8

4

2

1

7

3

6

Heuristic Function

  • Function h(N) that estimates the cost of the cheapest path from node N to goal node.

  • Example: 8-puzzle

h(N) = number of misplaced tiles = 6

goal

N


Heuristic function1

1

2

3

4

5

6

7

8

5

8

4

2

1

7

3

6

Heuristic Function

  • Function h(N) that estimate the cost of the cheapest path from node N to goal node.

  • Example: 8-puzzle

h(N) = sum of the distances of

every tile to its goal position

= 2 + 3 + 0 + 1 + 3 + 0 + 3 + 1

= 13

goal

N


8 puzzle

3

3

4

5

3

4

2

4

2

1

3

3

0

4

5

4

8-Puzzle

f(N) = h(N) = number of misplaced tiles


8 puzzle1

3+3

1+5

2+3

3+4

5+2

0+4

3+2

4+1

2+3

1+3

5+0

3+4

1+5

2+4

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles


8 puzzle2

6

5

2

5

2

1

3

4

0

4

6

5

8-Puzzle

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


8 puzzle3

1

2

3

4

5

6

7

8

5

8

4

2

1

7

3

6

8-Puzzle

N

goal

  • h1(N) = number of misplaced tiles = 6 is admissible

  • h2(N) = sum of distances of each tile to goal = 13 is admissible

  • h3(N) = (sum of distances of each tile to goal) + 3 x (sum of score functions for each tile) = 49 is not admissible


Robot navigation4

Robot navigation

f(N) = g(N) + h(N), with h(N) = straight-line distance from N to goal

Cost of one horizontal/vertical step = 1

Cost of one diagonal step = 2


Consistent heuristic

N

c(N,N’)

N’

h(N)

h(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’)(triangular inequality)


8 puzzle4

1

2

3

4

5

6

7

8

  • h1(N) = number of misplaced tiles

5

8

  • h2(N) = sum of distances of each tile to goal

  • are both consistent

4

2

1

7

3

6

8-Puzzle

N

goal


Robot navigation5

Cost of one horizontal/vertical step = 1

Cost of one diagonal step = 2

Robot navigation

h(N) = straight-line distance to the goal is consistent


Claims

N

c(N,N’)

N’

h(N)

h(N’)

Claims

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


Claims1

N

c(N,N’)

N’

h(N)

h(N’)

Claims

  • If h is consistent, then the function f alongany 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’)


Claims2

N

c(N,N’)

N’

h(N)

h(N’)

Claims

  • If h is consistent, then the function f alongany 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


Avoiding repeated states in a

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


Heuristic accuracy

HeuristicAccuracy

  • h(N) = 0 for all nodes is admissible and consistent. Hence, breadth-first and uniform-cost are particular A* !!!

  • Let h1 and h2 be two admissible and consistent heuristics such that for all nodes N: h1(N)  h2(N).

  • Then, every node expanded by A* using h2 is also expanded by A* using h1.

  • h2 is more informed than h1


Iterative deepening a ida

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 puzzle5

4

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=4


8 puzzle6

4

4

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=4


8 puzzle7

4

5

4

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=4


8 puzzle8

5

4

5

4

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=4


8 puzzle9

6

5

4

5

4

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=4


8 puzzle10

4

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=5


8 puzzle11

4

4

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=5


8 puzzle12

4

5

4

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=5


8 puzzle13

4

5

4

7

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=5


8 puzzle14

4

5

5

4

7

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=5


8 puzzle15

4

5

5

5

4

7

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=5


8 puzzle16

4

5

5

5

4

7

6

6

8-Puzzle

f(N) = g(N) + h(N)

with h(N) = number of misplaced tiles

Cutoff=5


About heuristics

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

What’s the Issue?

  • Search is an iterative local procedure

  • Good heuristics should provide some global look-ahead (at low computational cost)


Another approach

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

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

Hill climbing on a surface of states

Height Defined by Evaluation Function


Hill climbing

Hill climbing

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


Robot navigation6

Robot Navigation

Local-minimum problem

f(N) = h(N) = straight distance to the goal


Examples of problems with hc

Examples of problems with HC

  • applet


Drawbacks of hill climbing

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 issue1

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

5

8

3

1

6

4

7

2

4

8

1

4

7

6

5

2

3

1

3

5

2

8

5

7

5

6

3

8

4

7

6

3

1

8

1

7

6

4

5

1

3

8

4

7

6

2

2

2

Hill climbing example

start

h = 0

goal

h = -4

-2

-5

-5

h = -3

h = -1

-3

-4

h = -2

h = -3

-4

f(n) = -(number of tiles out of place)


Example of a local maximum

6

2

7

4

8

6

3

1

2

5

7

4

8

6

3

1

8

6

1

2

5

7

8

3

3

1

2

5

7

4

4

5

3

1

2

5

7

4

8

6

Example of a local maximum

-4

start

goal

-4

0

-3

-4


Potential fields

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

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

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

  • 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

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

The simulated annealing algorithm


Simulated annealing1

Simulated Annealing

  • applet

  • Successful application: circuit routing, traveling sales person (TSP)


Summary local search algorithms

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

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

Summary

  • Heuristic function

  • Best-first search

  • Admissible heuristic and A*

  • A* is complete and optimal

  • Consistent heuristic and repeated states

  • Heuristic accuracy

  • IDA*


  • Login