Topic 1 Uninformed Search

Similar documents
Topic 1 Uninformed Search (Updates: Jan. 30, 2017)

Uninformed search strategies (Section 3.4) Source: Fotolia

CAP 4630 Artificial Intelligence

Set 2: State-spaces and Uninformed Search. ICS 271 Fall 2015 Kalev Kask

Lecture 3. Uninformed Search

CS 4700: Foundations of Artificial Intelligence. Bart Selman. Search Techniques R&N: Chapter 3

HW#1 due today. HW#2 due Monday, 9/09/13, in class Continue reading Chapter 3

Efficient memory-bounded search methods

Uninformed Search Methods

CS 771 Artificial Intelligence. Problem Solving by Searching Uninformed search

Uninformed (also called blind) search algorithms

Artificial Intelligence

Chapter 3: Solving Problems by Searching

Uninformed Search. CS171, Winter 2018 Introduction to Artificial Intelligence Prof. Richard Lathrop. Reading: R&N

Algorithms for Data Structures: Uninformed Search. Phillip Smith 19/11/2013

Informed search strategies (Section ) Source: Fotolia

Search Algorithms. Uninformed Blind search. Informed Heuristic search. Important concepts:

ARTIFICIAL INTELLIGENCE. Pathfinding and search

Basic Search. Fall Xin Yao. Artificial Intelligence: Basic Search

Artificial Intelligence

COMP9414: Artificial Intelligence Informed Search

Uninformed Search Strategies AIMA 3.4

Problem Solving and Search

Problem Solving. Russell and Norvig: Chapter 3

State Spaces

Lecture 4: Search 3. Victor R. Lesser. CMPSCI 683 Fall 2010

COMP9414: Artificial Intelligence Informed Search

Search. CS 3793/5233 Artificial Intelligence Search 1

Chapter 4. Uninformed Search Strategies

Chapter 3. A problem-solving agent is a kind of goal-based agent. It decide what to do by finding sequences of actions that lead to desirable states.

Route planning / Search Movement Group behavior Decision making

CMU-Q Lecture 2: Search problems Uninformed search. Teacher: Gianni A. Di Caro

Search EECS 395/495 Intro to Artificial Intelligence

Search EECS 348 Intro to Artificial Intelligence

mywbut.com Informed Search Strategies-I

CPS 170: Artificial Intelligence Search

Wissensverarbeitung. - Search - Alexander Felfernig und Gerald Steinbauer Institut für Softwaretechnologie Inffeldgasse 16b/2 A-8010 Graz Austria

3 SOLVING PROBLEMS BY SEARCHING

Artificial Intelligence

Week 3: Path Search. COMP9414/ 9814/ 3411: Artificial Intelligence. Motivation. Example: Romania. Romania Street Map. Russell & Norvig, Chapter 3.

Chapter3. Problem-Solving Agents. Problem Solving Agents (cont.) Well-defined Problems and Solutions. Example Problems.

Artificial Intelligence Uninformed search

An Appropriate Search Algorithm for Finding Grid Resources

Expert Systems (Graz) Heuristic Search (Klagenfurt) - Search -

Search: Advanced Topics and Conclusion

Problem Solving & Heuristic Search

521495A: Artificial Intelligence

Uninformed Search Strategies AIMA

Solving Problems by Searching

Uninformed search strategies

Computer Science and Software Engineering University of Wisconsin - Platteville. 3. Search (Part 1) CS 3030 Lecture Notes Yan Shi UW-Platteville

Uninformed Search. Day 1 & 2 of Search. Russel & Norvig Chap. 3. Material in part from

Artificial Intelligence

AI: problem solving and search

Search : Lecture 2. September 9, 2003

Uninformed Search. Reading: Chapter 4 (Tuesday, 2/5) HW#1 due next Tuesday

CSC 2114: Artificial Intelligence Search

ARTIFICIAL INTELLIGENCE (CSC9YE ) LECTURES 2 AND 3: PROBLEM SOLVING

521495A: Artificial Intelligence

