Download presentation

Presentation is loading. Please wait.

Published bySara Pope Modified over 3 years ago

1
1/21/20141 Solving problems by searching Course Teacher: Moona Kanwal

2
1/21/20142 Outline Well-defined Problems Well-defined Problems Solutions (as a sequence of actions). Solutions (as a sequence of actions). Examples Examples Search Trees Search Trees Uninformed Search Algorithms Uninformed Search Algorithms

3
1/21/20143 Problem-Solving Goal formulation Goal formulation (final state): limits objectives Problem formulation Problem formulation (set of states): actions+states Search Search (solution): sequence of actions Execution Execution (follows states in solution)

4
1/21/20144 Problem types Deterministic, fully observable Deterministic, fully observable single-state problem: initial state known, results of action known Non-observable Non-observable sensor less problem (conformant problem): initial state not known, results of action known Nondeterministic and/or partially observable Nondeterministic and/or partially observable contingency problem: unknown states on some results of action Unknown state space Unknown state space exploration problem: unknown states, unknown actions

5
1/21/20145 Well Defined Problems A problem is defined by four items A problem is defined by four items : 1. initial state 2. actions or successor function 2. actions or successor function S(x) = set of action–state pairs 3. goal test or predicate 3. goal test or predicate γ : S {0, 1} is 1 iff goal state Explicit: concrete goal implicit : abstract description of goal path cost path cost (additive): g, assigns a numeric cost to a given path.

6
1/21/20146 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 that can be reached by any sequence of actions applied to the initial state, e.g., Formally, the state space is the set of states that can be reached by any sequence of actions applied to the initial state, e.g., S = {s 0,...,A i1 s 0,...,A i1 Ai 2 s 0,...,A i1 A i2 A ik s 0,... } S = {s 0,...,A i1 s 0,...,A i1 Ai 2 s 0,...,A i1 A i2 A ik s 0,... } A path is a particular sequence of actions applied to the initial state. A path is a particular sequence of actions applied to the initial state.

7
1/21/20147 Solutions A solution is a sequence of actions leading from the initial state to a goal state A solution is a sequence of actions leading from the initial state to a goal state A solution is a path that satisfies the goal test. A solution is a path that satisfies the goal test. An optimal solution is a solution with minimal cost. An optimal solution is a solution with minimal cost.

8
1/21/20148

9
9 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

10
1/21/ Example: Romania

11
1/21/201411

12
1/21/ Example: The 8-puzzle states? actions? goal test? path cost?

13
1/21/ Example: The 8-puzzle locations of tiles states? locations of tiles move blank left, right, up, down actions? move blank left, right, up, down goal state (given) goal test? = goal state (given) 1 per move path cost? 1 per move

14
1/21/201414

15
1/21/ Example: vacuum world Single-state, Single-state, start in #5 start in #5. Solution?

16
1/21/ Example: vacuum world Single-state, Single-state, start in #5 start in #5. [Right, Suck] Solution? [Right, Suck] Sensorless Sensorless, start in {1,2,3,4,5,6,7,8} e.g., Right goes to {2,4,6,8} Solution?

17
1/21/ Example: vacuum world Sensorless Sensorless, start in {1,2,3,4,5,6,7,8} e.g., Right goes to {2,4,6,8} Solution? [Right,Suck,Left,Suck] Contingency Contingency Nondeterministic: Suck may dirty a clean carpet Partially observable: location, dirt at current location. Percept: [L, Clean], i.e., start in #5 or #7 Solution?

18
1/21/ Example: vacuum world Sensorless Sensorless, start in {1,2,3,4,5,6,7,8} e.g., Right goes to {2,4,6,8 } Solution? [Right,Suck,Left,Suck] Contingency Contingency Nondeterministic: Suck may dirty a clean carpet Partially observable: location, dirt at current location. Percept: [L, Clean], i.e., start in #5 or #7 Solution? [Right, if dirt then Suck]

19
1/21/ Vacuum world state space graph states? actions? goal test? path cost?

20
1/21/ Vacuum world state space graph integer dirt and robot location states? integer dirt and robot location Left, Right, Suck actions? Left, Right, Suck no dirt at all locations goal test? no dirt at all locations 1per action path cost? 1 per action

21
1/21/ Example: robotic assembly real-valued coordinates of robot joint angles parts of the object to be assembled states?: real-valued coordinates of robot joint angles parts of the object to be assembled continuous motions of robot joints actions?: continuous motions of robot joints complete assembly goal test?: complete assembly time to execute path cost?: time to execute

22
1/21/201422

23
1/21/201423

24
1/21/201424

