Basic Search Methods How to solve the control problem in production-rule systems? Basic techniques to find paths through state- nets. For the moment: -

Slides:



Advertisements
Similar presentations
Blind Search1 Solving problems by searching Chapter 3.
Advertisements

©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Artificial Intelligence (CS 461D)
Advanced Topics in Algorithms and Data Structures 1 Rooting a tree For doing any tree computation, we need to know the parent p ( v ) for each node v.
Branch and Bound Similar to backtracking in generating a search tree and looking for one or more solutions Different in that the “objective” is constrained.
Chapter 5 Trees PROPERTIES OF TREES 3 4.
Structures and Strategies for State Space Search
Artificial Intelligence Chapter 3: Solving Problems by Searching
Using Search in Problem Solving
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
Using Search in Problem Solving
1 Structures and Strategies for State Space Search 3 3.0Introduction 3.1Graph Theory 3.2Strategies for State Space Search 3.3Using the State Space to Represent.
Search  Exhaustive/Blind Search Methods Depth First Search Breadth First Search  Heuristic Methods Hill Climbing Beam Search Best First Search…
CSC 2300 Data Structures & Algorithms February 6, 2007 Chapter 4. Trees.
Intro to AI, Fall 2004 © L. Joskowicz 1 Introduction to Artificial Intelligence LECTURE 3: Uninformed Search Problem solving by search: definitions Graph.
Chapter 18 - basic definitions - binary trees - tree traversals Intro. to Trees 1CSCI 3333 Data Structures.
Busby, Dodge, Fleming, and Negrusa. Backtracking Algorithm Is used to solve problems for which a sequence of objects is to be selected from a set such.
CS-2852 Data Structures LECTURE 11 Andrew J. Wozniewicz Image copyright © 2010 andyjphoto.com.
For Friday Finish reading chapter 4 Homework: –Lisp handout 4.
For Monday Read chapter 4, section 1 No homework..
Lecture 3: Uninformed Search
Problem solving by search Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;
Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.
1 Kuliah 4 : Informed Search. 2 Outline Best-First Search Greedy Search A* Search.
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches - Introduction.
Union By Rank Ackermann’s Function Graph Algorithms Rajee S Ramanikanthan Kavya Reddy Musani.
Solving problems by searching A I C h a p t e r 3.
Source: David Lee Matuszek
Best-first search is a search algorithm which explores a graph by expanding the most promising node chosen according to a specified rule.
For Monday Read chapter 4 exercise 1 No homework.
Biointelligence Lab School of Computer Sci. & Eng. Seoul National University Artificial Intelligence Chapter 8 Uninformed Search.
Trees A non-linear implementation for collection classes.
1 Traversal Algorithms  sequential polling algorithm  traversing connected networks (tree construction) complexity measures tree terminology tarry’s.
TREES From root to leaf. Trees  A tree is a non-linear collection  The elements are in a hierarchical arrangement  The elements are not accessible.
Lecture 3 Problem Solving through search Uninformed Search
Lecture 3: Uninformed Search
Adversarial Search and Game-Playing
Solving problems by searching
Chapter 10 Trees © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Lecture 1 (UNIT -4) TREE SUNIL KUMAR CIT-UPES.
For Monday Chapter 6 Homework: Chapter 3, exercise 7.
i206: Lecture 13: Recursion, continued Trees
Artificial Intelligence (CS 370D)
Alyce Brady CS 470: Data Structures CS 510: Computer Algorithms
Problem Solving and Searching
Branch and Bound.
What to do when you don’t know anything know nothing
Searching for Solutions
Analysis & Design of Algorithms (CSCE 321)
Problem Solving and Searching
Depth-First Searches Introduction to AI.
Artificial Intelligence Problem solving by searching CSC 361
Search Exercise Search Tree? Solution (Breadth First Search)?
Lecture 36 Section 12.2 Mon, Apr 23, 2007
Tree Searching.
Tree Searching.
Tree Searching.
UNINFORMED SEARCH -BFS -DFS -DFIS - Bidirectional
Two – One Problem Legal Moves: Slide Rules: 1s’ move right Hop
ECE457 Applied Artificial Intelligence Fall 2007 Lecture #2
Two – One Problem Legal Moves: Slide Rules: 1s’ move right Hop
CMSC 471 Fall 2011 Class #4 Tue 9/13/11 Uninformed Search
Lecture 4: Tree Search Strategies
Problem Solving by Searching Search Methods :
Trees.
Basic Search Methods How to solve the control problem in production-rule systems? Basic techniques to find paths through state- nets. For the moment: -
Depth-First Searches.
Presentation transcript:

Basic Search Methods How to solve the control problem in production-rule systems? Basic techniques to find paths through state- nets. For the moment: - no attempt to find optimal solutions - a ‘tree-search’ approach

2 A running example:  Two possible tasks:  1. FIND a (the) path. = computational cost  2. TRAVERSE the path. = travel cost  2. relates to finding optimal paths (next chapter). Implicit network A D B E C F G S

