1 search cs 331/531 dr m m awais representation methods represent the information: animals are...

82
CS 331/531 Dr M M Awais 1 search REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further classified into large birds and small birds. Small birds include sparrows, and crows. The large birds are ostriches. The mammals include whales, monkeys, and elephants. Charlie is a elephant.

Upload: charlotte-evans

Post on 18-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 1

search

REPRESENTATION METHODS

Represent the information:

Animals are generally divided into birds and mammals. Birds are further classified into large birds and small birds. Small birds include sparrows, and crows. The large birds are ostriches. The mammals include whales, monkeys, and elephants. Charlie is a elephant.

Page 2: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 2

search

Predicate

• types(Animals, Birds,Mammals)

• types(Birds, Largebirds, Smallbirds)

• Etc…

• Unify to answer the queries

• IS THERE ANY OTHER WAY?

Page 3: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 3

search

Semantic Nets (Graphical Methods)

Instance

IS-A

IS-A IS-A

Animal

Bird Mammal

Elephant whales

charlie

small

Large

IS-A

IS-A IS-A

sparrow

crow

instance

instance

Super Class: Animal

Page 4: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 4

search

Semantic Nets (Graphical Methods)

Instance

IS-A

IS-A IS-A

Animal

Bird Mammal

Elephant whales

charlie

small

Large

IS-A

IS-A IS-A

sparrow

crow

instance

instance

IS_A: Relation

Animal: SuperBird: Class

Mammal: Class

Page 5: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 5

search

Semantic Nets (Graphical Methods)

Instance

IS-A

IS-A IS-A

Animal

Bird Mammal

Elephant whales

charlie

small

Large

IS-A

IS-A IS-A

sparrow

crow

instance

instance

Instance: defines a specific instance of a class

Page 6: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 6

search

Semantic Nets (Graphical Methods)

Instance

IS-A

IS-A IS-A

Animal

Bird Mammal

Elephant whales

charlie

small

Large

IS-A

IS-A IS-A

sparrow

crow

instance

instance

Page 7: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 7

search

Semantic Nets (Graphical Methods)

Instance

IS-A

IS-A IS-A

Animal

Bird Mammal

Elephant whales

charlie

small

Large

IS-A

IS-A IS-A

sparrow

crow

instance

instance

bananas

likes

Can have attribute link: likes for instance, class, superclass

Page 8: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 8

search

SEARCH METHODS

• Formulate a problem as a search

• Can answer queries such as:

Is CHARLIE an animal?

Page 9: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 9

search

Search RepresentationAnimal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Level 0: Root node

Page 10: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 10

search

Search RepresentationAnimal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Level 0: Root node

Level 1

Page 11: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 11

search

Search RepresentationAnimal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Level 0: Root node

Level 1

Level 2

Page 12: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 12

search

Search RepresentationAnimal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Level 0: Root node

Level 1

Level 2

Level 3

Page 13: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 13

search

Answering QueriesAnimal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Level 0: Root node

Level 1

Level 2

Level 3

Is charlie an animal?Answer:Traverse the treeIf charlie node present then answer is YES otherwise NO

Page 14: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 14

search

Answering QueriesAnimal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Level 0: Root node

Level 1

Level 2

Level 3

Is charlie an animal?Answer:Traverse the treeIf charlie node present then answer is YES otherwise NO

The way one traverses the tree defines SEARCH TYPES

Page 15: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 15

search

SEARCH METHODS

• Blind Search

•Breadth First

•Depth First

•Iterative Deepening

• Heuristic search

•Hill Climbing

•Best First

•A* Search

Page 16: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 16

search

Standard Terms

Animal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Root node

Page 17: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 17

search

Standard Terms

Animal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Child of Animal node

Page 18: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 18

search

Standard Terms

Animal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Bird and Mammal are Siblings

Page 19: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 19

search

Standard Terms

Animal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Root node

Path to a node is the list of nodes from the root to the goal node.

GOAL node

Page 20: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 20

search

Standard Terms

Animal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Root node

Path to a node is the list of nodes to the goal node (bold lines).

GOAL node

Page 21: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 21

search

How to Traverse the Tree to find PATH?

Animal

Bird Mammal

Elephant whales

charlie

smallLarge

sparrow

crow

Page 22: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 22

search

ANALYSIS OF SEARCH STRATEGIES

Completeness: is the strategy guaranteed to find a solution where there is one?

Time Complexity: How long does it take to find a solution?

Space Complexity: How much memory does it need to perform the search?

Optimality: Does the strategy find the highest quality solution when there are several different solutions?

Page 23: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 23

search

Exhaustive Search

One can systematically check every state that is reachable from initial state to end state if it is a goal state.

