osrm-backend/features/testbot/distance_matrix.feature
Kajari Ghosh fbba23e66d set up for computing durations while unpacking them
copy dummy cache over

implement retrievePackedPathFromSearchSpace

calculate packed_path_from_source_to_middle

debugging the retrievePackedPathFromSearchSpace function implementation

adding in packed_path_from_source_to_middle

cache is partway working

unpack path and get duration that way

the computeDurationForEdge method

comment out cache

clean up the code

move vector creation and allocation to outside of loop

hack to not return vectors on facade.GetUncompressedForwardDurations and facade.GetUncompressedReverseDurations

clean up hack

add exclude_index to cache key

clearing cache with timestamp

rebase against vectors->range pr

swapped out unordered_map cache with a boost_lru implementation

calculation for cache size

cleaned up comment about cache size calculations

unit tests

cache uses unsigned char for exclude index

clean up cache and unit tests

pass in a hashed key to the threadlocal cache

500 mb threadlocal 2 t

fixes and a rebase

correct calculation
2018-05-04 11:31:38 -04:00

574 lines
19 KiB
Gherkin

@matrix @testbot @ch
Feature: Basic Distance Matrix
# note that results of travel distance are in metres
Background:
Given the profile "testbot"
And the partition extra arguments "--small-component-size 1 --max-cell-sizes 2,4,8,16"
Scenario: Testbot - Travel distance matrix of minimal network
Given the node map
"""
a b
"""
And the ways
| nodes |
| ab |
When I request a travel distance matrix I should get
| | a | b |
| a | 0 | 100+-1 |
| b | 100+-1 | 0 |
Scenario: Testbot - Travel distance matrix of minimal network with toll exclude
Given the query options
| exclude | toll |
Scenario: Testbot - Travel time matrix of minimal network with excludes
Given the query options
| exclude | toll |
Given the node map
"""
a b
c d
"""
And the ways
| nodes | highway | toll | # |
| ab | motorway | | not drivable for exclude=motorway |
| cd | primary | | always drivable |
| ac | highway | yes | not drivable for exclude=motorway exclude=toll and exclude=motorway,toll |
| bd | highway | yes | not drivable for exclude=motorway exclude=toll |
When I request a travel time matrix I should get
| | a | b | c | d |
| a | 0 | 15 | | |
| b | 15 | 0 | | |
| c | | | 0 | 10 |
| d | | | 10 | 0 |
Scenario: Testbot - Travel time matrix of minimal network with different exclude
Given the query options
| exclude | motorway |
Given the node map
"""
a b
c d
"""
And the ways
| nodes | highway | toll | # |
| ab | motorway | | not drivable for exclude=motorway |
| cd | primary | | always drivable |
| ac | highway | yes | not drivable for exclude=motorway exclude=toll and exclude=motorway,toll |
| bd | highway | yes | not drivable for exclude=motorway exclude=toll |
When I request a travel time matrix I should get
| | a | b | c | d |
| a | 0 | 40 | 15 | 25 |
| b | 40 | 0 | 25 | 15 |
| c | 15 | 25 | 0 | 10 |
| d | 25 | 15 | 10 | 0 |
Scenario: Testbot - Travel time matrix of minimal network with excludes combination
Given the query options
| exclude | motorway,toll |
Given the node map
"""
a b
c d
"""
And the ways
| nodes | highway | toll | # |
| ab | motorway | | not drivable for exclude=motorway |
| cd | primary | | always drivable |
| ac | highway | yes | not drivable for exclude=motorway exclude=toll and exclude=motorway,toll |
| bd | highway | yes | not drivable for exclude=motorway exclude=toll |
When I request a travel time matrix I should get
| | a | b | c | d |
| a | 0 | 10 | 0 | 10 |
| b | 10 | 0 | 10 | 0 |
| c | 0 | 10 | 0 | 10 |
| d | 10 | 0 | 10 | 0 |
Scenario: Testbot - Travel time matrix with different way speeds
Given the node map
"""
a b
c d
"""
And the ways
| nodes | highway | toll | # |
| ab | motorway | | not drivable for exclude=motorway |
| cd | primary | | always drivable |
| ac | primary | yes | not drivable for exclude=toll and exclude=motorway,toll |
| bd | motorway | yes | not drivable for exclude=toll and exclude=motorway,toll |
When I request a travel distance matrix I should get
| | a | b | c | d |
| a | 0 | 100+-1 | | |
| b | 100+-1 | 0 | | |
| c | | | 0 | 100+-1 |
| d | | | 100+-1 | 0 |
Scenario: Testbot - Travel distance matrix of minimal network with motorway exclude
Given the query options
| exclude | motorway |
Given the node map
"""
a b
c d
"""
And the ways
| nodes | highway | # |
| ab | motorway | not drivable for exclude=motorway |
| cd | residential | |
| ac | residential | |
| bd | residential | |
When I request a travel distance matrix I should get
| | a | b | c | d |
| a | 0 | 300+-2 | 100+-2 | 200+-2 |
Scenario: Testbot - Travel distance matrix of minimal network disconnected motorway exclude
Given the query options
| exclude | motorway |
And the extract extra arguments "--small-component-size 4"
Given the node map
"""
ab efgh
cd
"""
And the ways
| nodes | highway | # |
| be | motorway | not drivable for exclude=motorway |
| abcd | residential | |
| efgh | residential | |
When I request a travel distance matrix I should get
| | a | b | e |
| a | 0 | 50+-1 | |
Scenario: Testbot - Travel distance matrix of minimal network with motorway and toll excludes
Given the query options
| exclude | motorway,toll |
Given the node map
"""
a b e f
c d g h
"""
And the ways
| nodes | highway | toll | # |
| be | motorway | | not drivable for exclude=motorway |
| dg | primary | yes | not drivable for exclude=toll |
| abcd | residential | | |
| efgh | residential | | |
When I request a travel distance matrix I should get
| | a | b | e | g |
| a | 0 | 100+-1 | | |
Scenario: Testbot - Travel distance matrix with different way speeds
Given the node map
"""
a b c d
"""
And the ways
| nodes | highway |
| ab | primary |
| bc | secondary |
| cd | tertiary |
When I request a travel distance matrix I should get
| | a | b | c | d |
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
| c | 200+-1 | 100+-1 | 0 | 100+-1 |
| d | 300+-1 | 200+-1 | 100+-1 | 0 |
When I request a travel distance matrix I should get
| | a | b | c | d |
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
When I request a travel distance matrix I should get
| | a |
| a | 0 |
| b | 100+-1 |
| c | 200+-1 |
| d | 300+-1 |
Scenario: Testbot - Travel distance matrix of small grid
Given the node map
"""
a b c
d e f
"""
And the ways
| nodes |
| abc |
| def |
| ad |
| be |
| cf |
When I request a travel distance matrix I should get
| | a | b | e | f |
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
| e | 200+-1 | 100+-1 | 0 | 100+-1 |
| f | 300+-1 | 200+-1 | 100+-1 | 0 |
Scenario: Testbot - Travel distance matrix of network with unroutable parts
Given the node map
"""
a b
"""
And the ways
| nodes | oneway |
| ab | yes |
When I request a travel distance matrix I should get
| | a | b |
| a | 0 | 100+-1 |
| b | | 0 |
Scenario: Testbot - Travel distance matrix of network with oneways
Given the node map
"""
x a b y
d e
"""
And the ways
| nodes | oneway |
| abeda | yes |
| xa | |
| by | |
When I request a travel distance matrix I should get
| | x | y | d | e |
| x | 0 | 300+-2 | 400+-2 | 300+-2 |
| y | 500+-2 | 0 | 300+-2 | 200+-2 |
| d | 200+-2 | 300+-2 | 0 | 300+-2 |
| e | 300+-2 | 400+-2 | 100+-2 | 0 |
Scenario: Testbot - Rectangular travel distance matrix
Given the node map
"""
a b c
d e f
"""
And the ways
| nodes |
| abc |
| def |
| ad |
| be |
| cf |
When I request a travel distance matrix I should get
| | a | b | e | f |
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
When I request a travel distance matrix I should get
| | a |
| a | 0 |
| b | 100+-1 |
| e | 200+-1 |
| f | 300+-1 |
When I request a travel distance matrix I should get
| | a | b | e | f |
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
When I request a travel distance matrix I should get
| | a | b |
| a | 0 | 100+-1 |
| b | 100+-1 | 0 |
| e | 200+-1 | 100+-1 |
| f | 300+-1 | 200+-1 |
When I request a travel distance matrix I should get
| | a | b | e | f |
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
| e | 200+-1 | 100+-1 | 0 | 100+-1 |
When I request a travel distance matrix I should get
| | a | b | e |
| a | 0 | 100+-1 | 200+-1 |
| b | 100+-1 | 0 | 100+-1 |
| e | 200+-1 | 100+-1 | 0 |
| f | 300+-1 | 200+-1 | 100+-1 |
When I request a travel distance matrix I should get
| | a | b | e | f |
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
| b | 100+-1 | 0 | 100+-1 | 200+-1 |
| e | 200+-1 | 100+-1 | 0 | 100+-1 |
| f | 300+-1 | 200+-1 | 100+-1 | 0 |
Scenario: Testbot - Travel distance 3x2 matrix
Given the node map
"""
a b c
d e f
"""
And the ways
| nodes |
| abc |
| def |
| ad |
| be |
| cf |
When I request a travel distance matrix I should get
| | b | e | f |
| a | 100+-1 | 200+-1 | 300+-1 |
| b | 0 | 100+-1 | 200+-1 |
Scenario: Testbot - All coordinates are from same small component
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the node map
"""
a b f
d e g
"""
And the ways
| nodes |
| ab |
| be |
| ed |
| da |
| fg |
When I request a travel distance matrix I should get
| | f | g |
| f | 0 | 300+-2 |
| g | 300+-2 | 0 |
Scenario: Testbot - Coordinates are from different small component and snap to big CC
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the node map
"""
a b f h
d e g i
"""
And the ways
| nodes |
| ab |
| be |
| ed |
| da |
| fg |
| hi |
When I route I should get
| from | to | distance |
| f | g | 300m |
| f | i | 300m |
| g | f | 300m |
| g | h | 300m |
| h | g | 300m |
| h | i | 300m |
| i | f | 300m |
| i | h | 300m |
When I request a travel distance matrix I should get
| | f | g | h | i |
| f | 0 | 300+-2 | 0 | 300+-2 |
| g | 300+-2 | 0 | 300+-2 | 0 |
| h | 0 | 300+-2 | 0 | 300+-2 |
| i | 300+-2 | 0 | 300+-2 | 0 |
Scenario: Testbot - Travel distance matrix with loops
Given the node map
"""
a 1 2 b
d 4 3 c
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
| cd | yes |
| da | yes |
When I request a travel distance matrix I should get
| | 1 | 2 | 3 | 4 |
| 1 | 0 | 100+-1 | 400+-1 | 500+-1 |
| 2 | 700+-1 | 0 | 300+-1 | 400+-1 |
| 3 | 400+-1 | 500+-1 | 0 | 100+-1 |
| 4 | 300+-1 | 400+-1 | 700+-1 | 0 |
Scenario: Testbot - Travel distance matrix based on segment durations
Given the profile file
"""
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.traffic_signal_penalty = 0
profile.u_turn_penalty = 0
return profile
end
functions.process_segment = function(profile, segment)
segment.weight = 2
segment.duration = 11
end
return functions
"""
And the node map
"""
a-b-c-d
.
e
"""
And the ways
| nodes |
| abcd |
| ce |
When I request a travel distance matrix I should get
| | a | b | c | d | e |
| a | 0 | 100+-2 | 200+-2 | 300+-2 | 400+-2 |
| b | 100+-2 | 0 | 100+-2 | 200+-2 | 300+-2 |
| c | 200+-2 | 100+-2 | 0 | 100+-2 | 200+-2 |
| d | 300+-2 | 200+-2 | 100+-2 | 0 | 300+-2 |
| e | 400+-2 | 300+-2 | 200+-2 | 300+-2 | 0 |
Scenario: Testbot - Travel distance matrix for alternative loop paths
Given the profile file
"""
local functions = require('testbot')
functions.setup_testbot = functions.setup
functions.setup = function()
local profile = functions.setup_testbot()
profile.traffic_signal_penalty = 0
profile.u_turn_penalty = 0
profile.weight_precision = 3
return profile
end
functions.process_segment = function(profile, segment)
segment.weight = 777
segment.duration = 3
end
return functions
"""
And the node map
"""
a 2 1 b
7 4
8 3
c 5 6 d
"""
And the ways
| nodes | oneway |
| ab | yes |
| bd | yes |
| dc | yes |
| ca | yes |
When I request a travel distance matrix I should get
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 1 | 0 | 1100+-5 | 300+-5 | 200+-5 | 600+-5 | 500+-5 | 900+-5 | 800+-5 |
| 2 | 100+-5 | 0 | 400+-5 | 300+-5 | 700+-5 | 600+-5 | 1000+-5 | 900+-5 |
| 3 | 900+-5 | 800+-5 | 0 | 1100+-5 | 300+-5 | 200+-5 | 600+-5 | 500+-5 |
| 4 | 1000+-5 | 900+-5 | 100+-5 | 0 | 400+-5 | 300+-5 | 700+-5 | 600+-5 |
| 5 | 600+-5 | 500+-5 | 900+-5 | 800+-5 | 0 | 1100+-5 | 300+-5 | 200+-5 |
| 6 | 700+-5 | 600+-5 | 1000+-5 | 900+-5 | 100+-5 | 0 | 400+-5 | 300+-5 |
| 7 | 300+-5 | 200+-5 | 600+-5 | 500+-5 | 900+-5 | 800+-5 | 0 | 1100+-5 |
| 8 | 400+-5 | 300+-5 | 700+-5 | 600+-5 | 1000+-5 | 900+-5 | 100+-5 | 0 |
Scenario: Testbot - Travel distance matrix with ties
Given the node map
"""
a b
c d
"""
And the ways
| nodes |
| ab |
| ac |
| bd |
| dc |
When I route I should get
| from | to | route | distance | time | weight |
| a | c | ac,ac | 200m | 20s | 20 |
When I route I should get
| from | to | route | distance |
| a | b | ab,ab | 300m +- 1 |
| a | c | ac,ac | 200m |
| a | d | ab,bd,bd | 500m +- 1 |
When I request a travel distance matrix I should get
| | a | b | c | d |
| a | 0 | 300+-2 | 200+-2 | 500+-2 |
When I request a travel distance matrix I should get
| | a |
| a | 0 |
| b | 300+-2 |
| c | 200+-2 |
| d | 500+-2 |
# Check rounding errors
Scenario: Testbot - Long distances in tables
Given a grid size of 1000 meters
Given the node map
"""
a b c d
"""
And the ways
| nodes |
| abcd |
When I request a travel distance matrix I should get
| | a | b | c | d |
| a | 0 | 1000+-3 | 2000+-3 | 3000+-3 |