View
4
Download
0
Category
Preview:
Citation preview
J E F F R E Y L . P O P Y A C K
GRAPHSEARCH
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
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
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
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:
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
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
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
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
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
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.
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
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
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
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).
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).
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.
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.
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
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
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
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
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
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.
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
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
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!
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.
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.
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
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
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
Recommended