580 Dijk Stra
-
Upload
juan-perez-cotapo -
Category
Documents
-
view
216 -
download
0
Transcript of 580 Dijk Stra
-
7/28/2019 580 Dijk Stra
1/11
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
CSCE 580Artificial IntelligenceDijkstras Algorithm: Notes to
Complement and Reinforcethe Graduate Student
PresentationFall 2008
Marco Valtorta
-
7/28/2019 580 Dijk Stra
2/11
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Example: Romania
-
7/28/2019 580 Dijk Stra
3/11
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Single-State ProblemFormulation
A problem is defined by four items:
1. initial state e.g., "at Arad"2. actions or successor functionS(x) = set of action
state pairs e.g., S(Arad) = {,
, }3. goal test, can be
explicit, e.g.,x= "at Bucharest" implicit, e.g., Checkmate(x)
4. path cost (additive) e.g., sum of distances, number of actions
executed, etc. c(x,a,y) is the step cost, assumed to be 0
A solution is a sequence of actions leading fromthe initial state to a goal state
-
7/28/2019 580 Dijk Stra
4/11
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Uniform-Cost (Dijkstra) forGraphs
Original Reference: Dijkstra, E. W. "A Note on Two Problems inConnexion with Graphs. Numerische Matematik, 1 (1959),269-271
1. Put the start node s in OPEN. Set g(s) to 0 2. If OPEN is empty, exit with failure
3. Remove from OPEN and place in CLOSED a node n forwhich g(n) is minimum; in case of ties, favor a goal node
4. If n is a goal node, exit with the solution obtained bytracing back pointers from n to s
5. Expand n, generating all of its successors. For eachsuccessor n' of n:
a. compute g'(n')=g(n)+c(n,n') b. if n' is already on OPEN, and g'(n')
-
7/28/2019 580 Dijk Stra
5/11
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Properties of DijkstrasAlgorithm
g(n) is the distance (cost) of some path from the startnode to node n
f*(n) is the minimum of g(n) over all possible paths fromthe start node to node n
f*(k) is the distance of the goal node from the start
node---assume a single goal node, k, for simplicity A search algorithm is admissible if it returns the
shortest path
1. When node n is closed in step 3, g(n)=f*(n)
2. When node n is closed at step 3, g(n) is at least as
high as the g value of all already closed nodes and allnodes with lower g values than g(n) have already beenclosed
3. Only nodes for which g(n)
-
7/28/2019 580 Dijk Stra
6/11
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Property 1 of DijkstrasAlgorithm
When node n is closed in step 3, g(n)=f*(n) The proof is by induction on the number of
closed nodes. For the base case, g(s) = f*(s) =0.
Let n1,,nq be the nodes in OPEN. Let n = ni Consider the path to n through nodes in
CLOSED that establishes that n is to be closedin step 3
Assume that there is a shorter path to n thanthe one chosen by Dijkstras algorithm. Let npbe the first node in OPEN on that path. Sincepath snpni is shorter than g(n), then pathsnp is shorter than path sni.This means thatwhen executing step 3, g(np) < g(ni), andtherefore np would be closed in step 3 instead
-
7/28/2019 580 Dijk Stra
7/11UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Property 2 of DijkstrasAlgorithm
When node n is closed at step 3, g(n) is atleast as high as the g value of all alreadyclosed nodes and all nodes with lower g
values than g(n) have already beenclosed
This can also be proven by induction. For theinduction step, note that the node that is
closed at step 3 has g(n) value that is at leastas high than that of all previously closednodes---otherwise it would have been closedbefore!
Also note that this proof depends crucially onhaving non-negative edge costs
-
7/28/2019 580 Dijk Stra
8/11UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Property 3 and 4 of DijkstrasAlgorithm
Only nodes for which g(n)
-
7/28/2019 580 Dijk Stra
9/11UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Property 5 of DijkstrasAlgorithm
Dijkstra's algorithm expands the least numberof nodes among all admissible blind,
unidirectional search algorithms
Adversary argument
I claim there is an algorithm (say, B) that does notexpand node m, for which g(m) < f*(k) on somegraph search problem (say, G) and is admissible
Let f*(k)-g(m) = e
Consider an instance of graph search problemidentical to G except for the additional edge mkof cost e/2
Since B does not expand node m, it will not returnthe shortest path of length f*(k)-(e/2)
Therefore, B is not admissible
-
7/28/2019 580 Dijk Stra
10/11UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Lower Bound Assumptions and notation:
decision-tree model (count comparisons of edge costs) blind unidirectional algorithms
n is the number of nodes and m is the number of edgesin the (implicit) graph been searched
Property 5 implies (m) (n log(n)) follows from a transformation of
sorting to finding the shortest path spanning treeand a sequence of all the n nodes ordered inincreasing distance from the start node
Overall: (m + n log(n))
The Fibonacci tree implementation of Dijkstrasalgorithm matches the lower bound and istherefore optimal
See reference in notes
-
7/28/2019 580 Dijk Stra
11/11UNIVERSITY OF SOUTH CAROLINA Department of Computer Science andEn ineerin
Bidirectional Uniform-CostAlgorithm (Assume that there is only one goal node, k.)
1. Put the start node s in OPEN1 and the goal node k in OPEN2. Set g(s) andh(k) to 0
2'. If OPEN1 is empty, exit with failure 3'. Remove from OPEN1 and place in CLOSED1 a node n for which g(n) is
minimum 4'. If n is in CLOSED2, exit with the solution obtained by tracing backpointers
from n to s and forward pointers from n to k 5'. Expand n, generating all of its successors. For each successor n' of n:
a. compute g'(n')=g(n)+c(n,n') b. if n' is already on OPEN1, and g'(n')