course: engineering artificial intelligence

60
University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture 2

Upload: zitkalasa-ramirez

Post on 03-Jan-2016

34 views

Category:

Documents


3 download

DESCRIPTION

Course: Engineering Artificial Intelligence. Dr. Radu Marinescu. Lecture 2. Fundamental issues for most AI problems. Representation Search Inference Planning Learning. Representation. Facts about the world have to be represented in some way, e.g., mathematical logic Deals with: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Course:Engineering Artificial Intelligence

Dr. Radu Marinescu

Lecture 2

Page 2: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Fundamental issues for most AI problems

o Representationo Searcho Inferenceo Planningo Learning

R. Marinescu October-2009 page 2

Page 3: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Representation

o Facts about the world have to be represented in some way, e.g., mathematical logic

o Deals with:• What to represent and how to represent?• How to structure knowledge?• What is explicit and what must be inferred?• How to encode “rules”?• How to deal with incomplete, inconsistent and probabilistic

knowledge?• What kinds of knowledge are required to solve problems?

R. Marinescu October-2009 page 3

Page 4: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Search

o Many tasks can be viewed as searching a very large problem space for a solution

• For example, Tic-Tac-Toe has 765 states, Chess has about 250 states, while Go has about 2100 states

R. Marinescu October-2009 page 4

Page 5: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Inference

o From some facts others can be inferred (related to search)

• For example, knowing "All elephants have trunks" and "Clyde is an elephant," can we answer the question "Does Clyde have a trunk?"

• What about "Peanuts has a trunk, is it an elephant?" Or "Peanuts lives in a tree and has a trunk, is it an elephant?”

R. Marinescu October-2009 page 5

Page 6: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Learning and planning

o Learning• Learn new facts about the world: e.g., machine learning

o Planning• Starting with general facts about the world, facts about the effects

of basic actions, facts about a particular situation, and a statement of a goal generate a strategy for achieving that goal in terms of a sequence of primitive steps or actions

R. Marinescu October-2009 page 6

Page 7: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Fundamental issues for most AI problems

o Representationo Searcho Inferenceo Planningo Learning

R. Marinescu October-2009 page 7

Page 8: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Search

o Main idea: Search allows exploring alternatives

o Backgroundo State space representationo Uninformed vs. informedo Any path vs. optimal patho Implementation and performance

R. Marinescu October-2009 page 8

Page 9: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Trees and graphs

R. Marinescu October-2009 page 9

C

B

ATree

root

Terminal(leaf)

Link(edge)

B is parent of CC is child of BA is ancestor of CC is descendant of A

Page 10: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Trees and graphs

R. Marinescu October-2009 page 10

C

B

ATree

root

Terminal(leaf)

Link(edge)

B is parent of CC is child of BA is ancestor of CC is descendant of A

Directed Graph(one way streets)

Page 11: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Trees and graphs

R. Marinescu October-2009 page 11

C

B

ATree

root

Terminal(leaf)

Link(edge)

B is parent of CC is child of BA is ancestor of CC is descendant of A

Directed Graph(one way streets)

Undirected Graph(two way streets)

Page 12: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Examples of graphs

R. Marinescu October-2009 page 12

San FranBoston

Wash DC

LA Dallas

Airline routes

Page 13: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Examples of graphs

R. Marinescu October-2009 page 13

San FranBoston

Wash DC

LA Dallas

Airline routes

Planning actions(graph of possible statesof the world)

A B C

A BC

A

BC

ACB B

AC

Put C on A

Put C on B

Put B on C

Put A on C

Put C on A

Page 14: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Problem solving paradigm

o What are the states? (All relevant aspects of the problem)

• Arrangement of parts (to plan an assembly)• Positions of trucks (to plan package distribution)• Cities (to plan a trip)• Set of facts (e.g., to prove a mathematical theorem)

o What are the actions (operators)? (deterministic, discrete)

• Assemble two parts• Move a truck to a new position• Fly to a new city• Apply a theorem to derive a new fact

