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

Re-costing A Path #2425

Merged
merged 47 commits into from
Aug 7, 2020
Merged

Re-costing A Path #2425

merged 47 commits into from
Aug 7, 2020

Conversation

kevinkreiser
Copy link
Member

@kevinkreiser kevinkreiser commented Jun 17, 2020

Re-costing a path is an interesting concept. It can be useful when you have a shortcut in your path but for proper guidance you dont want to return a route with shortcuts, so you recover them but now the edge labels from the shortcut path and their costs need to be divided up. A recosting method would allow recovering the costs for the non-shortcut version of the path.

Re-costing could also be useful in determining the relative value of a certain path amongst differently configured costing models. For example one could change the start date_time of a given path and see how it fluctuates over the course of some period of time. Or you could even change something like use_hills to see if hilliness is a major contributor to cost along a given path.

Finally recosting can and will be used in time dependent bidirectional a*. One of the main issues with that refactoring is that you need to make a guess at the time at one end of the search. After the search is completed you need to update your guess to the real measured time of arrival/departure. To do this we can simply recost the final path to get the final time.

EDIT:

I ran RAD on 14k random auto routes of various lengths. Diffing for everything from the directions output (time/distance/narrative) there were a total of 63 differences. When removing time/distance from the output (because many of them were off by a single second) there were 0 differences.

@kevinkreiser kevinkreiser marked this pull request as ready for review June 26, 2020 15:38
src/sif/autocost.cc Outdated Show resolved Hide resolved
src/sif/bicyclecost.cc Outdated Show resolved Hide resolved
src/thor/triplegbuilder.cc Show resolved Hide resolved
src/sif/util.cc Outdated Show resolved Hide resolved
src/sif/util.cc Outdated
// get the previous edges node
node = edge ? reader.nodeinfo(edge->endnode(), tile) : nullptr;
if (edge && !node) {
throw std::runtime_error("Node cannot be found");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: these unexpected errors should not be caught by the caller, should bubble up to become a 500 error.

@kevinkreiser kevinkreiser requested a review from danpat July 13, 2020 16:17
@kevinkreiser kevinkreiser assigned purew and unassigned purew Jul 13, 2020
@kevinkreiser kevinkreiser requested a review from purew July 13, 2020 18:02
src/sif/bicyclecost.cc Outdated Show resolved Hide resolved
}

/**
* Helper function to initialize the object from a location. Uses the graph to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/from a location/from a datetime

test/gurka/test_recost.cc Outdated Show resolved Hide resolved
@@ -155,6 +155,7 @@ const std::unordered_map<unsigned, std::string> OSRM_ERRORS_CODES{
{124, R"({"code":"InvalidOptions","message":"Options are invalid."})"},
{125, R"({"code":"InvalidOptions","message":"Options are invalid."})"},
{126, R"({"code":"InvalidOptions","message":"Options are invalid."})"},
{127, R"({"code":"InvalidOptions","message":"Options are invalid."})"},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a more recostings-specific error message here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should save that for another pr. at the moment, to remain osrm compatible we decided to, as much as we could, use messages that existed in that project. maybe its time to open up a discussion around whether that really makes sense anymore. i hope you are cool with doing that on another issue/PR though?

* use constrained time of day by default for any non-time dependent speed look up

* didnt need this change

* i didnt touch this code but somehow its linted differently..

* routes bench adapt to costing refactor
// TODO: test restrictions
// we need to move to the next node which has the elapsed time at the end of the edge
++elapsed_itr;
EXPECT_NEAR(elapsed_itr->cost().elapsed_cost().seconds(), label.cost().secs, .1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we test only that the transition.secs and elapsed.secs are the same between route and recost, we should also test that the costs are the same

@kevinkreiser kevinkreiser merged commit de546d7 into master Aug 7, 2020
// TODO: There's a difference in the way a route is costed in reverse vs forward this could be
// a result of FormPath in timedep_reverse or it could be a result of the difference between
// TransitionCost and TransitionCostReverse. When that is resolved we can enable these tests
return;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to get to the bottom of this, but in a separate issue/pr

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

Successfully merging this pull request may close these issues.

5 participants