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

[NOT READY] Add a roundtrip/TSP plugin to OSRM #1609

Closed
wants to merge 79 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
7345dc6
Move graph compression code outside of EBGF
TheMarex Jun 23, 2015
3ef34fb
Rename GeometryCompressor and add unit tests
TheMarex Jun 24, 2015
fd30e82
Add graph compressor unit tests
TheMarex Jun 28, 2015
faa880d
Remove unused memebers and rename to currrent style convention
TheMarex Jun 28, 2015
4a74516
Fix data_structure test thanks to new assertion
TheMarex Jun 28, 2015
021a1c7
Restructure the construction of the undirected graph
TheMarex Jun 28, 2015
922e8a4
Return the correct size
TheMarex Jul 1, 2015
f0389c0
Restructure CMakeFile to fix shared library linking errors
TheMarex Jul 8, 2015
8f4e332
Link restrictions to datastore test
TheMarex Jul 8, 2015
486d7b6
Fix typo in foot profile that removed traffic lights
TheMarex Jul 9, 2015
0cd3f37
AppVeyor: create artifacts
wilhelmberg Jul 13, 2015
0352d9c
AppVeyor: wrong paths when creating artifacts
wilhelmberg Jul 13, 2015
94f44e1
Make sure to capture floating point return values from lua
TheMarex Aug 1, 2015
b526cad
Initial version of core ch
Jul 13, 2015
c43c043
Add docker port of build instructions
TheMarex Mar 13, 2015
1acde59
Fix docker run step
TheMarex Mar 16, 2015
00b0ff5
Add clang and README
TheMarex Mar 16, 2015
8b7b32e
Added ccmake to docker image
TheMarex Apr 15, 2015
43b881d
Simplify test.sh
TheMarex Aug 2, 2015
3c05564
Remove reference to restrictions and bollard nodes because it does no…
TheMarex Jul 1, 2015
2621f4a
Allow any input format for StaticGraph and check if edge list is sorted
TheMarex Jul 3, 2015
c2f0e4f
Implement correct const iterator for DeallocatingVector
TheMarex Jul 4, 2015
c80c223
Find components on edge-expanded graph
TheMarex Jul 4, 2015
35542e5
Change interface of Tarjan get_component_size to take component id
TheMarex Jul 7, 2015
d4356b0
Move comparators to struct
TheMarex Jul 15, 2015
1cc75ca
Only swap nodes if it contains a big component
TheMarex Aug 6, 2015
f838f34
Fix static graph test
TheMarex Aug 6, 2015
a7eabeb
gps_precision and matching_beta can be used as a float value
agruss Aug 11, 2015
49adf21
Move calculate_coordinate to algorithms/
TheMarex Aug 6, 2015
4b4bc0d
Fix postgis lua example
TheMarex Aug 7, 2015
c43a251
Rename tiny_components.hpp to tarjan_scc.hpp
TheMarex Aug 7, 2015
e30f0e8
Always announce a turn on mode change
TheMarex Aug 7, 2015
bd37c48
Add test for mode change
TheMarex Aug 7, 2015
84e72ed
Warn if an edge references a missing node
TheMarex Aug 14, 2015
62b2076
Modernize the code base to C++11 standards and beyond.
daniel-j-h Aug 18, 2015
ca7abd7
Merge pull request #1603 from Project-OSRM/refactor/clang_modernize
TheMarex Aug 19, 2015
338ac5d
Rename map to describe what it actually does
TheMarex Aug 7, 2015
ddff9b6
Serialize out .core file containing core node markers
TheMarex Aug 8, 2015
707dd70
Write number of markers to .core file
TheMarex Aug 9, 2015
9387f58
Add loading of .core file to InternalDataFacade
TheMarex Aug 9, 2015
7cc875b
Initial version of core based search
TheMarex Aug 9, 2015
2ff2ce4
Add .core to cucumber renaming
TheMarex Aug 9, 2015
48d1a5e
Make sure to terminate when the core heaps are empty
TheMarex Aug 9, 2015
92956f2
Also support loading core information into shared memory
TheMarex Aug 19, 2015
e55ba26
add round trip plugin with greedy approximation
chaupow Apr 22, 2015
f47443b
add support for locations that are not reachable as well as informati…
chaupow Apr 23, 2015
3b6a8da
fix a lotta bugs
chaupow Apr 23, 2015
40808a3
fix small bugs
chaupow Apr 24, 2015
a550877
add more comments for better understanding
chaupow May 25, 2015
c0e69b6
rename subroute to via_point
chaupow May 26, 2015
a52314d
merge is_lonely_island and is_connected to make code easier to unders…
chaupow May 26, 2015
4b84411
capsule tsp round trip computation in a private method
chaupow May 26, 2015
ef0a6a1
rename result_table to dist_table
chaupow May 26, 2015
25e97b4
add timer to check runtime of round trip algorithm
chaupow May 26, 2015
c082754
add description of farthest insertion algorithm
chaupow May 27, 2015
d07eb80
add first working version of farthest insertion algorithm for round trip
chaupow Jun 15, 2015
4a085e9
add a new, messier but better implementation of the farthest insertio…
chaupow Jun 16, 2015
c651889
remove total distance computation and compute only diff instead
chaupow Jun 16, 2015
f18de0e
add brute force algorithm for tsp for small tests
chaupow Jun 16, 2015
2e382a2
move implementation of algorithms to own hpp in routing_algorithms fo…
chaupow Jun 16, 2015
c59d937
add changes to improve readability
chaupow Jun 16, 2015
99b7359
split algorithms in different plugins for better evaluation
chaupow Jun 22, 2015
b15e483
split tsp brute force algorithm for better testing
chaupow Jun 24, 2015
aed24dd
refactor and clean up
chaupow Jun 29, 2015
6e5db10
add jarnik prim algorithm on distance table for undirected graphs
chaupow Jun 29, 2015
4ac246b
filter request for unaccessible locations and remove them
chaupow Jul 1, 2015
aad0737
remove attention on unaccessible locations as we filter them beforehand
chaupow Jul 1, 2015
cbc402c
clean up some code
chaupow Jul 1, 2015
11433a5
Compute roundtrips even if locations are not in the same strong conne…
chaupow Jul 4, 2015
1df6fbc
refactor and improve the round trip computation of multiple SCCs
chaupow Jul 5, 2015
d4b9d1b
fix bug for scc split computation
chaupow Jul 6, 2015
b757d43
add parameter to choose algorithm for tsp calculation and remove redu…
chaupow Jul 10, 2015
e4a6a94
fix bugs
chaupow Aug 18, 2015
873295f
add todos of code review session with daniel-j-h
chaupow Aug 18, 2015
2636537
solve merge conflicts
chaupow Aug 19, 2015
7415867
use typedefs from typedefs.h
chaupow Aug 19, 2015
6909955
return roundtrip result as a return parameter and not as an input par…
chaupow Aug 19, 2015
8d88719
have less redundant code for requests with one or multiple SCCs
chaupow Aug 19, 2015
b86c26c
add a wrapper for the distance table for better access
chaupow Aug 19, 2015
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
17 changes: 9 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,22 @@ set(ExtractorSources extract.cpp ${ExtractorGlob})
add_executable(osrm-extract ${ExtractorSources} $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:FINGERPRINT> $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:IMPORT> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR>)