Search Space

The set of all states is the search space

• For simple/small search space exhaustive search is applicable [BRUTE FORCE or BLIND SEARCH]

• For complex search space HEURISTIC SEARCH is used

Page 24: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 24

search

GRAPHS AND TREES

Graphs:-

• Consist of a set of nodes with links between them

• links can be directed / undirected

• Path is the sequence of nodes connected nodes via links.

Acyclic graphs = (Paths linking a node

with itself are absent)

Trees???

Page 25: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 25

search

Tree:-

A tree is a special kind of graph with only one path to each node, usually represented with a special root node at

the top

Relationship between nodes

• Parent

• Children

• Sibling

Ancestor Node, Descendant Node, Leaf Node

Page 26: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 26

search

Graphs VS Trees Compare the searches in the two (which

is efficient)

a

b

c

d a

b c

de f g

Page 27: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 27

searchRelating State and Graph Nodes

Every physical state of a problem can be represented as a node in a graph/tree

The link between the nodes represent action required to change the states

For a navigation problem: Link: driving action Node:cities

For the Wumpus world problem: Link: movement of the agent Node:present position of the agent

Page 28: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 28

search

8 Puzzle Problem: states vs. nodes

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

Page 29: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 29

search

8 Puzzle Problem: states vs. nodes

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

Page 30: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 30

search

Tree search algorithms Basic idea:

offline, simulated exploration of state space by generating successors of already-explored states (a.k.a.~expanding states)

Page 31: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 31

search

Example: Romania

Page 32: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 32

search

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 33: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 33

search

Tree search example

Page 34: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 34

search

Tree search example

Page 35: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 35

search

Tree search example

Keep on expanding unless you reach the goal

Page 36: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 36

search

Search strategies A search strategy is defined by picking the order of

node expansion 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?

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

Page 37: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 37

search

Blind Search: Strategies

Breadth First (Breadth wise expansion)

Depth First (Depth wise expansion) Iterative Deepening (Depth Limit)

Page 38: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 38

search

Breadth-first search Expand shallowest unexpanded

node Implementation:

FIFO queue, i.e., new successors go at end

Page 39: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 39

search

Breadth-first search

Page 40: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 40

search

Breadth-first search

Page 41: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 41

search

Breadth-first search

Page 42: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 42

search 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 43: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 43

search

1. Start with queue = [initial - state] and found = FALSE

2. While queue not empty and not found do:

(a) Remove the first node n from queue

(b) if N is a goal state then found = TRUE

(c ) Find all the successor nodes of X, and put them on the end of the queue

Breath First: Algorithm

Page 44: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 44

search

1. Open = [A]; closed = []

• Evaluate A not goal

Goal: D

Page 45: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 45

search

1. Open = [A]; closed = []

• Evaluate A not goal

2. Open = [B,C];closed =[A]

• Evaluate B not goal

Goal: D

Page 46: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 46

search

1. Open = [A]; closed = []

• Evaluate A not goal

2. Open = [B,C];closed =[A]

• Evaluate B not goal

3. Open = [C,D,E];closed = [B,A]

• Evaluate C not goal

Goal: D

Page 47: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 47

search

1. Open = [A]; closed = []

• Evaluate A not goal

2. Open = [B,C];closed =[A]

• Evaluate B not goal

3. Open = [C,D,E];closed = [B,A]

• Evaluate C not goal

4. Open = [D,E,G,F];closed = [C,B,A]

1. Evaluate D is goal: STOP

Goal: D

Path: A B D

Path Cost: The cost in reaching D from A

Path cost = 2A to B=1, B to D=1(assuming a unit cost between nodes)

Page 48: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 48

search

Uniform-cost search

Expand least-cost unexpanded node Implementation:

queue ordered by path cost Equivalent to breadth-first if step costs all

equal

Page 49: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 49

search

Depth-first search Expand deepest unexpanded node Implementation:

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

Page 50: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 50

search

Depth-first search

Page 51: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 51

search

Depth-first search

Page 52: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 52

search

Depth-first search

Page 53: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 53

search

Depth-first search

Page 54: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 54

search

Depth-first search

Page 55: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 55

search

Depth-first search

Page 56: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 56

search

Depth-first search

Page 57: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 57

search

Depth-first search

Page 58: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 58

search

Depth-first search

Page 59: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 59

search

Depth-first search

Page 60: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 60

search

Depth-first search

Page 61: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 61

search 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 62: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 62

search

1. Start with agenda = [initial - state] and found = FALSE

2. While agenda not empty and not found do:

(a) Remove the first node N from agenda

(b) if N is not in visited then

(I) Add N to visited

(II) if N is a goal state then found = TRUE

