Notes 5: Heuristic Search - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Notes 5: Heuristic Search

Description:

For your project, you will be implementing A* as defined on next ... h2 = sum of Manhattan distances. ICS-171:Notes 5: 20. The Dynamic Programming Principle ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 22
Provided by: padhrai
Category:

less

Transcript and Presenter's Notes

Title: Notes 5: Heuristic Search


1
Notes 5 Heuristic Search
  • ICS 171 Summer 1999

2
Summary
  • Heuristic search strategies
  • heuristics and heuristic estimates
  • best-first search
  • hill-climbing
  • A optimal search using heuristics
  • dynamic programmingWe will see that A can find
    optimal paths and expand relatively few nodes by
    using heuristics

3
Example of Path Costs
Optimal (minimum cost) path is S-A-D-E-F-G
4
Heuristics and Search
  • in general
  • a heuristic is a rule-of-thumb based on
    domain-dependent knowledge to help you solve a
    problem
  • in search
  • one uses a heuristic function of a state where
    h(node) estimated cost of cheapest
    path from the state for that node to a goal
    state G
  • h(G) 0
  • h(other nodes) gt 0
  • (note we will assume all individual node-to-node
    costs are gt 0)
  • How does this help in search
  • we can use knowledge (in the form of h(node))to
    reduce search time
  • generally, will explore more promising nodes
    before less promising ones

5
Example of Heuristic Functions
B
C
A
10.4
4.0
6.7
11.0
G
S
8.9
3.0
6.9
D
F
E
6
Search Method 8 Best First Search
  • Best-First
  • uses estimated path cost from node to goal
    (heuristic, hcost)
  • ignores actual path cost
  • after each expansion
  • sort nodes according to estimated path-cost from
    node to goal
  • in effect, it always expands the most promising
    node on the fringe (according to the heuristic)
  • e.g., finding a route to Seattle, always extend
    the path from the most northerly city among the
    existing routes
  • Uniform Cost
  • uses path cost from root to node
  • after each expansion
  • sort nodes according to path-cost from start S to
    node

7
Example of Best-First Search in action
S
10.4
8.9
D
A
10.4
A
6.9
E
3.0
F
B
6.7
0
G
Note this is not the optimal path for this
problem
8
Properties of Uniform Cost and Best-First Search
  • Completeness
  • Both Best-first and Uniform Cost search are
    complete
  • Optimality
  • Best-first is not optimal in general
  • why? its ordering of nodes according to estimated
    cost to goal G there is no reason this will
    produce the path which is really lowest-cost
    first
  • e.g. most northerly gt route to Seattle might
    go through Denver!
  • uniform cost is optimal
  • Time and Space Complexity
  • Both could be O(bd) in the worst case
  • But in practice, best-first usually uses far
    fewer nodes

9
Search Method 9 Hill-Climbing Search
  • General Idea of hill-climbing
  • always expand the node which appears closest to
    goal (according to the heuristic function h)
    (greedy)
  • only keep 1 node in memory (on the Q) at any time
    (no backtracking)
  • also known as steepest ascent or
    steepest-descent
  • can be used to maximize (climb) or minimize
    (descend)
  • is it complete? optimal? what is the time and
    space complexity?
  • Relation to the Best-First Search Algorithm?
  • it is a special case, but where the memory is
    limited to a single node at any time (i.e., no
    backtracking)
  • hill-climbing with multiple restarts from
    randomly chosen initial conditions is often
    extremely simple to implement and can be quite
    effective (usually worth trying)

10
Combining heuristic and path costs
  • So far,
  • we have only considered cost of path from start
    to current node
  • or separately considered estimate of cost from
    node to goal
  • We can also use both costs together
  • fcost(node) d(S to node)
    h(node to G)
  • Notation
  • fcost(N) estimated cost from S to G via N
  • d(A to B) path cost from A to B (exact)
  • h(N to S) estimate of path cost from N to G
  • If heuristic is accurate we will quickly zero in
    on goal
  • But in general it is difficult to come up with a
    good heuristic

11
Comments on heuristic estimation
  • The estimate of the distance is called a
    heuristic
  • typically it comes from domain knowledge
  • e.g., the straight-line distance between 2
    points
  • The closer the heuristic is to the real (unknown)
    path cost, the more effective it will be
  • If the heuristic never overestimates, then the
    search procedure using this heuristic is
    admissible, i.e.,
  • h(N) is less than or equal to realcost(N to
    G)
  • Admissible search is optimal
  • i.e., if one uses an admissible heuristic to
    order the search one is guaranteed to find the
    optimal solution

12
Heuristic Underestimates of Path Cost
  • Underestimates
  • say we use a heuristic function h which is never
    greater than the true path-cost from a node to a
    goal G fcost(node) d(S to node) h(node
    to G)
  • use branch-and-bound, ordering Q according to
    ucost
  • This is optimal Why?
  • consider a node N behind the optimal path in
    the Q
  • if so, then fcost(G) lt fcost(N)
  • on the LHS, fcost(G) realcost(G) by definition
  • on the RHS fcost(N) is less than or equal to
    realcost(N) (since the heuristic underestimates,
    by assumption)
  • so realcost(G) lt realcost(N)
  • if we extend N further, its cost can only
    increase, i.e., so it cannot be optimal (i.e.,
    have realcost lt realcost(G)).

13
The A Algorithm (Search Method 10)
  • The A algorithm simply orders the nodes on the Q
    according to fcost(node) where f(cost) uses an
    admissible heuristic
  • i.e., it sorts nodes on Q according to an
    admissible heuristic h
  • It is like uniform-cost,
  • but uses fcost(node) path-cost(S to node)
    h(node)
  • rather than just path cost(S to node)
  • For your project, you will be implementing A as
    defined on next overhead

14
Pseudo-code for the A Search Algorithm
Initialize Let Q S While Q is not
empty pull Q1, the first element in Q if Q1 is
a goal report(success) and quit else child_node
s expand(Q1) lteliminate child_nodes which
represent loopsgt put remaining child_nodes in
Q sort Q according to ucost pathcost(S to
node) h(node) end Continue

15
4
1
B
A
C
2
5
G
2
S
3
5
4
2
D
E
F
16
Example of A in action
S
5 8.9 13.9
2 10.4 12..4
D
A
17
Example of A Algorithm in action
S
5 8.9 13.9
2 10.4 12..4
D
A
3 6.7 9.7
D
B
4 8.9 12.9
7 4 11
8 6.9 14.9
6 6.9 12.9
E
C
E
Dead End
B
F
10 3.0 13
11 6.7 17.7
G
13 0 13
18
Examples of Heuristic Functions for A
  • the 8-puzzle problem
  • the number of tiles in the wrong position
  • is this admissible?
  • the sum of distances of the tiles from their goal
    positions, where distance is counted as the sum
    of vertical and horizontal tile displacements
    (Manhattan distance)
  • is this admissible?
  • How can we invent admissible heuristics in
    general?
  • look at relaxed problem where constraints are
    removed
  • e.g., we can move in straight lines between
    cities
  • e.g., we can move tiles independently of each
    other

19
Effectiveness of A Search Algorithm
Average number of nodes expanded
d IDS A(h1) A(h2) 2 10 6 6 4 112 13 12
8 6384 39 25 12 364404 227 73 14 3473941 53
9 113 20 ------------ 7276 676
Average over 100 randomly generated 8-puzzle
problems h1 number of tiles in the wrong
position h2 sum of Manhattan distances
20
The Dynamic Programming Principle
S
A
D
6
B
D
7
3
  • S-D is cheaper (6 units) than S-A-D (7 units)
  • so we can eliminate the S-A-D path from
    consideration forever
  • in general, for any state in state-space
  • we need only consider 1 path to that state
  • this 1 path is the shortest path found so far
  • this is non-trivial to implement in code
  • General principle
  • min distance from S to G through D sum
    mindistance(S-D) mindistance(D-G)

21
Summary
  • In practice we often want the goal with the
    minimum cost path
  • Exhaustive search is impractical except on small
    problems
  • Uniform cost search always expands the lowest
    path-cost node on the fringe
  • Heuristic estimates of the path cost from a node
    to the goal can be efficient in reducing the
    search space (used in best-first search)
  • The A algorithm combines both of these ideas
    with admissible heuristics (which underestimate)
    guaranteeing optimality.
  • Reading
  • Chapter 4 pages 92 to 104
Write a Comment
User Comments (0)
About PowerShow.com