add_library(RESTRICTION OBJECT data_structures/restriction_map.cpp)
add_library(COMPRESSEDEDGE OBJECT data_structures/compressed_edge_container.cpp)
add_library(GRAPHCOMPRESSOR OBJECT algorithms/graph_compressor.cpp)

file(GLOB PrepareGlob contractor/*.cpp data_structures/hilbert_value.cpp {RestrictionMapGlob})
set(PrepareSources prepare.cpp ${PrepareGlob})
add_executable(osrm-prepare ${PrepareSources} $<TARGET_OBJECTS:ANGLE> $<TARGET_OBJECTS:FINGERPRINT> $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:IMPORT> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:RESTRICTION> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR>)
add_executable(osrm-prepare ${PrepareSources} $<TARGET_OBJECTS:ANGLE> $<TARGET_OBJECTS:FINGERPRINT> $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:IMPORT> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:RESTRICTION> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR> $<TARGET_OBJECTS:COMPRESSEDEDGE> $<TARGET_OBJECTS:GRAPHCOMPRESSOR>)

file(GLOB ServerGlob server/*.cpp)
file(GLOB DescriptorGlob descriptors/*.cpp)
file(GLOB DatastructureGlob data_structures/search_engine_data.cpp data_structures/route_parameters.cpp util/bearing.cpp)
list(REMOVE_ITEM DatastructureGlob data_structures/Coordinate.cpp)
file(GLOB CoordinateGlob data_structures/coordinate*.cpp)
file(GLOB AlgorithmGlob algorithms/*.cpp)
file(GLOB CoordinateGlob data_structures/coordinate.cpp algorithms/coordinate_calculation.cpp)
file(GLOB AlgorithmGlob algorithms/polyline_compressor.cpp algorithms/polyline_formatter.cpp algorithms/douglas_peucker.cpp)
file(GLOB HttpGlob server/http/*.cpp)
file(GLOB LibOSRMGlob library/*.cpp)
file(GLOB DataStructureTestsGlob unit_tests/data_structures/*.cpp data_structures/hilbert_value.cpp)
file(GLOB AlgorithmTestsGlob unit_tests/algorithms/*.cpp)
file(GLOB AlgorithmTestsGlob unit_tests/algorithms/*.cpp algorithms/graph_compressor.cpp)

set(
OSRMSources
Expand All @@ -90,7 +91,7 @@ set(

add_library(COORDINATE OBJECT ${CoordinateGlob})
add_library(GITDESCRIPTION OBJECT util/git_sha.cpp)
add_library(OSRM ${OSRMSources} $<TARGET_OBJECTS:ANGLE> $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:FINGERPRINT> $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:PHANTOMNODE> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR> $<TARGET_OBJECTS:IMPORT>)
add_library(OSRM ${OSRMSources} $<TARGET_OBJECTS:ANGLE> $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:FINGERPRINT> $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:RESTRICTION> $<TARGET_OBJECTS:PHANTOMNODE> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR> $<TARGET_OBJECTS:IMPORT>)

add_library(FINGERPRINT OBJECT util/fingerprint.cpp)
add_dependencies(FINGERPRINT FingerPrintConfigure)
Expand All @@ -101,8 +102,8 @@ add_executable(osrm-routed routed.cpp ${ServerGlob} $<TARGET_OBJECTS:EXCEPTION>)
add_executable(osrm-datastore datastore.cpp $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:FINGERPRINT> $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR>)

# Unit tests
add_executable(datastructure-tests EXCLUDE_FROM_ALL unit_tests/datastructure_tests.cpp ${DataStructureTestsGlob} $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:PHANTOMNODE> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR>)
add_executable(algorithm-tests EXCLUDE_FROM_ALL unit_tests/algorithm_tests.cpp ${AlgorithmTestsGlob} $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:PHANTOMNODE> $<TARGET_OBJECTS:EXCEPTION>)
add_executable(datastructure-tests EXCLUDE_FROM_ALL unit_tests/datastructure_tests.cpp ${DataStructureTestsGlob} $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:PHANTOMNODE> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR> $<TARGET_OBJECTS:COMPRESSEDEDGE> $<TARGET_OBJECTS:GRAPHCOMPRESSOR> $<TARGET_OBJECTS:RESTRICTION>)
add_executable(algorithm-tests EXCLUDE_FROM_ALL unit_tests/algorithm_tests.cpp ${AlgorithmTestsGlob} $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:PHANTOMNODE> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:RESTRICTION> $<TARGET_OBJECTS:COMPRESSEDEDGE>)

# Benchmarks
add_executable(rtree-bench EXCLUDE_FROM_ALL benchmarks/static_rtree.cpp $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:PHANTOMNODE> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR>)
Expand Down
9 changes: 5 additions & 4 deletions algorithms/bayes_classifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cmath>

#include <vector>
#include <utility>

struct NormalDistribution
{
Expand Down Expand Up @@ -80,11 +81,11 @@ class BayesClassifier
};
using ClassificationT = std::pair<ClassLabel, double>;

BayesClassifier(const PositiveDistributionT &positive_distribution,
const NegativeDistributionT &negative_distribution,
BayesClassifier(PositiveDistributionT positive_distribution,
NegativeDistributionT negative_distribution,
const double positive_apriori_probability)
: positive_distribution(positive_distribution),
negative_distribution(negative_distribution),
: positive_distribution(std::move(positive_distribution)),
negative_distribution(std::move(negative_distribution)),
positive_apriori_probability(positive_apriori_probability),
negative_apriori_probability(1. - positive_apriori_probability)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ constexpr static const float RAD = 0.017453292519943295769236907684886f;
constexpr static const float earth_radius = 6372797.560856f;
}

double coordinate_calculation::great_circle_distance(const int lat1,
namespace coordinate_calculation
{

double great_circle_distance(const int lat1,
const int lon1,
const int lat2,
const int lon2)
Expand Down Expand Up @@ -74,21 +77,21 @@ double coordinate_calculation::great_circle_distance(const int lat1,
return earth_radius * cHarv;
}

double coordinate_calculation::great_circle_distance(const FixedPointCoordinate &coordinate_1,
double great_circle_distance(const FixedPointCoordinate &coordinate_1,
const FixedPointCoordinate &coordinate_2)
{
return great_circle_distance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat,
coordinate_2.lon);
}

float coordinate_calculation::euclidean_distance(const FixedPointCoordinate &coordinate_1,
float euclidean_distance(const FixedPointCoordinate &coordinate_1,
const FixedPointCoordinate &coordinate_2)
{
return euclidean_distance(coordinate_1.lat, coordinate_1.lon, coordinate_2.lat,
coordinate_2.lon);
}

float coordinate_calculation::euclidean_distance(const int lat1,
float euclidean_distance(const int lat1,
const int lon1,
const int lat2,
const int lon2)
Expand All @@ -108,7 +111,7 @@ float coordinate_calculation::euclidean_distance(const int lat1,
return std::hypot(x_value, y_value) * earth_radius;
}

float coordinate_calculation::perpendicular_distance(const FixedPointCoordinate &source_coordinate,
float perpendicular_distance(const FixedPointCoordinate &source_coordinate,
const FixedPointCoordinate &target_coordinate,
const FixedPointCoordinate &query_location)
{
Expand All @@ -119,7 +122,7 @@ float coordinate_calculation::perpendicular_distance(const FixedPointCoordinate
nearest_location, ratio);
}

float coordinate_calculation::perpendicular_distance(const FixedPointCoordinate &segment_source,
float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
FixedPointCoordinate &nearest_location,
Expand All @@ -132,7 +135,7 @@ float coordinate_calculation::perpendicular_distance(const FixedPointCoordinate
nearest_location, ratio);
}

float coordinate_calculation::perpendicular_distance_from_projected_coordinate(
float perpendicular_distance_from_projected_coordinate(
const FixedPointCoordinate &source_coordinate,
const FixedPointCoordinate &target_coordinate,
const FixedPointCoordinate &query_location,
Expand All @@ -146,7 +149,7 @@ float coordinate_calculation::perpendicular_distance_from_projected_coordinate(
nearest_location, ratio);
}

float coordinate_calculation::perpendicular_distance_from_projected_coordinate(
float perpendicular_distance_from_projected_coordinate(
const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
Expand Down Expand Up @@ -221,29 +224,29 @@ float coordinate_calculation::perpendicular_distance_from_projected_coordinate(
BOOST_ASSERT(nearest_location.is_valid());

const float approximate_distance =
coordinate_calculation::euclidean_distance(query_location, nearest_location);
euclidean_distance(query_location, nearest_location);
BOOST_ASSERT(0.f <= approximate_distance);
return approximate_distance;
}

void coordinate_calculation::lat_or_lon_to_string(const int value, std::string &output)
void lat_or_lon_to_string(const int value, std::string &output)
{
char buffer[12];
buffer[11] = 0; // zero termination
output = printInt<11, 6>(buffer, value);
}

float coordinate_calculation::deg_to_rad(const float degree)
float deg_to_rad(const float degree)
{
return degree * (static_cast<float>(M_PI) / 180.f);
}

float coordinate_calculation::rad_to_deg(const float radian)
float rad_to_deg(const float radian)
{
return radian * (180.f * static_cast<float>(M_1_PI));
}

float coordinate_calculation::bearing(const FixedPointCoordinate &first_coordinate,
float bearing(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate)
{
const float lon_diff =
Expand All @@ -266,3 +269,5 @@ float coordinate_calculation::bearing(const FixedPointCoordinate &first_coordina
}
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,50 @@ struct FixedPointCoordinate;
#include <string>
#include <utility>

struct coordinate_calculation
namespace coordinate_calculation
{
static double
double
great_circle_distance(const int lat1, const int lon1, const int lat2, const int lon2);

static double great_circle_distance(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);
double great_circle_distance(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);

static float euclidean_distance(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);
float euclidean_distance(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);

static float euclidean_distance(const int lat1, const int lon1, const int lat2, const int lon2);
float euclidean_distance(const int lat1, const int lon1, const int lat2, const int lon2);

static void lat_or_lon_to_string(const int value, std::string &output);
void lat_or_lon_to_string(const int value, std::string &output);

static float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location);
float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location);

static float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
FixedPointCoordinate &nearest_location,
float &ratio);
float perpendicular_distance(const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
FixedPointCoordinate &nearest_location,
float &ratio);

static float perpendicular_distance_from_projected_coordinate(
float perpendicular_distance_from_projected_coordinate(
const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
const std::pair<double, double> &projected_coordinate);

static float perpendicular_distance_from_projected_coordinate(
float perpendicular_distance_from_projected_coordinate(
const FixedPointCoordinate &segment_source,
const FixedPointCoordinate &segment_target,
const FixedPointCoordinate &query_location,
const std::pair<double, double> &projected_coordinate,
FixedPointCoordinate &nearest_location,
float &ratio);

static float deg_to_rad(const float degree);
static float rad_to_deg(const float radian);
float deg_to_rad(const float degree);
float rad_to_deg(const float radian);

static float bearing(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);
};
float bearing(const FixedPointCoordinate &first_coordinate,
const FixedPointCoordinate &second_coordinate);
}

#endif // COORDINATE_CALCULATION
4 changes: 2 additions & 2 deletions algorithms/douglas_peucker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ void DouglasPeucker::Run(RandomAccessIt begin, RandomAccessIt end, const unsigne

{
BOOST_ASSERT_MSG(zoom_level < DOUGLAS_PEUCKER_THRESHOLDS.size(), "unsupported zoom level");
RandomAccessIt left_border = begin;
RandomAccessIt right_border = std::next(begin);
auto left_border = begin;
auto right_border = std::next(begin);
// Sweep over array and identify those ranges that need to be checked
do
{
Expand Down
Loading