Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate expected distance #6

Closed
mpadge opened this issue Mar 22, 2017 · 5 comments
Closed

Calculate expected distance #6

mpadge opened this issue Mar 22, 2017 · 5 comments
Assignees

Comments

@mpadge
Copy link
Contributor

mpadge commented Mar 22, 2017

This is described at the start of Appendix D in Saerens et al. (2009) - implement it!

@karpfen one for you: This actually requires an additional modification of the current osmlines_as_network function because edge weights are distances times the weighting system for the preferred type of routing. The routing has to be calculated from these weights, but we also need a final (probabilistic) distance which has to be calculated from the raw distances. So the result of osmlines_as_network needs both of these columns.

The rcpp_router function thus needs to be modified accordingly. Maybe I'll do that, and you can fix up osmlines_as_network?

@karpfen
Copy link
Member

karpfen commented Mar 22, 2017

That does make sense. I'll get to it tomorrow!

@karpfen
Copy link
Member

karpfen commented Mar 24, 2017

Allright, I finished adapting osmlines_as_network. You can pass a road type as a parameter and the distance is weighted according to the Routino weighting profiles, which I put in osmprob::weightingProfiles. You can try it with

devtools::load_all ()
q <- osmdata::opq (bbox = c (11.58, 48.14, 11.585, 48.145))
dat <- osmdata::osmdata_sf (q, "tests/osm-ways-munich.osm")
graph <- osmlines_as_network (dat, profileName = "horse")

graph now has a column d_weighted with the weighted distance.

@karpfen karpfen added this to the Finish R part of the package milestone May 1, 2017
@karpfen
Copy link
Member

karpfen commented Jun 1, 2017

I fiddled around some more, trying to figure out what's wrong with the distance estimation. No results so far, but looking at the distance value, I saw that it's in the ballpark of the sum of all edge ids.

devtools::load_all (export_all = FALSE)
graph <- readRDS ("tests/compact-ways-munich.rds")
start_pt <- c (11.58, 48.14)
end_pt <- c (11.585, 48.145)
pts <- select_vertices_by_coordinates (graph, start_pt, end_pt)
route_start <- pts[1]
route_end <- pts [2]
prob <- get_probability (graph, route_start, route_end, eta = 1)
path <- get_shortest_path (graph, route_start, route_end)

path$distance # 0.7924514 (unit: km)
prob$distance # 584169
sum (prob$probability$edge_id) # 569309

also note that prob$distance is an integer and no float. Could it be that this is just a simple column mix up? I tried to figure it out, but r_router_prob is an enigma to us mere mortals.

@karpfen
Copy link
Member

karpfen commented Jun 1, 2017

Actually, scratch that! I ran some more examples today and they all came out just fine.

devtools::load_all (export_all = FALSE)
start_pt <- c (10.5350035429,47.6034937672)
end_pt <- c (10.5384796858,47.6071612749)

graph <- download_graph (start_pt, end_pt)
pts <- select_vertices_by_coordinates (graph, start_pt, end_pt)
route_start <- pts[1]
route_end <- pts [2]
path <- get_shortest_path (graph, route_start, route_end)
path$distance # 0.1426759

prob <- get_probability (graph, route_start, route_end, eta = 1.0)
prob$distance # 0.191191
prob <- get_probability (graph, route_start, route_end, eta = 0.2)
prob$distance # 0.2769817
prob <- get_probability (graph, route_start, route_end, eta = 0.1)
prob$distance # 0.3704895

Maybe it was just some error in the graph from the first example or so.

@mpadge
Copy link
Contributor Author

mpadge commented Jun 2, 2017

distance calculation generally works, so closing this and removing remaining issue to #30

@mpadge mpadge closed this as completed Jun 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants