- 80 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' Outline' - gay-holt

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Outline

- We will look at Dijkstra’s Shortest Path Algorithm.
- The issues in real world way-finding.
- The additional algorithms available in pgRouting
- OGC Location Services (OpenLS): Core Services

Permanent Labels Temporary Labels

V the set of vertices in the graph, xpaths are next steps

F set of vertices whose shortest-path lengths remains to be calculated

V – F (permanent labels) set of vertices whose shortest-path lengths have been calculated

Each iteration moves one vertex from F to (V – F)

Dijkstra’s Shortest Path Algorithm

- Dijkstra’s algorithm (Breath First Search (BFS)) for finding the shortest from a to v, involves assigning labels to vertices. Let L(v) denote the label of vertex v. At any point, some vertices have temporary labels and the rest have permanent labels, these are shown in red in the following slides. We let T denote the set of vertices having temporary labels.

After First Iteration Graph G(*)

For each x in T adjacent to v: L(x) = min{Lold(x),L(v)+w(v,x)}

Where w(v,x)

is distance

from v to x.

2

2

b

c

T := set of all temporary vertices

2

1

3

4

z

2

a

4

1

d

e

Labels

L(a)=min(,0)

L(f) = min{,0+1}

L(b) = min{,0+2}

6

7

3

f

g

1

5

Chose (v= f)∊ T as minimum L(v)

After Second Iteration Graph G(*)

For each x in T adjacent to v: L(x) = min{Lold(x),L(v)+w(v,x)}

Where w(v,x)

is distance

from v to x.

2

2

b

c

T := set of all temporary vertices

2

1

3

4

z

2

a

Labels

L(a)=min(,0)

L(f) = min{,0+1}

L(b) = min{,0+2}

L(d) = min{,0+1+3}

L(g) = min{,0+1+5}

1

4

4

d

e

6

7

3

f

g

1

6

5

Chose (v= b )∊ T as minimum L(v)

For each x in T adjacent to v: L(x) = min{Lold(x),L(v)+w(v,x)}

Where w(v,x)

is distance

from v to x.

2

4

2

b

c

T := set of all temporary vertices

2

1

3

4

z

2

a

Labels

L(a)=min(,0)

L(f) = min{,0+1}

L(b) = min{,0+2}

L(c) = min{,0+2+2}

L(d) = min{,0+1+3}

L(d) = min{4,0+2+2} --dif. path

L(e) = min{,0+2+4}

L(g) = min{,0+1+5}

6

1

4

4

d

e

6

7

3

f

g

6

5

1

Chose (v= c)∊ T as minimum L(v)

For each x in T adjacent to v: L(x) = min{Lold(x),L(v)+w(v,x)}

Where w(v,x)

is distance

from v to x.

2

4

2

b

c

T := set of all temporary vertices

2

1

3

4

z

5

2

a

Labels

L(a)=min(,0)

L(f) = min{,0+1}

L(b) = min{,0+2}

L(c) = min{,0+2+2}

L(d) = min{,0+1+3}

L(d) = min{4,0+2+2} dif. Path

L(e) = min{,0+2+4}

L(z) = min{,0+2+2+1}

L(g) = min{,0+1+5}

L(e) = min{6,0+2+2+3} dif. Path

6

4

1

4

d

e

6

7

3

f

g

6

5

1

Chose (v= d )∊ T as minimum L(v)

For each x in T adjacent to v: L(x) = min{Lold(x),L(v)+w(v,x)}

Where w(v,x)

is distance

from v to x.

2

4

2

b

c

T := set of all temporary vertices

2

1

3

4

z

5

2

a

Labels

L(a)=min(,0)

L(f) = min{,0+1}

L(b) = min{,0+2}

L(c) = min{,0+2+2}

L(d) = min{4,0+2+2}

L(z) = min{,0+2+2+1}

L(e) = min{,0+2+4}

L(g) = min{,0+1+5}

L(e) = min{6,0+2+2+3}

dif. Path a b c e

6

4

1

4

d

e

6

7

3

f

g

6

5

1

Chose (v= z)∊ T as minimum L(v)

For each x in T adjacent to v: L(x) = min{Lold(x),L(v)+w(v,x)}

Where w(v,x)

is distance

from v to x.

2

4

2

b

c

T := set of all temporary vertices

2

1

3

4

z

5

2

a

6

4

1

Labels

L(a)=min(,0)

L(f) = min{,0+1}

L(b) = min{,0+2}

L(c) = min{,0+2+2}

L(d) = min{,0+1+3}

L(d) = min{4,0+2+2} dif. Path

L(z) = min{,0+2+2+1}

L(e) = min{,0+2+4}

L(g) = min{,0+1+5}

L(e) = min{6,0+2+2+3} dif. Path

4

d

e

6

7

3

f

g

6

5

1

Terminate zT

Path to Z shorter than any unexplored path

a.2

3

b

c

2

2

0

1

z

a

1

Labels

L(b) = min{,0+2}

L(d) = min{,0+1}

2

1

d

e

a,1

Choose v ∊ T with minimum L(v)=d

a,2

3

b

c

2

2

0

1

z

a

1

Labels

L(b) = min{,0+2}

L(d) = min{,0+1}

L(e)=min{,0+1+1}

2

1

d

e

d.2

a.1

Choose v ∊ T with minimum L(v)=b

a,2

3

b,5

b

c

2

2

0

1

z

a

1

Labels

L(b) = min{,0+2}

L(d) = min{,0+1}

L(e)=min{,0+1+1}

L(c)=min{,0+2+3}

L(e)=min{2,0+2+1} diff path

2

1

d

e

d.2

a.1

Choose v ∊ T with minimum L(v) =e

a,2

3

b,5

b

c

2

2

0

1

a

z

e,4

1

Labels

L(b) = min{,0+2}

L(d) = min{,0+1}

L(e)=min{,0+1+1}

L(c)=min{,0+2+3}

L(e)=min{2,0+2+1} diff path

L(z)=min{,0+1+1+2}

Each node is labelled with its source node and the distance from the start node

2

1

d

e

d.2

a.1

Shortest path: a,d,e,z

Choose v ∊ T with minimum L(v)=z

7

d

b

2

10

5

2

f

4

3

e

Labels

L(b) = min{,0+5}

L(c) = min{,0+6}

Each node is labelled with its source node and the distance from the start node

a(0,a)

a

6

7

c

7

d

b

2

10

5

2

f

4

3

e

Labels

L(b) = min{,0+5}

L(c) = min{,0+6}

L(d) = min{,0+5+7}

L(f) = min{,0+5+10}

L(e) = min{,0+5+2}

L(c) = min{,0+5+3}

Each node is labelled with its source node and the distance from the start node

a(0,a)

a

6

7

c

c

7

d

b

2

10

5

2

f

4

3

e

Labels

L(b) = min{,0+5}

L(c) = min{,0+6}

L(d) = min{,0+5+7}

L(f) = min{,0+5+10}

L(e) = min{,0+5+2}

L(c) = min{,0+5+3}

Each node is labelled with its source node and the distance from the start node

a(0,a)

a

6

7

c

7

d

b

2

10

5

2

f

4

3

e

Labels

L(b) = min{,0+5}

L(c) = min{,0+6}

L(d) = min{,0+5+7}

L(f) = min{,0+5+10}

L(e) = min{,0+5+2}

L(c) = min{,0+5+3}

L(e) = min{,0+6+7}

Each node is labelled with its source node and the distance from the start node

a(0,a)

a

6

7

c

7

d

b

Minimum

Paths

2

10

5

2

f

4

3

e

a(0,a)

Labels

L(b) = min{,0+5} –from a

L(c) = min{,0+6} –from a

L(d) = min{,0+5+7} –from b

