Top Banner

of 23

Tree Search

Apr 04, 2018

Download

Documents

srinivasaraov
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/31/2019 Tree Search

    1/23

    1

    Tree Searching Strategies

    Updated: 2010/12/27

  • 7/31/2019 Tree Search

    2/23

    2

    The procedure of solving manyproblems may be represented by trees.

    Therefore the solving of these problemsbecomes a tree searching problem.

  • 7/31/2019 Tree Search

    3/23

    3

    Satisfiability problemx1 x2 x3

    F F F

    F F TF T F

    F T T

    T F F

    T F TT T F

    T T TTree Representation of Eight Assignments.

    If there are n variables x1, x2, ,xn, then there are 2n

    possible assignments.

  • 7/31/2019 Tree Search

    4/23

    4

    Satisfiability problem An instance:

    -x1..(1)

    x1

    ..(2)

    x2 v x5..(3)

    x3..(4)

    -x2..(5)

    A Partial Tree to Determinethe Satisfiability Problem.

    We may not need to examine all possible

    assignments.

  • 7/31/2019 Tree Search

    5/23

    5

    Hamiltonian circuit problem E.g. the Hamiltonian circuit problem

    A Graph Containing a Hamiltonian Circuit

  • 7/31/2019 Tree Search

    6/23

    6

    Fig. 6-8 The Tree Representation of Whether There Exists a

    Hamiltonian Circuit of the Graph in Fig. 6-6

  • 7/31/2019 Tree Search

    7/237

    A tree showing the non-existence of

    any Hamiltonian circuit.

  • 7/31/2019 Tree Search

    8/238

    8-Puzzle Problem

    Initial State:

    2 3

    1 8 4

    7 6 5

    Goal State:

    1 2 3

    8 4

    7 6 5

  • 7/31/2019 Tree Search

    9/239

    Tree Representation of the

    solution of 8-puzzle problem

  • 7/31/2019 Tree Search

    10/2310

    How to expand the tree ? Breadth-First Search

    Depth-First Search

    Hill Climbing

    Best-First Search

  • 7/31/2019 Tree Search

    11/2311

    Breadth-First Search Scheme In breadth-first search, all the

    nodes on one level of the tree are

    examined before the nodes on thenext level are examined.

    It can be accomplished with thehelp of the queue.

  • 7/31/2019 Tree Search

    12/2312

    Breadth-First Search Scheme Step1: Form a one-element queue consisting

    of the root node. Step2: Test to see if the first element in the

    queue is a goal node. If it is, stop. Step3: Remove the first element from the

    queue. Add all descendants of the firstelement, if any, to the end of the queue one

    by one. Step4: If the queue is empty, then signal

    failure. Otherwise, go to Step 2.

  • 7/31/2019 Tree Search

    13/2313

    2 3

    1 8 4

    7 6 5

    2 31 8 4

    7 6 5

    1 2 3

    8 47 6 5

    2 8 31 4

    7 6 5

    2 3

    1 8 47 6 5

    1 2 37 8 4

    6 5

    1 2 38 4

    7 6 5

    1

    23

    4

    5

    6

    7Goal Node

  • 7/31/2019 Tree Search

    14/23

    14

    Depth-First Search Scheme The depth-first search always

    selects the deepest node for

    expansion.

    It can be accomplished with the

    help of the stack.

  • 7/31/2019 Tree Search

    15/23

    15

    Depth-First Search Scheme Step1: Form a one-element stack consisting

    of the root node. Step2: Test to see if the top element in the

    stack is a goal node. If it is, stop. Step3: Remove the top element from the

    stack. Add all descendants of the firstelement, if any, to the top of the stack one by

    one. Step4: If the stack is empty, then signal

    failure. Otherwise, go to Step 2.

  • 7/31/2019 Tree Search

    16/23

    16

    E.G.: the depth-first search E.g. sum of subset problem

    Given a set S={7, 5, 1, 2, 10},answer if S S sum of S = 9.

    The Sum of Subset Problem

    Solved by Depth-First Search.

  • 7/31/2019 Tree Search

    17/23

    17

    Hill climbingA variant ofdepth-first search

    The method selects the locally optimal

    node to expand.

    E.g. for the 8-puzzle problem,

    evaluation function f(n) = w(n),

    where w(n) is the number of misplacedtiles in node n.

  • 7/31/2019 Tree Search

    18/23

    18

    Hill Climbing Search Scheme Step1: Form a one-element stack consisting

    of the root node. Step2: Test to see if the top element in the

    stack is a goal node. If it is, stop. Step3: Remove the top element from the

    stack. Add the first elements descendants, ifany, to the top of the stack according to

    order computed by the evaluation function. Step4: If the stack is empty, then signal

    failure. Otherwise, go to Step 2.

  • 7/31/2019 Tree Search

    19/23

    19An 8-Puzzle Problem Solved by the Hill Climbing Method

  • 7/31/2019 Tree Search

    20/23

    20

    Best-first search strategy Combing depth-first search and breadth-first

    search

    Selecting the node with the best estimatedcost among all nodes.

    This method has a global view.

  • 7/31/2019 Tree Search

    21/23

    21

    Best-First Search Scheme Step1:Consturct a heap by using the

    evaluation function. First, form a 1-elementheap consisting of the root node.

    Step2:Test to see if the root element in theheap is a goal node. If it is, stop.

    Step3:Remove the root element from theheap and expand the element, i.e., add all

    descendants of the element into the heap. Step4:If the heap is empty, then signal failure.

    Otherwise, go to Step 2.

  • 7/31/2019 Tree Search

    22/23

    22An 8-Puzzle Problem Solved by the Best-First Search Scheme

    Goal Node

  • 7/31/2019 Tree Search

    23/23

    Q&A23