Graphsearch - Drexel CCI

32
JEFFREY L. POPYACK GRAPHSEARCH

Transcript of Graphsearch - Drexel CCI

Page 1: Graphsearch - Drexel CCI

J E F F R E Y L . P O P Y A C K

GRAPHSEARCH

Page 2: Graphsearch - Drexel CCI

GRAPHSEARCH

Review:• Irrevocable vs. Tentative Strategies• Implicit vs. Explicit Graphs• Implicit vs. Explicit Enumeration• Weighted Graphs vs. Uniform CostIrrevocable Tentative

Flail Wildly BacktrackHill Climbing - heuristicsSimulated Annealing - symmetryTabu Search - forward/backward searchGenetic Algorithms Graphsearch

Swarm Optimization

Page 3: Graphsearch - Drexel CCI

GRAPHSEARCH

• Maintain all nodes generated, not just current path• Each node will have one parent as its predecessor

(if nodes recur w/different parents, choose one that provides best path from start to current node)

Example: F has two parents, B and EClearly, B is the better choice, so forget E-F edge.

Result will be a search tree, where each node has exactly one path back to the root.

A

B C D

EF G H I J

Page 4: Graphsearch - Drexel CCI

GRAPHSEARCH

• Result is a subtree of the problem graph.• How to decide which node to examine next is the

philosophy that provides different versions of the Graphsearch algorithm.

Variations of Graphsearch:• Breadth-First Search• Depth-First Search• Best-First Search

A

B C D

EF G H I J

Page 5: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph:

Page 6: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph: Search Tree:

A

Begin with the start node (A).

Level 0

Page 7: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

Examine a node, and generate its offspring (successors). This is called "expanding" a node.

Level 0

Level 1

Page 8: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

Choose a node at Level 1, and expand it. Note C has already been generated. Is B preferable to A as C's current parent?

Level 0

Level 1

Level 2

Page 9: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

Choose a node at Level 1, and expand it. Note C has already been generated. Is B preferable to A as C's current parent?Apparently not! But if edges do not

have uniform costs, it's possible.

Level 0

Level 1

Level 2

Page 10: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

Expand another node at Level 1. Chas children G and H. G has already been generated. No apparent advantage to reassigning its parent.

Level 0

Level 1

Level 2

Page 11: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

Expand another node at Level 1. Chas children G and H. G has already been generated. No apparent advantage to reassigning its parent.

Level 0

Level 1

Level 2

KEY DIFFERENCE:Breadth-First Search will examine C or D next. Depth First Search will examine E, F or G next.

Page 12: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G H

Expand another node at Level 1. Chas children G and H. G has already been generated. No apparent advantage to reassigning its parent.

Level 0

Level 1

Level 2

Page 13: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G H

Expand another node at Level 1. D has children H, I and J. No need to change H's parent.

Level 0

Level 1

Level 2

Page 14: Graphsearch - Drexel CCI

BREADTH-FIRST SEARCH

Breadth-First Search: Build search tree by examining all nodes at level k before examining any at level k+1, k+2, etc.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G H I J

Expand another node at Level 1. D has children H, I and J. No need to change H's parent.

Level 0

Level 1

Level 2

Page 15: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

We again begin with the start node (A).

Page 16: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

Likewise, expand a node's to reveal its offspring (successors).

Page 17: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

At this point, the search tree for Depth-First search is identical to that for Breadth-First search.

Page 18: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

At this point, the search tree for Depth-First search is identical to that for Breadth-First search. We again decide not to reassign C's parent.

Page 19: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

The children of Eare D, F, G (no need to change parents) and I.

I

Page 20: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

We next examine I (no children), then F, and G (no children).

I

Page 21: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

C has children G (already seen – and expanded, no need to reassign parent) and H.

I

H

Page 22: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

C has children G (already seen – and expanded, no need to reassign parent) and H.

I

H

Page 23: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

H has no children.I

H

Page 24: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

I

H J

D has children H(already seen, and expanded, no need to reassign parent), I, J.

Page 25: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G

I

H

I's parent is reassigned to D, since it is closer.

J

Page 26: Graphsearch - Drexel CCI

DEPTH-FIRST SEARCH

Depth-First Search: Build search tree by examining most recently generated children first.

A

B C D

EF G H I J

Graph: Search Tree:

A

B C D

E F G H

I's parent is reassigned to D, since it is closer.

JI

Page 27: Graphsearch - Drexel CCI

FINER POINTS

In this small example, Breadth-First Search and Depth-First search eventually generated the same search trees of the problem graph.

Don’t count on that happening in general!

Page 28: Graphsearch - Drexel CCI

FINER POINTS

Difference between handling • a node that has been seen previously, but not

expanded, and • a node that has both been seen previously, and

expanded A

B C D

E F G

I

H J

Suppose in previous example that I had other offspring:

KL

MN

By reassigning I's parent, future generationsare also reassigned.

And their depths are recomputed.

Page 29: Graphsearch - Drexel CCI

FINER POINTS

Graphsearch will be a generalized algorithm that describes both depth-first and breadth-first search.• The depth of each node is an important attribute,

and will have to be re-calculated after reassigning parent links.

Page 30: Graphsearch - Drexel CCI

FINER POINTS

• When generating a node's offspring/successors ("expanding the node"):• Some offspring may have been seen before,

but not expanded (like C):Or like I – we find a shorter path the next time:Choose to re-adjust who the parent of that nodeis, based on path cost from root to that node.

A

B C

A

B D

E

I

Page 31: Graphsearch - Drexel CCI

FINER POINTS

• When generating a node's offspring/successors ("expanding the node"):• Some offspring may have been seen before,

but not expanded (like C):Or like I – we find a shorter path the next time:Choose to re-adjust who the parent of that nodeis, based on path cost from root to that node.

• Some offspring may have been seen before, and expanded (like I in the lastexample):Adjust depth value of all descendants of the child node.

A

B C

KL

MN

A

B D

E

I

0

11

3

2

4

54

5

Page 32: Graphsearch - Drexel CCI

FINER POINTS

• When generating a node's offspring/successors ("expanding the node"):• Some offspring may have been seen before,

but not expanded (like C):Or like I – we find a shorter path the next time:Choose to re-adjust who the parent of that nodeis, based on path cost from root to that node.

• Some offspring may have been seen before, and expanded (like I in the lastexample):Adjust depth value of all descendants of the child node.

A

B C

KL

MN

A

B D

E

I

0

11

3 2

2

3 4

4 54 3

5 4