25
1/21/ Tree search algorithms Basic idea Basic idea : offline, simulated exploration of state space by generating successors of already-explored states (a.k.a.expanding states) offline, simulated exploration of state space by generating successors of already-explored states (a.k.a.expanding states)

26
1/21/ Tree search example

27
1/21/ Tree search example

28
1/21/ Tree search example

29
1/21/ Implementation: general tree search

30
1/21/ Implementation: states vs. nodes A state is a (representation of) a physical configuration A state is a (representation of) a physical configuration A node is a data structure constituting part of a search tree includes state, parent node, action, path cost g(x), depth A node is a data structure constituting part of a search tree includes state, parent node, action, path cost g(x), depth The Expand function creates new nodes, filling in the various fields and using the Success or Fn of the problem to create the corresponding states. The Expand function creates new nodes, filling in the various fields and using the Success or Fn of the problem to create the corresponding states.

31
1/21/201431

32
1/21/ Search strategies Time and space complexity are measured in terms of b: maximum branching factor of the search tree b: maximum branching factor of the search tree d: depth of the least-cost solution d: depth of the least-cost solution m: maximum depth of the state space (may be ) m: maximum depth of the state space (may be )

33
1/21/201433

34
1/21/ Uninformed search strategies Uninformed search strategies use only the information available in the problem definition Breadth-first search Breadth-first search Uniform-cost search Uniform-cost search Depth-first search Depth-first search Depth-limited search Depth-limited search Iterative deepening search Iterative deepening search

35
1/21/ Breadth-first search Expand shallowest unexpanded node Expand shallowest unexpanded node Implementation : fringe is a FIFO queue, i.e., new successors go at end

36
1/21/ Breadth-first search Expand shallowest unexpanded node Expand shallowest unexpanded node Implementation : fringe is a FIFO queue, i.e., new successors go at end

37
1/21/ Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end

38
1/21/ Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end

39
1/21/201439

40
1/21/201440

41
1/21/201441

42
1/21/201442

43
1/21/201443

44
1/21/201444

45
1/21/201445

46
1/21/201446

47
1/21/201447

48
1/21/201448

49
1/21/201449

50
1/21/201450

51
1/21/201451

52
1/21/201452

53
1/21/ Properties of breadth-first search Complete? Yes (if b is finite) Time? 1+b+b 2 +b 3 +… +b d + b(b d -1) = O(b d+1 ) Space? O(b d+1 ) (keeps every node in memory) Optimal? Yes (if cost = 1 per step) Space is the bigger problem (more than time)

54
1/21/ 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(b ceiling(C*/ ε) ) where C * is the cost of the optimal solution Space? # of nodes with g cost of optimal solution, O(b ceiling(C*/ ε) ) Optimal? Yes – nodes expanded in increasing order of g(n)

55
1/21/201455

56
1/21/201456

57
1/21/201457

58
1/21/201458

59
1/21/201459

60
1/21/201460

61
1/21/201461

62
1/21/201462

63
1/21/201463

64
1/21/201464

65
1/21/201465

66
1/21/201466

67
1/21/201467

68
1/21/201468

69
1/21/201469

70
1/21/201470

71
1/21/201471

72
1/21/201472

73
1/21/201473

74
1/21/201474

75
1/21/201475

76
1/21/201476

77
1/21/201477

78
1/21/201478

79
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

80
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

81
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

82
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

83
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

84
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

85
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

86
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

87
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

88
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

89
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

90
1/21/ Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

91
1/21/201491

92
1/21/201492

93
1/21/201493

94
1/21/201494

95
1/21/201495

96
1/21/201496

97
1/21/201497

98
1/21/201498

99
1/21/201499

100
1/21/

101
1/21/

102
1/21/

103
1/21/ 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

104
1/21/ Depth-limited search = depth-first search with depth limit l, i.e., nodes at depth l have no successors Recursive implementation:

105
1/21/ Iterative deepening search

106
1/21/ Iterative deepening search

107
1/21/ Iterative deepening search

108
1/21/ Iterative deepening search

109
1/21/ Iterative deepening search

110
1/21/ 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 = , , ,000 = 111,111 NIDS = , , ,000 = 123,456 Overhead = (123, ,111)/111,111 = 11%

111
1/21/ Properties of iterative deepening search Complete? Yes Time? (d+1)b 0 + d b 1 + (d-1)b 2 + … + b d = O(b d ) Space? O(bd) Optimal? Yes, if step cost = 1

112
1/21/ Summary of algorithms

113
1/21/ Repeated states Failure to detect repeated states can turn a linear problem into an exponential one !

114
1/21/ Graph search

115
1/21/ 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

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google