Docsity

Path Planning: Dijkstra's Algorithms - Lecture Notes | CS 351L, Study notes of Computer Science

Partial preview of the text

Download Path Planning: Dijkstra's Algorithms - Lecture Notes | CS 351L and more Study notes Computer Science in PDF only on Docsity!

Path Planning: Dijkstra’s

Algorithm

How to get from here to there (when you’re not a crow)

Administrivia

Groups:

Send me list of people in your group

Pick a group name (optional)

Schedule weekly progress meetings w/ me

A bit more formally...

First step: pin down precisely what we’re talking about

Let G =< V , E > be a graph with vertex set V and edge set E

In P3: G is complete map

V is set of cells (locations where a UNIT can be)

E is transitions between those cells (N, S, E, W)

Let every edge, ( v i , v j )∈ E have an associated weight :

w ( v i , v j ) == distance to go from v i to v j

Caveat: w ( v i , v j )≥ 0 ∀ v i , v j

∈ V

In P3: weight == move cost*move rate

What we’re looking for...

Given:

Source node, s ∈ V (UNIT’s current location)

Terminal node, t ∈ V (UNIT’s goal location)

Find:

Path

Such that total weight (length or cost) of path,

is minimized

p = 〈s, v 1 , v 2 ,... , vn , t〉

|p|− 1

i=

w(p[i], p[i + 1])

Accounting

At the end of the algorithm, we’ll want to know 2 things:

Distance from s to every node along the shortest path

The shortest path from s to t itself

As a side-effect, we’ll also know:

Distance and shortest path from s to all points along p

Distance and shortest path from s to a whole bunch of other stuff in the graph (map)

Accounting info

To handle the accounting info, maintain 2 different data structs:

d [ v ]==shortest path estimate from s to v

Upper bound -- can be greater than true shortest dist during execution of alg.

π [ v ]==predecessor of v along (current best- known) shortest path from s to v

Written as arrays, but that’s not necessarily the best representation...

At termination of alg, d [ v ] will be exact shortest- path distance and π [ v ] will be exact shortest path

Subroutine 2: Relaxation

function relax( u , v , w ): // u : current node // v : successor node // w : weight function if d [ u ]+ w ( u , v )< d [ v ] { d [ v ]= d [ u ]+ w ( u , v ); π [ v ]= u ; }

Main routine: Dijkstra’s

function dijkstraSSP( G , w , s ): // G : complete graph // w : weight function // s : source node (start location) initializeSSPDataStructs(); Set S=new Set(); Queue Q=new PriorityQueue( G. V , d ); while (!Q.isEmpty()) { Vertex u =Q.extractMin(); S.add( u ); for (Iterator i= u .neighbors();i.hasNext();) { Vertex v =i.next(); relax( u , v , w ); } }