3 A D B E C F G S The associated loop-free tree of partial paths 2 S AD BDEA CEEBBF DFBFCEACG GCGF G

4 Comments:  We are not interested in optimal paths in this chapter, so we can drop the costs. S AD BDEA CEEBBF DFBFCEACG GCGF G  Nodes do not denote themselves, but denote the partial path from the root to themselves!! Denotes:SA Denotes:SDA Denotes: SDEBA SDEBA

5Terminology:  Node, link (or edge), branch  Parent, child, ancestor, descendant  Root node, goal node  Expand / Open node / Closed node / Branching factor S AD BDEA CEEBBF DFBFCEACG GCGF G

BLIND Search Methods Methods that do not use any specific knowledge about the problem: Depth-firstBreadth-first Non-deterministic search Iterative deepening Bi-directional search

Depth-first search Expand the tree as deep as possible, returning to upper levels when needed.

8 Depth-first search = Chronological backtracking  Select a child  convention: left-to-right  Repeatedly go to next child, as long as possible.  Return to left-over alternatives (higher-up) only when needed. B C E D F G S A

9 Depth-first algorithm: 1. QUEUE <-- path only containing the root; 2. WHILE QUEUE is not empty AND goal is not reached AND goal is not reached DO remove the first path from the QUEUE; DO remove the first path from the QUEUE; create new paths (to all children); create new paths (to all children); reject the new paths with loops; reject the new paths with loops; add the new paths to front of QUEUE; add the new paths to front of QUEUE; 3. IF goal reached THEN success; THEN success; ELSE failure; ELSE failure;

10 A D B E C F G S QUEUE <-- path only containing the root; 2. WHILE QUEUE is not empty AND goal is not reached AND goal is not reached DO remove the first path from the QUEUE; DO remove the first path from the QUEUE; create new paths (to all children); create new paths (to all children); reject the new paths with loops; reject the new paths with loops; add the new paths to front of QUEUE; add the new paths to front of QUEUE; 3. IF goal reached THEN success; THEN success; ELSE failure; ELSE failure;

11 Trace of depth-first for running example:  (S) S removed, (SA,SD) computed and added  (SA, SD)SA removed, (SAB,SAD,SAS) computed, (SAB,SAD) added  (SAB,SAD,SD) SAB removed, (SABA,SABC,SABE) computed, (SABC,SABE) added  (SABC,SABE,SAD,SD) SABC removed, (SABCB) computed, nothing added  (SABE,SAD,SD)SABE removed, (SABEB,SABED,SABEF) computed, (SABED,SABEF)added  (SABED,SABEF,SAD,SD) SABED removed, (SABEDS,SABEDA.SABEDE) computed, nothing added  (SABEF,SAD,SD) SABEF removed, (SABEFE,SABEFG) computed, (SABEFG) added  (SABEFG,SAD,SD)goal is reached: reports success

12 Evaluation criteria:  Completeness:  Does the algorithm always find a path?  (for every NET such that a path exits)  Speed (worst time complexity) :  What is the highest number of nodes that may need to be created?  Memory (worst space complexity) :  What is the largest amount of nodes that may need to be stored?  Expressed in terms of:  d = depth of the tree  b = (average) branching factor of the tree  m = depth of the shallowest solution

13 Note: approximations !!  In our complexity analysis, we do not take the built- in loop-detection into account.  The results only ‘formally’ apply to the variants of our algorithms WITHOUT loop-checks.  Studying the effect of the loop-checking on the complexity is hard:  overhead of the checking MAY or MAY NOT be compensated by the reduction of the size of the tree.  Also: our analysis DOES NOT take the length (space) of representing paths into account !!

14 Completeness (depth-first)  Complete for FINITE (implicit) NETS.  (= NETS with finitely many nodes)  IMPORTANT:  This is due to integration of LOOP-checking in this version of Depth-First (and in all other algorithms that will follow) !  IF we do not remove paths with loops, then Depth-First is not complete (may get trapped in loops of a finite NET)  Note: does NOT find the shortest path.

15 A D B E C F G S S AD BDEA CEEBBF DFBFCEACG GCGF G

16 Speed (depth-first)  In the worst case:  the (only) goal node may be on the right-most branch, G d b  Time complexity == b d + b d-1 + … + 1 = b d+1 -1  Thus: O(b d ) b - 1

17 Memory (depth-first)  Largest number of nodes in QUEUE is reached in bottom left-most node.  Example: d = 3, b = 3 :...  QUEUE contains all nodes. Thus: 7.  In General: ((b-1) * d) + 1  Order: O(d*b)

Breadth-first search Expand the tree layer by layer, progressing in depth.

19 Breadth-first search:  Move downwards, level by level, until goal is reached. SA D B D A E C EE BBF D F B FC E A C G G GG FC

