-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Always use original weights when handling --parse-conditionals-from-now #6399
base: master
Are you sure you want to change the base?
Changes from all commits
9fd452f
db82cec
4f10b15
dc27a07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,6 +353,28 @@ Feature: Car - Turn restrictions | |
| b | a | bj,jc,jc,aj,aj | | ||
| b | d | bj,jd,jd | | ||
|
||
# here we check that conditional restrictions can be updated via re-run of `contract`/`customize` with updated `--parse-conditionals-from-now` | ||
# 10am utc, sat | ||
When I run "osrm-contract {osm_file} --time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1494064800" | ||
When I run "osrm-customize {osm_file} --time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1494064800" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also probably we should vendor geojson with time zones to the repo, not sure what can be problem here, but it would ease a lot usage of this feature for beginners. |
||
|
||
When I route I should get | ||
| from | to | route | | ||
| b | c | bj,jc,jc | | ||
| b | a | bj,aj,aj | | ||
| b | d | bj,jd,jd | | ||
|
||
# 10am utc, wed | ||
When I run "osrm-contract {osm_file} --time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493805600" | ||
When I run "osrm-customize {osm_file} --time-zone-file=test/data/tz/{timezone_names}/guinea.geojson --parse-conditionals-from-now=1493805600" | ||
|
||
When I route I should get | ||
| from | to | route | | ||
| b | c | bj,jc,jc | | ||
| b | a | bj,jc,jc,aj,aj | | ||
| b | d | bj,jd,jd | | ||
|
||
|
||
@no_turning @conditionals | ||
Scenario: Car - Conditional restriction with multiple time windows | ||
Given the extract extra arguments "--parse-conditional-restrictions" | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -583,8 +583,17 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e | |||||||||||||||||||
[&] { extractor::files::readNodeData(config.GetPath(".osrm.ebg_nodes"), node_data); }, | ||||||||||||||||||||
|
||||||||||||||||||||
[&] { | ||||||||||||||||||||
extractor::files::readTurnWeightPenalty( | ||||||||||||||||||||
config.GetPath(".osrm.turn_weight_penalties"), turn_weight_penalties); | ||||||||||||||||||||
// we are going to overwrite this `.turn_weight_penalties` afterwards, | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code modifies a couple of other files too and probably we should use similar approach for them too, but it is not so obvious as here: IIUC other files are related to traffic handling, i.e. it is more obvious for users that they need to provide data for all edges while updating speeds(but tbh I just had brief look into that code and not confident in it :) ). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On another hand it seems to be good idea to preserve "default" speed weights for segments user didn't provide data for 🤔 So would appreciate opinions here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mjjbell wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current behaviour of overwriting the files on updates means that you can make multiple independent changes and they will all apply. This proposed change would alter that behaviour (only last update is applied), with the alternative being to apply the cumulative changes on every update, which will be slower. So I don't think we should go with this. For someone who is updating turn weights via traffic updates, we can probably assume they have a model of the data for any time, so aren't too bothered about recovering the original weights. For conditional penalties, I think what we need is an osrm-backend/src/updater/updater.cpp Lines 514 to 521 in 2cf9571
Alternatively, rather then overwriting the weight value when the conditional is applied, we only set it in the local value used to update the edge weights? That way we aren't destroying the value used when the conditional doesn't apply. osrm-backend/src/updater/updater.cpp Line 765 in 2cf9571
|
||||||||||||||||||||
// so here we backup the original turn penalties if we didn't do that yet in order | ||||||||||||||||||||
// to guarantee that subsequent runs of this code will work on top of original | ||||||||||||||||||||
// weights | ||||||||||||||||||||
auto path = config.GetPath(".osrm.turn_weight_penalties").string() + ".original"; | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this problem made me think about if we can handle all these time based restrictions automatically without forcing users to make error-prone operations to handle this. It feels it should be relatively not so many time based restrictions in the graph and we probably can just handle it dynamically. It seems to be a bit against philosophy of OSRM when it tries to precalculate all weights to be as fast as possible, but at the same time it should add a lot of flexibility:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can probably be discussed separately. There will be practical as well as philosophical issues. |
||||||||||||||||||||
if (!boost::filesystem::exists(path)) | ||||||||||||||||||||
{ | ||||||||||||||||||||
boost::filesystem::copy_file(config.GetPath(".osrm.turn_weight_penalties"), | ||||||||||||||||||||
path); | ||||||||||||||||||||
} | ||||||||||||||||||||
extractor::files::readTurnWeightPenalty(path, turn_weight_penalties); | ||||||||||||||||||||
}, | ||||||||||||||||||||
[&] { | ||||||||||||||||||||
extractor::files::readTurnDurationPenalty( | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to just extend existing test, but not add new one.