CS 312: Algorithm Analysis - PowerPoint PPT Presentation

1 / 39
About This Presentation
Title:

CS 312: Algorithm Analysis

Description:

Expand most desirable unexpanded node. Implementation: ... Let n be an unexpanded node in the fringe such that n is on a shortest path to ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 40
Provided by: rivit
Category:

less

Transcript and Presenter's Notes

Title: CS 312: Algorithm Analysis


1
CS 312 Algorithm Analysis
  • Lecture 35 Heuristic Search Algorithms A

Credit These slides are primarily by Stuart
Russell of UC Berkeley.
2
Announcements
  • Homework 24 due today
  • Project 6 Solving the TSP using Branch and
    Bound
  • Early day Friday (4/13)
  • Due date next Monday (4/16)
  • No Improvement
  • This project report is worth 10 of final grade
  • Give this project your best effort!
  • Clarification 10 rows in the results table
  • Another Help Session
  • Tuesday (4/10)
  • 5-6pm
  • Location meet at CS 312 desk

3
HW 24 Problem 1
4
Objectives
  • Lecture 35 Heuristic Search Algorithms A
  • To understand Best-first search as a class of
    algorithms
  • To reconsider Greedy best-first search
  • To understand Branch Bound in this setting
  • To introduce A Search
  • To understand Admissible Heuristics
  • To consider the Relaxed Problem
  • Lecture 34 Solving the TSP with BB, II
  • Consider an alternate way to search the solution
    space.
  • i.e., an alternate way to generate children in
    your search for a TSP tour.
  • Put the pieces together

5
Credit
  • Russell Norvig 4.1-4.2

6
Review Tree search
  • Basic idea
  • offline, simulated exploration of state space by
    generating successors of already-explored states
    (a.k.a. expanding states)
  • A search strategy is defined by picking the order
    of node expansion

7
Uninformed search strategies
  • Uninformed search strategies use only the
    information available in the problem definition
  • Breadth-first search
  • Uniform-cost search
  • Depth-first search
  • Depth-limited search
  • Iterative deepening search

8
Best-first search
  • Idea use an evaluation function f(n) for each
    node
  • estimate of "desirability"
  • Expand most desirable unexpanded node
  • Implementation
  • Order the nodes in fringe in decreasing order of
    desirability
  • Special cases
  • Greedy best-first search
  • Branch and Bound search
  • A search

9
Romania with step costs in km
10
Greedy best-first search
  • Evaluation function f(n) h(n) (heuristic)
  • estimate of cost from n to goal
  • e.g., hSLD(n) straight-line distance from n to
    Bucharest
  • Greedy best-first search expands the node that
    appears to be closest to goal
  • Youve seen this before! Recall the simple
    greedy algorithm from your Intelligent Scissors
    project

11
Greedy best-first search example
12
Greedy best-first search example
13
Greedy best-first search example
14
Greedy best-first search example
15
Search strategies
  • A search strategy is defined by picking the order
    of node expansion
  • Strategies are evaluated along the following
    dimensions
  • completeness does it always find a solution if
    one exists?
  • time efficiency number of nodes generated
  • space efficiency maximum number of nodes in
    memory
  • optimality does it always find a least-cost
    solution?
  • Time and space efficiency are measured in terms
    of
  • b maximum branching factor of the search tree
  • d depth of the least-cost solution
  • m maximum depth of the state space (may be 8)

16
Properties of greedy best-first search
  • Complete?
  • No can get stuck in loops, e.g., Iasi ? Neamt ?
    Iasi ? Neamt ?
  • Time?
  • O(mb)
  • Space?
  • O(b)
  • Optimal?
  • No

17
Branch and Bound Search
  • Idea avoid expanding paths that are already
    expensive at best
  • Bound function f(n)
  • estimated total cost of path through state n to
    goal
  • BSSF best solution so far
  • You know this well!

18
Properties of Branch and Bound
  • Complete?
  • Yes
  • (unless there are infinitely many nodes with f
    f(G) )
  • Time?
  • O(bm), Exponential
  • Space?
  • O(bm), At worst, keeps all nodes in memory and
    does not prune. At best, ?
  • Optimal?
  • Yes

19
A search
  • Idea avoid expanding paths that are already
    expensive
  • Evaluation function f(n) g(n) h(n)
  • g(n) cost so far to reach n
  • h(n) estimated cost from n to goal
  • f(n) estimated total cost of path through n to
    goal