L(f) = min{,0+5+10} – from b

L(e) = min{,0+5+2} –from b

L(c) = min{6,0+5+3} –from b

L(c) = min{6,0+5+2 +7} –from e

L(f) = min{, 0+5+2 +4} – from e

d not explored because (5+2+4)<12

a

6

7

c

Shortest path: a,b,e,f

Length of path =11

5

v2

v3

3

6

3

1

2

v6

v1

0

1

6

3

4

v4

v5

Find the shortest distance from v1 to all other vertices

The shortest distance to each vertex can be read off the bottom row.

Len = 6

Yet another example

Each node is labelled with total distance and predecessor node

Find the shortest path from a to f in the graph G

All paths example

Find the shortest distance from v1 to all other vertices

The shortest distance to each vertex can be read off the bottom row.

Computer Graph Representation 1

- Adjacency matrix
- Rows and columns are labeled with ordered vertices write a 1 if there is an edge between the row vertex and the column vertex and 0 if no edge exists between them

Label rows with vertices

Label columns with edges

1 if an edge is incident to a vertex, 0 otherwise

Computer Graph Representation 2Issues when implementing networks and route finding in GIS(*)

- Real world networks (e.g. roads) tend to have many intermediate non-branching vertices (e.g. polylines) which contribute to large adjacency matrices.
- Networks often multi leveled (e.g walk, bus , train, bus, ferry, car).
- In some cases shortest path problems are subject to additional ‘thematic’ or ‘semantic’ constraints. (e.g. road type or quality of transmission line) Constrained Shortest Path Problem (CSPP).

Issues when implementing networks and route finding in GIS(*)

- Basic Dijkstra-type algorithms provide inconsistent run-times on real-world networks, principally because such networks have very limited vertex connectivity (their adjacency matrices are very sparse)1.
- Most network algorithms are 2-D, route on map maybe be in 3-D, (e.g. cross mountains).

Issues when implementing networks and route finding in GIS GIS(*)

- The OGC Simple Feature (SFSQL) standard used in PostGIS does not include any network representation, therefore an additional Network ADT must be provided, which must integrate with the existing standard. Ideally we would want to avoid two distinct non-compatible ADTs. The existing OGC data structures and algorithms for 2-dimensional objects contain polygons, edges, and vertices and must be augmented with connectivity information. Also, the OGC SFSQL must integrate with the 1-D route finding algorithms and network data structures. The Geographic Markup Language (GML1) provides network support.

Issues when GIS(*)using networks and route finding in GIS(*)

- The user must be able to understand how to use the Network ADT (e.g. pgRouting).
- User must make sure that the data in the appropriate format for the network ADT. This may require manual or software conversion of the data.

pgRouting: preparation GIS(*)

- A simple line graph needs to be transformed to include network topology, with connective nodes and edges, by issuing this command in the SQL Shell or pgAdmin SQL Query tool:
SELECT assign_vertex_id('edges', 0.001, 'the_geom', 'gid');

- assign_vertex_id() is a function included with the pgRouting extension. This is explained in the tutorial.
- In general, we need to update a table by adding a numerical value to a column that we previously created when issued the CREATE TABLE statement.
UPDATE edges SET length = length(the_geom);

- This creates a length field to hold the length value of network edges. This can be a cost. We would also use the same statement to update a “cost” column.

pgRouting GIS(*)

- Now we can use any of the GIS functions provided by PostGIS and pgRouting.
- Dijkstra’s algorithm is a good single-source routing algorithm provided by pgRouting.

Methods for Analysis GIS(*)

- To run the query and get an answer in WKT (Well-Known-Text), you can issue this command in pgAdmin’s SQL Query tool:
SELECT gid, AsText(the_geom) AS the_geom

FROM dijkstra_sp('edges', 1, 8);

Starting node = 1

Destination node = 8

‘edges’ = the table containing the network

Results GIS(*)

