lecture07 search uninformed

106
06/13/22 1 Solving problems by searching Course Teacher: Moona Kanwal

Upload: ali-siddiqui

Post on 11-Jan-2016

232 views

Category:

Documents


1 download

DESCRIPTION

Uninformed Search Artificial Intelligence.

TRANSCRIPT

Page 1: Lecture07 Search Uninformed

04/21/23 1

Solving problems by searching

Course Teacher: Moona Kanwal

Page 2: Lecture07 Search Uninformed

04/21/23 2

Outline

Well-defined ProblemsWell-defined Problems Solutions (as a sequence of actions).Solutions (as a sequence of actions). ExamplesExamples Search TreesSearch Trees Uninformed Search AlgorithmsUninformed Search Algorithms

Page 3: Lecture07 Search Uninformed

04/21/23 3

Recall:Problem-Solving

Goal formulationGoal formulation (final state): limits objectives

Problem formulationProblem formulation (set of states): actions+states

Search Search (solution): sequence of actions

ExecutionExecution (follows states in solution)

Page 4: Lecture07 Search Uninformed

04/21/23 4

Recall:Well Defined Problems

A problem is defined by four itemsA problem is defined by four items:

1.1. initial stateinitial state2.2. actions or successor functionactions or successor function S(x) = set of

action–state pairs

3.3. goal test or predicate goal test or predicate γ : S → {0, 1} is 1 iff goal state

Explicit: concrete goal implicit : abstract description of goal

path costpath cost (additive):g, assigns a numeric cost to a given path.

Page 5: Lecture07 Search Uninformed

04/21/23 5

Well Defined Problems

State-Space State-Space An Initial State, s0 ∈ S. A Set of Operators (or Actions), {Ai|i = 1, 2, . . }

Formally, the state space is the set of states Formally, the state space is the set of states that can be reached by any sequence of that can be reached by any sequence of actions applied to the initial state, e.g.,actions applied to the initial state, e.g.,

S = {sS = {s00, . . . ,A, . . . ,Ai1i1ss00, . . . ,A, . . . ,Ai1i1AiAi22ss00, . . . ,A, . . . ,Ai1i1AAi2i2 ・・・・・・ AAikikss00, . . . }, . . . }

A path is a particular sequence of actions A path is a particular sequence of actions applied to the initial state.applied to the initial state.

Page 6: Lecture07 Search Uninformed

04/21/23 6

Solutions

A solution is a sequence of actions A solution is a sequence of actions leading from the initial state to a leading from the initial state to a goal stategoal state

A solution is a path that satisfies A solution is a path that satisfies the goal test.the goal test.

An optimal solution is a solution An optimal solution is a solution with minimal cost.with minimal cost.

Page 7: Lecture07 Search Uninformed

04/21/23 7

Page 8: Lecture07 Search Uninformed

04/21/23 8

Example: Romania

On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest Formulate goal:

be in Bucharest Formulate problem:

states: various cities actions: drive between cities

Find solution: sequence of cities, e.g., Arad, Sibiu, Fagaras,

Bucharest

Page 9: Lecture07 Search Uninformed

04/21/23 9

Example: Romania

Page 10: Lecture07 Search Uninformed

04/21/23 10

Page 11: Lecture07 Search Uninformed

04/21/23 11

Page 12: Lecture07 Search Uninformed

04/21/23 12

Vacuum world state space graph

states? integer dirt and robot locationinteger dirt and robot location actions? Left, Right, SuckLeft, Right, Suck goal test? no dirt at all locationsno dirt at all locations path cost? 11 per actionper action

Page 13: Lecture07 Search Uninformed

04/21/23 13

Page 14: Lecture07 Search Uninformed

04/21/23 14

Page 15: Lecture07 Search Uninformed

04/21/23 15

Page 16: Lecture07 Search Uninformed

04/21/23 16

Tree search algorithms

Basic ideaBasic idea: offline, simulated exploration of state offline, simulated exploration of state

space by generating successors of already-space by generating successors of already-explored states (a.k.a.expanding states)explored states (a.k.a.expanding states)

Page 17: Lecture07 Search Uninformed

04/21/23 17

Tree search example

Page 18: Lecture07 Search Uninformed

04/21/23 18

Tree search example

Page 19: Lecture07 Search Uninformed

04/21/23 19

Tree search example

Page 20: Lecture07 Search Uninformed

04/21/23 20

Implementation: general tree search

Page 21: Lecture07 Search Uninformed

04/21/23 21

Implementation: states vs. nodes

A state is a (representation of) a physical configurationA state is a (representation of) a physical configuration A node is a data structure constituting part of a search tree A node is a data structure constituting part of a search tree

includes state, parent node, action, path cost g(x), depthincludes state, parent node, action, path cost g(x), depth