o What is the goal test? (Condition for success)

• All parts in place• All packages delivered• Reached destination city• Derived goal fact

R. Marinescu October-2009 page 14

Page 15: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Example: holiday in Romania

o On vacation in Romania, currently in Arado Flight home leaves tomorrow from Bucharest

R. Marinescu October-2009 page 15

Page 16: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Example: holiday in Romania

o Goal• Be in Bucharest

o State-space• States: various cities• Actions: drive between cities

o Solution• Sequence of actions to destination

R. Marinescu October-2009 page 16

Page 17: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Solution to the holiday problem

R. Marinescu October-2009 page 17

Solution: go(Sibiu), go(Fagaras), go(Bucharest)

Cost: 140 + 99 + 211 = 450

Page 18: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

State-space problem formulation

o A problem is defined by 4 items:• Initial state: e.g., in(Arad)• Actions or successor function: S(X) = set of action-state pairs

e.g., S(Arad) = {<go(Sibiu), in(Sibiu)>, <go(Zerind), in(Zerind)>, <go(Timisoara), in(Timisoara)>}

• Goal test: e.g., in(Bucharest)• Path cost (additive)

e.g., sum of distances to drive

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

R. Marinescu October-2009 page 18

Page 19: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Vacuum cleaner state space

o States: location of dirt and roboto Initial state: anyo Actions: move robot left, right and sucko Goal state: no dirt at all locationso Path cost: 1 per action

R. Marinescu October-2009 page 19

Page 20: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

8-queen puzzle state space

o States: arrangements of n ≤ 8 queens in the leftmost n columns, 1 per column, such that no queen attacks another

o Initial state: no queens on the board

o Actions: add queen to the leftmost empty column such that it is not attacked by any other queen

o Goal state: 8 queens on the board, none attacked

o Path cost: 1 per action

R. Marinescu October-2009 page 20

Page 21: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Sliding tile puzzle state space

o Stateso Initial stateo Actionso Goal stateo Path cost

R. Marinescu October-2009 page 21

Try yourselves

Page 22: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Sliding tile puzzle state space

o States: locations of tileso Initial state: given (left)o Actions: move blank left, right, up, downo Goal state: given (right)o Path cost: 1 per action

R. Marinescu October-2009 page 22

Page 23: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Sliding tile puzzle state space

R. Marinescu October-2009 page 23

Page 24: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Search algorithms

o Basic idea• Exploration of state space graph by generating successors of already-

explored states (a.k.a. expanding states)

• Every states is evaluated: is it a goal state?

R. Marinescu October-2009 page 24

Page 25: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Terminology

o State – Used to refer to the vertices in the underlying graph that is being searched, that is states in the problem domain, for example, a city, an arrangement of blocks or the arrangement of parts in a puzzle

o Search node – Refers to the vertices in the search tree that is being generated by the search algorithm. Each node refers to a state of the world; many nodes may refer to the same state.

• Importantly, a node implicitly represents a path (from the start state of the search tree to the state associated with the node). Because search nodes are part of the search tree, they have a unique ancestor node (except for the root node)

R. Marinescu October-2009 page 25

Page 26: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Terminology: more details

o A state is a (representation of) a physical configurationo A node is a data structure constituting part of a search

tree contains info such as: state, parent node, action, path cost g(x), depth

R. Marinescu October-2009 page 26

Page 27: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Search strategies

o A search strategy is defined by picking the order of node expansion

o Search strategies are evaluated along the following dimensions:

• completeness: does it always find a solution if one exists?• time complexity: number of nodes generated• space complexity: maximum number of nodes in memory• optimality: does it always find a least-cost solution?

o Time and space complexity are measured in terms of

• b: maximum branching factor of the search tree• d: depth of the search tree

R. Marinescu October-2009 page 27

Page 28: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Classes of search

o Any path search• Uninformed search• Informed search

o Optimal path search• Uninformed search• Informed search

