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

Favor turn channels more #3222

Merged
merged 5 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* **Removed**
* **Bug Fix**
* **Enhancement**
* CHANGED: Favor turn channels more [#3222](https://github.com/valhalla/valhalla/pull/3222)

## Release Date: 2021-07-20 Valhalla 3.1.3
* **Removed**
Expand Down
5 changes: 1 addition & 4 deletions src/mjolnir/speed_assigner.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using namespace valhalla::baldr;

// Factors used to adjust speed assignments
constexpr float kTurnChannelFactor = 1.25f;
constexpr float kRampDensityFactor = 0.8f;
constexpr float kRampFactor = 0.85f;
constexpr float kRoundaboutFactor = 0.5f;
Expand Down Expand Up @@ -263,9 +262,7 @@ class SpeedAssigner {
if (directededge.link()) {
uint32_t speed = directededge.speed();
Use use = directededge.use();
if (use == Use::kTurnChannel && infer_turn_channels) {
speed = static_cast<uint32_t>((speed * kTurnChannelFactor) + 0.5f);
Copy link
Contributor Author

@merkispavel merkispavel Jul 20, 2021

Choose a reason for hiding this comment

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

Should be noticed that durations will be increased after removing this line so I'm hesitating if it's the right move..
Alternative safe solution might be

  • leave speed_assigner code as it is
  • handle only if (edge.has_historic_speeds) case in the AutoCost::EdgeCost

cons:

  • Different turn channel factor in 2 places. It would be better to have everything in one place

Copy link
Member

Choose a reason for hiding this comment

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

thats a very good question you raise... here's my opinion:

in general, our speed assignments are always too optimistic. also turn channels are by definition short. i think its maybe its not a big deal to get 20% slower considering these two facts..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also turn channels are by definition short. i think its maybe its not a big deal to get 20% slower considering these two facts

agreed

} else if ((use == Use::kRamp) && (directededge.speed_type() != SpeedType::kTagged)) {
if ((use == Use::kRamp) && (directededge.speed_type() != SpeedType::kTagged)) {
// If no tagged speed set ramp speed to slightly lower than speed
// for roads of this classification
RoadClass rc = directededge.classification();
Expand Down
6 changes: 6 additions & 0 deletions src/sif/autocost.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ constexpr float kTaxiFactor = 0.85f;
// Do not avoid alleys by default
constexpr float kDefaultAlleyFactor = 1.0f;

// How much to favor turn channels
constexpr float kTurnChannelFactor = 0.6f;

// Turn costs based on side of street driving
constexpr float kRightSideTurnCosts[] = {kTCStraight, kTCSlight, kTCFavorable,
kTCFavorableSharp, kTCReverse, kTCUnfavorableSharp,
Expand Down Expand Up @@ -502,6 +505,9 @@ Cost AutoCost::EdgeCost(const baldr::DirectedEdge* edge,
case Use::kServiceRoad:
factor *= service_factor_;
break;
case Use::kTurnChannel:
factor *= kTurnChannelFactor;
break;
default:
break;
}
Expand Down
Loading