(III) Put N’s successors on the front of the stack

Depth First

Page 63: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 63

search

Open=[A],closed=[] Evaluate A not a goal

Goal: C

Page 64: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 64

search

Open=[A],closed=[] Evaluate A not a goal

Open=[B,C];closed=[A] Evaluate B not a

goal

Goal: C

Page 65: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 65

search

Open=[A],closed=[] Evaluate A not a goal

Open=[B,C];closed=[A] Evaluate B not a goal

Open=[D,E,C];closed=[B,A] Evaluate D not a goal

Goal: C

Page 66: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 66

search

Open=[A],closed=[] Evaluate A not a goal

Open=[B,C];closed=[A] Evaluate B not a goal

Open=[D,E,C];closed=[B,A] Evaluate D not a goal

Open=[H,I,E,C];closed=[D,B,A] Evaluate H not a goal

Goal: C

Page 67: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 67

search

Open=[A],closed=[] Evaluate A not a goal

Open=[B,C];closed=[A] Evaluate B not a goal

Open=[D,E,C];closed=[B,A] Evaluate D not a goal

Open=[H,I,E,C];closed=[D,B,A] Evaluate H not a goal

Open=[I,E,C];closed=[H,D,B,A] Evaluate I not a goal

Goal: C

Page 68: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 68

search

Open=[A],closed=[] Evaluate A not a goal

Open=[B,C];closed=[A] Evaluate B not a goal

Open=[D,E,C];closed=[B,A] Evaluate D not a goal

Open=[H,I,E,C];closed=[D,B,A] Evaluate H not a goal

Open=[I,E,C];closed=[H,D,B,A] Evaluate I not a goal

Open=[E,C];closed=[I,H,D,B,A] Evaluate E not a goal

Goal: C

Page 69: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 69

search

Open=[A],closed=[] Evaluate A not a goal

Open=[B,C];closed=[A] Evaluate B not a goal

Open=[D,E,C];closed=[B,A] Evaluate D not a goal

Open=[H,I,E,C];closed=[D,B,A] Evaluate H not a goal

Open=[I,E,C];closed=[H,D,B,A] Evaluate I not a goal

Open=[E,C];closed=[I,H,D,B,A] Evaluate E not a goal

Open=[J,K,C];closed=[E,I,H,D,B,A]

Evaluate J not a goal

Goal: C

Page 70: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 70

search

Open=[A],closed=[] Evaluate A not a goal

Open=[B,C];closed=[A] Evaluate B not a goal

Open=[D,E,C];closed=[B,A] Evaluate D not a goal

Open=[H,I,E,C];closed=[D,B,A] Evaluate H not a goal

Open=[I,E,C];closed=[H,D,B,A] Evaluate I not a goal

Open=[E,C];closed=[I,H,D,B,A] Evaluate E not a goal

Open=[J,K,C];closed=[E,I,H,D,B,A] Evaluate J not a goal

Open=[K,C];closed=[K, E,I,H,D,B,A]

Evaluate K not a goal

Goal: C

Page 71: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 71

search

Open=[A],closed=[] Evaluate A not a goal

Open=[B,C];closed=[A] Evaluate B not a goal

Open=[D,E,C];closed=[B,A] Evaluate D not a goal

Open=[H,I,E,C];closed=[D,B,A] Evaluate H not a goal

Open=[I,E,C];closed=[H,D,B,A] Evaluate I not a goal

Open=[E,C];closed=[I,H,D,B,A] Evaluate E not a goal

Open=[J,K,C];closed=[E,I,H,D,B,A] Evaluate J not a goal

Open=[K,C];closed=[J,E,I,H,D,B,A]

Evaluate K not a goal

Open=[C];closed=[K,E,I,H,D,B,A]

Evaluate C is goal: STOP

Goal: C

Page 72: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 72

search

Depth-limited search depth-first search with depth limit L nodes at depth L have no successors Do not apply depth first after a certain depth

Iterative Deepening tries almost all depth limits

Searches the tree with L=0, L=1, L=2, etc…

Page 73: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 73

search

Iterative deepening search L=0

For depth 0, evaluate the root node and stop

Page 74: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 74

search

Iterative deepening search L=1

Page 75: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 75

search

Iterative deepening search L=1

Page 76: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 76

search

Iterative deepening search L=1

Page 77: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 77

search

Iterative deepening search L=2

Page 78: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 78

search

Iterative deepening search L=2

Page 79: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 79

search

Iterative deepening search L=3

Page 80: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 80

search

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 b1 + (d-1)b2 + … + 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 81: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 81

search 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 82: 1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further

CS 331/531 Dr M M Awais 82

search

Summary of algorithms