- Dijkstra’s results expressed in WKT:
- The “gid” is synonymous with “FID” in ArcGIS, and “the_geom” in this case is expressed in WKT. The numbers shown represent coordinate pairs that make up points along a polyline.
- WKT is an OGC (Open Geospatial Consortium) standard.
- In order to view the result in OpenJump we usually include the additional steps of making a result table or using an SQL view. Details are in the labs.

Dijkstra, A*, Shooting* GIS(*)

Anton Patrushev Shooting * includes turn restrictions, not covered on this course.

Dijkstra, A*, Shooting* GIS(*)

Anton Patrushev (Orkney, Inc.)

Dijkstra, A*, Shooting* GIS(*)

Anton Patrushev (Orkney, Inc.)

A heuristic algorithm GIS(*)

- A heuristic algorithm is an algorithm that is able to produce an acceptable solution to a problem in many practical scenarios, but for which there is no formal proof of its correctness. The algorithm uses a “rule of thumb” or “educated guess” to help find a solution.

A-Star a heuristic algorithm GIS(*)

- A* takes uses the distance so far plus cost heuristic.
- Two distinctions between Dijkstra and A*.
- A* uses a heuristic e.g. remaining distance.
- A* uses the distance already traveled and not simply the local cost from the previously expanded node. This in contrast to Dijkstra which is a greedy algorithm. Dijkstra can be used when the estimate to the goal is difficult or impossible to calculate.

A-Star a heuristic algorithm GIS(*)

- A* takes the distance already traveled into account and not simply the local cost from the previously expanded node. For each node x traversed, it maintains 3 values:
- g(x) : the actual shortest distance traveled from initial node to current node x.
- h(x) : the estimated (or "heuristic") distance from current node to goal
- f(x) : the sum of g(x) and h(x).

A-Star a heuristic algorithm GIS(*)

- The heuristics h(x) must not be an overestimate of the distance to the goal. The Euclidean (or straight line) distance is always less than or equal to the road distance.

pgRouting data structure GIS(*)

For further details of the data pgRouting structures see

http://pgrouting.postlbs.org/wiki/WorkshopFOSS4G2007

http://pgrouting.postlbs.org/wiki

Computational complexity GIS(*)1

- Computational complexity theory deals with the costs of computing a solution given problem. Costs can be measured in terms of time (e.g. number of iterations), space( e.g. memory required), best, average, and worst cases.
- CC can be applied to a wide range of algorithms including shortest path (e.g. Dijkstra and A*).

Complexity of GIS(*) DijkstraMathWorld--A Wolfram Web Resource

- The worst-case running time for the Dijkstra algorithm on a graph with n nodes and m edges is O(n2) because it allows for directed cycles. It can find the shortest paths from a source node s to all other nodes in the graph. This is basically O(n2) for node selection and O(m) for distance updates. While O(n2) is the best possible complexity for dense graphs, the complexity can be improved significantly for sparse graphs.

Complexity of GIS(*) A*Wikipedia

- The time complexity of A* depends on the heuristic. In the worst case, the number of nodes expanded is exponential in the length of the solution (the shortest path), but it is polynomial when the search space is a tree, there is a single goal state, and the heuristic function h meets the following condition:
- | h(x) − h*(x) | = O(log h*(x))
- where h* is the optimal heuristic, i.e. the exact cost to get from x to the goal. The error of h should not grow faster than the logarithm of the “perfect heuristic” h* that returns the true distance from x to the goal

Gateway Service Details GIS(*)

Gateway Mobile Location Center

Position Determination Entity

GMLC/MPC: this interface is modeled after the Mobile Location Protocol (MLP), Standard Location Immediate Service.

OGC OpenLS GIS(*)