R. Marinescu October-2009 page 28

Page 29: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Classes of search

R. Marinescu October-2009 page 29

Class Name Operation

Any Path Depth-First Systematic exploration of whole tree

Uninformed Breadth-First until a goal node is found.

Any Path Best-First Uses heuristic measure of goodness

Informed of a state, e.g. estimated distance to goal.

Optimal Uniform-Cost Uses path “length” measure.

Uninformed Finds shortest path.

Optimal A* Uses path “length” measure and heuristic

Informed Finds shortest path.

Page 30: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Simple search algorithm

o A search node is a path from some state X to the start state, e.g., (X B A S)o The state of a search node is the most recent state of the path, e.g., Xo Let Q be a list of search nodes, e.g., ((X B A S) (C B A S) …)o Let S be the start state

1. Initialize Q with search node (S) as only entry, set Visited = (S)

2. If Q is empty, fail. Else, pick some node N from Q

3. If state(N) is goal, return N (we’ve reached the goal)

4. (Otherwise) Remove N from Q

5. Find all descendants of state(N) not in Visited and create all the one-step extensions of N to each descendant

6. Add the extended paths to Q; add children of state(N) to Visited

7. Go to step 2.

R. Marinescu October-2009 page 30

Page 31: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Simple search algorithm

o A search node is a path from some state X to the start state, e.g., (X B A S)o The state of a search node is the most recent state of the path, e.g., Xo Let Q be a list of search nodes, e.g., ((X B A S) (C B A S) …)o Let S be the start state

1. Initialize Q with search node (S) as only entry, set Visited = (S)

2. If Q is empty, fail. Else, pick some node N from Q

3. If state(N) is goal, return N (we’ve reached the goal)

4. (Otherwise) Remove N from Q

5. Find all descendants of state(N) not in Visited and create all the one-step extensions of N to each descendant

6. Add the extended paths to Q; add children of state(N) to Visited

7. Go to step 2.

R. Marinescu October-2009 page 31

Critical decisions:Step 2: picking N from Q

Step 6: adding extensions of N to Q

Page 32: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Implementing the search strategies

o Depth-first• Pick first element of Q• Add path extensions to front of Q

o Breadth-first• Pick first element of Q• Add path extensions to end of Q

R. Marinescu October-2009 page 32

Page 33: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Terminology

o Visited – a state M is first visited when a path to M first gets added to Q. In general, a state is said to have been visited if it has ever shown up in a search node in Q. The intuition is that we have briefly “visited” them to place them in Q, but we have not yet examined them carefully.

o Expanded – a state M is expanded when it is the state of a search node that is pulled off of Q. At that point, the descendants of M are visited and the path that led to M is extended to the eligible descendants. We sometimes refer to the search node that led to M (instead of M itself) as being expanded. However, once a node is expanded we are done with it; we will not need to expand it again. In fact, we discard it from Q

R. Marinescu October-2009 page 33

Page 34: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First

R. Marinescu October-2009 page 34

S

A

B

C

D

G

Pick first element of Q; Add path extensions to front of Q

Q Visited

1

2

3

4

5

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

Page 35: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First

R. Marinescu October-2009 page 35

S

A

B

C

D

G

Pick first element of Q; Add path extensions to front of Q

Q Visited

1 (S) S

2

3

4

5

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

1

Page 36: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First

R. Marinescu October-2009 page 36

S

A

B

C

D

G

Pick first element of Q; Add path extensions to front of Q

Q Visited

1 (S) S

2 (A S) (B S) A, B, S

3

4

5

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

1

2

Page 37: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First

R. Marinescu October-2009 page 37

S

A

B

C

D

G

Pick first element of Q; Add path extensions to front of Q

Q Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (C A S) (D A S) (B S) C, B, A, S

4

5

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

1

2

3

Page 38: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First

R. Marinescu October-2009 page 38

S

A

B

C

D

G

Pick first element of Q; Add path extensions to front of Q

Q Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (C A S) (D A S) (B S) C, B, A, S