20
A search example
21
A search example
22
A search example
23
A search example
24
A search example
25
A search example
26
Admissible heuristics
  • A heuristic h(n) is admissible if for every node
    n,
  • h(n) h(n), where h(n) is the true cost to
    reach the goal state from n.
  • An admissible heuristic never overestimates the
    cost to reach the goal, i.e., it is optimistic
  • Example hSLD(n) (never overestimates the actual
    road distance)
  • Theorem If h(n) is admissible, A using
    TREE-SEARCH is optimal

27
Optimality of A (proof)
  • Suppose some suboptimal goal G2 has been
    generated and is in the fringe. Let n be an
    unexpanded node in the fringe such that n is on a
    shortest path to an optimal goal G.
  • f(G2) g(G2) since h(G2) 0
  • g(G2) gt g(G) since G2 is suboptimal
  • f(G) g(G) since h(G) 0
  • f(G2) gt f(G) from above

28
Optimality of A (proof continued)
  • f(G2) gt f(G) from above
  • h(n) h(n) since h is admissible
  • g(n) h(n) g(n) h(n)
  • f(n) f(G)
  • Hence f(G2) gt f(n), and A will never select G2
    for expansion

29
Consistent heuristics
  • A heuristic is consistent if for every node n,
    every successor n' of n generated by any action
    a,
  • h(n) c(n,a,n') h(n')
  • If h is consistent, we have
  • f(n') g(n') h(n')
  • g(n) c(n,a,n') h(n')
  • g(n) h(n)
  • f(n)
  • i.e., f(n) is non-decreasing along any path.
  • Theorem If h(n) is consistent, A using
    GRAPH-SEARCH is optimal

30
Optimality of A
  • A expands nodes in order of increasing f value
  • Gradually adds "f-contours" of nodes
  • Contour i has all nodes with ffi, where fi lt fi1

31
Properties of A
  • Complete?
  • Yes (unless there are infinitely many nodes with
    f f(G) )
  • Time?
  • O(bm), Exponential
  • Space?
  • O(bm), Keeps all nodes in memory
  • Optimal?
  • Yes

32
Example The 8-puzzle
  • states?
  • actions?
  • goal test?
  • path cost?

33
Example The 8-puzzle
  • states? locations of tiles
  • actions? move blank left, right, up, down
  • goal test? goal state (given)
  • path cost? 1 per move
  • Note optimal solution of n-Puzzle family is
    NP-hard

34
Admissible heuristics?
35
Admissible heuristics
  • E.g., for the 8-puzzle
  • h1(n) number of misplaced tiles
  • h2(n) total Manhattan distance
  • (i.e., no. of squares from desired location of
    each tile)
  • h1(S) ?
  • h2(S) ?

36
Admissible heuristics
  • E.g., for the 8-puzzle
  • h1(n) number of misplaced tiles
  • h2(n) total Manhattan distance
  • (i.e., no. of squares from desired location of
    each tile)
  • h1(S) ? 8
  • h2(S) ? 31222332 18

37
Dominance
  • If h2(n) h1(n) for all n (both admissible)
  • then h2 dominates h1
  • h2 is better for search
  • Typical search costs (average number of nodes
    expanded)
  • d12 IDS 3,644,035 nodes A(h1) 227 nodes
    A(h2) 73 nodes
  • d24 IDS too many nodes A(h1) 39,135 nodes
    A(h2) 1,641 nodes

38
Relaxed problems
  • A problem with fewer restrictions on the actions
    is called a relaxed problem
  • The cost of an optimal solution to a relaxed
    problem is an admissible heuristic for the
    original problem
  • If the rules of the 8-puzzle are relaxed so that
    a tile can move anywhere, then h1(n) gives the
    shortest solution
  • If the rules are relaxed so that a tile can move
    to any adjacent square, then h2(n) gives the
    shortest solution

39
In Summary
  • A and Branch and Bound
  • Reasoning about an admissible heuristic in A is
    like reasoning about tight bounds in BB
  • A doesnt include a BSSF, by default
  • Thus, BB is potentially more memory efficient

40
Assignment
  • None
  • Work hard on Project 6!
Write a Comment
User Comments (0)
About PowerShow.com