COMP3702/7702 Artificial Intelligence Week2: Search (Russell & Norvig ch. 3)" Hanna Kurniawati"

Solving Problems by Searching

Solving Problems by Searching

Solving Problems by Searching

Artificial Intelligence

Search I. slides from: Padhraic Smyth, Bryan Low, S. Russell and P. Norvig

Problem Solving and Searching

Week 4 Lecture Notes Part 1 Blind Search cont. and Informed Search

CSE 473. Chapter 4 Informed Search. CSE AI Faculty. Last Time. Blind Search BFS UC-BFS DFS DLS Iterative Deepening Bidirectional Search

Graphs vs trees up front; use grid too; discuss for BFS, DFS, IDS, UCS Cut back on A* optimality detail; a bit more on importance of heuristics,

DFS. Depth-limited Search

An Exploratory study of Critical Factors Affecting the Efficiency of Uninformed Tree based Search Algorithms

Uninformed Search strategies. AIMA sections 3.4,3.5

Lecture 3 of 42. Lecture 3 of 42

Solving problems by searching

A4B36ZUI - Introduction ARTIFICIAL INTELLIGENCE

Search: Advanced Topics and Conclusion

Uniformed Search (cont.)

Introduction to Intelligent Systems

S A E RC R H C I H NG N G IN N S T S A T T A E E G R G A R PH P S

CS:4420 Artificial Intelligence

Informed State Space Search B4B36ZUI, LS 2018

Outline for today s lecture. Informed Search I. One issue: How to search backwards? Very briefly: Bidirectional search. Outline for today s lecture

Problem solving and search

Uninformed Search B. Navigating through a search tree. Navigating through a search tree. Navigating through a search tree

UNINFORMED SEARCH. Announcements Reading Section 3.4, especially 3.4.1, 3.4.2, 3.4.3, 3.4.5

Blind (Uninformed) Search (Where we systematically explore alternatives)

Ar#ficial)Intelligence!!

Problem Solving as Search. CMPSCI 383 September 15, 2011

ARTIFICIAL INTELLIGENCE SOLVING PROBLEMS BY SEARCHING. Chapter 3

Search with Costs and Heuristic Search

Pengju XJTU 2016

Solving problems by searching

Problem Solving Agents

Searching: Where it all begins...

Announcements. Project 0: Python Tutorial Due last night

Lecture 2: Fun with Search. Rachel Greenstadt CS 510, October 5, 2017

CS 4100 // artificial intelligence

Last time: Problem-Solving

Lecture 14: March 9, 2015

CS 5522: Artificial Intelligence II

Transcription:

Topic 1 Uninformed Search [George F Luger. 2008. Artificial Intelligence Structures and Strategies for Complex Problem Solving. 6 th Ed. Pearson. ISBN: 0321545893.] 1

Contents 1. Depth-First Search (DFS) 2. Breadth-First Search (BFS) 3. Depth-Limited Search (DLS) 4. Iterative-Deepening Search (IDS) 5. Uniform-Cost Search (UCS) 6. Bidirectional Search (BDS) 2

Introduction Uninformed search is brute-force (or blind) search. Informed search is heuristic search. A graph is a useful representation for a state space. A graph is made up of nodes (vertices) connected by edges (arcs). A graphs is easily represented by an adjacency matrix. 3

1. Depth-First Search (DFS). Search order by DFS 4

1. Depth-First Search (DFS) Depth-First Search (DFS) uses a stack (or LIFO) structure to support searching branches to their greatest depth before backtracking to previously unexplored branches. Definition of tree depth: The depth of a tree is the length of the simple path (i.e., no cycle or loop) from the root node to the furthest node. 5

1. Depth-First Search (DFS) function DFS; // George F. Luger, Stack open = [Start] // initialize closed = [ ] while open [ ] do // states remain remove leftmost state X from open if X is a goal then return SUCCESS // goal found else generate children of X put X on closed 6

1. Depth-First Search (DFS) end if a child Y of X already on open or closed discard Y // loop check put remaining children on left end of open end // end else end // end while return FAIL // no states left 7