The Expand function creates new nodes, filling in the various The Expand function creates new nodes, filling in the various fields and using the Success or Fn of the problem to create the fields and using the Success or Fn of the problem to create the corresponding states.corresponding states.

Page 22: Lecture07 Search Uninformed

04/21/23 22

Page 23: Lecture07 Search Uninformed

04/21/23 23

Search strategies

Time and space complexity are measured Time and space complexity are measured in terms of in terms of b: maximum branching factor of the b: maximum branching factor of the

search treesearch tree d: depth of the least-cost solutiond: depth of the least-cost solution m: maximum depth of the state space m: maximum depth of the state space

(may be (may be ∞∞))

Page 24: Lecture07 Search Uninformed

04/21/23 24

Page 25: Lecture07 Search Uninformed

04/21/23 25

Uninformed search strategies

Uninformed search strategies use only the Uninformed search strategies use only the information available in the problem information available in the problem definitiondefinition

Breadth-first searchBreadth-first search Uniform-cost searchUniform-cost search Depth-first searchDepth-first search Depth-limited searchDepth-limited search Iterative deepening searchIterative deepening search

Page 26: Lecture07 Search Uninformed

04/21/23 26

Breadth-first search

Expand shallowest unexpanded nodeExpand shallowest unexpanded node Implementation:

fringe is a FIFO queue, i.e., new successors go at end

Page 27: Lecture07 Search Uninformed

04/21/23 27

Breadth-first search

Expand shallowest unexpanded nodeExpand shallowest unexpanded node Implementation:

fringe is a FIFO queue, i.e., new successors go at end

Page 28: Lecture07 Search Uninformed

04/21/23 28

Breadth-first search

Expand shallowest unexpanded node Implementation:

fringe is a FIFO queue, i.e., new successors go at end

Page 29: Lecture07 Search Uninformed

04/21/23 29

Breadth-first search

Expand shallowest unexpanded node Implementation:

fringe is a FIFO queue, i.e., new successors go at end

Page 30: Lecture07 Search Uninformed

04/21/23 30

Page 31: Lecture07 Search Uninformed

04/21/23 31

Page 32: Lecture07 Search Uninformed

04/21/23 32

Page 33: Lecture07 Search Uninformed

04/21/23 33

Page 34: Lecture07 Search Uninformed

04/21/23 34

Page 35: Lecture07 Search Uninformed

04/21/23 35

Page 36: Lecture07 Search Uninformed

04/21/23 36

Page 37: Lecture07 Search Uninformed

04/21/23 37

Page 38: Lecture07 Search Uninformed

04/21/23 38

Page 39: Lecture07 Search Uninformed

04/21/23 39

Page 40: Lecture07 Search Uninformed

04/21/23 40

Page 41: Lecture07 Search Uninformed

04/21/23 41

Page 42: Lecture07 Search Uninformed

04/21/23 42

Page 43: Lecture07 Search Uninformed

04/21/23 43

Page 44: Lecture07 Search Uninformed

04/21/23 44

Properties of breadth-first search

Complete? Yes (if b is finite) Time? 1+b+b2+b3+… +bd + b(bd-1) =

O(bd+1) Space? O(bd+1) (keeps every node in

memory) Optimal? Yes (if cost = 1 per step)

Space is the bigger problem (more than time)

Page 45: Lecture07 Search Uninformed

04/21/23 45

Uniform-cost search

Expand least-cost unexpanded node Implementation:

fringe = queue ordered by path cost Equivalent to breadth-first if step costs all equal Complete? Yes, if step cost ≥ ε Time? # of nodes with g ≤ cost of optimal solution,

O(bceiling(C*/ ε)) where C* is the cost of the optimal solution

Space? # of nodes with g ≤ cost of optimal solution, O(bceiling(C*/ ε))

Optimal? Yes – nodes expanded in increasing order of g(n)

Page 46: Lecture07 Search Uninformed

04/21/23 46

Page 47: Lecture07 Search Uninformed

04/21/23 47

Page 48: Lecture07 Search Uninformed

04/21/23 48

Page 49: Lecture07 Search Uninformed

04/21/23 49

Page 50: Lecture07 Search Uninformed

04/21/23 50

Page 51: Lecture07 Search Uninformed

04/21/23 51

Page 52: Lecture07 Search Uninformed

04/21/23 52

Page 53: Lecture07 Search Uninformed

04/21/23 53

Page 54: Lecture07 Search Uninformed

04/21/23 54

Page 55: Lecture07 Search Uninformed

04/21/23 55

Page 56: Lecture07 Search Uninformed

04/21/23 56

Page 57: Lecture07 Search Uninformed

04/21/23 57

