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

Distances in MLD #5019

Merged
merged 3 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
92 changes: 81 additions & 11 deletions features/testbot/distance_matrix.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@matrix @testbot @ch
@matrix @testbot
Feature: Basic Distance Matrix
# note that results of travel distance are in metres

Expand Down Expand Up @@ -66,8 +66,7 @@ Feature: Basic Distance Matrix
| | a | b | c | d |
| a | 0 | 300+-2 | 100+-2 | 200+-2 |


Scenario: Testbot - Travel distance matrix of minimal network disconnected motorway exclude
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"
Expand All @@ -88,7 +87,6 @@ Feature: Basic Distance Matrix
| | 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 |
Expand Down Expand Up @@ -212,6 +210,13 @@ Feature: Basic Distance Matrix
| be |
| cf |

When I route I should get
| from | to | distance |
| e | a | 200m +- 1 |
| e | b | 100m +- 1 |
| f | a | 300m +- 1 |
| f | b | 200m +- 1 |

When I request a travel distance matrix I should get
| | a | b | e | f |
| a | 0 | 100+-1 | 200+-1 | 300+-1 |
Expand Down Expand Up @@ -255,7 +260,6 @@ Feature: Basic Distance Matrix
| 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
"""
Expand Down Expand Up @@ -445,10 +449,21 @@ Feature: Basic Distance Matrix
| 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 |

When I request a travel distance matrix I should get
| | 1 |
| 1 | 0 |
| 2 | 100+-5 |
| 3 | 900+-5 |
| 4 | 1000+-5 |
| 5 | 600+-5 |
| 6 | 700+-5 |
| 7 | 300+-5 |
| 8 | 400+-5 |

Scenario: Testbot - Travel distance matrix with ties
Given the node map
"""
a b
a b

c d
"""
Expand All @@ -466,21 +481,26 @@ Feature: Basic Distance Matrix

When I route I should get
| from | to | route | distance |
| a | b | ab,ab | 300m +- 1 |
| a | b | ab,ab | 450m |
| a | c | ac,ac | 200m |
| a | d | ab,bd,bd | 500m +- 1 |
| a | d | ac,dc,dc | 500m +- 1 |

When I request a travel distance matrix I should get
| | a | b | c | d |
| a | 0 | 300+-2 | 200+-2 | 500+-2 |
| a | 0 | 450+-2 | 200+-2 | 500+-2 |

When I request a travel distance matrix I should get
| | a |
| a | 0 |
| b | 300+-2 |
| b | 450+-2 |
| c | 200+-2 |
| d | 500+-2 |

When I request a travel distance matrix I should get
| | a | c |
| a | 0 | 200+-2 |
| c | 200+-2 | 0 |


# Check rounding errors
Scenario: Testbot - Long distances in tables
Expand All @@ -492,8 +512,58 @@ Feature: Basic Distance Matrix

And the ways
| nodes |
| abcd |
| abcd |

When I request a travel distance matrix I should get
| | a | b | c | d |
| a | 0 | 1000+-3 | 2000+-3 | 3000+-3 |


Scenario: Testbot - OneToMany vs ManyToOne
Given the node map
"""
a b
c
"""

And the ways
| nodes | oneway |
| ab | yes |
| ac | |
| bc | |

When I request a travel distance matrix I should get
| | a | b |
| b | 240.4 | 0 |

When I request a travel distance matrix I should get
| | a |
| a | 0 |
| b | 240.4 |

Scenario: Testbot - Varying distances between nodes
Given the node map
"""
a b c d

e