20 ONLY DIFFERENCE ! Breadth-first algorithm: 1. QUEUE <-- path only containing the root; 2. WHILE QUEUE is not empty AND goal is not reached AND goal is not reached DO remove the first path from the QUEUE; DO remove the first path from the QUEUE; create new paths (to all children); create new paths (to all children); reject the new paths with loops; reject the new paths with loops; add the new paths to back of QUEUE; add the new paths to back of QUEUE; 3. IF goal reached THEN success; THEN success; ELSE failure; ELSE failure;

21 Trace of breadth-first for running example:  (S) S removed, (SA,SD) computed and added  (SA, SD)SA removed, (SAB,SAD,SAS) computed, (SAB,SAD) added  (SD,SAB,SAD) SD removed, (SDA,SDE,SDS) computed, (SDA,SDE) added  (SAB,SAD,SDA,SDE) SAB removed, (SABA,SABE,SABC) computed, (SABE,SABC) added  (SAD,SDA,SDE,SABE,SABC)SAD removed, (SADS,SADA, SADE) computed, (SADE) added  etc, until QUEUE contains:  (SABED,SABEF,SADEB,SADEF,SDABC,SDABE,SDEBA,SDEBC, SDEFG) goal is reached: reports success

22 Completeness (breadth-first)  COMPLETE  even for infinite implicit NETS !  Would even remain complete without our loop- checking.  Note: ALWAYS finds the shortest path.

23 Speed (breadth-first)  If a goal node is found on depth m of the tree, all nodes up till that depth are created. d G b m  Thus: O(b m )  note: depth-first would also visit deeper nodes.

24 Memory (breadth-first)  Largest number of nodes in QUEUE is reached on the level m of the goal node. G d b m G  QUEUE contains all and nodes. (Thus: 4).  In General: b m  This usually is MUCH worse than depth-first !!

25 Practical evaluation:  Depth-first:  IF the search space contains very deep branches without solution, THEN Depth-first may waist much time in them.  Breadth-first:  Is VERY demanding on memory !  Solutions ??  Non-deterministic search  Iterative deepening

26 Non-deterministic search: 1. QUEUE <-- path only containing the root; 2. WHILE QUEUE is not empty AND goal is not reached AND goal is not reached DO remove the first path from the QUEUE; DO remove the first path from the QUEUE; create new paths (to all children); create new paths (to all children); reject the new paths with loops; reject the new paths with loops; add the new paths in random places in QUEUE; add the new paths in random places in QUEUE; 3. IF goal reached THEN success; THEN success; ELSE failure; ELSE failure;

27 Iterative deepening search  Restrict a depth-first search to a fixed depth.  If no path was found, increase the depth and restart the search.

28 Depth-limited search: 1. DEPTH 1. DEPTH QUEUE <-- path only containing the root; QUEUE <-- path only containing the root; 2. WHILE QUEUE is not empty AND goal is not reached AND goal is not reached DO remove the first path from the QUEUE; DO remove the first path from the QUEUE; IF path has length smaller than DEPTH IF path has length smaller than DEPTH create new paths (to all children); create new paths (to all children); reject the new paths with loops; reject the new paths with loops; add the new paths to front of QUEUE; add the new paths to front of QUEUE; 3. IF goal reached THEN success; THEN success; ELSE failure; ELSE failure;

29 Iterative deepening algorithm: 1. DEPTH < WHILE goal is not reached DO perform Depth-limited search; DO perform Depth-limited search; increase DEPTH by 1; increase DEPTH by 1;

30 Iterative deepening: the best ‘blind’ search.  Complete: yes - even finds the shortest path (like breadth first). b - 1  b m-1 + b m-2 + … + 1 = b m -1 = O(b m-1 ) In general: VERY good trade-off  While the work spent at DEPTH = m itself is O(b m )  Memory: b*m (combines advantages of depth- and breadth-first)  Speed:  If the path is found for Depth = m, then how much time was waisted constructing the smaller trees??

31 Bi-directional search  Compute the tree both from the start-node and from a goal node, until these meet.

32 Bi-directional search  IF you are able to EXPLICITLY describe the GOAL state, AND  you have BOTH rules for FORWARD reasoning AND BACKWARD reasoning: GoalStart

33 Bi-directional algorithm: 1. QUEUE1 <-- path only containing the root; QUEUE2 <-- path only containing the goal; QUEUE2 <-- path only containing the goal; 2. WHILE both QUEUEi are not empty AND QUEUE1 and QUEUE2 do NOT share a state AND QUEUE1 and QUEUE2 do NOT share a state DO remove their first paths; DO remove their first paths; create their new paths (to all children); create their new paths (to all children); reject their new paths with loops; reject their new paths with loops; add their new paths to back; add their new paths to back; 3. IF QUEUE1 and QUEUE2 share a state THEN success; THEN success; ELSE failure; ELSE failure;

34 Properties (Bi-directional) :  Complete: Yes.  Speed: If the test on common state can be done in constant time (hashing):  2 * O(b m/2 ) = O(b m/2 )  Memory: similarly: O(b m/2 )