1. Depth-First Search (DFS). Figure 3.15 Graph for DFS example (U is goal). 8

1. Depth-First Search (DFS) 0. open = [A]; closed = [ ] 1. open = [B, C, D]; closed = [A] 2. open = [E, F, C, D]; closed = [B, A] 3. open = [K, L, F, C, D]; closed = [E, B, A] 4. open = [S, L, F, C, D]; closed = [K, E, B, A] 5. open = [L, F, C, D]; closed = [S, K, E, B, A] 6. open = [T, F, C, D]; closed = [L, S, K, E, B, A] 9

1. Depth-First Search (DFS) 7. open = [F, C, D]; closed = [T, L, S, K, E, B, A] 8. open = [M, C, D], (as L is already on closed); closed = [F, T, L, S, K, E, B, A] 9. open = [C, D]; closed = [M, F, T, L, S, K, E, B, A] 10. open = [G, H, D]; closed = [C, M, F, T, L, S, K, E, B, A] 11. and so on until either U is found or open = [ ]. 10

1. Depth-First Search (DFS) If a search algorithm always finds a solution (if a solution exists) in a graph, the search algorithm is called completeness. If a search algorithm always finds the best solution (i.e., the lowest path cost among all solutions) in a graph, the search algorithm is called optimality. DFS is not complete and optimal. 11

1. Depth-First Search (DFS) DFS is best-first search (BestFS) with f(n) = depth(n). 12

Contents 1. Depth-First Search (DFS) 2. Breadth-First Search (BFS) 3. Depth-Limited Search (DLS) 4. Iterative-Deepening Search (IDS) 5. Uniform-Cost Search (UCS) 6. Bidirectional Search (BDS) 13

2. Breadth-First Search (DFS). Search order by BFS 14

2. Breadth-First Search (BFS) Breadth-First Search (BFS) uses a queue (or FIFO) to support search of most recently unexplored nodes first. BFS always expands the shallowest unexpanded node. 15

2. Breadth-First Search (BFS) Definition of branching factor (BF): - The node BF is number of children of the node. - If all nodes have the same BF, the tree BF is the node BF. - If the tree is not uniform (i.e., different nodes have different BFs), the tree BF is defined as the average of BFs. 16

2. Breadth-First Search (BFS) function BFS // George F. Luger open = [Start] // initialize closed = [ ] while open [ ] do // states remain remove leftmost state X from open if X is a goal then return SUCCESS // goal found else generate children of X put X on closed 17

2. Breadth-First Search (BFS) end if a child Y of X already on open or closed discard Y // loop check put remaining children on right end of open end // end else end // end while return FAIL // no states left 18

2. Breadth-First Search (BFS). Figure 3.15 Graph for BFS example (U is goal). 19

2. Breadth-First Search (BFS) 0. open = [A]; closed = [ ] 1. open = [B, C, D]; closed = [A] 2. open = [C, D, E, F]; closed = [B, A] 3. open = [D, E, F, G, H]; closed = [C, B, A] 4. open = [E, F, G, H, I, J]; closed = [D, C, B, A] 20

2. Breadth-First Search (BFS) 5. open = [F, G, H, I, J, K, L]; closed = [E, D, C, B, A] 6. open = [G, H, I, J, K, L, M] (as L is already on open); closed = [F, E, D, C, B, A] 7. open = [H, I, J, K, L, M, N]; closed = [G, F, E, D, C, B, A] 8. and so on until either U is found or open = [ ]. 21

2. Breadth-First Search (BFS) BFS is complete if branching factor b is finite. That is, if b is finite, BFS always finds the shallowest solution. BFS is optimal if all step costs are identical. BFS is a special case of uniform-coast search (UCS). That is, when all step costs are equal (i.e., g(n) = depth(n)), UCS becomes (or reproduces) BFS. In other words, BFS is UCS with g(n) = depth(n). BFS is best-first search (BestFS) with f(n) = depth(n). 22