Page 58: Lecture07 Search Uninformed

04/21/23 58

Page 59: Lecture07 Search Uninformed

04/21/23 59

Page 60: Lecture07 Search Uninformed

04/21/23 60

Page 61: Lecture07 Search Uninformed

04/21/23 61

Page 62: Lecture07 Search Uninformed

04/21/23 62

Page 63: Lecture07 Search Uninformed

04/21/23 63

Page 64: Lecture07 Search Uninformed

04/21/23 64

Page 65: Lecture07 Search Uninformed

04/21/23 65

Page 66: Lecture07 Search Uninformed

04/21/23 66

Page 67: Lecture07 Search Uninformed

04/21/23 67

Page 68: Lecture07 Search Uninformed

04/21/23 68

Page 69: Lecture07 Search Uninformed

04/21/23 69

Page 70: Lecture07 Search Uninformed

04/21/23 70

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 71: Lecture07 Search Uninformed

04/21/23 71

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 72: Lecture07 Search Uninformed

04/21/23 72

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 73: Lecture07 Search Uninformed

04/21/23 73

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 74: Lecture07 Search Uninformed

04/21/23 74

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 75: Lecture07 Search Uninformed

04/21/23 75

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 76: Lecture07 Search Uninformed

04/21/23 76

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 77: Lecture07 Search Uninformed

04/21/23 77

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 78: Lecture07 Search Uninformed

04/21/23 78

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 79: Lecture07 Search Uninformed

04/21/23 79

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 80: Lecture07 Search Uninformed

04/21/23 80

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 81: Lecture07 Search Uninformed

04/21/23 81

Depth-first search

Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 82: Lecture07 Search Uninformed

04/21/23 82

Page 83: Lecture07 Search Uninformed

04/21/23 83

Page 84: Lecture07 Search Uninformed

04/21/23 84

Page 85: Lecture07 Search Uninformed

04/21/23 85

Page 86: Lecture07 Search Uninformed

04/21/23 86

Page 87: Lecture07 Search Uninformed

04/21/23 87

Page 88: Lecture07 Search Uninformed

04/21/23 88

Page 89: Lecture07 Search Uninformed

04/21/23 89

Page 90: Lecture07 Search Uninformed

04/21/23 90

Page 91: Lecture07 Search Uninformed

04/21/23 91

Page 92: Lecture07 Search Uninformed

04/21/23 92

Page 93: Lecture07 Search Uninformed

04/21/23 93

Page 94: Lecture07 Search Uninformed

04/21/23 94

Properties of depth-first search

Complete? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path

complete in finite spaces

Time? O(bm): terrible if m is much larger than d but if solutions are dense, may be much faster

than breadth-first Space? O(bm), i.e., linear space! Optimal? No

Page 95: Lecture07 Search Uninformed

04/21/23 95

Depth-limited search

= depth-first search with depth limit l,i.e., nodes at depth l have no successors

Recursive implementation:

Page 96: Lecture07 Search Uninformed

04/21/23 96

Iterative deepening search

Page 97: Lecture07 Search Uninformed

04/21/23 97

Iterative deepening search

Page 98: Lecture07 Search Uninformed

04/21/23 98

Iterative deepening search

Page 99: Lecture07 Search Uninformed

04/21/23 99

Iterative deepening search

Page 100: Lecture07 Search Uninformed

04/21/23 100

Iterative deepening search

Page 101: Lecture07 Search Uninformed

04/21/23 101

Iterative deepening search

Number of nodes generated in a depth-limited search to depth d with branching factor b:

NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd

Number of nodes generated in an iterative deepening search to depth d with branching factor b:

NIDS = (d+1)b0 + d b^1 + (d-1)b^2 + … + 3bd-2 +2bd-1 + 1bd

For b = 10, d = 5, NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 =

111,111 NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 =

123,456

Overhead = (123,456 - 111,111)/111,111 = 11%

Page 102: Lecture07 Search Uninformed

04/21/23 102

Properties of iterative deepening search

Complete? Yes Time? (d+1)b0 + d b1 + (d-1)b2 + … +

bd = O(bd) Space? O(bd) Optimal? Yes, if step cost = 1

Page 103: Lecture07 Search Uninformed

04/21/23 103

Summary of algorithms

Page 104: Lecture07 Search Uninformed

04/21/23 104

Repeated states

Failure to detect repeated states can turn a linear problem into an exponential one!

Page 105: Lecture07 Search Uninformed

04/21/23 105

Graph search

Page 106: Lecture07 Search Uninformed

04/21/23 106

Summary

Problem formulation usually requires abstracting away real-world details to define a state space that can feasibly be explored

Variety of uninformed search strategies

Iterative deepening search uses only linear space and not much more time than other uninformed algorithms