Skip to content

Commit

Permalink
make speed fading configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-no committed Oct 17, 2023
1 parent 4ab376a commit ec49e9a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* ADDED: the workflow to find landmarks in a graph tile, associate them with nearby edges, and update the graph tile to store the associations [#4278](https://github.com/valhalla/valhalla/pull/4278)
* ADDED: update maneuver generation to add nearby landmarks to maneuvers as direction support [#4293](https://github.com/valhalla/valhalla/pull/4293)
* CHANGED: the boost property tree config is now read into a singleton that doesn't need to be passed around anymore [#4220](https://github.com/valhalla/valhalla/pull/4220)
* ADDED: Make livespeed fading time configurable in valhalla.json [#4177](https://github.com/valhalla/valhalla/pull/4177)

## Release Date: 2023-05-11 Valhalla 3.4.0
* **Removed**
Expand Down
6 changes: 6 additions & 0 deletions scripts/valhalla_build_config
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ config = {
'max_exclude_polygons_length': 10000,
'max_distance_disable_hierarchy_culling': 0,
},
'baldr': {
'live_speed_fading_sec': 3600
},
'statsd': {
'host': Optional(str),
'port': 8125,
Expand Down Expand Up @@ -549,6 +552,9 @@ help_text = {
'batch_size': 'Approximate maximum size in bytes of each batch of stats to send to statsd',
'tags': 'List of tags to include with each metric',
},
'baldr': {
'live_speed_fading_sec': 'The time (in seconds) over which the live speed will be faded into the traffic speed sources',
},
}


Expand Down
6 changes: 6 additions & 0 deletions src/baldr/graphtile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "baldr/sign.h"
#include "baldr/tilehierarchy.h"
#include "filesystem.h"
#include "config.h"
#include "midgard/aabb2.h"
#include "midgard/pointll.h"
#include "midgard/tiles.h"
Expand Down Expand Up @@ -368,6 +369,11 @@ void GraphTile::Initialize(const GraphId& graphid) {
lane_connectivity_size_ = header_->end_offset() - header_->lane_connectivity_offset();
}

try {
live_speed_fading_sec_ = config().get<float>("baldr.live_speed_fading_sec", 3600);
} catch (const ConfigUninitializedException &e){
live_speed_fading_sec_ = 3600;
}
// For reference - how to use the end offset to set size of an object (that
// is not fixed size and count).
// example_size_ = header_->end_offset() - header_->example_offset();
Expand Down
7 changes: 5 additions & 2 deletions valhalla/baldr/graphtile.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,12 @@ class GraphTile {
// TODO(danpat): for short-ish durations along the route, we should fade live
// speeds into any historic/predictive/average value we'd normally use

constexpr double LIVE_SPEED_FADE = 1. / 3600.;
double live_speed_fade = 1. / live_speed_fading_sec_;
// This parameter describes the weight of live-traffic on a specific edge. In the beginning of the
// route live-traffic gives more information about current congestion situation. But the further
// we go the less consistent this traffic is. We prioritize predicted traffic in this case.
// Want to have a smooth decrease function.
float live_traffic_multiplier = 1. - std::min(seconds_from_now * LIVE_SPEED_FADE, 1.);
float live_traffic_multiplier = 1. - std::min(seconds_from_now * live_speed_fade, 1.);
uint32_t partial_live_speed = 0;
float partial_live_pct = 0;
if ((flow_mask & kCurrentFlowMask) && traffic_tile() && live_traffic_multiplier != 0.) {
Expand Down Expand Up @@ -872,6 +872,9 @@ class GraphTile {
// Predicted speeds
PredictedSpeeds predictedspeeds_;

// Time (in seconds) over which live speed will be faded into other traffic speed sources
float live_speed_fading_sec_;

// Map of stop one stops in this tile.
std::unordered_map<std::string, GraphId> stop_one_stops;

Expand Down

0 comments on commit ec49e9a

Please sign in to comment.