f
"""

And the ways
| nodes | oneway |
| feabcd | yes |
| ec | |
| fd | |

When I request a travel distance matrix I should get
| | a | b | c | d | e | f |
| a | 0 | 100+-1 | 300+-1 | 650+-1 | 1930+-1 | 1533+-1 |
| b | 760+-1 | 0 | 200+-1 | 550+-1 | 1830+-1 | 1433+-1 |
| c | 560+-2 | 660+-2 | 0 | 350+-1 | 1630+-1 | 1233+-1 |
| d | 1480+-2 | 1580+-1 | 1780+-1 | 0 | 1280+-1 | 883+-1 |
| e | 200+-2 | 300+-2 | 500+-1 | 710+-1 | 0 | 1593+-1 |
| f | 597+-1 | 696+-1 | 896+-1 | 1108+-1 | 400+-3 | 0 |
22 changes: 22 additions & 0 deletions features/testbot/duration_matrix.feature
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,25 @@ Feature: Basic Duration Matrix
| b | 1 |
| c | 15 |
| d | 10 |

Scenario: Testbot - OneToMany vs ManyToOne
Given the node map
"""
a b
c
"""

And the ways
| nodes | oneway |
| ab | yes |
| ac | |
| bc | |

When I request a travel time matrix I should get
| | a | b |
| b | 24.1 | 0 |

When I request a travel time matrix I should get
| | a |
| a | 0 |
| b | 24.1 |
34 changes: 34 additions & 0 deletions features/testbot/multi_level_routing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,40 @@ Feature: Multi level routing
| l | 144.7 | 60 |
| o | 124.7 | 0 |


When I request a travel distance matrix I should get
| | a | f | l | o |
| a | 0+-2 | 2287+-2 | 1443+-2 | 1243+-2 |
| f | 2284+-2 | 0+-2 | 1241+-2 | 1443+-2 |
| l | 1443+-2 | 1244+-2 | 0+-2 | 600+-2 |
| o | 1243+-2 | 1444+-2 | 600+-2 | 0+-2 |

When I request a travel distance matrix I should get
| | a | f | l | o |
| a | 0 | 2287.2+-2 | 1443+-2 | 1243+-2 |

When I request a travel distance matrix I should get
| | a |
| a | 0 |
| f | 2284.5+-2 |
| l | 1443.1 |
| o | 1243 |

When I request a travel distance matrix I should get
| | a | f | l | o |
| a | 0 | 2287+-2 | 1443+-2 | 1243+-2 |
| o | 1243 | 1444+-2 | 600+-2 | 0+-2 |


When I request a travel distance matrix I should get
| | a | o |
| a | 0+-2 | 1243+-2 |
| f | 2284+-2 | 1443+-2 |
| l | 1443+-2 | 600+-2 |
| o | 1243+-2 | 0+-2 |



Scenario: Testbot - Multi level routing: horizontal road
Given the node map
"""
Expand Down
2 changes: 1 addition & 1 deletion features/testbot/traffic_speeds.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Feature: Traffic - speeds
| a | d | ad,ad | 27 km/h | 1275.7,0 | 1 |
| d | c | dc,dc | 36 km/h | 956.8,0 | 0 |
| g | b | fb,fb | 36 km/h | 164.7,0 | 0 |
| a | g | ad,df,fb,fb | 30 km/h | 1275.7,487.5,304.7,0 | 1:0:0 |
| a | g | ad,df,fb,fb | 30 km/h | 1295.7,487.5,304.7,0 | 1:0:0 |


Scenario: Weighting based on speed file weights, ETA based on file durations
Expand Down
19 changes: 15 additions & 4 deletions include/engine/routing_algorithms/many_to_many.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,35 @@ namespace engine
{
namespace routing_algorithms
{

namespace
{
struct NodeBucket
{
NodeID middle_node;
NodeID parent_node;
unsigned column_index; // a column in the weight/duration matrix
unsigned column_index : 31; // a column in the weight/duration matrix
unsigned from_clique_arc : 1;
EdgeWeight weight;
EdgeDuration duration;

NodeBucket(NodeID middle_node,
NodeID parent_node,
bool from_clique_arc,
unsigned column_index,
EdgeWeight weight,
EdgeDuration duration)
: middle_node(middle_node), parent_node(parent_node), column_index(column_index),
from_clique_arc(from_clique_arc), weight(weight), duration(duration)
{
}

NodeBucket(NodeID middle_node,
NodeID parent_node,
unsigned column_index,
EdgeWeight weight,
EdgeDuration duration)
: middle_node(middle_node), parent_node(parent_node), column_index(column_index),
weight(weight), duration(duration)
from_clique_arc(false), weight(weight), duration(duration)
{
}

Expand Down Expand Up @@ -74,7 +85,7 @@ struct NodeBucket
}
};
};
}
} // namespace

template <typename Algorithm>
std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>>
Expand Down
Loading