diff --git a/features/car/stoppage.feature b/features/car/stoppage.feature deleted file mode 100644 index 762cca14f..000000000 --- a/features/car/stoppage.feature +++ /dev/null @@ -1,36 +0,0 @@ -@routing @maxspeed @car -Feature: Car - Acceleration profiles - - Background: Use specific speeds - Given the profile "car" - Given a grid size of 1000 meters - - Scenario: Car - Use stoppage penalty at waypoints - Given the node map - """ - a 1 2 3 4 5 b - """ - - And the ways - | nodes | highway | maxspeed:forward | maxspeed:backward | - | ab | trunk | 60 | 45 | - - And the query options - | stoppage_penalty | 5,100 | - - When I route I should get - | from | to | route | time | - | a | b | ab,ab | 481.1s | - - When I route I should get - | from | to | route | time | - | b | a | ab,ab | 609.9s | - - When I route I should get - | from | to | route | time | - | a | a | ab,ab | 0s | - - When I request a travel time matrix I should get - | | a | b | - | a | 0 | 481.1 | - | b | 609.9 | 0 | diff --git a/features/testbot/stoppage.feature b/features/testbot/stoppage.feature deleted file mode 100644 index 34a874c13..000000000 --- a/features/testbot/stoppage.feature +++ /dev/null @@ -1,36 +0,0 @@ -@routing @maxspeed @testbot -Feature: Testbot - Acceleration profiles - - Background: Use specific speeds - Given the profile "testbot" - Given a grid size of 1000 meters - - Scenario: Testbot - Use stoppage penalty at waypoints - Given the node map - """ - a 1 2 3 4 5 b - """ - - And the ways - | nodes | highway | maxspeed:forward | maxspeed:backward | - | ab | trunk | 60 | 45 | - - And the query options - | stoppage_penalty | 5,100 | - - When I route I should get - | from | to | route | time | - | a | b | ab,ab | 412.3s | - - When I route I should get - | from | to | route | time | - | b | a | ab,ab | 505.9s | - - When I route I should get - | from | to | route | time | - | a | a | ab,ab | 0s | - - When I request a travel time matrix I should get - | | a | b | - | a | 0 | 412.3 | - | b | 505.9 | 0 | diff --git a/include/engine/api/base_parameters.hpp b/include/engine/api/base_parameters.hpp index 16df39429..91ac937b4 100644 --- a/include/engine/api/base_parameters.hpp +++ b/include/engine/api/base_parameters.hpp @@ -81,8 +81,6 @@ struct BaseParameters bool generate_hints = true; SnappingType snapping = SnappingType::Default; - double min_stoppage_penalty = INVALID_MINIMUM_STOPPAGE_PENALTY; - double max_stoppage_penalty = INVALID_MAXIMUM_STOPPAGE_PENALTY; BaseParameters(const std::vector coordinates_ = {}, const std::vector> hints_ = {}, @@ -91,23 +89,16 @@ struct BaseParameters std::vector> approaches_ = {}, bool generate_hints_ = true, std::vector exclude = {}, - const SnappingType snapping_ = SnappingType::Default, - double min_stoppage_penalty_ = INVALID_MINIMUM_STOPPAGE_PENALTY, - double max_stoppage_penalty_ = INVALID_MAXIMUM_STOPPAGE_PENALTY) + const SnappingType snapping_ = SnappingType::Default) : coordinates(coordinates_), hints(hints_), radiuses(radiuses_), bearings(bearings_), approaches(approaches_), exclude(std::move(exclude)), generate_hints(generate_hints_), - snapping(snapping_), min_stoppage_penalty(min_stoppage_penalty_), - max_stoppage_penalty(max_stoppage_penalty_) + snapping(snapping_) { } // FIXME add validation for invalid bearing values bool IsValid() const { - if (min_stoppage_penalty <= 0 || max_stoppage_penalty <= 0 || - min_stoppage_penalty > max_stoppage_penalty) - return false; - return (hints.empty() || hints.size() == coordinates.size()) && (bearings.empty() || bearings.size() == coordinates.size()) && (radiuses.empty() || radiuses.size() == coordinates.size()) && diff --git a/include/engine/api/table_parameters.hpp b/include/engine/api/table_parameters.hpp index db6f670c8..fbbf6831e 100644 --- a/include/engine/api/table_parameters.hpp +++ b/include/engine/api/table_parameters.hpp @@ -78,6 +78,7 @@ struct TableParameters : public BaseParameters }; AnnotationsType annotations = AnnotationsType::Duration; + double scale_factor = 1; TableParameters() = default; @@ -112,6 +113,7 @@ struct TableParameters : public BaseParameters destinations{std::move(destinations_)}, fallback_speed{fallback_speed_}, fallback_coordinate_type{fallback_coordinate_type_}, annotations{annotations_}, scale_factor{scale_factor_} + { } @@ -164,8 +166,8 @@ inline TableParameters::AnnotationsType &operator|=(TableParameters::Annotations { return lhs = lhs | rhs; } -} // namespace api -} // namespace engine -} // namespace osrm +} +} +} #endif // ENGINE_API_TABLE_PARAMETERS_HPP diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 5d5c4d7a2..d28238bb8 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -384,84 +384,54 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade input_coordinate, max_results, max_distance, bearing, bearing_range, approach); } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, - const Approach approach, - const bool use_all_edges, - const double minimum_stoppage_penalty, - const double maximum_stoppage_penalty) const override final + std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, + const Approach approach, + const bool use_all_edges) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, - approach, - use_all_edges, - minimum_stoppage_penalty, - maximum_stoppage_penalty); + input_coordinate, approach, use_all_edges); } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, - const double max_distance, - const Approach approach, - const bool use_all_edges, - const double minimum_stoppage_penalty, - const double maximum_stoppage_penalty) const override final + std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, + const double max_distance, + const Approach approach, + const bool use_all_edges) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, - max_distance, - approach, - use_all_edges, - minimum_stoppage_penalty, - maximum_stoppage_penalty); + input_coordinate, max_distance, approach, use_all_edges); } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, - const double max_distance, - const int bearing, - const int bearing_range, - const Approach approach, - const bool use_all_edges, - const double minimum_stoppage_penalty, - const double maximum_stoppage_penalty) const override final + std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, + const double max_distance, + const int bearing, + const int bearing_range, + const Approach approach, + const bool use_all_edges) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, - max_distance, - bearing, - bearing_range, - approach, - use_all_edges, - minimum_stoppage_penalty, - maximum_stoppage_penalty); + input_coordinate, max_distance, bearing, bearing_range, approach, use_all_edges); } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, - const int bearing, - const int bearing_range, - const Approach approach, - const bool use_all_edges, - const double minimum_stoppage_penalty, - const double maximum_stoppage_penalty) const override final + std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, + const int bearing, + const int bearing_range, + const Approach approach, + const bool use_all_edges) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, - bearing, - bearing_range, - approach, - use_all_edges, - minimum_stoppage_penalty, - maximum_stoppage_penalty); + input_coordinate, bearing, bearing_range, approach, use_all_edges); } std::uint32_t GetCheckSum() const override final { return m_check_sum; } diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index 4f43dca79..da57dc9c5 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -157,36 +157,28 @@ class BaseDataFacade const double max_distance, const Approach approach) const = 0; - virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, - const Approach approach, - const bool use_all_edges, - const double minimum_stoppage_penalty, - const double maximum_stoppage_penalty) const = 0; - virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, - const double max_distance, - const Approach approach, - const bool use_all_edges, - const double minimum_stoppage_penalty, - const double maximum_stoppage_penalty) const = 0; - virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, - const double max_distance, - const int bearing, - const int bearing_range, - const Approach approach, - const bool use_all_edges, - const double minimum_stoppage_penalty, - const double maximum_stoppage_penalty) const = 0; - virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, - const int bearing, - const int bearing_range, - const Approach approach, - const bool use_all_edges, - const double minimum_stoppage_penalty, - const double maximum_stoppage_penalty) const = 0; + virtual std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, + const Approach approach, + const bool use_all_edges) const = 0; + virtual std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, + const double max_distance, + const Approach approach, + const bool use_all_edges) const = 0; + virtual std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, + const double max_distance, + const int bearing, + const int bearing_range, + const Approach approach, + const bool use_all_edges) const = 0; + virtual std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, + const int bearing, + const int bearing_range, + const Approach approach, + const bool use_all_edges = false) const = 0; virtual bool HasLaneData(const EdgeID id) const = 0; virtual util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const = 0; diff --git a/include/engine/geospatial_query.hpp b/include/engine/geospatial_query.hpp index a059e445b..67e2b3b69 100644 --- a/include/engine/geospatial_query.hpp +++ b/include/engine/geospatial_query.hpp @@ -206,9 +206,7 @@ template class GeospatialQuery NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double max_distance, const Approach approach, - const bool use_all_edges, - const double min_stoppage_penalty, - const double max_stoppage_penalty) const + const bool use_all_edges) const { bool has_small_component = false; bool has_big_component = false; @@ -250,13 +248,8 @@ template class GeospatialQuery } BOOST_ASSERT(results.size() == 1 || results.size() == 2); - return std::make_pair( - MakePhantomNode( - input_coordinate, results.front(), min_stoppage_penalty, max_stoppage_penalty) - .phantom_node, - MakePhantomNode( - input_coordinate, results.back(), min_stoppage_penalty, max_stoppage_penalty) - .phantom_node); + return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node, + MakePhantomNode(input_coordinate, results.back()).phantom_node); } // Returns the nearest phantom node. If this phantom node is not from a big component @@ -264,9 +257,7 @@ template class GeospatialQuery std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const Approach approach, - const bool use_all_edges, - const double min_stoppage_penalty, - const double max_stoppage_penalty) const + const bool use_all_edges) const { bool has_small_component = false; bool has_big_component = false; @@ -307,13 +298,8 @@ template class GeospatialQuery } BOOST_ASSERT(results.size() == 1 || results.size() == 2); - return std::make_pair( - MakePhantomNode( - input_coordinate, results.front(), min_stoppage_penalty, max_stoppage_penalty) - .phantom_node, - MakePhantomNode( - input_coordinate, results.back(), min_stoppage_penalty, max_stoppage_penalty) - .phantom_node); + return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node, + MakePhantomNode(input_coordinate, results.back()).phantom_node); } // Returns the nearest phantom node. If this phantom node is not from a big component @@ -323,9 +309,7 @@ template class GeospatialQuery const int bearing, const int bearing_range, const Approach approach, - const bool use_all_edges, - const double min_stoppage_penalty, - const double max_stoppage_penalty) const + const bool use_all_edges) const { bool has_small_component = false; bool has_big_component = false; @@ -373,13 +357,8 @@ template class GeospatialQuery } BOOST_ASSERT(results.size() > 0); - return std::make_pair( - MakePhantomNode( - input_coordinate, results.front(), min_stoppage_penalty, max_stoppage_penalty) - .phantom_node, - MakePhantomNode( - input_coordinate, results.back(), min_stoppage_penalty, max_stoppage_penalty) - .phantom_node); + return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node, + MakePhantomNode(input_coordinate, results.back()).phantom_node); } // Returns the nearest phantom node. If this phantom node is not from a big component @@ -390,9 +369,7 @@ template class GeospatialQuery const int bearing, const int bearing_range, const Approach approach, - const bool use_all_edges, - const double min_stoppage_penalty, - const double max_stoppage_penalty) const + const bool use_all_edges) const { bool has_small_component = false; bool has_big_component = false; @@ -442,13 +419,8 @@ template class GeospatialQuery } BOOST_ASSERT(results.size() > 0); - return std::make_pair( - MakePhantomNode( - input_coordinate, results.front(), min_stoppage_penalty, max_stoppage_penalty) - .phantom_node, - MakePhantomNode( - input_coordinate, results.back(), min_stoppage_penalty, max_stoppage_penalty) - .phantom_node); + return std::make_pair(MakePhantomNode(input_coordinate, results.front()).phantom_node, + MakePhantomNode(input_coordinate, results.back()).phantom_node); } private: @@ -467,9 +439,7 @@ template class GeospatialQuery } PhantomNodeWithDistance MakePhantomNode(const util::Coordinate input_coordinate, - const EdgeData &data, - const double min_stoppage_penalty = 0, - const double max_stoppage_penalty = 0) const + const EdgeData &data) const { util::Coordinate point_on_segment; double ratio; @@ -508,21 +478,16 @@ template class GeospatialQuery forward_durations.begin() + data.fwd_segment_position, EdgeDuration{0}); - // For measuring distance from begin up to end - const auto appx_distance = [this](decltype(forward_geometry.begin()) begin, - decltype(forward_geometry.begin()) end) { - EdgeDistance dist = 0; - for (; begin != end; ++begin) - { - dist += util::coordinate_calculation::fccApproximateDistance( - datafacade.GetCoordinateOfNode(*begin), - datafacade.GetCoordinateOfNode(*std::next(begin))); - } - return dist; - }; - - EdgeDistance forward_distance_offset = appx_distance( - forward_geometry.begin(), forward_geometry.begin() + data.fwd_segment_position); + EdgeDistance forward_distance_offset = 0; + // Sum up the distance from the start to the fwd_segment_position + for (auto current = forward_geometry.begin(); + current < forward_geometry.begin() + data.fwd_segment_position; + ++current) + { + forward_distance_offset += util::coordinate_calculation::fccApproximateDistance( + datafacade.GetCoordinateOfNode(*current), + datafacade.GetCoordinateOfNode(*std::next(current))); + } BOOST_ASSERT(data.fwd_segment_position < std::distance(forward_durations.begin(), forward_durations.end())); @@ -543,9 +508,16 @@ template class GeospatialQuery reverse_durations.end() - data.fwd_segment_position - 1, EdgeDuration{0}); - EdgeDistance reverse_distance_offset = - appx_distance(forward_geometry.begin() + data.fwd_segment_position + 1, - std::prev(forward_geometry.end())); + EdgeDistance reverse_distance_offset = 0; + // Sum up the distance from just after the fwd_segment_position to the end + for (auto current = forward_geometry.begin() + data.fwd_segment_position + 1; + current != std::prev(forward_geometry.end()); + ++current) + { + reverse_distance_offset += util::coordinate_calculation::fccApproximateDistance( + datafacade.GetCoordinateOfNode(*current), + datafacade.GetCoordinateOfNode(*std::next(current))); + } EdgeWeight reverse_weight = reverse_weights[reverse_weights.size() - data.fwd_segment_position - 1]; @@ -555,64 +527,16 @@ template class GeospatialQuery point_on_segment, datafacade.GetCoordinateOfNode(forward_geometry(data.fwd_segment_position + 1))); - // where does this speed lie with respect to the min/max penalizable speeds - auto penalty_range = min_stoppage_penalty != INVALID_MINIMUM_STOPPAGE_PENALTY && - max_stoppage_penalty != INVALID_MAXIMUM_STOPPAGE_PENALTY - ? max_stoppage_penalty - min_stoppage_penalty - : 0; - auto stoppage_penalty = - [penalty_range, min_stoppage_penalty, max_stoppage_penalty](double speed) -> double { - // You're so slow already you don't get a penalty - if (speed < MINIMAL_ACCEL_DECEL_PENALIZABLE_SPEED) - return 0; - - // Find where it is on the scale - constexpr auto max = - MAXIMAL_ACCEL_DECEL_PENALIZABLE_SPEED - MINIMAL_ACCEL_DECEL_PENALIZABLE_SPEED; - auto ratio = (speed - MINIMAL_ACCEL_DECEL_PENALIZABLE_SPEED) / max; - - // You're faster than the max so you get the max - if (ratio >= 1) - return max_stoppage_penalty; - - // You're in between so you get a linear combination - return min_stoppage_penalty + ratio * penalty_range; - }; - - // We may end up adding a stoppage penalty - EdgeDuration forward_stoppage_penalty = 0; - EdgeDuration reverse_stoppage_penalty = 0; - auto total_distance = penalty_range > 0 ? appx_distance(forward_geometry.begin(), - std::prev(forward_geometry.end())) - : 0.0; ratio = std::min(1.0, std::max(0.0, ratio)); if (data.forward_segment_id.id != SPECIAL_SEGMENTID) { forward_weight = static_cast(forward_weight * ratio); forward_duration = static_cast(forward_duration * ratio); - // Stoppage penalty based on speed - if (data.forward_segment_id.enabled && penalty_range > 0) - { - const auto total_duration = std::accumulate( - forward_durations.begin(), forward_durations.end(), EdgeDuration{0}); - const auto speed = total_distance / (total_duration * 0.1); - forward_stoppage_penalty = - static_cast((stoppage_penalty(speed) * 10) + .5); - } } if (data.reverse_segment_id.id != SPECIAL_SEGMENTID) { reverse_weight -= static_cast(reverse_weight * ratio); reverse_duration -= static_cast(reverse_duration * ratio); - // Stoppage penalty based on speed - if (data.reverse_segment_id.enabled && penalty_range > 0) - { - const auto total_duration = std::accumulate( - reverse_durations.begin(), reverse_durations.end(), EdgeDuration{0}); - const auto speed = total_distance / (total_duration * 0.1); - reverse_stoppage_penalty = - static_cast((stoppage_penalty(speed) * 10) + .5); - } } // check phantom node segments validity @@ -643,8 +567,6 @@ template class GeospatialQuery reverse_duration, forward_duration_offset, reverse_duration_offset, - forward_stoppage_penalty, - reverse_stoppage_penalty, is_forward_valid_source, is_forward_valid_target, is_reverse_valid_source, @@ -795,7 +717,7 @@ template class GeospatialQuery const CoordinateList &coordinates; DataFacadeT &datafacade; }; -} // namespace engine -} // namespace osrm +} +} #endif diff --git a/include/engine/guidance/assemble_leg.hpp b/include/engine/guidance/assemble_leg.hpp index cd10f70a6..5bd2cca0e 100644 --- a/include/engine/guidance/assemble_leg.hpp +++ b/include/engine/guidance/assemble_leg.hpp @@ -122,7 +122,7 @@ std::array summarizeRoute(const datafacade::BaseDa [](const NamedSegment &segment) { return segment.name_id; }); return summary; } -} // namespace detail +} inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade, const std::vector &route_data, @@ -166,7 +166,7 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade, // `forward_duration`: duration of (d,t) // `forward_offset`: duration of (c, d) // path_data will have entries for (s,b), (b, c), (c, d) but (d, t) is only - // captured by the phantom node. So we need to add the target duration here. + // caputed by the phantom node. So we need to add the target duration here. // On local segments, the target duration is already part of the duration, however. duration = duration + target_duration; @@ -182,13 +182,6 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade, duration = std::max(0, duration); } - // Add start and stop penalties - if (distance > 0) - duration += - (target_traversed_in_reverse - ? source_node.reverse_duration_penalty + target_node.reverse_duration_penalty - : source_node.forward_duration_penalty + target_node.forward_duration_penalty); - std::string summary; if (needs_summary) { diff --git a/include/engine/hint.hpp b/include/engine/hint.hpp index 179a716a4..3ab69b928 100644 --- a/include/engine/hint.hpp +++ b/include/engine/hint.hpp @@ -63,11 +63,11 @@ struct Hint friend std::ostream &operator<<(std::ostream &, const Hint &); }; -static_assert(sizeof(Hint) == sizeof(PhantomNode) + 4, "Hint is bigger than expected"); -constexpr std::size_t ENCODED_HINT_SIZE = 124; +static_assert(sizeof(Hint) == 80 + 4, "Hint is bigger than expected"); +constexpr std::size_t ENCODED_HINT_SIZE = 112; static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint), "ENCODED_HINT_SIZE does not match size of Hint"); -} // namespace engine -} // namespace osrm +} +} #endif diff --git a/include/engine/phantom_node.hpp b/include/engine/phantom_node.hpp index 8c948d16a..3cb0b9593 100644 --- a/include/engine/phantom_node.hpp +++ b/include/engine/phantom_node.hpp @@ -50,10 +50,9 @@ struct PhantomNode forward_distance(INVALID_EDGE_DISTANCE), reverse_distance(INVALID_EDGE_DISTANCE), forward_distance_offset(0), reverse_distance_offset(0), forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION), - forward_duration_offset(0), reverse_duration_offset(0), forward_duration_penalty(0), - reverse_duration_penalty(0), fwd_segment_position(0), is_valid_forward_source{false}, - is_valid_forward_target{false}, is_valid_reverse_source{false}, - is_valid_reverse_target{false}, bearing(0) + forward_duration_offset(0), reverse_duration_offset(0), fwd_segment_position(0), + is_valid_forward_source{false}, is_valid_forward_target{false}, + is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0) { } @@ -70,13 +69,13 @@ struct PhantomNode return reverse_weight_offset + reverse_weight; } - EdgeDuration GetForwardDuration() const + EdgeWeight GetForwardDuration() const { BOOST_ASSERT(forward_segment_id.enabled); return forward_duration + forward_duration_offset; } - EdgeDuration GetReverseDuration() const + EdgeWeight GetReverseDuration() const { BOOST_ASSERT(reverse_segment_id.enabled); return reverse_duration + reverse_duration_offset; @@ -164,12 +163,10 @@ struct PhantomNode EdgeDistance reverse_distance, EdgeDistance forward_distance_offset, EdgeDistance reverse_distance_offset, - EdgeDuration forward_duration, - EdgeDuration reverse_duration, - EdgeDuration forward_duration_offset, - EdgeDuration reverse_duration_offset, - EdgeDuration forward_duration_penalty, - EdgeDuration reverse_duration_penalty, + EdgeWeight forward_duration, + EdgeWeight reverse_duration, + EdgeWeight forward_duration_offset, + EdgeWeight reverse_duration_offset, bool is_valid_forward_source, bool is_valid_forward_target, bool is_valid_reverse_source, @@ -185,8 +182,6 @@ struct PhantomNode reverse_distance_offset{reverse_distance_offset}, forward_duration{forward_duration}, reverse_duration{reverse_duration}, forward_duration_offset{forward_duration_offset}, reverse_duration_offset{reverse_duration_offset}, - forward_duration_penalty{forward_duration_penalty}, - reverse_duration_penalty{reverse_duration_penalty}, component{component.id, component.is_tiny}, location{location}, input_location{input_location}, fwd_segment_position{other.fwd_segment_position}, is_valid_forward_source{is_valid_forward_source}, @@ -206,13 +201,10 @@ struct PhantomNode EdgeDistance reverse_distance; EdgeDistance forward_distance_offset; // TODO: try to remove -> requires path unpacking changes EdgeDistance reverse_distance_offset; // TODO: try to remove -> requires path unpacking changes - EdgeDuration forward_duration; - EdgeDuration reverse_duration; - EdgeDuration forward_duration_offset; // TODO: try to remove -> requires path unpacking changes - EdgeDuration reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes - EdgeDuration forward_duration_penalty; - EdgeDuration reverse_duration_penalty; - + EdgeWeight forward_duration; + EdgeWeight reverse_duration; + EdgeWeight forward_duration_offset; // TODO: try to remove -> requires path unpacking changes + EdgeWeight reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes ComponentID component; util::Coordinate location; // this is the coordinate of x @@ -227,7 +219,7 @@ struct PhantomNode unsigned short bearing : 12; }; -static_assert(sizeof(PhantomNode) == 88, "PhantomNode has more padding then expected"); +static_assert(sizeof(PhantomNode) == 80, "PhantomNode has more padding then expected"); using PhantomNodePair = std::pair; @@ -242,7 +234,7 @@ struct PhantomNodes PhantomNode source_phantom; PhantomNode target_phantom; }; -} // namespace engine -} // namespace osrm +} +} #endif // PHANTOM_NODES_H diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index 54f0b6ba2..78dd9e089 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -298,9 +298,7 @@ class BasePlugin parameters.bearings[i]->bearing, parameters.bearings[i]->range, approach, - use_all_edges, - parameters.min_stoppage_penalty, - parameters.max_stoppage_penalty); + use_all_edges); } else { @@ -310,9 +308,7 @@ class BasePlugin parameters.bearings[i]->bearing, parameters.bearings[i]->range, approach, - use_all_edges, - parameters.min_stoppage_penalty, - parameters.max_stoppage_penalty); + use_all_edges); } } else @@ -324,19 +320,13 @@ class BasePlugin parameters.coordinates[i], *parameters.radiuses[i], approach, - use_all_edges, - parameters.min_stoppage_penalty, - parameters.max_stoppage_penalty); + use_all_edges); } else { phantom_node_pairs[i] = facade.NearestPhantomNodeWithAlternativeFromBigComponent( - parameters.coordinates[i], - approach, - use_all_edges, - parameters.min_stoppage_penalty, - parameters.max_stoppage_penalty); + parameters.coordinates[i], approach, use_all_edges); } } diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index f340c934a..4afaae71f 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -86,7 +86,7 @@ void insertSourceInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no heap.Insert(phantom_node.forward_segment_id.id, -phantom_node.GetForwardWeightPlusOffset(), {phantom_node.forward_segment_id.id, - -phantom_node.GetForwardDuration() + phantom_node.forward_duration_penalty, + -phantom_node.GetForwardDuration(), -phantom_node.GetForwardDistance()}); } if (phantom_node.IsValidReverseSource()) @@ -94,7 +94,7 @@ void insertSourceInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no heap.Insert(phantom_node.reverse_segment_id.id, -phantom_node.GetReverseWeightPlusOffset(), {phantom_node.reverse_segment_id.id, - -phantom_node.GetReverseDuration() + phantom_node.reverse_duration_penalty, + -phantom_node.GetReverseDuration(), -phantom_node.GetReverseDistance()}); } } @@ -107,7 +107,7 @@ void insertTargetInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no heap.Insert(phantom_node.forward_segment_id.id, phantom_node.GetForwardWeightPlusOffset(), {phantom_node.forward_segment_id.id, - phantom_node.GetForwardDuration() + phantom_node.forward_duration_penalty, + phantom_node.GetForwardDuration(), phantom_node.GetForwardDistance()}); } if (phantom_node.IsValidReverseTarget()) @@ -115,7 +115,7 @@ void insertTargetInHeap(ManyToManyQueryHeap &heap, const PhantomNode &phantom_no heap.Insert(phantom_node.reverse_segment_id.id, phantom_node.GetReverseWeightPlusOffset(), {phantom_node.reverse_segment_id.id, - phantom_node.GetReverseDuration() + phantom_node.reverse_duration_penalty, + phantom_node.GetReverseDuration(), phantom_node.GetReverseDistance()}); } } diff --git a/include/extractor/speed_profile.hpp b/include/extractor/speed_profile.hpp deleted file mode 100644 index 072b91875..000000000 --- a/include/extractor/speed_profile.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "util/typedefs.h" - -namespace osrm -{ -namespace extractor -{ -namespace -{ -constexpr int 5_MINUTE_BUCKETS_PER_WEEK = 2016; -constexpr int 1_HOUR_BUCKETS_PER_WEEK = 168; -} // namespace - -/** - * Represents a simple piecewise linear function - * (https://en.wikipedia.org/wiki/Piecewise_linear_function) - * in the form of a regularly spaced set of buckets. - * Assumes that the spacing between buckets is equal. - */ -template struct PiecewiseLinearFunction -{ - std::array sample; - - inline DataType getAt(float position) - { - // Range check - assert(position >= 0); - assert(position < BUCKETCOUNT - 1); - } - - PiecewiseLinearFunction - merge(PiecewiseLinearFunction &other, float offset) - { - PiecewiseLinearFunction result; - - for (int i = 0; i < BUCKETCOUNT; i++) - { - for (int j = offset; j < BUCKETCOUNT + offset; j++) - { - - result.sample[i] = sample[i] + other.sample[j % BUCKETCOUNT]; - } - } - - return std::move(result); - } -} - -/** - * Represents variances in the default `.duration` of an edge - * over the space of a week. - */ -struct WeeklySpeedProfile -{ - using Multiplier = std::uint8_t; - - private: - PiecewiseLinearFunction fn; - - public: - SpeedProfile() : min(0), max(0) { multipliers.fill(0); } - SpeedProfile(const std::array &other) - { - fn.samples = other; - min = std::min(samples); - max = std::max(samples); - } - - inline EdgeDuration adjust(const EdgeDuration &original, const int bucket) const - { - // Treat Multiplier as an 8-bit fixed-point value. - EdgeDuration new_value = (original * multipliers[bucket]); - } - - inline EdgeDuration min(const EdgeDuration original) const {} - - inline EdgeDuration max(const EdgeDuration original) const {} - - duration = m * e1 + m2 * e2 -}; -} // namespace extractor -} // namespace osrm \ No newline at end of file diff --git a/include/nodejs/node_osrm_support.hpp b/include/nodejs/node_osrm_support.hpp index ab94de3a8..a4d291d15 100644 --- a/include/nodejs/node_osrm_support.hpp +++ b/include/nodejs/node_osrm_support.hpp @@ -721,51 +721,6 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg } } - if (obj->Has(Nan::New("stoppage_penalty").ToLocalChecked())) - { - v8::Local stoppage_penalty = - obj->Get(Nan::New("stoppage_penalty").ToLocalChecked()); - if (stoppage_penalty.IsEmpty()) - return false; - - if (!stoppage_penalty->IsArray()) - { - Nan::ThrowError("Stoppage penalty must be an array of 2 numbers [min,max]"); - return false; - } - - auto stoppage_penalty_array = v8::Local::Cast(stoppage_penalty); - - if (stoppage_penalty_array->Length() != 2) - { - Nan::ThrowError("Stoppage penalty must be an array of 2 numbers [min,max]"); - return false; - } - - if (!stoppage_penalty_array->Get(0)->IsNumber() || - !stoppage_penalty_array->Get(1)->IsNumber()) - { - Nan::ThrowError("Stoppage penalty must be an array of 2 numbers [min,max]"); - return false; - } - const auto min = static_cast(stoppage_penalty_array->Get(0)->NumberValue()); - const auto max = static_cast(stoppage_penalty_array->Get(1)->NumberValue()); - - if (min < 0 || max < 0) - { - Nan::ThrowError("Stoppage penalty min/max can't be less than zero"); - return false; - } - if (max < min) - { - Nan::ThrowError("Stoppage penalty max must be larger than min"); - return false; - } - - params->max_stoppage_penalty = min; - params->min_stoppage_penalty = max; - } - return true; } diff --git a/include/server/api/base_parameters_grammar.hpp b/include/server/api/base_parameters_grammar.hpp index 10484b26d..5615ee53f 100644 --- a/include/server/api/base_parameters_grammar.hpp +++ b/include/server/api/base_parameters_grammar.hpp @@ -135,16 +135,6 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar }, qi::_1)]; - stoppage_rule = qi::lit("stoppage_penalty=") > - (qi::double_ > ',' > qi::double_)[ph::bind( - [](engine::api::BaseParameters ¶ms, double min, double max) { - params.min_stoppage_penalty = min; - params.max_stoppage_penalty = max; - }, - qi::_r1, - qi::_1, - qi::_2)]; - query_rule = ((location_rule % ';') | polyline_rule | polyline6_rule)[ph::bind(&engine::api::BaseParameters::coordinates, qi::_r1) = qi::_1]; @@ -189,8 +179,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar | generate_hints_rule(qi::_r1) // | approach_rule(qi::_r1) // | exclude_rule(qi::_r1) // - | snapping_rule(qi::_r1) // - | stoppage_rule(qi::_r1); // + | snapping_rule(qi::_r1); } protected: @@ -207,7 +196,6 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar qi::rule generate_hints_rule; qi::rule approach_rule; qi::rule exclude_rule; - qi::rule stoppage_rule; qi::rule bearing_rule; qi::rule location_rule; diff --git a/include/server/api/table_parameter_grammar.hpp b/include/server/api/table_parameter_grammar.hpp index 74b4095c3..dc1a073f9 100644 --- a/include/server/api/table_parameter_grammar.hpp +++ b/include/server/api/table_parameter_grammar.hpp @@ -18,7 +18,7 @@ namespace { namespace ph = boost::phoenix; namespace qi = boost::spirit::qi; -} // namespace +} template @@ -106,8 +106,8 @@ struct TableParametersGrammar : public BaseParametersGrammar double_; }; -} // namespace api -} // namespace server -} // namespace osrm +} +} +} #endif diff --git a/include/util/ieee754.hpp b/include/util/ieee754.hpp index 3a6328dfd..16f37e15d 100644 --- a/include/util/ieee754.hpp +++ b/include/util/ieee754.hpp @@ -488,8 +488,8 @@ inline void Prettify(char *buffer, int length, int k) inline void dtoa_milo(double value, char *buffer) { // Not handling NaN and inf - assert(!std::isnan(value)); - assert(!std::isinf(value)); + assert(!isnan(value)); + assert(!isinf(value)); if (value == 0) { diff --git a/include/util/typedefs.hpp b/include/util/typedefs.hpp index 64af1c4cc..d647a7db7 100644 --- a/include/util/typedefs.hpp +++ b/include/util/typedefs.hpp @@ -48,7 +48,7 @@ struct osm_way_id struct duplicated_node { }; -} // namespace tag +} using OSMNodeID = osrm::Alias; static_assert(std::is_pod(), "OSMNodeID is not a valid alias"); using OSMWayID = osrm::Alias; @@ -116,11 +116,7 @@ static const EdgeDuration MAXIMAL_EDGE_DURATION = std::numeric_limits::max(); static const TurnPenalty INVALID_TURN_PENALTY = std::numeric_limits::max(); static const EdgeDistance INVALID_EDGE_DISTANCE = std::numeric_limits::max(); -static const EdgeDistance INVALID_FALLBACK_SPEED = std::numeric_limits::max(); -constexpr EdgeDuration INVALID_MINIMUM_STOPPAGE_PENALTY = std::numeric_limits::max(); -constexpr EdgeDuration INVALID_MAXIMUM_STOPPAGE_PENALTY = std::numeric_limits::max(); -constexpr double MINIMAL_ACCEL_DECEL_PENALIZABLE_SPEED = 10; // metres/second -constexpr double MAXIMAL_ACCEL_DECEL_PENALIZABLE_SPEED = 40; // metres/sec +static const EdgeDistance INVALID_FALLBACK_SPEED = std::numeric_limits::max(); // FIXME the bitfields we use require a reduced maximal duration, this should be kept consistent // within the code base. For now we have to ensure that we don't case 30 bit to -1 and break any diff --git a/src/engine/plugins/table.cpp b/src/engine/plugins/table.cpp index be8b1a606..f78645c9d 100644 --- a/src/engine/plugins/table.cpp +++ b/src/engine/plugins/table.cpp @@ -98,9 +98,7 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, std::vector estimated_pairs; // Scan table for null results - if any exist, replace with distance estimates - if (params.fallback_speed != INVALID_FALLBACK_SPEED || params.scale_factor != 1 || - (params.min_stoppage_penalty != INVALID_MINIMUM_STOPPAGE_PENALTY && - params.max_stoppage_penalty != INVALID_MAXIMUM_STOPPAGE_PENALTY)) + if (params.fallback_speed != INVALID_FALLBACK_SPEED || params.scale_factor != 1) { for (std::size_t row = 0; row < num_sources; row++) { @@ -108,10 +106,6 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, { const auto &table_index = row * num_destinations + column; BOOST_ASSERT(table_index < result_tables_pair.first.size()); - // Zero out the diagonal - if (result_tables_pair.first[table_index] != MAXIMAL_EDGE_DURATION && row == column) - result_tables_pair.first[table_index] = 0; - // Estimate null results based on fallback_speed (if valid) and distance if (params.fallback_speed != INVALID_FALLBACK_SPEED && params.fallback_speed > 0 && result_tables_pair.first[table_index] == MAXIMAL_EDGE_DURATION) { @@ -138,7 +132,6 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, estimated_pairs.emplace_back(row, column); } - // Apply a scale factor to non-null result if requested if (params.scale_factor > 0 && params.scale_factor != 1 && result_tables_pair.first[table_index] != MAXIMAL_EDGE_DURATION && result_tables_pair.first[table_index] != 0) @@ -165,6 +158,6 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, return Status::Ok; } -} // namespace plugins -} // namespace engine -} // namespace osrm +} +} +} diff --git a/test/nodejs/table.js b/test/nodejs/table.js index 661a85b7b..fc66b3c73 100644 --- a/test/nodejs/table.js +++ b/test/nodejs/table.js @@ -318,33 +318,5 @@ tables.forEach(function(annotation) { assert.throws(()=>osrm.table(options, (err, res) => {}), /scale_factor must be > 0/, "should throw on invalid scale_factor value"); }); - - test('table: ' + annotation + ' table in Monaco with stoppage_penalty values', function(assert) { - assert.plan(6); - var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); - var options = { - coordinates: two_test_coordinates, - annotations: [annotation.slice(0,-1)], - stoppage_penalty: [], - }; - - assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty must be an array of 2 numbers/, "should throw on empty array"); - - options.stoppage_penalty = ['a',1]; - assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty must be an array of 2 numbers/, "should throw on non-numeric value"); - - options.stoppage_penalty = [1,2,3]; - assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty must be an array of 2 numbers/, "should throw on too many values"); - - options.stoppage_penalty = [1]; - assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty must be an array of 2 numbers/, "should throw on not enough values"); - - options.stoppage_penalty = [2,1]; - assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty max must be larger than min/, "should throw on max < min"); - - options.stoppage_penalty = [-1,2]; - assert.throws(()=>osrm.table(options, (err, res) => {}), /Stoppage penalty min\/max can't be less than zero/, "should throw on negative value"); - - }); }); diff --git a/unit_tests/engine/offline_facade.cpp b/unit_tests/engine/offline_facade.cpp index 5c9dbdc0e..e7fe1dde1 100644 --- a/unit_tests/engine/offline_facade.cpp +++ b/unit_tests/engine/offline_facade.cpp @@ -282,48 +282,40 @@ class ContiguousInternalMemoryDataFacade return {}; } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate /*input_coordinate*/, - const Approach /*approach*/, - const bool /* use_all_edges */, - const double /* min_stoppage_penalty */, - const double /* max_stoppage_penalty */) const override + std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, + const Approach /*approach*/, + const bool /* use_all_edges */) const override { return {}; } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate /*input_coordinate*/, - const double /*max_distance*/, - const Approach /*approach*/, - const bool /* use_all_edges */, - const double /* min_stoppage_penalty */, - const double /* max_stoppage_penalty */) const override + std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, + const double /*max_distance*/, + const Approach /*approach*/, + const bool /* use_all_edges */) const override { return {}; } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate /*input_coordinate*/, - const double /*max_distance*/, - const int /*bearing*/, - const int /*bearing_range*/, - const Approach /*approach*/, - const bool /* use_all_edges */, - const double /* min_stoppage_penalty */, - const double /* max_stoppage_penalty */) const override + std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, + const double /*max_distance*/, + const int /*bearing*/, + const int /*bearing_range*/, + const Approach /*approach*/, + const bool /* use_all_edges */) const override { return {}; } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate /*input_coordinate*/, - const int /*bearing*/, - const int /*bearing_range*/, - const Approach /*approach*/, - const bool /* use_all_edges */, - const double /* min_stoppage_penalty */, - const double /* max_stoppage_penalty */) const override + std::pair + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, + const int /*bearing*/, + const int /*bearing_range*/, + const Approach /*approach*/, + const bool /* use_all_edges */) const override { return {}; } diff --git a/unit_tests/mocks/mock_datafacade.hpp b/unit_tests/mocks/mock_datafacade.hpp index 29ef2d1be..81c9498a2 100644 --- a/unit_tests/mocks/mock_datafacade.hpp +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -167,51 +167,39 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade } std::pair - NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate /*input_coordinate*/, - const engine::Approach /*approach*/, - const bool /* use_all_edges */, - const double /* min_stoppage_penalty */, - const double /* max_stoppage_penalty */) const override + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, + const engine::Approach /*approach*/, + const bool /* use_all_edges */) const override { return {}; } std::pair - NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate /*input_coordinate*/, - const double /*max_distance*/, - const engine::Approach /*approach*/, - const bool /* use_all_edges */, - const double /* min_stoppage_penalty */, - const double /* max_stoppage_penalty */) const override + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, + const double /*max_distance*/, + const engine::Approach /*approach*/, + const bool /* use_all_edges */) const override { return {}; } std::pair - NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate /*input_coordinate*/, - const double /*max_distance*/, - const int /*bearing*/, - const int /*bearing_range*/, - const engine::Approach /*approach*/, - const bool /* use_all_edges */, - const double /* min_stoppage_penalty */, - const double /* max_stoppage_penalty */) const override + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, + const double /*max_distance*/, + const int /*bearing*/, + const int /*bearing_range*/, + const engine::Approach /*approach*/, + const bool /* use_all_edges */) const override { return {}; } std::pair - NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate /*input_coordinate*/, - const int /*bearing*/, - const int /*bearing_range*/, - const engine::Approach /*approach*/, - const bool /* use_all_edges */, - const double /* min_stoppage_penalty */, - const double /* max_stoppage_penalty */) const override + NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, + const int /*bearing*/, + const int /*bearing_range*/, + const engine::Approach /*approach*/, + const bool /* use_all_edges */) const override { return {}; }