osrm-backend/src/contractor/contractor.cpp

119 lines
3.6 KiB
C++
Raw Normal View History

2016-01-02 11:13:44 -05:00
#include "contractor/contractor.hpp"
#include "contractor/contract_excludable_graph.hpp"
#include "contractor/contracted_edge_container.hpp"
#include "contractor/crc32_processor.hpp"
#include "contractor/files.hpp"
#include "contractor/graph_contractor.hpp"
#include "contractor/graph_contractor_adaptors.hpp"
#include "extractor/compressed_edge_container.hpp"
#include "extractor/edge_based_graph_factory.hpp"
#include "extractor/files.hpp"
2016-05-16 17:11:01 -04:00
#include "extractor/node_based_edge.hpp"
#include "storage/io.hpp"
#include "updater/updater.hpp"
2016-05-16 17:11:01 -04:00
#include "util/exception.hpp"
#include "util/exception_utils.hpp"
#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"
#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
#include <algorithm>
#include <bitset>
2016-05-16 17:11:01 -04:00
#include <cstdint>
#include <fstream>
2016-05-16 17:11:01 -04:00
#include <iterator>
2014-07-03 07:29:15 -04:00
#include <memory>
#include <vector>
2014-07-03 07:29:15 -04:00
2016-01-05 10:51:13 -05:00
namespace osrm
{
namespace contractor
{
int Contractor::Run()
2014-07-03 07:29:15 -04:00
{
2017-10-12 07:45:26 -04:00
if (config.core_factor)
{
2017-10-12 07:45:26 -04:00
util::Log(logWARNING) << "Using core factor is deprecated and will be ignored. Falling back to CH.";
config.core_factor = 1.0;
}
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);
util::Log() << "Reading node weights.";
std::vector<EdgeWeight> node_weights;
{
storage::io::FileReader reader(config.GetPath(".osrm.enw"),
2017-04-04 19:01:00 -04:00
storage::io::FileReader::VerifyFingerprint);
storage::serialization::read(reader, node_weights);
}
util::Log() << "Done reading node weights.";
util::Log() << "Loading edge-expanded graph representation";
2014-07-03 07:29:15 -04:00
std::vector<extractor::EdgeBasedEdge> edge_based_edge_list;
2015-07-04 11:37:24 -04:00
updater::Updater updater(config.updater_config);
EdgeID number_of_edge_based_nodes =
updater.LoadAndUpdateEdgeExpandedGraph(edge_based_edge_list, node_weights);
// Contracting the edge-expanded graph
2014-07-03 07:29:15 -04:00
TIMER_START(contraction);
std::vector<std::vector<bool>> node_filters;
{
extractor::EdgeBasedNodeDataContainer node_data;
extractor::files::readNodeData(config.GetPath(".osrm.ebg_nodes"), node_data);
extractor::ProfileProperties properties;
extractor::files::readProfileProperties(config.GetPath(".osrm.properties"), properties);
2017-06-15 10:52:14 -04:00
node_filters =
util::excludeFlagsToNodeFilter(number_of_edge_based_nodes, node_data, properties);
}
2014-07-03 07:29:15 -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;
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);
TIMER_STOP(contraction);
util::Log() << "Contracted graph has " << query_graph.GetNumberOfEdges() << " edges.";
util::Log() << "Contraction took " << TIMER_SEC(contraction) << " sec";
2014-07-03 07:29:15 -04:00
files::writeGraph(config.GetPath(".osrm.hsgr"), checksum, query_graph, edge_filters);
2017-04-13 05:45:35 -04:00
2015-04-23 12:53:36 -04:00
TIMER_STOP(preparing);
util::Log() << "Preprocessing : " << TIMER_SEC(preparing) << " seconds";
2015-04-23 12:53:36 -04:00
util::Log() << "finished preprocessing";
2015-04-23 12:53:36 -04:00
return 0;
}
} // namespace contractor
} // namespace osrm