58#pragma GCC diagnostic push
59#pragma GCC diagnostic ignored "-Wunused-parameter"
61#pragma GCC diagnostic pop
71template<
class E,
class V,
class GRAPH>
102 Operation operation,
const bool unbuildIsWarning,
105 SUMOAbstractRouter<E, V>(
"CCHRouter", unbuildIsWarning, operation, nullptr, false, false),
131 virtual void reset(
const V*
const vehicle) {
138 bool compute(
const E* from,
const E* to,
const V*
const vehicle,
139 SUMOTime msTime, std::vector<const E*>& into,
bool silent =
false) {
153 if (vehicle !=
nullptr && vehicle->ignoreTransientPermissions()) {
154 return myFallback->compute(from, to, vehicle, msTime, into, silent);
158 return myFallback->compute(from, to, vehicle, msTime, into, silent);
165 const bool fromTaz = from->isTazConnector() &&
myGraph->nodeOf(from) == GRAPH::INVALID_NODE;
166 const bool toTaz = to->isTazConnector() &&
myGraph->nodeOf(to) == GRAPH::INVALID_NODE;
173 if (vehicle !=
nullptr) {
174 if (!fromTaz && from->prohibits(vehicle)) {
180 if (!toTaz && to->prohibits(vehicle)) {
187 std::vector<unsigned> srcBuf, tgtBuf;
188 const std::vector<unsigned>* sources;
189 const std::vector<unsigned>* targets;
191 for (
const unsigned m :
myGraph->tazSources(from)) {
192 if ((
myGraph->edgeOf(m)->getPermissions() & vClass) != 0) {
198 const unsigned s =
myGraph->nodeOf(from);
199 if (s != GRAPH::INVALID_NODE) {
205 for (
const unsigned m :
myGraph->tazSinks(to)) {
206 if ((
myGraph->edgeOf(m)->getPermissions() & vClass) != 0) {
212 const unsigned t =
myGraph->nodeOf(to);
213 if (t != GRAPH::INVALID_NODE) {
218 if (sources->empty() || targets->empty()) {
221 return myFallback->compute(from, to, vehicle, msTime, into, silent);
230 from->getID(), to->getID());
234 std::vector<const E*> path;
235 buildPath(from, to, fromTaz, toTaz, path);
236 int visited = (int)path.size();
252 if (altMetric !=
nullptr && altMetric !=
metric
253 &&
runQuery(altMetric, *sources, *targets, vehicle, t)) {
254 std::vector<const E*> altPath;
255 buildPath(from, to, fromTaz, toTaz, altPath);
256 visited += (int)altPath.size();
264 into.insert(into.end(), path.begin(), path.end());
308 const std::vector<unsigned>& targets,
const V*
const vehicle,
double t) {
316 for (
const unsigned s : sources) {
321 for (
const unsigned tt : targets) {
330 void buildPath(
const E* from,
const E* to,
bool fromTaz,
bool toTaz,
331 std::vector<const E*>& path) {
334 path.push_back(from);
336 myGraph->expandNodePath(nodePath, path);
354 if ((item.second.permissions & vClass) != vClass
355 && (item.first->getPermissions() & vClass) != 0) {
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Contraction-hierarchy router over the edge graph mapped by GRAPH.
bool prohibitionsCoveredByMetric(SUMOVehicleClass vClass) const
Can the per-class CCH metric already express every edge this prohibition set forbids for vClass?...
SUMOTime(* PeriodEnd)(SUMOTime)
the end of the weight period containing the given time (SUMOTime_MAX = weights are static)....
SUMOAbstractRouter< E, V >::Prohibitions Prohibitions
void setMsgHandler(MsgHandler *const errorMsgHandler)
keep the fallback reporting through the same handler (duarouter swaps handlers around route repair; C...
SUMOAbstractRouter< E, V >::Operation Operation
RoutingKit::CustomizableContractionHierarchyQuery myQuery
CCHRouter & operator=(const CCHRouter &)=delete
void(* ResetHook)(const V *)
the host's efforts changed behind the metrics and it reset the router (SUMOAbstractRouter::reset – ma...
void prohibit(const Prohibitions &toProhibit)
prohibitions: a closure that is already a live permission change is served by the per-class metric (C...
CCHRouter(CCHRouter *other)
clone constructor: share graph + provider, clone the fallback, fresh query scratch
void setBulkMode(const bool mode)
virtual void reset(const V *const vehicle)
the host's efforts changed (see ResetHook): notify the metric store and reset the fallback's caches....
const RoutingKit::CustomizableContractionHierarchyMetric * MetricPtr
void buildPath(const E *from, const E *to, bool fromTaz, bool toTaz, std::vector< const E * > &path)
expand the last query's node path, bracketing it with the TAZ connectors where the endpoints are zone...
MetricPtr(* MetricProvider)(SUMOVehicleClass, SUMOTime, const V *)
supplies the metric for a vehicle class at a query time, or nullptr => fall back. The simulation igno...
bool runQuery(MetricPtr metric, const std::vector< unsigned > &sources, const std::vector< unsigned > &targets, const V *const vehicle, double t)
Bind the query to metric (rebinding only on change), seed all sources and targets and run it; true if...
virtual SUMOAbstractRouter< E, V > * clone()
Prohibitions myProhibited
SUMOAbstractRouter< E, V > * myFallback
MetricProvider myMetricProvider
bool supportsProhibitions() const
CCHRouter(const GRAPH *graph, MetricProvider provider, Operation operation, const bool unbuildIsWarning, SUMOAbstractRouter< E, V > *fallback, PeriodEnd periodEnd=nullptr, ResetHook onReset=nullptr)
Constructor.
bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
virtual void setBulkMode(const bool mode)
std::map< const E *, RouterProhibition > Prohibitions
double getEffort(const E *const e, const V *const v, double t) const
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
virtual void setMsgHandler(MsgHandler *const errorMsgHandler)
void endQuery(int visits)
MsgHandler * myErrorMsgHandler
the handler for routing errors
CustomizableContractionHierarchyMetric * metric
const unsigned inf_weight
std::vector< unsigned > get_node_path()
CustomizableContractionHierarchyQuery & run()
CustomizableContractionHierarchyQuery & add_source(unsigned s, unsigned dist_to_s=0)
CustomizableContractionHierarchyQuery & add_target(unsigned t, unsigned dist_to_t=0)
CustomizableContractionHierarchyQuery & reset()