Contents 1. Depth-First Search (DFS) 2. Breadth-First Search (BFS) 3. Depth-Limited Search (DLS) 4. Iterative-Deepening Search (IDS) 5. Uniform-Cost Search (UCS) 6. Bidirectional Search (BDS) 23

3. Depth-Limited Search (DLS). Search order by DLS (depth limit = 3) 24

3. Depth-Limited Search (DLS) function DLS(l); // depth limit / bound l = 0, 1, 2,... open = [Start] // initialize closed = [ ] while open [ ] do // states remain remove leftmost state X from open put X on closed if X is a goal then return SUCCESS // goal found if the depth of X is equal to the depth limit go back to while loop 25

3. Depth-Limited Search (DLS) end else generate children of X if a child Y of X already on open or closed discard Y // loop check put remaining children on left end of open end // end else end // end while return FAIL // no states left 26

3. Depth-Limited Search (DLS). Figure 3.15 Graph for DLS example (U is goal). 27

3. Depth-Limited Search (DLS) 0. open = [A]; closed = [ ] 1. open = [B, C, D]; closed = [A]; X = A; depth(a) = 0 < 2 2. open = [E, F, C, D]; closed = [B, A]; X = B; depth(b) = 1 < 2 3. open = [F, C, D]; closed = [E, B, A]; X = E; depth(e) = 2 = limit 28

3. Depth-Limited Search (DLS) 4. open = [C, D]; closed = [F, E, B, A]; X = F; depth(f) = 2 = limit 5. open = [G, H, D]; closed = [C, F, E, B, A]; X = C; depth(c) = 1 < 2 6. open = [H, D]; closed = [G, C, F, E, B, A]; X = G; depth(g) = 2 = limit 29

3. Depth-Limited Search (DLS) 7. open = [D]; closed = [H, G, C, F, E, B, A]; X = H; depth(h) = 2 = limit 8. open = [I, J], closed = [D, H, G, C, F, E, B, A]; X = D; depth(d) = 1 < 2 9. open = [J]; closed = [I, D, H, G, C, F, E, B, A]; X = I; depth(i) = 2 = limit 30

3. Depth-Limited Search (DLS) 10. open = []; closed = [J, I, D, H, G, C, F, E, B, A]; X = J; depth(j) = 2 = limit 11. open = [ ]. // return FAIL 31

3. Depth-Limited Search (DLS) DLS is not complete and optimal. 32

Contents 1. Depth-First Search (DFS) 2. Breadth-First Search (BFS) 3. Depth-Limited Search (DLS) 4. Iterative-Deepening Search (IDS) 5. Uniform-Cost Search (UCS) 6. Bidirectional Search (BDS) 33

4. Iterative-Deepening Search (IDS). Search order by IDS 34

4. Iterative-Deepening Search (IDS) IDS performs a DLS of the state space with a depth bound of 0. If it fails to find a goal, DLS performs another DLS with a depth bound of 1. This continues, increasing the depth bound by one each time. At each iteration, the algorithm performs a complete DLS with the current depth limit. No information about the state space is retained between iterations. 35

4. Iterative-Deepening Search (IDS). Figure 3.10 Node order in IDS [Matthew L. Ginsberg] 36

4. Iterative-Deepening Search (IDS) IDS is complete if branching factor b is finite. IDS is optimal if all step costs are equal. 37

Contents 1. Depth-First Search (DFS) 2. Breadth-First Search (BFS) 3. Depth-Limited Search (DLS) 4. Iterative-Deepening Search (IDS) 5. Uniform-Cost Search (UCS) 6. Bidirectional Search (BDS) 38

5. Uniform-Cost Search (UCS) UCS (or Branch and Bound) is a variation of the best-first search (BestFS). Let us denote the following notations. - g(n) is the lowest path cost of going from the start node s to the current node n. - h(n) is the heuristically estimated distance from the current node n to the goal node g. - f(n) = g(n) + h(n) is called a heuristic evaluation function. 39

5. Uniform-Cost Search (UCS) f(n) is the heuristically estimated distance from the start node s to the goal node g. UCS uses only g(n) when exploring (examining) each node n. The node with the lowest value of g is expanded first. 40

5. Uniform-Cost Search (UCS) UCS expands the node n with the lowest path cost g(n) by storing the frontier as a priority queue ordered by g. UCS expands nodes in order of their optimal path cost. Hence, the first goal node selected for expansion must be the optimal solution. 41

5. Uniform-Cost Search (UCS) Algorithm: Uniform-Coast Search // Ariel Felner Input: Source vertex s 0. closed = [] 1. open.insert(s) // open is a priority queue 2. while open empty do 3. u = open.extract_min() 4. if u is a goal then return the corresponding solution 42

5. Uniform-Cost Search (UCS) 5. for each vertex v Adj(u) do // for each child v of u 6. g(v) = g(u) + cost(u, v) 7. v = check_for duplicates(v) 8. open.insert(v ) 9. closed.insert(u) 43

5. Uniform-Cost Search (UCS) check_for_duplicates(v): Duplicate check is done as follows. When a new node v is generated, we check whether it is already in open. - If v is in open, we keep a single copy of v with the smallest g-value among the two copies (labeled v in the algorithm). - If v is in closed, its new copy is discarded. 44

5. Uniform-Cost Search (UCS). Graph for UCS example (start node S, goal node E) 45

5. Uniform-Cost Search (UCS) closed = [] open = [S] 1. u = X = S; open = [] v = B: g(v) = g(b) = g(s) + cost(s, B) g(b) = 0 + 80 = 80 v = C: g(v) = g(c) = g(s) + cost(s, C) g(c) = 0 + 99 = 99 open = [S B(80), S C(99)] closed = [S] 46

5. Uniform-Cost Search (UCS) 2. u = X = B; open = [S C(99)] v = D: g(v) = g(d) = g(b) + cost(b, D) g(d) = 80 + 97 = 177 open = [S C(99), S B D(177)] closed = [S, B] 47

5. Uniform-Cost Search (UCS) 3. u = X = C; open = [S B D(177)] v = E: g(v) = g(e) = g(c) + cost(c, E) g(e) = 99 + 211 = 310 open = [S B D(177), S C E(310)] closed = [S, B, C] 48

5. Uniform-Cost Search (UCS) 4. u = X = D; open = [S C E(310)] v = E: g(v) = g(e) = g(d) + cost(d, E) g(e) = 177 + 101 = 278 open = [S B D E(278), S C E(310)] open = [S B D E(278)] closed = [S, B, C, D] 49

5. Uniform-Cost Search (UCS) 5. u = X = E; open = [] u = E is a goal then return the corresponding solution: S B D E(278) v = none closed = [S, B, C, D, E] 6. open = [] stop. The solution path is S B D E(278) 50

5. Uniform-Cost Search (UCS) UCS is best-first search (BestFS) with f(n) = g(n). UCS is A * search with h(n) = 0 (i.e., f(n) = g(n)). 51

Contents 1. Depth-First Search (DFS) 2. Breadth-First Search (BFS) 3. Depth-Limited Search (DLS) 4. Iterative-Deepening Search (IDS) 5. Uniform-Cost Search (UCS) 6. Bidirectional Search (BDS) 52

6. Bidirectional Search (BDS). Search order by BDS 53

6. Bidirectional Search (BDS) When the start and goal nodes are known, the bidirectional search (BDS) can be used. The idea behind BDS is to run two search algorithms (e.g., BFS, O(b d )) simultaneously, namely one forward from the initial state and the other backward from the goal - hoping that the two searches meet in the middle. The motivation is that b d/2 + b d/2 is much less than b d. 54

6. Bidirectional Search (BDS) BDS is implemented by replacing the goal test with a check to see whether the frontiers of the two searches intersect; if they do, a solution has been found. The time complexity of BDS using breadth-first searches in both directions is O(b d/2 ). The space complexity of BDS is also O(b d/2 ). When the two paths meet at a common node, a complete and optimal solution path is found. 55

