Add update functionality to osrm-customize
All speed file flags are compatible with osrm-contract.
This commit is contained in:
parent
c6e9cc8024
commit
907f933a54
@ -668,7 +668,7 @@ target_link_libraries(osrm_update ${UPDATER_LIBRARIES})
|
||||
target_link_libraries(osrm_contract ${CONTRACTOR_LIBRARIES} osrm_update)
|
||||
target_link_libraries(osrm_extract ${EXTRACTOR_LIBRARIES})
|
||||
target_link_libraries(osrm_partition ${PARTITIONER_LIBRARIES})
|
||||
target_link_libraries(osrm_customize ${CUSTOMIZER_LIBRARIES})
|
||||
target_link_libraries(osrm_customize ${CUSTOMIZER_LIBRARIES} osrm_update)
|
||||
target_link_libraries(osrm_store ${STORAGE_LIBRARIES})
|
||||
|
||||
# BUILD_COMPONENTS
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace customize
|
||||
namespace customizer
|
||||
{
|
||||
|
||||
class CellCustomizer
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace customize
|
||||
namespace customizer
|
||||
{
|
||||
|
||||
class Customizer
|
||||
@ -14,7 +14,7 @@ class Customizer
|
||||
int Run(const CustomizationConfig &config);
|
||||
};
|
||||
|
||||
} // namespace customize
|
||||
} // namespace customizer
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_CUSTOMIZE_CUSTOMIZER_HPP
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef OSRM_CUSTOMIZE_CUSTOMIZER_CONFIG_HPP
|
||||
#define OSRM_CUSTOMIZE_CUSTOMIZER_CONFIG_HPP
|
||||
|
||||
#include "updater/updater_config.hpp"
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <array>
|
||||
@ -8,7 +10,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace customize
|
||||
namespace customizer
|
||||
{
|
||||
|
||||
struct CustomizationConfig
|
||||
@ -33,6 +35,10 @@ struct CustomizationConfig
|
||||
edge_based_graph_path = basepath + ".osrm.ebg";
|
||||
mld_partition_path = basepath + ".osrm.partition";
|
||||
mld_storage_path = basepath + ".osrm.cells";
|
||||
mld_graph_path = basepath + ".osrm.mldgr";
|
||||
|
||||
updater_config.osrm_input_path = basepath + ".osrm";
|
||||
updater_config.UseDefaultOutputNames();
|
||||
}
|
||||
|
||||
// might be changed to the node based graph at some point
|
||||
@ -40,8 +46,11 @@ struct CustomizationConfig
|
||||
boost::filesystem::path edge_based_graph_path;
|
||||
boost::filesystem::path mld_partition_path;
|
||||
boost::filesystem::path mld_storage_path;
|
||||
boost::filesystem::path mld_graph_path;
|
||||
|
||||
unsigned requested_num_threads;
|
||||
|
||||
updater::UpdaterConfig updater_config;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
49
include/customizer/edge_based_graph.hpp
Normal file
49
include/customizer/edge_based_graph.hpp
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef OSRM_CUSTOMIZE_EDGE_BASED_GRAPH_HPP
|
||||
#define OSRM_CUSTOMIZE_EDGE_BASED_GRAPH_HPP
|
||||
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "partition/edge_based_graph.hpp"
|
||||
#include "util/static_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace customizer
|
||||
{
|
||||
|
||||
struct StaticEdgeBasedGraph;
|
||||
|
||||
namespace io
|
||||
{
|
||||
void read(const boost::filesystem::path &path, StaticEdgeBasedGraph &graph);
|
||||
void write(const boost::filesystem::path &path, const StaticEdgeBasedGraph &graph);
|
||||
}
|
||||
|
||||
using EdgeBasedGraphEdgeData = partition::EdgeBasedGraphEdgeData;
|
||||
|
||||
struct StaticEdgeBasedGraph : util::StaticGraph<EdgeBasedGraphEdgeData>
|
||||
{
|
||||
using Base = util::StaticGraph<EdgeBasedGraphEdgeData>;
|
||||
using Base::Base;
|
||||
|
||||
friend void io::read(const boost::filesystem::path &path, StaticEdgeBasedGraph &graph);
|
||||
friend void io::write(const boost::filesystem::path &path, const StaticEdgeBasedGraph &graph);
|
||||
};
|
||||
|
||||
struct StaticEdgeBasedGraphView : util::StaticGraph<EdgeBasedGraphEdgeData, true>
|
||||
{
|
||||
using Base = util::StaticGraph<EdgeBasedGraphEdgeData, true>;
|
||||
using Base::Base;
|
||||
};
|
||||
|
||||
struct StaticEdgeBasedGraphEdge : StaticEdgeBasedGraph::InputEdge
|
||||
{
|
||||
using Base = StaticEdgeBasedGraph::InputEdge;
|
||||
using Base::Base;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
36
include/customizer/io.hpp
Normal file
36
include/customizer/io.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef OSRM_CUSTOMIZER_IO_HPP
|
||||
#define OSRM_CUSTOMIZER_IO_HPP
|
||||
|
||||
#include "customizer/edge_based_graph.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace customizer
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
|
||||
inline void read(const boost::filesystem::path &path, StaticEdgeBasedGraph &graph)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
reader.DeserializeVector(graph.node_array);
|
||||
reader.DeserializeVector(graph.edge_array);
|
||||
}
|
||||
|
||||
inline void write(const boost::filesystem::path &path, const StaticEdgeBasedGraph &graph)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
writer.SerializeVector(graph.node_array);
|
||||
writer.SerializeVector(graph.edge_array);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -8,6 +8,8 @@
|
||||
#include "engine/algorithm.hpp"
|
||||
#include "engine/geospatial_query.hpp"
|
||||
|
||||
#include "customizer/edge_based_graph.hpp"
|
||||
|
||||
#include "extractor/datasources.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
@ -1017,7 +1019,7 @@ class ContiguousInternalMemoryDataFacade<algorithm::MLD>
|
||||
public ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
|
||||
{
|
||||
private:
|
||||
using QueryGraph = util::StaticGraph<EdgeData, true>;
|
||||
using QueryGraph = customizer::StaticEdgeBasedGraphView;
|
||||
using GraphNode = QueryGraph::NodeArrayEntry;
|
||||
using GraphEdge = QueryGraph::EdgeArrayEntry;
|
||||
|
||||
|
43
include/partition/edge_based_graph.hpp
Normal file
43
include/partition/edge_based_graph.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef OSRM_EDGE_BASED_GRAPH_HPP
|
||||
#define OSRM_EDGE_BASED_GRAPH_HPP
|
||||
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "storage/io.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/dynamic_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace partition
|
||||
{
|
||||
|
||||
struct EdgeBasedGraphEdgeData : extractor::EdgeBasedEdge::EdgeData
|
||||
{
|
||||
// We need to write out the full edge based graph again.
|
||||
|
||||
// TODO: in case we want to modify the graph we need to store a boundary_arc flag here
|
||||
};
|
||||
|
||||
struct DynamicEdgeBasedGraph : util::DynamicGraph<EdgeBasedGraphEdgeData>
|
||||
{
|
||||
using Base = util::DynamicGraph<EdgeBasedGraphEdgeData>;
|
||||
using Base::Base;
|
||||
};
|
||||
|
||||
struct DynamicEdgeBasedGraphEdge : DynamicEdgeBasedGraph::InputEdge
|
||||
{
|
||||
using Base = DynamicEdgeBasedGraph::InputEdge;
|
||||
using Base::Base;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,6 +1,8 @@
|
||||
#ifndef OSRM_EDGE_BASED_GRAPH_READER_HPP
|
||||
#define OSRM_EDGE_BASED_GRAPH_READER_HPP
|
||||
|
||||
#include "partition/edge_based_graph.hpp"
|
||||
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "storage/io.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
@ -19,25 +21,6 @@ namespace osrm
|
||||
namespace partition
|
||||
{
|
||||
|
||||
struct EdgeBasedGraphEdgeData : extractor::EdgeBasedEdge::EdgeData
|
||||
{
|
||||
// We need to write out the full edge based graph again.
|
||||
|
||||
// TODO: in case we want to modify the graph we need to store a boundary_arc flag here
|
||||
};
|
||||
|
||||
struct EdgeBasedGraph : util::DynamicGraph<EdgeBasedGraphEdgeData>
|
||||
{
|
||||
using Base = util::DynamicGraph<EdgeBasedGraphEdgeData>;
|
||||
using Base::Base;
|
||||
};
|
||||
|
||||
struct EdgeBasedGraphEdge : EdgeBasedGraph::InputEdge
|
||||
{
|
||||
using Base = EdgeBasedGraph::InputEdge;
|
||||
using Base::Base;
|
||||
};
|
||||
|
||||
// Bidirectional (s,t) to (s,t) and (t,s)
|
||||
std::vector<extractor::EdgeBasedEdge>
|
||||
splitBidirectionalEdges(const std::vector<extractor::EdgeBasedEdge> &edges)
|
||||
@ -67,12 +50,12 @@ splitBidirectionalEdges(const std::vector<extractor::EdgeBasedEdge> &edges)
|
||||
return directed;
|
||||
}
|
||||
|
||||
std::vector<EdgeBasedGraphEdge>
|
||||
prepareEdgesForUsageInGraph(std::vector<extractor::EdgeBasedEdge> edges)
|
||||
template <typename OutputEdgeT>
|
||||
std::vector<OutputEdgeT> prepareEdgesForUsageInGraph(std::vector<extractor::EdgeBasedEdge> edges)
|
||||
{
|
||||
std::sort(begin(edges), end(edges));
|
||||
|
||||
std::vector<EdgeBasedGraphEdge> graph_edges;
|
||||
std::vector<OutputEdgeT> graph_edges;
|
||||
graph_edges.reserve(edges.size());
|
||||
|
||||
for (NodeID i = 0; i < edges.size();)
|
||||
@ -87,8 +70,8 @@ prepareEdgesForUsageInGraph(std::vector<extractor::EdgeBasedEdge> edges)
|
||||
continue;
|
||||
}
|
||||
|
||||
EdgeBasedGraphEdge forward_edge;
|
||||
EdgeBasedGraphEdge reverse_edge;
|
||||
OutputEdgeT forward_edge;
|
||||
OutputEdgeT reverse_edge;
|
||||
forward_edge.source = reverse_edge.source = source;
|
||||
forward_edge.target = reverse_edge.target = target;
|
||||
forward_edge.data.edge_id = reverse_edge.data.edge_id = edges[i].data.edge_id;
|
||||
@ -161,7 +144,7 @@ struct EdgeBasedGraphReader
|
||||
|
||||
// FIXME: wrapped in unique_ptr since dynamic_graph is not move-able
|
||||
|
||||
std::unique_ptr<EdgeBasedGraph> BuildEdgeBasedGraph()
|
||||
std::unique_ptr<DynamicEdgeBasedGraph> BuildEdgeBasedGraph()
|
||||
{
|
||||
// FIXME: The following is a rough adaption from:
|
||||
// - adaptToContractorInput
|
||||
@ -170,9 +153,9 @@ struct EdgeBasedGraphReader
|
||||
// FIXME: edges passed as a const reference, can be changed pass-by-value if can be moved
|
||||
|
||||
auto directed = splitBidirectionalEdges(edges);
|
||||
auto tidied = prepareEdgesForUsageInGraph(std::move(directed));
|
||||
auto tidied = prepareEdgesForUsageInGraph<DynamicEdgeBasedGraphEdge>(std::move(directed));
|
||||
|
||||
return std::make_unique<EdgeBasedGraph>(num_nodes, std::move(tidied));
|
||||
return std::make_unique<DynamicEdgeBasedGraph>(num_nodes, std::move(tidied));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -180,7 +163,7 @@ struct EdgeBasedGraphReader
|
||||
std::size_t num_nodes;
|
||||
};
|
||||
|
||||
inline std::unique_ptr<EdgeBasedGraph> LoadEdgeBasedGraph(const std::string &path)
|
||||
inline std::unique_ptr<DynamicEdgeBasedGraph> LoadEdgeBasedGraph(const std::string &path)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader(path, fingerprint);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define OSRM_PARTITION_IO_HPP
|
||||
|
||||
#include "partition/cell_storage.hpp"
|
||||
#include "partition/edge_based_graph.hpp"
|
||||
#include "partition/multi_level_partition.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
|
@ -71,7 +71,7 @@ struct StorageConfig final
|
||||
boost::filesystem::path turn_lane_description_path;
|
||||
boost::filesystem::path mld_partition_path;
|
||||
boost::filesystem::path mld_storage_path;
|
||||
boost::filesystem::path edge_based_graph_path;
|
||||
boost::filesystem::path mld_graph_path;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ class Updater
|
||||
public:
|
||||
Updater(UpdaterConfig config_) : config(std::move(config_)) {}
|
||||
|
||||
using NumNodesAndEdges = std::tuple<EdgeID, std::vector<extractor::EdgeBasedEdge>>;
|
||||
NumNodesAndEdges LoadAndUpdateEdgeExpandedGraph() const;
|
||||
|
||||
EdgeID
|
||||
LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
||||
std::vector<EdgeWeight> &node_weights) const;
|
||||
|
@ -52,6 +52,8 @@ template <> struct SortableEdgeWithData<void>
|
||||
NodeIterator source;
|
||||
NodeIterator target;
|
||||
|
||||
SortableEdgeWithData() = default;
|
||||
|
||||
SortableEdgeWithData(NodeIterator source, NodeIterator target) : source(source), target(target)
|
||||
{
|
||||
}
|
||||
@ -73,6 +75,8 @@ template <typename EdgeDataT> struct SortableEdgeWithData : SortableEdgeWithData
|
||||
|
||||
EdgeDataT data;
|
||||
|
||||
SortableEdgeWithData() = default;
|
||||
|
||||
template <typename... Ts>
|
||||
SortableEdgeWithData(NodeIterator source, NodeIterator target, Ts &&... data)
|
||||
: Base{source, target}, data{std::forward<Ts>(data)...}
|
||||
@ -85,6 +89,7 @@ template <typename EdgeDataT> struct SortableEdgeWithData : SortableEdgeWithData
|
||||
template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
{
|
||||
public:
|
||||
using InputEdge = static_graph_details::SortableEdgeWithData<EdgeDataT>;
|
||||
using NodeIterator = static_graph_details::NodeIterator;
|
||||
using EdgeIterator = static_graph_details::EdgeIterator;
|
||||
using EdgeRange = range<EdgeIterator>;
|
||||
@ -241,7 +246,7 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
const NodeArrayEntry &GetNode(const NodeID nid) const { return node_array[nid]; }
|
||||
const EdgeArrayEntry &GetEdge(const EdgeID eid) const { return edge_array[eid]; }
|
||||
|
||||
private:
|
||||
protected:
|
||||
template <typename OtherEdge>
|
||||
void CopyDataIfAvailable(EdgeArrayEntry &into, const OtherEdge &from, std::true_type)
|
||||
{
|
||||
|
@ -1,17 +1,22 @@
|
||||
#include "customizer/customizer.hpp"
|
||||
#include "customizer/cell_customizer.hpp"
|
||||
#include "partition/edge_based_graph_reader.hpp"
|
||||
#include "partition/io.hpp"
|
||||
#include "customizer/edge_based_graph.hpp"
|
||||
#include "customizer/io.hpp"
|
||||
|
||||
#include "partition/cell_storage.hpp"
|
||||
#include "partition/edge_based_graph_reader.hpp"
|
||||
#include "partition/io.hpp"
|
||||
#include "partition/io.hpp"
|
||||
#include "partition/multi_level_partition.hpp"
|
||||
|
||||
#include "updater/updater.hpp"
|
||||
|
||||
#include "util/log.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace customize
|
||||
namespace customizer
|
||||
{
|
||||
|
||||
template <typename Graph, typename Partition, typename CellStorage>
|
||||
@ -66,14 +71,32 @@ void CellStorageStatistics(const Graph &graph,
|
||||
}
|
||||
}
|
||||
|
||||
int Customizer::Run(const CustomizationConfig &config)
|
||||
auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config)
|
||||
{
|
||||
TIMER_START(loading_data);
|
||||
auto edge_based_graph = partition::LoadEdgeBasedGraph(config.edge_based_graph_path.string());
|
||||
updater::Updater updater(config.updater_config);
|
||||
|
||||
EdgeID num_nodes;
|
||||
std::vector<extractor::EdgeBasedEdge> edge_based_edge_list;
|
||||
std::tie(num_nodes, edge_based_edge_list) = updater.LoadAndUpdateEdgeExpandedGraph();
|
||||
|
||||
auto directed = partition::splitBidirectionalEdges(edge_based_edge_list);
|
||||
auto tidied =
|
||||
partition::prepareEdgesForUsageInGraph<StaticEdgeBasedGraphEdge>(std::move(directed));
|
||||
auto edge_based_graph = std::make_unique<StaticEdgeBasedGraph>(num_nodes, std::move(tidied));
|
||||
|
||||
util::Log() << "Loaded edge based graph for mapping partition ids: "
|
||||
<< edge_based_graph->GetNumberOfEdges() << " edges, "
|
||||
<< edge_based_graph->GetNumberOfNodes() << " nodes";
|
||||
|
||||
return edge_based_graph;
|
||||
}
|
||||
|
||||
int Customizer::Run(const CustomizationConfig &config)
|
||||
{
|
||||
TIMER_START(loading_data);
|
||||
|
||||
auto edge_based_graph = LoadAndUpdateEdgeExpandedGraph(config);
|
||||
|
||||
partition::MultiLevelPartition mlp;
|
||||
partition::io::read(config.mld_partition_path, mlp);
|
||||
|
||||
@ -93,10 +116,15 @@ int Customizer::Run(const CustomizationConfig &config)
|
||||
TIMER_STOP(writing_mld_data);
|
||||
util::Log() << "MLD customization writing took " << TIMER_SEC(writing_mld_data) << " seconds";
|
||||
|
||||
TIMER_START(writing_graph);
|
||||
io::write(config.mld_graph_path, *edge_based_graph);
|
||||
TIMER_STOP(writing_graph);
|
||||
util::Log() << "Graph writing took " << TIMER_SEC(writing_graph) << " seconds";
|
||||
|
||||
CellStorageStatistics(*edge_based_graph, mlp, storage);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace customize
|
||||
} // namespace customizer$
|
||||
} // namespace osrm
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "storage/storage.hpp"
|
||||
#include "contractor/query_edge.hpp"
|
||||
#include "customizer/edge_based_graph.hpp"
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
@ -441,23 +442,26 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
layout.SetBlockSize<char>(DataLayout::MLD_CELL_LEVEL_OFFSETS, 0);
|
||||
}
|
||||
|
||||
if (boost::filesystem::exists(config.edge_based_graph_path))
|
||||
if (boost::filesystem::exists(config.mld_graph_path))
|
||||
{
|
||||
io::FileReader ebg_file(config.edge_based_graph_path,
|
||||
io::FileReader::VerifyFingerprint);
|
||||
io::FileReader reader(config.mld_graph_path, io::FileReader::VerifyFingerprint);
|
||||
|
||||
const auto num_edges = ebg_file.ReadElementCount64();
|
||||
const auto num_nodes = ebg_file.ReadOne<EdgeID>() + 1;
|
||||
const auto num_nodes =
|
||||
reader.ReadVectorSize<customizer::StaticEdgeBasedGraph::NodeArrayEntry>();
|
||||
const auto num_edges =
|
||||
reader.ReadVectorSize<customizer::StaticEdgeBasedGraph::EdgeArrayEntry>();
|
||||
|
||||
layout.SetBlockSize<EdgeBasedGraph::NodeArrayEntry>(DataLayout::MLD_GRAPH_NODE_LIST,
|
||||
num_nodes + 1);
|
||||
layout.SetBlockSize<EdgeBasedGraph::EdgeArrayEntry>(DataLayout::MLD_GRAPH_EDGE_LIST,
|
||||
2 * num_edges);
|
||||
layout.SetBlockSize<customizer::StaticEdgeBasedGraph::NodeArrayEntry>(
|
||||
DataLayout::MLD_GRAPH_NODE_LIST, num_nodes);
|
||||
layout.SetBlockSize<customizer::StaticEdgeBasedGraph::EdgeArrayEntry>(
|
||||
DataLayout::MLD_GRAPH_EDGE_LIST, num_edges);
|
||||
}
|
||||
else
|
||||
{
|
||||
layout.SetBlockSize<char>(DataLayout::MLD_GRAPH_NODE_LIST, 0);
|
||||
layout.SetBlockSize<char>(DataLayout::MLD_GRAPH_EDGE_LIST, 0);
|
||||
layout.SetBlockSize<customizer::StaticEdgeBasedGraph::NodeArrayEntry>(
|
||||
DataLayout::MLD_GRAPH_NODE_LIST, 0);
|
||||
layout.SetBlockSize<customizer::StaticEdgeBasedGraph::EdgeArrayEntry>(
|
||||
DataLayout::MLD_GRAPH_EDGE_LIST, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -929,39 +933,21 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
||||
reader.ReadInto(mld_cell_level_offsets_ptr, size);
|
||||
}
|
||||
|
||||
if (boost::filesystem::exists(config.edge_based_graph_path))
|
||||
if (boost::filesystem::exists(config.mld_graph_path))
|
||||
{
|
||||
io::FileReader reader(config.edge_based_graph_path, io::FileReader::VerifyFingerprint);
|
||||
io::FileReader reader(config.mld_graph_path, io::FileReader::VerifyFingerprint);
|
||||
|
||||
const auto number_of_edges = reader.ReadElementCount64();
|
||||
const auto number_of_nodes = reader.ReadOne<EdgeID>() + 1;
|
||||
std::vector<extractor::EdgeBasedEdge> original_edges(number_of_edges);
|
||||
reader.ReadInto(original_edges);
|
||||
auto nodes_ptr =
|
||||
layout.GetBlockPtr<customizer::StaticEdgeBasedGraph::NodeArrayEntry, true>(
|
||||
memory_ptr, DataLayout::MLD_GRAPH_NODE_LIST);
|
||||
auto edges_ptr =
|
||||
layout.GetBlockPtr<customizer::StaticEdgeBasedGraph::EdgeArrayEntry, true>(
|
||||
memory_ptr, DataLayout::MLD_GRAPH_EDGE_LIST);
|
||||
|
||||
// FIXME: move graph pre-processing to a pre-processing tool #3783
|
||||
original_edges = partition::splitBidirectionalEdges(std::move(original_edges));
|
||||
auto edges = partition::prepareEdgesForUsageInGraph(std::move(original_edges));
|
||||
BOOST_ASSERT(edges.size() <= 2 * number_of_edges);
|
||||
|
||||
auto nodes_ptr = layout.GetBlockPtr<EdgeBasedGraph::NodeArrayEntry, true>(
|
||||
memory_ptr, DataLayout::MLD_GRAPH_NODE_LIST);
|
||||
auto edges_ptr = layout.GetBlockPtr<EdgeBasedGraph::EdgeArrayEntry, true>(
|
||||
memory_ptr, DataLayout::MLD_GRAPH_EDGE_LIST);
|
||||
|
||||
EdgeBasedGraph::EdgeIterator edge = 0;
|
||||
for (const auto node : util::irange(0u, number_of_nodes + 1))
|
||||
{
|
||||
EdgeBasedGraph::EdgeIterator last_edge = edge;
|
||||
while (edge < edges.size() && edges[edge].source == node)
|
||||
{
|
||||
edges_ptr[edge].target = edges[edge].target;
|
||||
edges_ptr[edge].data = edges[edge].data;
|
||||
++edge;
|
||||
}
|
||||
nodes_ptr[node].first_edge = last_edge;
|
||||
}
|
||||
|
||||
BOOST_ASSERT(edge == edges.size());
|
||||
auto num_nodes = reader.ReadElementCount64();
|
||||
reader.ReadInto(nodes_ptr, num_nodes);
|
||||
auto num_edges = reader.ReadElementCount64();
|
||||
reader.ReadInto(edges_ptr, num_edges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ StorageConfig::StorageConfig(const boost::filesystem::path &base)
|
||||
intersection_class_path{base.string() + ".icd"}, turn_lane_data_path{base.string() + ".tld"},
|
||||
turn_lane_description_path{base.string() + ".tls"},
|
||||
mld_partition_path{base.string() + ".partition"}, mld_storage_path{base.string() + ".cells"},
|
||||
edge_based_graph_path{base.string() + ".ebg"}
|
||||
mld_graph_path{base.string() + ".mldgr"}
|
||||
{
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ bool StorageConfig::IsValid() const
|
||||
CheckFileList({hsgr_data_path, core_data_path});
|
||||
|
||||
// MLD files
|
||||
CheckFileList({mld_partition_path, mld_storage_path, edge_based_graph_path});
|
||||
CheckFileList({mld_partition_path, mld_storage_path, mld_graph_path});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ enum class return_code : unsigned
|
||||
};
|
||||
|
||||
return_code
|
||||
parseArguments(int argc, char *argv[], customize::CustomizationConfig &customization_config)
|
||||
parseArguments(int argc, char *argv[], customizer::CustomizationConfig &customization_config)
|
||||
{
|
||||
// declare a group of options that will be allowed only on command line
|
||||
boost::program_options::options_description generic_options("Options");
|
||||
@ -34,7 +34,24 @@ parseArguments(int argc, char *argv[], customize::CustomizationConfig &customiza
|
||||
("threads,t",
|
||||
boost::program_options::value<unsigned int>(&customization_config.requested_num_threads)
|
||||
->default_value(tbb::task_scheduler_init::default_num_threads()),
|
||||
"Number of threads to use");
|
||||
"Number of threads to use")(
|
||||
"segment-speed-file",
|
||||
boost::program_options::value<std::vector<std::string>>(
|
||||
&customization_config.updater_config.segment_speed_lookup_paths)
|
||||
->composing(),
|
||||
"Lookup files containing nodeA, nodeB, speed data to adjust edge weights")(
|
||||
"turn-penalty-file",
|
||||
boost::program_options::value<std::vector<std::string>>(
|
||||
&customization_config.updater_config.turn_penalty_lookup_paths)
|
||||
->composing(),
|
||||
"Lookup files containing from_, to_, via_nodes, and turn penalties to adjust turn "
|
||||
"weights")("edge-weight-updates-over-factor",
|
||||
boost::program_options::value<double>(
|
||||
&customization_config.updater_config.log_edge_updates_factor)
|
||||
->default_value(0.0),
|
||||
"Use with `--segment-speed-file`. Provide an `x` factor, by which Extractor "
|
||||
"will log edge "
|
||||
"weights updated by more than this factor");
|
||||
|
||||
// hidden options, will be allowed on command line, but will not be
|
||||
// shown to the user
|
||||
@ -99,7 +116,7 @@ parseArguments(int argc, char *argv[], customize::CustomizationConfig &customiza
|
||||
int main(int argc, char *argv[]) try
|
||||
{
|
||||
util::LogPolicy::GetInstance().Unmute();
|
||||
customize::CustomizationConfig customization_config;
|
||||
customizer::CustomizationConfig customization_config;
|
||||
|
||||
const auto result = parseArguments(argc, argv, customization_config);
|
||||
|
||||
@ -131,7 +148,7 @@ int main(int argc, char *argv[]) try
|
||||
|
||||
tbb::task_scheduler_init init(customization_config.requested_num_threads);
|
||||
|
||||
auto exitcode = customize::Customizer().Run(customization_config);
|
||||
auto exitcode = customizer::Customizer().Run(customization_config);
|
||||
|
||||
util::DumpMemoryStats();
|
||||
|
||||
|
@ -162,6 +162,14 @@ void CheckWeightsConsistency(
|
||||
}
|
||||
#endif
|
||||
|
||||
Updater::NumNodesAndEdges Updater::LoadAndUpdateEdgeExpandedGraph() const
|
||||
{
|
||||
std::vector<extractor::EdgeBasedEdge> edge_based_edge_list;
|
||||
std::vector<EdgeWeight> node_weights;
|
||||
auto max_edge_id = Updater::LoadAndUpdateEdgeExpandedGraph(edge_based_edge_list, node_weights);
|
||||
return std::make_tuple(max_edge_id + 1, std::move(edge_based_edge_list));
|
||||
}
|
||||
|
||||
EdgeID
|
||||
Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
||||
std::vector<EdgeWeight> &node_weights) const
|
||||
@ -525,7 +533,8 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
// Update the node-weight cache. This is the weight of the edge-based-node only,
|
||||
// it doesn't include the turn. We may visit the same node multiple times, but
|
||||
// we should always assign the same value here.
|
||||
node_weights[inbuffer.source] = new_weight;
|
||||
if (node_weights.size() > 0)
|
||||
node_weights[inbuffer.source] = new_weight;
|
||||
|
||||
// We found a zero-speed edge, so we'll skip this whole edge-based-edge which
|
||||
// effectively removes it from the routing network.
|
||||
|
@ -7,6 +7,7 @@ SCRIPT_ROOT:=../../scripts
|
||||
OSRM_EXTRACT:=$(OSRM_BUILD_DIR)/osrm-extract
|
||||
OSRM_CONTRACT:=$(OSRM_BUILD_DIR)/osrm-contract
|
||||
OSRM_PARTITION:=$(OSRM_BUILD_DIR)/osrm-partition
|
||||
OSRM_CUSTOMIZE:=$(OSRM_BUILD_DIR)/osrm-customize
|
||||
OSRM_ROUTED:=$(OSRM_BUILD_DIR)/osrm-routed
|
||||
POLY2REQ:=$(SCRIPT_ROOT)/poly2req.js
|
||||
MD5SUM:=$(SCRIPT_ROOT)/md5sum.js
|
||||
@ -48,6 +49,7 @@ $(DATA_NAME)_MLD.osrm.partition: $(DATA_NAME)_MLD.osrm $(PROFILE) $(OSRM_PARTITI
|
||||
@echo "Running osrm-partition..."
|
||||
$(TIMER) "osrm-contract" $(OSRM_CONTRACT) $<
|
||||
$(TIMER) "osrm-partition" $(OSRM_PARTITION) $<
|
||||
$(TIMER) "osrm-customize" $(OSRM_CUSTOMIZE) $<
|
||||
|
||||
$(DATA_NAME).requests: $(DATA_NAME).poly
|
||||
$(POLY2REQ) $(DATA_NAME).poly > $(DATA_NAME).requests
|
||||
|
@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(test_mld)
|
||||
using namespace osrm;
|
||||
EngineConfig config;
|
||||
config.use_shared_memory = false;
|
||||
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/monaco_CoreCH.osrm");
|
||||
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/monaco_MLD.osrm");
|
||||
config.algorithm = EngineConfig::Algorithm::MLD;
|
||||
OSRM osrm{config};
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "util/static_graph.hpp"
|
||||
|
||||
using namespace osrm;
|
||||
using namespace osrm::customize;
|
||||
using namespace osrm::customizer;
|
||||
using namespace osrm::partition;
|
||||
using namespace osrm::util;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user