Uninformed Search Russell and Norvig chap. 3 Following this, the - - PowerPoint PPT Presentation

uninformed search
SMART_READER_LITE
LIVE PREVIEW

Uninformed Search Russell and Norvig chap. 3 Following this, the - - PowerPoint PPT Presentation

Uninformed Search Russell and Norvig chap. 3 Following this, the pong paddle went on a mission to destroy Atari headquarters and, due to a mixup, found himself inside the game The Matrix Reloaded. Boy, was THAT ever hard to explain to him.


slide-1
SLIDE 1

Uninformed Search

Russell and Norvig chap. 3

Following this, the pong paddle went on a mission to destroy Atari headquarters and, due to a mixup, found himself inside the game The Matrix Reloaded. Boy, was THAT ever hard to explain to him.

slide-2
SLIDE 2

Navigating through a search tree

A B C D E F G H I J L K

slide-3
SLIDE 3

Navigating through a search tree

A

slide-4
SLIDE 4

Navigating through a search tree

A B C

slide-5
SLIDE 5

Navigating through a search tree

A B C D E

slide-6
SLIDE 6

Navigating through a search tree

A B C D E F G

slide-7
SLIDE 7

Navigating through a search tree

A B C D E F G H I

slide-8
SLIDE 8

Navigating through a search tree

A B C D E F G H I F

slide-9
SLIDE 9

Navigating through a search tree

A B C D E F G H I J

slide-10
SLIDE 10

Navigating through a search tree

A B C D E F G H I J H I

slide-11
SLIDE 11

Navigating through a search tree

A B C D E F G H I J L K

slide-12
SLIDE 12

Navigating through a search tree

A B C D E F G H I J L K K L

slide-13
SLIDE 13

Navigating through a search tree

A B C D E F G H I J L K

slide-14
SLIDE 14

Unexpanded nodes: the frontier

A B C D E F G H I At every point in the search process we keep track of a list of nodes that haven’t been expanded yet: the frontier

slide-15
SLIDE 15

Tree search

A

function TREE-SEARCH(problem) return a solution or failure Initialize frontier using the initial state of problem do if the frontier is empty then return failure choose leaf node from the frontier if node is a goal state then return solution else expand the node and add resulting nodes to the frontier Initial state

slide-16
SLIDE 16

Tree search

A B C D E

function TREE-SEARCH(problem) return a solution or failure Initialize frontier using the initial state of problem do if the frontier is empty then return failure choose leaf node from the frontier if node is a goal state then return solution else expand the node and add resulting nodes to the frontier

slide-17
SLIDE 17

What’s in a node

n State n Parent n Action (the action that got us from the parent) n Depth n Path-cost (total cost to get to the node)

Why do we need the parent and action information?

slide-18
SLIDE 18

When the search graph is not a tree

n Need to avoid repeated states! n Happens in problems with reversible operators

Examples: missionaries and cannibals problem, sliding blocks puzzles, route finding problems.

n Detection: compare a node to be expanded to those

already expanded.

n Increases memory requirements (especially for

DFS): bounded by the size of the state space.

slide-19
SLIDE 19

Graph Search

function GRAPH-SEARCH(problem) return a solution or failure initialize the frontier using the initial state of problem initialize the explored set to be empty loop do if the frontier is empty then return failure choose a node from the frontier if node is a goal state then return the corresponding solution add the node to the explored set expand the node, adding the resulting nodes to the frontier (only if not in the frontier or explored set) Algorithms that forget their history are doomed to repeat it

slide-20
SLIDE 20

Search strategies

function GRAPH-SEARCH(problem) return a solution or failure initialize the frontier using the initial state of problem initialize the explored set to be empty loop do if the frontier is empty then return failure choose a node from the frontier if node is a goal state then return the corresponding solution add the node to the explored set expand the node, adding the resulting nodes to the frontier (only if not in the frontier or explored set)

Search strategies differ in how a node is chosen from the frontier

slide-21
SLIDE 21

Show code for DFS/BFS tree/ graph search

slide-22
SLIDE 22

Uninformed search strategies

n a.k.a. blind search = use only information

available in problem definition.

q When strategies can determine whether one

non-goal state is better than another → informed search.

n Search algorithms are defined by the node

expansion method:

q Breadth-first search q Uniform-cost search q Depth-first search q Depth-limited search q Iterative deepening search. q Bidirectional search

slide-23
SLIDE 23

Metrics for comparing search strategies

n A strategy is defined by the order of node expansion. n Problem-solving performance is measured in four ways:

q

Completeness: Does it always find a solution if one exists?

q

Optimality: Does it always find the least-cost solution?

q

Time Complexity: Number of nodes generated/expanded.

q

Space Complexity: Number of nodes stored in memory during search.

n

Time and space complexity are measured in terms of:

q

b - maximum branching factor of the search tree

q

d - depth of the least-cost solution

q

m - maximum depth of the state space (may be ∞)

slide-24
SLIDE 24

Breadth-First Search (BFS)

n Expand all nodes at depth d before

proceeding to depth d+1. Return the first goal node found

n Implementation: queue (FIFO). A B C D E F G

slide-25
SLIDE 25

Evaluation of BFS

n Completeness:

q Does it always find a solution if one exists?

slide-26
SLIDE 26

Evaluation of BFS

n Completeness:

q Does it always find a solution if one exists?

YES (if shallowest goal node is at some finite depth d)

slide-27
SLIDE 27

Evaluation of BFS

n

Completeness:

q

YES

n

Time complexity:

q

Assume a state space where every state has b successors.

n

Assume solution is at depth d

n

Worst case: generate all but the last node at depth d

n

Total number of nodes generated:

b+ b2 + b3 +...+ bd = O(bd)

slide-28
SLIDE 28

Evaluation of BFS

n

Completeness:

q

YES

n

Time complexity:

q

Total number of nodes generated:

n

Space complexity:

q

Same, if each node is retained in memory

b+ b2 + b3 +...+ bd = O(bd)

slide-29
SLIDE 29

Evaluation of BFS

n

Completeness:

q

YES

n

Time complexity:

q

Total number of nodes generated:

n

Space complexity:

q

Same, if each node is retained in memory

n Optimality:

q

Does it always find the least-cost solution? YES (if all actions have the same cost)

b+ b2 + b3 +...+ bd = O(bd)

slide-30
SLIDE 30

BFS evaluation

n Memory requirements are a bigger problem than its execution time. n Exponential complexity search problems cannot be solved by

uninformed search methods for any but the smallest instances.

DEPTH NODES TIME MEMORY 2 1100 0.11 seconds 1 megabyte 4 111100 11 seconds 106 megabytes 6 107 19 minutes 10 gigabytes 8 109 31 hours 1 terabyte 10 1011 129 days 101 terabytes 12 1013 35 years 10 petabytes 14 1015 3523 years 1 exabyte

Time and memory requirements for BFS for b=10, 10,000 nodes/sec; 1000 bytes/node

slide-31
SLIDE 31

Uniform cost search

n Extension of BFS:

q Expand node with lowest path cost

n Implementation: fringe = priority queue ordered by

path cost.

n Same as BFS when all step-costs are equal. n What’s the relationship to Dijkstra’s algorithm?

slide-32
SLIDE 32

Uniform cost search

n Completeness:

q YES

n Time complexity:

q Assume C* the cost of the optimal solution. q Assume that every action costs at least ε q Worst-case:

n Space complexity:

q Same as time complexity

n Optimality:

q YES (nodes expanded in order of increasing path cost)

O(bC*/ε )

slide-33
SLIDE 33

Uniform cost search

Note the use of a priority queue and the extra check in case a shorter path to a frontier state is discovered

function UNIFORM-COST-SEARCH(problem) returns a solution, or failure node ← a node with STATE = problem.INITIAL-STATE, PATH-COST = 0 frontier ← a priority queue ordered by PATH-COST, with node as the only element explored ← an empty set loop do if EMPTY?(frontier) then return failure node ← POP(frontier) /* chooses the lowest-cost node in frontier */ if problem.GOAL-TEST(node.STATE) then return SOLUTION(node) for each action in problem.ACTIONS(node.STATE) do child ← CHILD-NODE(problem,node,action) if child.STATE is not in explored or frontier then add child.STATE to explored frontier ← INSERT(child,frontier) else if child.STATE is in frontier with higher PATH-COST then replace that frontier node with child

slide-34
SLIDE 34

Depth First Search (DFS)

A B C

Expand deepest unexpanded node

slide-35
SLIDE 35

Depth First Search (DFS)

Expand deepest unexpanded node

A B C D E

slide-36
SLIDE 36

Depth First Search (DFS)

Expand deepest unexpanded node

A B C D H I E

slide-37
SLIDE 37

Depth First Search (DFS)

Expand deepest unexpanded node

A B C D H I L K E

slide-38
SLIDE 38

Depth First Search (DFS)

Expand deepest unexpanded node

A B D E H I L K C

slide-39
SLIDE 39

Depth First Search (DFS)

Expand deepest unexpanded node

A B C D E F G H I L K

slide-40
SLIDE 40

Depth First Search (DFS)

Expand deepest unexpanded node

A B C D E F H I J L K G

slide-41
SLIDE 41

Depth First Search (DFS)

Expand deepest unexpanded node

A B C D E F H I J L K G

slide-42
SLIDE 42

Depth First Search (DFS)

Expand deepest unexpanded node

A B C D E F H I J L K G

Implementation: frontier is a stack (LIFO)

slide-43
SLIDE 43

DFS evaluation

n Completeness:

q Does it always find a solution if one exists?

slide-44
SLIDE 44

DFS evaluation

n Completeness:

q Does it always find a solution if one exists?

NO

n

unless search space is finite (also beware of loops if using tree search)

slide-45
SLIDE 45

DFS evaluation

n Completeness:

q NO (unless search space is finite).

n Time complexity:

q Terrible if m (depth of search space) is much larger than d (depth

  • f optimal solution)

q But if many solutions, then might be faster than BFS

slide-46
SLIDE 46

DFS evaluation

n Completeness:

q NO (unless search space is finite).

n Time complexity: O(bm) – m is maximum depth of graph n Space complexity: O(bm)

q Assumes we are not keeping track of explored nodes

slide-47
SLIDE 47

DFS evaluation

n Completeness:

q NO (unless search space is finite).

n Time complexity: O(bm) n Space complexity: O(bm) n Optimality: No

slide-48
SLIDE 48

Depth-limited search

n DFS with depth limit l.

q Treat nodes at depth l as if they have no successors.

n Solves the infinite-path problem. n If l < d (depth of least cost solution) then incomplete. n Not optimal. n Time complexity: O(bl) n Space complexity: O(bl)

slide-49
SLIDE 49

Iterative deepening search (IDS)

n A strategy to find best depth limit l. n Depth-Limited Search to depth 1, 2, … n Expands from the root each time. n Appears very wasteful, but combinatorics can be

counter intuitive:

N(DLS) = b + b2 +…+ bd-1 + bd = O(bd) N(IDS) = db + (d-1)b2 +…+ 2bd-1 + bd = O(bd) N(BFS) = b + b2 +…+ bd = O(bd)

slide-50
SLIDE 50

Iterative deepening search

function ITERATIVE_DEEPENING_SEARCH(problem) return a solution

  • r failure

for depth = 0 to ∞ do result ← DEPTH-LIMITED_SEARCH(problem, depth) if result ≠ cutoff then return result Note: depth-limited_search returns cutoff when it has reached the given depth without finding a solution

slide-51
SLIDE 51

Evaluation of IDS

n Completeness:

q YES (no infinite paths)

slide-52
SLIDE 52

Evaluation of IDS

n Completeness:

q YES

n Time complexity: O(bd)

slide-53
SLIDE 53

Evaluation of IDS

n Completeness:

q YES

n Time complexity: O(bd)

n Space complexity: O(bd)

q Same as DFS

slide-54
SLIDE 54

Evaluation of IDS

n Completeness:

q YES

n Time complexity: O(bd) n Space complexity: O(bd)

q Same as DFS

n Optimality:

q YES if step cost is 1.

slide-55
SLIDE 55

Iterative Deepening Search

n Analogous to BFS: explores a complete layer

  • f nodes before proceeding to the next one.

n Combines benefits of DFS and BFS.

slide-56
SLIDE 56

Bidirectional Search

n Two simultaneous searches from start and goal.

q Motivation: bd/2 + bd/2 much less than bd

n Before a node is expanded it is checked if it is in the fringe of the other

search.

n Need to keep at least one of the fringes in memory n Time complexity: O(bd/2). n Space complexity: same. n Complete and optimal (for uniform step costs) if both searches are BFS

slide-57
SLIDE 57

Bidirectional Search

Issues in applying:

n The predecessor of each node should be efficiently computable.

q When actions are easily reversible.

n Goal node: sometimes not unique or known explicitly (e.g. in

chess).

n Memory consumption

slide-58
SLIDE 58

Comparison of search strategies

Criterion Breadth- First Uniform- cost Depth-First Depth- limited Iterative deepening Bidirection al search Complete? YES* YES* NO YES, if l ≥ d YES YES* Time bd+1 bC*/e bm bl bd bd/2 Space bd+1 bC*/e bm bl bd bd/2 Optimal? YES* YES* NO NO YES YES