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

Add use_tunnels option #4318

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Conversation

ADMUKHE
Copy link

@ADMUKHE ADMUKHE commented Oct 3, 2023

Add Tunnel factor to Autocost

Presently valhalla cannot avoid roads if tunnel is present. These changes will add tunnel factor in Edge Cost Calculations.

The program was tested solely for our own use cases, which might differ otherwise. I acknowledge that these changes have the potential to impact other use cases, and it is essential to exercise caution and thorough testing when merging them to the master. Your expert opinion is requested to help us review, test, and adapt these modifications as needed. I am also looking forward to other implementation ideas and discussions about how we can tackle this issue. Aditionally i am trying to learn more about valhalla and need your comments to improve my coding

Tasklist

  • Add tests
  • Add #fixes with the issue number that this PR addresses
  • Update the docs with any new request parameters or changes to behavior described
  • Update the changelog
  • If you made changes to the lua files, update the taginfo too.

Adrika Mukherjee adrika.mukherjee@mercedes-benz.com, Mercedes-Benz Tech Innovation GmbH
Provider Information

@ADMUKHE ADMUKHE closed this Oct 3, 2023
@ADMUKHE ADMUKHE reopened this Oct 3, 2023
@ADMUKHE ADMUKHE marked this pull request as ready for review October 3, 2023 22:46
@johannes-no
Copy link
Contributor

Since this is a soft avoidance of tunnels, there should be a boolean set like has_tunnel in the route summary indicating whether the route uses tunnels.

Copy link
Member

@nilsnolde nilsnolde left a comment

Choose a reason for hiding this comment

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

IMO it only makes sense to expose a use_tunnel option. PR looks generally fine, just LOTS of unrelated adverse changes in the test.

Also

  • I'd personally like to see a gurka test as well for the costing option, parameterized for all modes that use this. Ideally we'd not create an additional test file, but rather consolidate the other test_use_* into one single file for the sake of compilation speed (i.e. test_use_lit.cc, test_use_living_streets.cc, test_use_tracks.cc)
  • an additional edge and check in gurka/test_use_feature.cc
  • we should do this for all motorized vehicles I think? for ped (and bike?) we had a discussion before around safety issues, I think that'd need to be differently handled than the rest

@@ -333,7 +334,7 @@ std::string get_request_str(const std::string& parent_key,
return R"({")" + parent_key + R"(":{)" + get_kv_str(key, expected_value) + R"(}})";
}

std::string get_kv_str(const std::string& key, const std::vector<std::string>& values) {
std::string get_kv_str(const std::string& key) {
Copy link
Member

Choose a reason for hiding this comment

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

why this change?

@@ -457,8 +458,7 @@ void test_filter_action_parsing(const valhalla::FilterAction expected_value,
validate(key, expected_value, true, request.options().filter_action());
}

void test_filter_attributes_parsing(const std::vector<std::string>& expected_values,
const Options::Action action = Options::trace_attributes) {
void test_filter_attributes_parsing(const Options::Action action = Options::trace_attributes) {
Copy link
Member

Choose a reason for hiding this comment

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

and why this change?

@@ -1537,7 +1554,6 @@ void test_bicycle_parsing(const Costing::Type costing_type,

void test_filter_stop_parsing(const Costing::Type costing_type,
const valhalla::FilterAction filter_action,
const std::vector<std::string>& filter_ids,
Copy link
Member

Choose a reason for hiding this comment

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

and this?

@@ -1555,7 +1571,6 @@ void test_filter_stop_parsing(const Costing::Type costing_type,

void test_filter_route_parsing(const Costing::Type costing_type,
const valhalla::FilterAction filter_action,
const std::vector<std::string>& filter_ids,
Copy link
Member

Choose a reason for hiding this comment

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

and this?

@@ -1573,7 +1588,6 @@ void test_filter_route_parsing(const Costing::Type costing_type,

void test_filter_operator_parsing(const Costing::Type costing_type,
const valhalla::FilterAction filter_action,
const std::vector<std::string>& filter_ids,
Copy link
Member

Choose a reason for hiding this comment

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

and this?

@@ -566,4 +566,4 @@ inline void from_ll(valhalla::Location* l, const midgard::PointLL& p) {
l->mutable_ll()->set_lng(p.lng());
}

} // namespace valhalla
} // namespace valhalla
Copy link
Member

Choose a reason for hiding this comment

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

and this?

@@ -399,6 +402,14 @@ AutoCost::AutoCost(const Costing& costing, uint32_t access_mask)
toll_factor_ = use_tolls < 0.5f ? (4.0f - 8 * use_tolls) : // ranges from 4 to 0
(0.5f - use_tolls) * 0.03f; // ranges from 0 to -0.15

// Preference to use tunnel roads. Sets a tunnel
// factor. A tunnel factor of 0 would indicate no adjustment to weighting for tunnel roads.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// factor. A tunnel factor of 0 would indicate no adjustment to weighting for tunnel roads.
// factor. A tunnel factor of 0.5 would indicate no adjustment to weighting for tunnel roads.

@nilsnolde
Copy link
Member

I'd recommend you go through the Github view of the diff in https://github.com/valhalla/valhalla/pull/4318/files after you commit (ideally in your own IDE before you even push to not needlessly run CI with stuff that'll break for sure).

@nilsnolde
Copy link
Member

Bonus points for adding comments on your own PR to explain non-obvious changes, which saves tons of time for the reviewers. (e.g. here I personally would have noted that the costing change is a 100% copy of use_tolls)

@ADMUKHE
Copy link
Author

ADMUKHE commented Oct 19, 2023

@nilsnolde for ped and bike then would you suggest to have a seperate PR?

@nilsnolde
Copy link
Member

If you’re interested in the functionality, I’d prefer a separate PR bcs the discussion would be very different and we’d first open an issue for that. But don’t feel obliged to take care of that too. It’s fine to not expose for those modes for the time being.

@kevinkreiser
Copy link
Member

there is a slight technical detail here that i thought someone mentioned but i dont see it mentioned here:
https://github.com/valhalla/valhalla/blob/3806832a11fe250e08f6f21c9f55da0e052bfc80/src/mjolnir/shortcutbuilder.cc#L69C1-L71C28

we create shortcuts overtop of bridges and tunnels which means the costing will not avoid a tunnel if its part of a shortcut that the algorithm is using. given that tunnels arent as prevalant as bridges we could probably get away with adding tunnel as an attribute that has to match during shortcut building. bridges could be a pretty big problem though..

@kevinkreiser
Copy link
Member

i also agree with @nilsnolde that we should consider just adding use_tunnels to all motorized vehicles. we could move the parsing and factor to the base costing class and just use it from the children that make sense.

the rest of the pr looks great!

@nilsnolde
Copy link
Member

Just as a note: the only thing missing is a gurka test to verify the behavior of the costing option. Then it’s good to merge.

@ADMUKHE
Copy link
Author

ADMUKHE commented Dec 4, 2023

@nilsnolde is it not covered in the test_use_feature test? can you give any reference to any other gurka test specific to costing option in case you are talking about something else?

@nilsnolde
Copy link
Member

No, that is only testing that it's flagged in the response, it's not testing that the costing is actually doing anything with it. I already described it: #4318 (review). If you have specific questions, feel free to ask.

@nilsnolde
Copy link
Member

Oh, and an important note: if we use tunnels to break up shortcuts, we'll need to do a thorough perf test and see if it's fine. Ideally that's done by the committer, but it's poorly documented atm. I always wanted to document that a bit better. We might want to add some Switzerland routes for this:)

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.

None yet

4 participants