Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Tree Searching Strategies. 2 The procedure of solving many problems may be represented by trees. Therefore the solving of these problems becomes a tree.

Similar presentations


Presentation on theme: "1 Tree Searching Strategies. 2 The procedure of solving many problems may be represented by trees. Therefore the solving of these problems becomes a tree."— Presentation transcript:

1 1 Tree Searching Strategies

2 2 The procedure of solving many problems may be represented by trees. Therefore the solving of these problems becomes a tree searching problem.

3 3 Satisfiability problem Tree Representation of Eight Assignments. If there are n variables x 1, x 2, …,x n, then there are 2 n possible assignments.

4 4 Satisfiability problem An instance: -x 1 …….. …… (1) x 1 …………..(2) x 2 v x 5 …. ….(3) x 3 ……. …….(4) -x 2 ……. …….(5) A Partial Tree to Determine the Satisfiability Problem. We may not need to examine all possible assignments.

5 5 Hamiltonian circuit problem E.g. the Hamiltonian circuit problem A Graph Containing a Hamiltonian Circuit

6 6 Fig. 6-8 The Tree Representation of Whether There Exists a Hamiltonian Circuit of the Graph in Fig. 6-6

7 7 A tree showing the non-existence of any Hamiltonian circuit.

8 8 8-Puzzle Problem Initial State: 23 184 765 Goal State: 123 84 765

9 9 Tree Representation of the solution of 8-puzzle problem

10 10 How to expand the tree ? Breadth-First Search Depth-First Search Hill Climbing Best-First Search Branch-and-Bound Strategy (for optimization problems) A* Algorithm

11 11 Breadth-First Search Scheme Step1 Step1: Form a one-element queue consisting of the root node. Step2 Step2: Test to see if the first element in the queue is a goal node. If it is, stop. Otherwise, go to step 3. Step3 Step3: Remove the first element from the queue. Add the first element ’ s descendants, if any, to the end of the queue. Step4 Step4: If the queue is empty, then signal failure. Otherwise, go to Step 2.

12 12 23 184 765 23 184 765 123 84 765 283 14 765 23 184 765 123 784 65 123 84 765 1 2 3 4 5 6 7 Goal Node

13 13 Depth-First Search Scheme Step1 Step1: Form a one-element stack consisting of the root node. Step2 Step2: Test to see if the top element in the queue is a goal node. If it is, stop. Otherwise, go to step 3. Step3 Step3: Remove the top element from the stack. Add the first element ’ s descendants, if any, to the top of the stack. Step4 Step4: If the stack is empty, then signal failure. Otherwise, go to Step 2.

14 14 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.

15 15 Hill climbing A variant of depth-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 misplaced tiles in node n.

16 16 Hill Climbing Search Scheme Step1 Step1: Form a one-element stack consisting of the root node. Step2 Step2: Test to see if the top element in the queue is a goal node. If it is, stop. Otherwise, go to step 3. Step3 Step3: Remove the top element from the stack. Add the first element ’ s descendants, if any, to the top of the stack according to order computed by the evaluation function. Step4 Step4: If the stack is empty, then signal failure. Otherwise, go to Step 2.

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

18 18 Best-first search strategy Combing depth-first search and breadth-first search Selecting the node with the best estimated cost among all nodes. This method has a global view.

19 19 Best-First Search Scheme Step1 Step1:Consturct a heap by using the evaluation function. First, form a 1-element heap consisting of the root node. Step2 Step2:Test to see if the root element in the heap is a goal node. If it is, stop; otherwise, go to Step 3. Step3 Step3:Remove the root element from the heap and expand the element. Add the descendants of the element into the heap. Step4 Step4:If the heap is empty, then signal failure. Otherwise, go to Step 2.

20 20 An 8-Puzzle Problem Solved by the Best-First Search Scheme Goal Node

21 21 Feasible Solution vs. Optimal Solution DFS, BFS, hill climbing and best-first search can not be used to solve optimization problems. They only point out a feasible solution.

22 22 The branch-and-bound strategy This strategy can be used to solve optimization problems without an exhaustive search.

23 23 Global Maximum and Local Maximum local maximum global maximum

24 24 A Multi-Stage Graph Searching Problem.

25 25 E.G.:A Multi-Stage Graph Searching Problem

26 26 Solved by branch-and-bound

27 27 Solved by branch-and-bound

28 28 Branch-and-bound strategy 2 mechanisms: A mechanism to generate branches A mechanism to generate a bound so that many braches can be terminated. Although it is usually very efficient, a very large tree may be generated in the worst case. It is efficient in the sense of average case.

29 29 Exercise Use BFS, DFS, Hill-Climbing and Best-First Search schemes to solve the following 8-puzzle problem with the evaluation function being the number of misplaced tiles. 23 184 765 Initial State: Goal State: 123 784 65


Download ppt "1 Tree Searching Strategies. 2 The procedure of solving many problems may be represented by trees. Therefore the solving of these problems becomes a tree."

Similar presentations


Ads by Google