Skip to content

Usage of negative turn penalties #3683

@oxidase

Description

@oxidase

Some tests in OSRM make turn penalties updates with negative value. This introduces incorrect behavior in snapping start points and may lead to quite non-obvious problems like #3647 and #3641.
Practically, negative turn penalties would make turns more preferable instead of going straight with 0 turn penalty. This can be achieved also by using a positive bias value and making all turn weight penalties positive. Duration values are not used as key values in heaps and can be negative.

  • clarify domain of turn penalties
  • review tests features/car/traffic_turn_penalties.feature and features/testbot/traffic_turn_penalties.feature
  • adjust updates
    if (turn_weight_penalty + new_weight < weight_min_value)
    {
    util::Log(logWARNING) << "turn penalty " << turn_weight_penalty << " for turn "
    << turn_index.from_id << ", " << turn_index.via_id << ", "
    << turn_index.to_id
    << " is too negative: clamping turn weight to "
    << weight_min_value;
    turn_weight_penalty = weight_min_value - new_weight;
    }
  • add non-negativity check of weights at
    auto segment_speed_lookup = CSVFilesParser<Segment, SpeedSource>(
    1, qi::ulong_long >> ',' >> qi::ulong_long, qi::uint_ >> -(',' >> qi::double_))(
    config.segment_speed_lookup_paths);
    auto turn_penalty_lookup = CSVFilesParser<Turn, PenaltySource>(
    1 + config.segment_speed_lookup_paths.size(),
    qi::ulong_long >> ',' >> qi::ulong_long >> ',' >> qi::ulong_long,
    qi::double_ >> -(',' >> qi::double_))(config.turn_penalty_lookup_paths);
  • add at
    const EdgeWeight to_weight = weight + edge_weight;
    assertion that to_weight >= 0

/cc @danpat

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions