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

Shortest-ish #2555

Merged
merged 46 commits into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b7064fc
add plumbing for shortest distance(ish) routes for just auto costing
kevinkreiser Aug 24, 2020
a2a1435
changelog stub
kevinkreiser Aug 24, 2020
bcabf61
Update CHANGELOG.md
kevinkreiser Aug 24, 2020
eabdb9e
typos
kevinkreiser Aug 24, 2020
c3d4847
Merge remote-tracking branch 'origin/shortestish' into shortestish
kevinkreiser Aug 24, 2020
b998edf
Merge branch 'master' into shortestish
nilsnolde Sep 11, 2020
ba4b2e1
add gurka test for shortest auto
nilsnolde Sep 11, 2020
5dc06c8
add truck shortest
nilsnolde Sep 13, 2020
4ce4b11
resolve conflicts with master
nilsnolde Sep 21, 2020
5a20b24
Merge branch 'master' into shortestish
nilsnolde Sep 21, 2020
211cdc1
add shortest to other profiles, update test; motor_scooter & bike sti…
nilsnolde Sep 21, 2020
8e37b95
add to docs
nilsnolde Sep 21, 2020
6547eca
add stashed changes
nilsnolde Sep 21, 2020
48c1874
format
nilsnolde Sep 21, 2020
25feb2d
Merge branch 'master' into shortestish
kevinkreiser Sep 24, 2020
9f2d677
resolve proto.options
nilsnolde Oct 5, 2020
e33083e
comment scooter/bike/ped test until better solution has been found
nilsnolde Oct 5, 2020
12fe6e6
Merge branch 'master' into shortestish [ci skip]
nilsnolde Oct 15, 2020
2cdeec3
fix tests for ped, bike, scooter
nilsnolde Oct 16, 2020
467b74d
fix tests for ped, bike, scooter
nilsnolde Oct 16, 2020
bb597d3
some more docu info
nilsnolde Oct 16, 2020
fa23b48
strike-through auto_shorter
nilsnolde Oct 16, 2020
ee00a92
resolve error in debug-lint build
nilsnolde Oct 16, 2020
b987eed
Merge branch 'shortestish' of github.com:valhalla/valhalla into short…
nilsnolde Oct 16, 2020
f517ee4
Merge branch 'master' into shortestish
nilsnolde Oct 16, 2020
609b52b
choose a saner tag combo so it doesn't break in the future
nilsnolde Oct 17, 2020
59affa1
sidewalk_factor was missing in docs
nilsnolde Oct 17, 2020
314f5e7
wrong assert for ferry speed
nilsnolde Oct 17, 2020
895a11e
Merge branch 'master' into shortestish
nilsnolde Oct 20, 2020
b86d0b0
missed shortest_ in other overload
nilsnolde Oct 20, 2020
5fbdc78
resolve conflict with master
nilsnolde Oct 20, 2020
e99b3a4
some major flaws in ped/bike edgecost computation; some places (trans…
nilsnolde Oct 20, 2020
c6712ca
profiles -> costing models
nilsnolde Oct 20, 2020
29ea4d3
revert change to get road speed in pedestrian edgecost
nilsnolde Oct 20, 2020
f351177
introduce code to change auto_shorter to auto with shortest: true; ad…
nilsnolde Oct 20, 2020
99c4b68
remove auto_shorter from other locations
nilsnolde Oct 20, 2020
3c76b00
revert removing auto_shorter from codebase
nilsnolde Oct 21, 2020
c6cd36f
mdk auto_shorter and fix merge conflict bug
kevinkreiser Oct 23, 2020
cb7eb25
patch up bicycle cost for shortest and fix base_cost to retain the ti…
kevinkreiser Oct 24, 2020
ad712eb
further gut costing stuff that is no longer needed, update tests
kevinkreiser Oct 24, 2020
f126b0c
move deprecation tests into other tests and only test parsing
kevinkreiser Oct 24, 2020
a6a95b4
remove redundant test from cmakelists
nilsnolde Oct 24, 2020
0adf518
consistent use of rapidjson shortcut methods
nilsnolde Oct 24, 2020
d378b9b
profile is an osrm term
kevinkreiser Oct 25, 2020
8a07b1b
Merge remote-tracking branch 'origin/shortestish' into shortestish
kevinkreiser Oct 25, 2020
15880ba
simplify test
kevinkreiser Oct 25, 2020
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 @@ -154,6 +154,7 @@
* ADDED: Migrated to Ubuntu 20.04 base-image [#2508](https://github.com/valhalla/valhalla/pull/2508)
* CHANGED: Speed up parseways stage by avoiding multiple string comparisons [#2518](https://github.com/valhalla/valhalla/pull/2518)
* CHANGED: Speed up enhance stage by avoiding GraphTileBuilder copying [#2468](https://github.com/valhalla/valhalla/pull/2468)
* ADDED: Costing options now includes shortest flag which favors shortest path routes [#2555](https://github.com/valhalla/valhalla/pull/2555)
* ADDED: Incidents in intersections [#2547](https://github.com/valhalla/valhalla/pull/2547)
* CHANGED: Refactor mapmatching configuration to use a struct (instead of `boost::property_tree::ptree`). [#2485](https://github.com/valhalla/valhalla/pull/2485)
* ADDED: Save exit maneuver's begin heading when combining enter & exit roundabout maneuvers. [#2554](https://github.com/valhalla/valhalla/pull/2554)
Expand Down
11 changes: 9 additions & 2 deletions docs/api/turn-by-turn/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ Valhalla's routing service uses dynamic, run-time costing to generate the route
| Costing model | Description |
| :----------------- | :----------- |
| `auto` | Standard costing for driving routes by car, motorcycle, truck, and so on that obeys automobile driving rules, such as access and turn restrictions. `Auto` provides a short time path (though not guaranteed to be shortest time) and uses intersection costing to minimize turns and maneuvers or road name changes. Routes also tend to favor highways and higher classification roads, such as motorways and trunks. |
| `auto_shorter` | Alternate costing for driving that provides a short path (though not guaranteed to be shortest distance) that obeys driving rules for access and turn restrictions. |
| `bicycle` | Standard costing for travel by bicycle, with a slight preference for using [cycleways](http://wiki.openstreetmap.org/wiki/Key:cycleway) or roads with bicycle lanes. Bicycle routes follow regular roads when needed, but avoid roads without bicycle access. |
| `bus` | Standard costing for bus routes. Bus costing inherits the auto costing behaviors, but checks for bus access on the roads. |
|**BETA** `bikeshare` | A combination of pedestrian and bicycle. Use bike share station(`amenity:bicycle_rental`) to change the travel mode |
Expand All @@ -88,6 +87,8 @@ Costing methods can have several options that can be adjusted to develop the rou
* Penalty options are fixed costs in seconds that are only added to the path cost. Penalties can influence the route path determination but do not add to the estimated time along the path. For example, add a `toll_booth_penalty` to create route paths that tend to avoid toll booths. Penalties must be in the range of 0.0 seconds to 43200.0 seconds (12 hours), otherwise a default value will be assigned.
* Factor options are used to multiply the cost along an edge or road section in a way that influences the path to favor or avoid a particular attribute. Factor options do not impact estimated time along the path, though. Factors must be in the range 0.1 to 100000.0, where factors of 1.0 have no influence on cost. Anything outside of this range will be assigned a default value. Use a factor less than 1.0 to attempt to favor paths containing preferred attributes, and a value greater than 1.0 to avoid paths with undesirable attributes. Avoidance factors are more effective than favor factors at influencing a path. A factor's impact also depends on the length of road containing the specified attribute, as longer roads have more impact on the costing than very short roads. For this reason, penalty options tend to be better at influencing paths.

A special costing option is `shortest`, which, when `true`, will solely use distance as cost and disregard all other costs, penalties and factors. It's available for all costing models except `multimodal` & `bikeshare`.

##### Automobile and bus costing options

These options are available for `auto`, `auto_shorter`, `bus`, and `truck` costing methods.
Expand All @@ -104,6 +105,7 @@ These options are available for `auto`, `auto_shorter`, `bus`, and `truck` costi
| `use_tolls` | This value indicates the willingness to take roads with tolls. This is a range of values between 0 and 1. Values near 0 attempt to avoid tolls and values near 1 will not attempt to avoid them. The default value is 0.5. Note that sometimes roads with tolls are required to complete a route so values of 0 are not guaranteed to avoid them entirely. |
| `country_crossing_cost` | A cost applied when encountering an international border. This cost is added to the estimated and elapsed times. The default cost is 600 seconds. |
| `country_crossing_penalty` | A penalty applied for a country crossing. This penalty can be used to create paths that avoid spanning country boundaries. The default penalty is 0. |
| `shortest` | Changes the metric to quasi-shortest, i.e. purely distance-based costing. Note, this will disable all other costings & penalties. Also note, `shortest` will not disable hierarchy pruning, leading to potentially sub-optimal routes for some costing models. The default is `false`. |

###### Truck-specific costing options

Expand Down Expand Up @@ -140,6 +142,7 @@ These additional options are available for bicycle costing methods.
| `avoid_bad_surfaces` | This value is meant to represent how much a cyclist wants to avoid roads with poor surfaces relative to the bicycle type being used. This is a range of values between 0 and 1. When the value is 0, there is no penalization of roads with different surface types; only bicycle speed on each surface is taken into account. As the value approaches 1, roads with poor surfaces for the bike are penalized heavier so that they are only taken if they significantly improve travel time. When the value is equal to 1, all bad surfaces are completely disallowed from routing, including start and end points. The default value is 0.25. |
|`bss_return_cost`| This value is useful when `bikeshare` is chosen as travel mode. It is meant to give the time will be used to return a rental bike. This value will be displayed in the final directions and used to calculate the whole duation. The default value is 120 seconds.|
|`bss_return_penalty`| This value is useful when `bikeshare` is chosen as travel mode. It is meant to describe the potential effort to return a rental bike. This value won't be displayed and used only inside of the algorithm.|
| `shortest` | Changes the metric to quasi-shortest, i.e. purely distance-based costing. Note, this will disable all other costings & penalties. Also note, `shortest` will not disable hierarchy pruning, leading to potentially sub-optimal routes for some costing models. The default is `false`. |

##### Motor_scooter costing options
Standard costing for travel by motor scooter or moped. By default, motor_scooter costing will avoid higher class roads unless the country overrides allows motor scooters on these roads. Motor scooter routes follow regular roads when needed, but avoid roads without motor_scooter, moped, or mofa access. The costing model recognizes factors unique to motor_scooter travel and offers options for tuning motor_scooter routes. Factors unique to travel by motor_scooter influence the resulting route.
Expand All @@ -151,6 +154,7 @@ All of the options described above for autos also apply to motor_scooter costing
| `top_speed` | Top speed the motorized scooter can go. Used to avoid roads with higher speeds than this value. This value must be between 20 and 120 KPH. The default value is 45 KPH (~28 MPH) |
| `use_primary` | A riders's propensity to use primary roads. This is a range of values from 0 to 1, where 0 attempts to avoid primary roads, and 1 indicates the rider is more comfortable riding on primary roads. Based on the `use_primary` factor, roads with certain classifications and higher speeds are penalized in an attempt to avoid them when finding the best path. The default value is 0.5. |
| `use_hills` | A riders's desire to tackle hills in their routes. This is a range of values from 0 to 1, where 0 attempts to avoid hills and steep grades even if it means a longer (time and distance) path, while 1 indicates the rider does not fear hills and steeper grades. Based on the `use_hills` factor, penalties are applied to roads based on elevation change and grade. These penalties help the path avoid hilly roads in favor of flatter roads or less steep grades where available. Note that it is not always possible to find alternate paths to avoid hills (for example when route locations are in mountainous areas). The default value is 0.5. |
| `shortest` | Changes the metric to quasi-shortest, i.e. purely distance-based costing. Note, this will disable all other costings & penalties. Also note, `shortest` will not disable hierarchy pruning, leading to potentially sub-optimal routes for some costing models. The default is `false`. |

##### Motorcycle costing options -> **BETA**
Standard costing for travel by motorcycle. By default, motorcycle costing will default to higher class roads. The costing model recognizes factors unique to motorcycle travel and offers options for tuning motorcycle routes.
Expand All @@ -162,6 +166,7 @@ The following options are available for motorcycle costing:
| :-------------------------- | :----------- |
| `use_highways` | A riders's propensity to prefer the use of highways. This is a range of values from 0 to 1, where 0 attempts to avoid highways, and values toward 1 indicates the rider prefers highways. The default value is 1.0. |
| `use_trails` | A riders's desire for adventure in their routes. This is a range of values from 0 to 1, where 0 will avoid trails, tracks, unclassified or bad surfaces and values towards 1 will tend to avoid major roads and route on secondary roads. The default value is 0.0. |
| `shortest` | Changes the metric to quasi-shortest, i.e. purely distance-based costing. Note, this will disable all other costings & penalties. Also note, `shortest` will not disable hierarchy pruning, leading to potentially sub-optimal routes for some costing models. The default is `false`. |

##### Pedestrian costing options

Expand All @@ -170,14 +175,16 @@ These options are available for pedestrian costing methods.
| Pedestrian options | Description |
| :-------------------------- | :----------- |
| `walking_speed` | Walking speed in kilometers per hour. Must be between 0.5 and 25 km/hr. Defaults to 5.1 km/hr (3.1 miles/hour). |
| `walkway_factor` | A factor that modifies the cost when encountering roads or paths that do not allow vehicles and are set aside for pedestrian use. Pedestrian routes generally attempt to favor using these [walkways and sidewalks](http://wiki.openstreetmap.org/wiki/Sidewalks). The default walkway_factor is 1.0. |
| `walkway_factor` | A factor that modifies the cost when encountering roads classified as `footway` (no motorized vehicles allowed), which may be designated footpaths or designated sidewalks along residential roads. Pedestrian routes generally attempt to favor using these [walkways and sidewalks](https://wiki.openstreetmap.org/wiki/Sidewalks). The default walkway_factor is 1.0. |
| `sidewalk_factor` | A factor that modifies the cost when encountering roads with dedicated sidewalks. Pedestrian routes generally attempt to favor using [sidewalks](https://wiki.openstreetmap.org/wiki/Key:sidewalk). The default sidewalk_factor is 1.0. |
| `alley_factor` | A factor that modifies (multiplies) the cost when [alleys](http://wiki.openstreetmap.org/wiki/Tag:service%3Dalley) are encountered. Pedestrian routes generally want to avoid alleys or narrow service roads between buildings. The default alley_factor is 2.0. |
| `driveway_factor` | A factor that modifies (multiplies) the cost when encountering a [driveway](http://wiki.openstreetmap.org/wiki/Tag:service%3Ddriveway), which is often a private, service road. Pedestrian routes generally want to avoid driveways (private). The default driveway factor is 5.0. |
| `step_penalty` | A penalty in seconds added to each transition onto a path with [steps or stairs](http://wiki.openstreetmap.org/wiki/Tag:highway%3Dsteps). Higher values apply larger cost penalties to avoid paths that contain flights of steps. |
| `use_ferry` | This value indicates the willingness to take ferries. This is range of values between 0 and 1. Values near 0 attempt to avoid ferries and values near 1 will favor ferries. The default value is 0.5. Note that sometimes ferries are required to complete a route so values of 0 are not guaranteed to avoid ferries entirely. |
| `max_hiking_difficulty` | This value indicates the maximum difficulty of hiking trails that is allowed. Values between 0 and 6 are allowed. The values correspond to *sac_scale* values within OpenStreetMap, see reference [here](https://wiki.openstreetmap.org/wiki/Key:sac_scale). The default value is 1 which means that well cleared trails that are mostly flat or slightly sloped are allowed. Higher difficulty trails can be allowed by specifying a higher value for max_hiking_difficulty.
|`bss_rent_cost`| This value is useful when `bikeshare` is chosen as travel mode. It is meant to give the time will be used to rent a bike from a bike share station. This value will be displayed in the final directions and used to calculate the whole duation. The default value is 120 seconds.|
|`bss_rent_penalty`| This value is useful when `bikeshare` is chosen as travel mode. It is meant to describe the potential effort to rent a bike from a bike share station. This value won't be displayed and used only inside of the algorithm.|
| `shortest` | Changes the metric to quasi-shortest, i.e. purely distance-based costing. Note, this will disable all other costings & penalties. Also note, `shortest` will not disable hierarchy pruning, leading to potentially sub-optimal routes for some costing models. The default is `false`. |
##### Transit costing options

These options are available for transit costing when the multimodal costing model is used.
Expand Down
5 changes: 3 additions & 2 deletions proto/options.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum ShapeFormat {

enum Costing {
auto_ = 0;
auto_shorter = 1;
// deprecated auto_shorter = 1;
bicycle = 2;
bus = 3;
hov = 4;
Expand All @@ -43,7 +43,7 @@ enum Costing {
transit = 8;
truck = 9;
motorcycle = 10;
auto_data_fix = 11;
// deprecated auto_data_fix = 11;
taxi = 12;
none_ = 13;
bikeshare = 14;
Expand Down Expand Up @@ -118,6 +118,7 @@ message CostingOptions {
optional bool ignore_oneways = 61;
optional bool ignore_access = 62;
optional bool ignore_closures = 63;
optional bool shortest = 64;

// these are not specified directly by the user but they get filled in as the request is parsed and fulfilled
optional Costing costing = 90;
Expand Down
8 changes: 4 additions & 4 deletions src/proto_conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const std::string& Options_Action_Enum_Name(const Options::Action action) {
bool Costing_Enum_Parse(const std::string& costing, Costing* c) {
static const std::unordered_map<std::string, Costing> costings{
{"auto", Costing::auto_},
{"auto_shorter", Costing::auto_shorter},
// auto_shorter is deprecated
{"bicycle", Costing::bicycle},
{"bus", Costing::bus},
{"hov", Costing::hov},
Expand All @@ -136,7 +136,7 @@ bool Costing_Enum_Parse(const std::string& costing, Costing* c) {
{"transit", Costing::transit},
{"truck", Costing::truck},
{"motorcycle", Costing::motorcycle},
{"auto_data_fix", Costing::auto_data_fix},
// auto_data_fix is deprecated
{"none", Costing::none_},
{"", Costing::none_},
{"bikeshare", Costing::bikeshare},
Expand All @@ -152,7 +152,7 @@ const std::string& Costing_Enum_Name(const Costing costing) {
static const std::string empty;
static const std::unordered_map<int, std::string> costings{
{Costing::auto_, "auto"},
{Costing::auto_shorter, "auto_shorter"},
// auto_shorter is deprecated
{Costing::bicycle, "bicycle"},
{Costing::bus, "bus"},
{Costing::hov, "hov"},
Expand All @@ -163,7 +163,7 @@ const std::string& Costing_Enum_Name(const Costing costing) {
{Costing::transit, "transit"},
{Costing::truck, "truck"},
{Costing::motorcycle, "motorcycle"},
{Costing::auto_data_fix, "auto_data_fix"},
// auto_data_fix is deprecated
{Costing::none_, "none"},
{Costing::bikeshare, "bikeshare"},
};
Expand Down
Loading