2016-01-02 11:13:44 -05:00
|
|
|
#include "contractor/contractor.hpp"
|
2017-08-20 19:24:05 -04:00
|
|
|
#include "contractor/contract_excludable_graph.hpp"
|
|
|
|
#include "contractor/contracted_edge_container.hpp"
|
2016-03-09 07:18:09 -05:00
|
|
|
#include "contractor/crc32_processor.hpp"
|
2017-04-04 18:00:17 -04:00
|
|
|
#include "contractor/files.hpp"
|
2016-01-07 13:19:55 -05:00
|
|
|
#include "contractor/graph_contractor.hpp"
|
2017-01-13 02:32:17 -05:00
|
|
|
#include "contractor/graph_contractor_adaptors.hpp"
|
2015-11-09 15:14:39 -05:00
|
|
|
|
2016-01-29 20:52:20 -05:00
|
|
|
#include "extractor/compressed_edge_container.hpp"
|
2016-06-24 01:01:37 -04:00
|
|
|
#include "extractor/edge_based_graph_factory.hpp"
|
2017-08-20 19:24:05 -04:00
|
|
|
#include "extractor/files.hpp"
|
2016-05-16 17:11:01 -04:00
|
|
|
#include "extractor/node_based_edge.hpp"
|
2016-01-29 20:52:20 -05:00
|
|
|
|
2016-11-18 06:14:38 -05:00
|
|
|
#include "storage/io.hpp"
|
2017-03-07 18:30:49 -05:00
|
|
|
|
|
|
|
#include "updater/updater.hpp"
|
|
|
|
|
2016-05-16 17:11:01 -04:00
|
|
|
#include "util/exception.hpp"
|
2016-12-06 15:30:46 -05:00
|
|
|
#include "util/exception_utils.hpp"
|
2017-08-20 19:24:05 -04:00
|
|
|
#include "util/exclude_flag.hpp"
|
|
|
|
#include "util/filtered_graph.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "util/graph_loader.hpp"
|
|
|
|
#include "util/integer_range.hpp"
|
2016-12-06 15:30:46 -05:00
|
|
|
#include "util/log.hpp"
|
2016-05-16 17:11:01 -04:00
|
|
|
#include "util/static_graph.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "util/string_util.hpp"
|
|
|
|
#include "util/timing_util.hpp"
|
|
|
|
#include "util/typedefs.hpp"
|
2014-07-03 07:29:15 -04:00
|
|
|
|
2016-05-20 13:20:12 -04:00
|
|
|
#include <algorithm>
|
2016-01-07 04:33:47 -05:00
|
|
|
#include <bitset>
|
2016-05-16 17:11:01 -04:00
|
|
|
#include <cstdint>
|
2016-05-18 10:59:52 -04:00
|
|
|
#include <fstream>
|
2016-05-16 17:11:01 -04:00
|
|
|
#include <iterator>
|
2014-07-03 07:29:15 -04:00
|
|
|
#include <memory>
|
2016-05-18 10:59:52 -04:00
|
|
|
#include <vector>
|
2014-07-03 07:29:15 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace contractor
|
|
|
|
{
|
2016-09-12 12:16:56 -04:00
|
|
|
|
2016-01-07 13:19:55 -05:00
|
|
|
int Contractor::Run()
|
2014-07-03 07:29:15 -04:00
|
|
|
{
|
2016-01-05 06:04:04 -05:00
|
|
|
if (config.core_factor > 1.0 || config.core_factor < 0)
|
2015-10-14 18:08:22 -04:00
|
|
|
{
|
2016-12-06 15:30:46 -05:00
|
|
|
throw util::exception("Core factor must be between 0.0 to 1.0 (inclusive)" + SOURCE_REF);
|
2015-10-14 18:08:22 -04:00
|
|
|
}
|
|
|
|
|
2017-08-20 19:24:05 -04:00
|
|
|
if (config.use_cached_priority)
|
|
|
|
{
|
|
|
|
util::Log(logWARNING) << "Using cached priorities is deprecated and they will be ignored.";
|
|
|
|
}
|
|
|
|
|
2014-07-03 07:29:15 -04:00
|
|
|
TIMER_START(preparing);
|
|
|
|
|
2016-12-08 17:35:34 -05:00
|
|
|
util::Log() << "Reading node weights.";
|
|
|
|
std::vector<EdgeWeight> node_weights;
|
|
|
|
{
|
2017-06-16 04:45:24 -04:00
|
|
|
storage::io::FileReader reader(config.GetPath(".osrm.enw"),
|
2017-04-04 19:01:00 -04:00
|
|
|
storage::io::FileReader::VerifyFingerprint);
|
2017-04-04 18:00:17 -04:00
|
|
|
storage::serialization::read(reader, node_weights);
|
2016-12-08 17:35:34 -05:00
|
|
|
}
|
|
|
|
util::Log() << "Done reading node weights.";
|
|
|
|
|
2016-12-06 15:30:46 -05:00
|
|
|
util::Log() << "Loading edge-expanded graph representation";
|
2014-07-03 07:29:15 -04:00
|
|
|
|
2017-01-13 02:32:17 -05:00
|
|
|
std::vector<extractor::EdgeBasedEdge> edge_based_edge_list;
|
2015-07-04 11:37:24 -04:00
|
|
|
|
2017-03-07 18:30:49 -05:00
|
|
|
updater::Updater updater(config.updater_config);
|
2017-09-25 09:37:11 -04:00
|
|
|
EdgeID number_of_edge_based_nodes =
|
|
|
|
updater.LoadAndUpdateEdgeExpandedGraph(edge_based_edge_list, node_weights);
|
2017-02-10 05:41:31 -05:00
|
|
|
|
2015-04-23 11:48:41 -04:00
|
|
|
// Contracting the edge-expanded graph
|
2014-07-03 07:29:15 -04:00
|
|
|
|
|
|
|
TIMER_START(contraction);
|
2017-08-20 19:24:05 -04:00
|
|
|
|
|
|
|
std::vector<std::vector<bool>> node_filters;
|
2015-11-09 15:14:39 -05:00
|
|
|
{
|
2017-08-20 19:24:05 -04:00
|
|
|
extractor::EdgeBasedNodeDataContainer node_data;
|
|
|
|
extractor::files::readNodeData(config.GetPath(".osrm.ebg_nodes"), node_data);
|
2016-01-07 04:33:47 -05:00
|
|
|
|
2017-08-20 19:24:05 -04:00
|
|
|
extractor::ProfileProperties properties;
|
|
|
|
extractor::files::readProfileProperties(config.GetPath(".osrm.properties"), properties);
|
2017-06-15 10:52:14 -04:00
|
|
|
|
2017-09-25 09:37:11 -04:00
|
|
|
node_filters =
|
|
|
|
util::excludeFlagsToNodeFilter(number_of_edge_based_nodes, node_data, properties);
|
2017-01-13 02:32:17 -05:00
|
|
|
}
|
2014-07-03 07:29:15 -04:00
|
|
|
|
2017-08-20 19:24:05 -04:00
|
|
|
RangebasedCRC32 crc32_calculator;
|
|
|
|
const unsigned checksum = crc32_calculator(edge_based_edge_list);
|
|
|
|
|
|
|
|
QueryGraph query_graph;
|
|
|
|
std::vector<std::vector<bool>> edge_filters;
|
|
|
|
std::vector<std::vector<bool>> cores;
|
2017-09-25 09:37:11 -04:00
|
|
|
std::tie(query_graph, edge_filters, cores) = contractExcludableGraph(
|
|
|
|
toContractorGraph(number_of_edge_based_nodes, std::move(edge_based_edge_list)),
|
|
|
|
std::move(node_weights),
|
|
|
|
std::move(node_filters),
|
|
|
|
config.core_factor);
|
2017-08-20 19:24:05 -04:00
|
|
|
TIMER_STOP(contraction);
|
|
|
|
util::Log() << "Contracted graph has " << query_graph.GetNumberOfEdges() << " edges.";
|
2016-12-06 15:30:46 -05:00
|
|
|
util::Log() << "Contraction took " << TIMER_SEC(contraction) << " sec";
|
2014-07-03 07:29:15 -04:00
|
|
|
|
2017-08-20 19:24:05 -04:00
|
|
|
files::writeGraph(config.GetPath(".osrm.hsgr"), checksum, query_graph, edge_filters);
|
2017-04-13 05:45:35 -04:00
|
|
|
|
2017-08-20 19:24:05 -04:00
|
|
|
files::writeCoreMarker(config.GetPath(".osrm.core"), cores);
|
2015-04-23 12:53:36 -04:00
|
|
|
|
|
|
|
TIMER_STOP(preparing);
|
|
|
|
|
2016-12-06 15:30:46 -05:00
|
|
|
util::Log() << "Preprocessing : " << TIMER_SEC(preparing) << " seconds";
|
2015-04-23 12:53:36 -04:00
|
|
|
|
2016-12-06 15:30:46 -05:00
|
|
|
util::Log() << "finished preprocessing";
|
2015-04-23 12:53:36 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-01-13 02:32:17 -05:00
|
|
|
} // namespace contractor
|
|
|
|
} // namespace osrm
|