4 (D A S) (B S) C, D, B, A, S

5

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

1

2

3

4

Page 39: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First

R. Marinescu October-2009 page 39

S

A

B

C

D

G

Pick first element of Q; Add path extensions to front of Q

Q Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (C A S) (D A S) (B S) C, B, A, S

4 (D A S) (B S) C, D, B, A, S

5 (G D A S) (B S) G, C, D, B, A, S

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

1

2

3

4

5

Page 40: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First

R. Marinescu October-2009 page 40

S

A

B

C

D

G

Pick first element of Q; Add path extensions to front of Q

Q Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (C A S) (D A S) (B S) C, B, A, S

4 (D A S) (B S) C, D, B, A, S

5 (G D A S) (B S) G, C, D, B, A, S

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

1

2

3

4

5

Page 41: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First: another (easier?) way to see it

R. Marinescu October-2009 page 41

S

A

B

C

D

G

S

A B

1

1

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & ExpandedGray fill = Visited

Page 42: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First: another (easier?) way to see it

R. Marinescu October-2009 page 42

S

A

B

C

D

G

S

A B

1

1

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & ExpandedGray fill = Visited

C D

2

2

Page 43: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First: another (easier?) way to see it

R. Marinescu October-2009 page 43

S

A

B

C

D

G

S

A B

1

1

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & ExpandedGray fill = Visited

C D

2

23

3

Page 44: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First: another (easier?) way to see it

R. Marinescu October-2009 page 44

S

A

B

C

D

G

S

A B

1

1

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & ExpandedGray fill = Visited

C D

2

23

3

C G

4

4

NB: C is notvisited again

Page 45: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Depth-First: another (easier?) way to see it

R. Marinescu October-2009 page 45

S

A

B

C

D

G

S

A B

1

1

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & ExpandedGray fill = Visited

C D

2

23

3

C G

4

4

5

5

Page 46: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Implementing the search strategies

o Depth-first• Pick first element of Q• Add path extensions to front of Q

o Breadth-first• Pick first element of Q• Add path extensions to end of Q

R. Marinescu October-2009 page 46

Page 47: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Breadth-First

R. Marinescu October-2009 page 47

Pick first element of Q; Add path extensions to end of Q

S

A

B

C

D

GQ Visited

1 (S) S

2

3

4

5

6

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

Page 48: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Breadth-First

R. Marinescu October-2009 page 48

Pick first element of Q; Add path extensions to end of Q

S

A

B

C

D

GQ Visited

1 (S) S

2 (A S) (B S) A, B, S

3

4

5

6

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

1

Page 49: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Breadth-First

R. Marinescu October-2009 page 49

Pick first element of Q; Add path extensions to end of Q

S

A

B

C

D

GQ Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (B S) (C A S) (D A S) C, D, B, A, S

4

5

6

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry

1

2

Page 50: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Breadth-First

R. Marinescu October-2009 page 50

Pick first element of Q; Add path extensions to end of Q

S

A

B

C

D

GQ Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (B S) (C A S) (D A S) C, D, B, A, S

4 (C A S) (D A S) (G B S)* G, C, D, B, A, S

5

6

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry* We could have stopped here, when the first path to the goal was generated

1

2

3

Page 51: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Breadth-First

R. Marinescu October-2009 page 51

Pick first element of Q; Add path extensions to end of Q

S

A

B

C

D

GQ Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (B S) (C A S) (D A S) C, D, B, A, S

4 (C A S) (D A S) (G B S)* G, C, D, B, A, S

5 (D A S) (G B S) G, C, D, B, A, S

6

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry* We could have stopped here, when the first path to the goal was generated

1

2

3

4

Page 52: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Breadth-First

R. Marinescu October-2009 page 52

Pick first element of Q; Add path extensions to end of Q

S

A

B

C

D

GQ Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (B S) (C A S) (D A S) C, D, B, A, S

4 (C A S) (D A S) (G B S)* G, C, D, B, A, S

5 (D A S) (G B S) G, C, D, B, A, S

6

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry* We could have stopped here, when the first path to the goal was generated

1

2

3

4

5

Page 53: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Breadth-First

R. Marinescu October-2009 page 53

Pick first element of Q; Add path extensions to end of Q

S

A

B

C

D

GQ Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (B S) (C A S) (D A S) C, D, B, A, S

4 (C A S) (D A S) (G B S)* G, C, D, B, A, S

5 (D A S) (G B S) G, C, D, B, A, S

6 (G B S) G, C, D, B, A, S

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry* We could have stopped here, when the first path to the goal was generated

1

2

3

4

5

6

Page 54: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Breadth-First

R. Marinescu October-2009 page 54

Pick first element of Q; Add path extensions to end of Q

S

A

B

C

D

GQ Visited

1 (S) S

2 (A S) (B S) A, B, S

3 (B S) (C A S) (D A S) C, D, B, A, S

4 (C A S) (D A S) (G B S)* G, C, D, B, A, S

5 (D A S) (G B S) G, C, D, B, A, S

6 (G B S) G, C, D, B, A, S

Added paths in blueWe show the paths in reversed order; the node’s state is the first entry* We could have stopped here, when the first path to the goal was generated

1

2

3

4

5

6

Page 55: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Breadth-First: another (easier?) way to see it

R. Marinescu October-2009 page 55

1

2

3

4

5

6

S

A B

1

C D

2

45

3

D G 6

Numbers indicate order pulled off of Q (expanded)

Blue fill = Visited & ExpandedGray fill = Visited

NB: D is notvisited again

Page 56: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Worst case running time

o The number of states in the search space may be exponential in the some “depth” parameter, e.g. number of actions in a plan, number of moves in a game

o All searches may have to visit each state at least one, in the worst case

o So, all searches will have worst case running times that are at least proportional to the total number of states and therefore exponential in the “depth” parameter

R. Marinescu October-2009 page 56

b=2d=0

d=1

d=2

d is depthb is branching factor

bd < (bd+1 – 1) / (b - 1) < bd+1 states in tree

Max Time α Max # Visited

Page 57: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Worst case space

R. Marinescu October-2009 page 57

Depth-first max Q size(b – 1)d ≈ bd

visitedexpanded

Max Q size = Max(#Visited - #Expanded)

Breadth-first max Q sizebd

Page 58: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Cost performance of any-path methods

R. Marinescu October-2009 page 58

Search Worst Worst Fewest Guaranteed to

Method Time Space States find path?

Depth-First bd+1 bd No Yes*

Breadth-First bd+1 bd Yes Yes

Searching a tree with branching factor b and depth d(without a Visited list)

* If there are no infinitely long paths in the search space

Worst case time is proportional to the number of nodes added to QWorst case space is proportional to the maximal length of Q

Page 59: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Space (the final frontier)

o In large search problems, memory is often the limiting factor

o Imagine searching a tree with branching factor 8 and depth 10. Assume a node requires just 8 bytes of storage. The, breadth-first search might require up to

(23)10 x 23 = 233 bytes = 8,000 Mbytes = 8 Gbyteso One strategy is to trade time for memory. For example, we can

emulate breadth-first search by repeated application of depth-first search, each up to a preset depth limit. This is called iterative deepening search (IDS)

1. C = 12. Do DFS to max depth C. If path found, return it3. Otherwise, increment C and go to 2.

R. Marinescu October-2009 page 59

Page 60: Course: Engineering Artificial Intelligence

University College Cork (Ireland) Department of Civil and Environmental Engineering

Summary

o State-space formulation• Abstract representation of the problem

o Search for a solution• Depth-first search: exponential time, linear space• Breadth-first search: exponential time, exponential space, but

finds the “shallowest” goal• Iterative deepening search: trades off time for space (simulates

breadth-first search) o Readings

• Chapter 3 in R&N book

R. Marinescu October-2009 page 60