- Standards with respect to LBSs have been set up by the International Standard Organisation (ISO) and by the Open Geospatial Consortium (OGC). The OGS has released the Open Location Services (OpenLS - Open Geospatial Consortium 2005). OpenLS defines core services, their access and abstract data types which form together a framework for a open service platform, the so called GeoMobility server. The server acts as application server and should process and answer core service requests. The role of this server is pictured in the previous slide. It should be noticed that service requests to a GeoMobility server can be send from a mobile user, from Internet users and also from other application servers.

Applications of LBS GIS(*)

- Traffic Information: there is a traffic queue, so turn right.
- Emergency Services: help, I'm having a heart attack!
- Roadside Emergency; “help, my car has broken down!
- Law Enforcement: what is the speed limit on this road
- Classified Advertising; where are nearby sales featuring antiques
- Object visualization: where is the historic parcel boundary
- Underground Object Visualization: “where is the water main?”
- Public Safety Vehicle Mgt: who is closest to that emergency?”
- Location-Based Billing; free calls on your phone, in a location
- Leisure Information: How do we get to the Club from here
- Road Service Information: Where is the nearest petrol station
- Directions: I'm lost, where is nearest Metro station
- Vehicle Navigation; how do I get back to the Interstate from here?
- Vehicle Theft Detection: my car has been stolen, where is it
- Child Safety: tell me if my child strays beyond the neighborhood.

Location Based Services GIS(*)

Please read Navigation Systems: A Spatial Database Perspective

http://www-users.cs.umn.edu/~shekhar/research/lbsChapter.pdf

OGS OpenLS GIS(*)

Location Utilities Service GIS(*)

- The OpenLS utilities specification provides two services, geocoding and reverse geocoding, and an abstract data type named as Address. The geocoder service is a network-accessible service that transforms a description of a location into a normalized description of the location with point geometry. The reverse geocoder service maps a given position into a normalized description of a feature location.

Directory Service GIS(*)

- The directory service provides a search capability for one or more points of interest (e.g., a place, product, or service with a fixed position) or area of interest (e.g., a polygon or a bounding box). The DS is a network-accessible service that provides access to an online directory (a kind of spatial Yellow Pages) to find the location of a specific or nearest place, product or service. An example query is ‘‘Where is the nearest thesis binder to Kevin Street?’’

Presentation Service. GIS(*)

- This service deals with visualization of the spatial information as a map, route, and/or textual information (e.g., route description). The Presentation (Map Portrayal) Service portrays a map made up of a base map derived from any geospatial data and a set of Abstract Data Types as overlays.

Gateway Service GIS(*)

- This service enables obtaining the position of a mobile terminal from the network. The Gateway Service is a network-accessible service that fetches the position of a known mobile terminal from the network. The gateway is the interface between the GeoMobility Server and the Location Server from the Positioning Service. It is useful to request for the current location with different modes (e.g. multi or single terminal, immediate or periodic position).

Gateway Service Details GIS(*)

Gateway Mobile Location Center

Position Determination Entity

GMLC/MPC: this interface is modeled after the Mobile Location Protocol (MLP), Standard Location Immediate Service.

Route Determination Service GIS(*)

- This service provides the ability to find a best route between two points that satisfies user constraints. RDS determines travel routes and navigation information according to diverse criteria.

Suggested reading GIS(*)

- Paper
- Navigation Systems: A Spatial Database Perspective by Shashi Shekhar, Ranga Raju Vatsavai, Xiaobin Ma, and Jin Soung Yoo.
http://www-users.cs.umn.edu/~shekhar/research/lbsChapter.pdf

- Book: Location-Based Services: by Schiller & Voisard
- Web
- http://www.opengeospatial.org/standards/ols
- http://pgrouting.postlbs.org/
- http://www.openrouteservice.org/
- http://www.davidgis.fr/documentation/pgrouting-1.02/http://www.utdallas.edu/~ama054000/rt_tutorial.html
- http://www.directionsmag.com/article.php?article_id=2876&trv=1
- http://www.geographie.uni-bonn.de/karto/

Download Presentation

Connecting to Server..