Skip to content

Commit

Permalink
restore libosrm interface for corech, fallback to ch
Browse files Browse the repository at this point in the history
  • Loading branch information
karenzshea authored and Patrick Niklaus committed Oct 13, 2017
1 parent 4f3414c commit e385f63
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 16 deletions.
9 changes: 3 additions & 6 deletions include/contractor/contract_excludable_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ namespace osrm
namespace contractor
{

using GraphFilterAndCore =
std::tuple<QueryGraph, std::vector<std::vector<bool>>>;
using GraphFilterAndCore = std::tuple<QueryGraph, std::vector<std::vector<bool>>>;

inline auto contractExcludableGraph(ContractorGraph contractor_graph_,
std::vector<EdgeWeight> node_weights,
Expand All @@ -38,10 +37,8 @@ inline auto contractExcludableGraph(ContractorGraph contractor_graph_,
// a very dense core. This increases the overall graph sizes a little bit
// but increases the final CH quality and contraction speed.
constexpr float BASE_CORE = 0.9;
is_shared_core = contractGraph(contractor_graph,
std::move(always_allowed),
node_weights,
BASE_CORE);
is_shared_core =
contractGraph(contractor_graph, std::move(always_allowed), node_weights, BASE_CORE);

// Add all non-core edges to container
{
Expand Down
1 change: 1 addition & 0 deletions include/contractor/contractor_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct ContractorConfig final : storage::IOConfig

updater::UpdaterConfig updater_config;

// DEPRECATED to be removed in v6.0
bool use_cached_priority;

unsigned requested_num_threads;
Expand Down
16 changes: 7 additions & 9 deletions include/engine/engine_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,14 @@ namespace engine
*
* You can chose between three algorithms:
* - Algorithm::CH
* Contraction Hierarchies, extremely fast queries but slow pre-processing. The default right
* Contraction Hierarchies, extremely fast queries but slow pre-processing. The default right
* now.
* - Algorithm::CoreCH
* Contractoin Hierachies with partial contraction for faster pre-processing but slower queries.
* Deprecated, to be removed in v6.0
* Contraction Hierachies with partial contraction for faster pre-processing but slower
* queries.
* - Algorithm::MLD
* Multi Level Dijkstra which is experimental and moderately fast in both pre-processing and
* query.
*
* Algorithm::CH is specified we will automatically upgrade to CoreCH if we find the data for it.
* If Algorithm::CoreCH is specified and we don't find the speedup data, we fail hard.
* Multi Level Dijkstra, moderately fast in both pre-processing and query.
*
* \see OSRM, StorageConfig
*/
Expand All @@ -76,8 +74,8 @@ struct EngineConfig final

enum class Algorithm
{
CH, // will upgrade to CoreCH if it finds core data
CoreCH, // will fail hard if there is no core data
CH,
CoreCH, // Deprecated, will be removed in v6.0
MLD
};

Expand Down
8 changes: 7 additions & 1 deletion src/osrm/osrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ OSRM::OSRM(engine::EngineConfig &config)
// Now, check that the algorithm requested can be used with the data
// that's available.

if (config.algorithm == EngineConfig::Algorithm::CH)
if (config.algorithm == EngineConfig::Algorithm::CH ||
config.algorithm == EngineConfig::Algorithm::CoreCH)
{
if (config.algorithm == EngineConfig::Algorithm::CoreCH)
{
util::Log(logWARNING) << "Using CoreCH is deprecated. Falling back to CH";
config.algorithm = EngineConfig::Algorithm::CH;
}
bool ch_compatible = engine::Engine<CH>::CheckCompatibility(config);

// throw error if dataset is not usable with CH
Expand Down
6 changes: 6 additions & 0 deletions src/tools/contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ return_code parseArguments(int argc,
&contractor_config.updater_config.turn_penalty_lookup_paths)
->composing(),
"Lookup files containing from_, to_, via_nodes, and turn penalties to adjust turn weights")(
"level-cache,o",
boost::program_options::value<bool>(&contractor_config.use_cached_priority)
->default_value(false),
"DEPRECATED: Will always be false. Use .level file to retain the contraction level for "
"each "
"node from the last run.")(
"edge-weight-updates-over-factor",
boost::program_options::value<double>(
&contractor_config.updater_config.log_edge_updates_factor)
Expand Down
8 changes: 8 additions & 0 deletions unit_tests/library/algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ BOOST_AUTO_TEST_CASE(test_incompatible_with_mld)
osrm::exception);
}

BOOST_AUTO_TEST_CASE(test_compatible_with_corech_fallback)
{
// Note - this tests that given the CoreCH algorithm config option, configuration falls back to
// CH and is compatible with CH data
BOOST_CHECK_NO_THROW(
getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm", osrm::EngineConfig::Algorithm::CoreCH));
}

BOOST_AUTO_TEST_CASE(test_incompatible_with_ch)
{
// Can't use the CH algorithm with MLD data
Expand Down
43 changes: 43 additions & 0 deletions unit_tests/library/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ BOOST_AUTO_TEST_CASE(test_tile_ch)
validate_tile(osrm);
}

BOOST_AUTO_TEST_CASE(test_tile_corech)
{
// Note: this tests that given the CoreCH algorithm config option, configuration falls back to
// CH and is compatible with CH data
using namespace osrm;
auto osrm =
getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm", osrm::EngineConfig::Algorithm::CoreCH);
validate_tile(osrm);
}

BOOST_AUTO_TEST_CASE(test_tile_mld)
{
using namespace osrm;
Expand Down Expand Up @@ -543,6 +553,17 @@ BOOST_AUTO_TEST_CASE(test_tile_turns_ch)
test_tile_turns(osrm);
}

BOOST_AUTO_TEST_CASE(test_tile_turns_corech)
{
// Note: this tests that given the CoreCH algorithm config option, configuration falls back to
// CH and is compatible with CH data
using namespace osrm;
auto osrm =
getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm", osrm::EngineConfig::Algorithm::CoreCH);

test_tile_turns(osrm);
}

BOOST_AUTO_TEST_CASE(test_tile_turns_mld)
{
using namespace osrm;
Expand Down Expand Up @@ -724,6 +745,17 @@ BOOST_AUTO_TEST_CASE(test_tile_speeds_ch)
test_tile_speeds(osrm);
}

BOOST_AUTO_TEST_CASE(test_tile_speeds_corech)
{
// Note: this tests that given the CoreCH algorithm config option, configuration falls back to
// CH and is compatible with CH data
using namespace osrm;

auto osrm =
getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm", osrm::EngineConfig::Algorithm::CoreCH);
test_tile_speeds(osrm);
}

BOOST_AUTO_TEST_CASE(test_tile_speeds_mld)
{
using namespace osrm;
Expand Down Expand Up @@ -820,6 +852,17 @@ BOOST_AUTO_TEST_CASE(test_tile_nodes_ch)
test_tile_nodes(osrm);
}

BOOST_AUTO_TEST_CASE(test_tile_nodes_corech)
{
// Note: this tests that given the CoreCH algorithm config option, configuration falls back to
// CH and is compatible with CH data
using namespace osrm;

auto osrm =
getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm", osrm::EngineConfig::Algorithm::CoreCH);
test_tile_nodes(osrm);
}

BOOST_AUTO_TEST_CASE(test_tile_nodes_mld)
{
using namespace osrm;
Expand Down

0 comments on commit e385f63

Please sign in to comment.