6. Bidirectional Search (BDS) A major disadvantage of BDS is that BDS requires knowledge of the goal node. The goal node is the most commonly desired node in search, and is therefore not commonly known a priori. 56

6. Bidirectional Search (BDS) Notations used s = start (initial) node, t = terminal (goal) node. S = set of nodes reached from s whose minimum distance from s is known. S = set of nodes reached from S by one edge but are not in S. g s (x) = current shortest distance from s to x. g s (s) = 0 57

6. Bidirectional Search (BDS) wf(x) = the immediate predecessor node of x along the path from s to x (i.e., parent of x). T = set of nodes which have a path to t whose minimum distance is already found. T = set of nodes reached from T by one edge but are not in T. g t (x) = current shortest distance from x to t. wt(x) = the immediate successor node of x along the path from x to t (i.e., child of x). 58

6. Bidirectional Search (BDS) Call the forward algorithm F and the backward algorithm B; we now wish to combine them into a bidirectional search (BDS) algorithm. Algorithm BDS // Ira Pohl 1. (Initialize) Perform F 1 (the first step of the forward algorithm) and B 1. That is, S = {s}, T = {t} 59

6. Bidirectional Search (BDS) 2. (Strategy) Decide to go forward (go to Step 3) or backward (go to Step 4). 3. (Forward expansion) Perform F 2. If n T go to Step 5 else go to Step 2. 4. (Backward expansion) Perform B 2. If n S go to Step 5 else go to Step 2. 5. (Terminate) If x S T, stop. The solution path is (s x t). 60

6. Bidirectional Search (BDS) Example: Apply the BDS to the figure given below, where start node is A and goal node is I. 61

6. Bidirectional Search (BDS) 1. F 1 : S = {A}, B 1 : T = {I} 2. Decide to go to Step 3. 3. F 2 : S = {A, E, B, J}. Go back to Step 2 2. Decide to go to Step 4. 4. B 2 : T = {I, G}. Go back to Step 2 62

6. Bidirectional Search (BDS) 2. Decide to go to Step 4. 4. B 3 : T = {I, G, E, H}. n = E S so go to Step 5. 5. x S T = {E}. Stop. The solution path is (A E G I) It is noted that the decision made in Step 2 really affects the performance of the bidirectional search (BDS). 63

6. Bidirectional Search (BDS) The cardinality comparison principle can be used for Step 2 as follows. // 2. (Strategy) Decide to go forward (go to Step 3) or backward (go to Step 4). 2. If S < T then go to Step 3 else go to Step 4. 64

Exercises 1. Provide the search order for the nodes shown in the figure given below for DFS, BFS, DLS (d = 2), IDS (start depth = 1) and BDS (start node A, goal node N). 65

Exercises 2. In general, IDS is better than DFS. Draw a graph to show the case in which DFS is better than IDS. 3. Explain why DLS is not complete in general. 66

Exercises 4. Using the UCS algorithm, find the shortest path from the start node A to the goal node F from the figure given below. 67

References 1. George F Luger. 2008. Artificial Intelligence Structures and Strategies for Complex Problem Solving. 6 th Ed. Pearson. ISBN: 0321545893. 2. M. Tim Jones. 2008. Artificial Intelligence A Systems Approach. Jones & Bartlett Learning. ISBN: 0763773379. 68

References 3. Ben Coppin. 2004. Artificial Intelligence Illuminated. Jones & Bartlett Learning. ISBN: 0763732303. 4. Ivan Bratko. 2011. Prolog Programming for Artificial Intelligence. 4 th Ed. Pearson. ISBN: 0321417461. 69

References 5. Stuart J. Russell, Peter Norvig. 2009. Artificial Intelligence A Modern Approach. 3 rd Ed. Pearson. ISBN: 0136042597. 6. Matthew L. Ginsberg. 1993. Essentials of Artificial Intelligence. Morgan Kaufmann. ISBN: 0124121535. 70