Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
ROCCHMetrics.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// The CCH metric store of the router applications (see ROCCHMetrics.h).
19/****************************************************************************/
20#include <config.h>
21
22#include "ROCCHMetrics.h"
23
24#include "ROEdge.h"
25#include "ROVehicle.h"
26
27// ===========================================================================
28// static member definitions
29// ===========================================================================
31
32
33// ===========================================================================
34// ROCCHMetrics method definitions
35// ===========================================================================
36void
38 SUMOTime begin, SUMOTime weightPeriod) {
39 delete myFamily;
40 // no reference-vehicle factory: each (type, period) pair is customized
41 // exactly once per fill, so the first querying vehicle of a type is that
42 // type's effort reference
43 myFamily = new ROCCHMetricFamily(graph, effort, begin, weightPeriod,
45}
46
47
50 if (myFamily == nullptr) {
51 return nullptr; // not initialised -> caller falls back to A*
52 }
53 // keyed by the TYPE (nullptr covers vehicle-less queries): everything the
54 // effort function reads from the type is exact per metric -- see
55 // CCHMetricFamily.h
56 return myFamily->get(veh == nullptr ? nullptr : veh->getType(), vClass, time, veh);
57}
58
59
62 return myFamily == nullptr ? SUMOTime_MAX : myFamily->periodEnd(time);
63}
64
65
66void
67ROCCHMetrics::reset(const ROVehicle* /* veh */) {
68 if (myFamily != nullptr) {
70 }
71}
72
73
74void
76 std::vector<unsigned>& weights) {
77 if (veh == nullptr || veh->getType()->paramRestrictions.empty()) {
78 return;
79 }
80 // mask the edges that restrict this type (restricts() depends only on
81 // the type's paramRestrictions vector). arcsOfEdge of a real edge is
82 // exactly the arcs headed by it -- via chains hold internal edges only --
83 // matching what the exact routers check per relaxation.
84 for (const ROEdge* const e : ROEdge::getAllEdges()) {
85 if (!e->isInternal() && !e->isTazConnector() && e->restricts(veh)) {
86 for (const unsigned a : graph->arcsOfEdge(e)) {
87 weights[a] = RoutingKit::inf_weight;
88 }
89 }
90 }
91}
long long int SUMOTime
Definition GUI.h:36
CCHMetricFamily< ROEdge, ROVehicle, SUMOVTypeParameter > ROCCHMetricFamily
the ROEdge instantiation of the CCH metric store, keyed by the vehicle-type parameters (stable pointe...
#define SUMOTime_MAX
Definition SUMOTime.h:34
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Metric-independent RoutingKit CCH topology over the PURE road graph.
Definition CCHGraph.h:86
double(* EffortOperation)(const E *const, const V *const, double)
effort callback signature, matching SUMOAbstractRouter::Operation
Definition CCHGraph.h:89
per-vehicle-type CCH metric store over a shared CCHGraph
MetricPtr get(const K *key, SUMOVehicleClass vClass, SUMOTime time, const V *veh)
the metric for (type key, period of time), built on the first query of the pair; nullptr before init....
void flagStale()
the efforts behind the cached metrics changed – a runtime permission change in the simulation (the ca...
SUMOTime periodEnd(SUMOTime time) const
the end of the weight period containing the given time (SUMOTime_MAX when the weights are static); CC...
static SUMOTime periodEnd(SUMOTime time)
the end of the weight period containing the given time (SUMOTime_MAX when the weights are static); CC...
static void reset(const ROVehicle *veh)
the edge weights changed behind the metrics (marouter after an assignment iteration,...
static void patchRestrictions(const ROCCHGraph *graph, const ROVehicle *veh, std::vector< unsigned > &weights)
post-fill hook: mask the edges that restrict the querying vehicle's type to inf_weight (restriction-p...
static ROCCHMetricFamily * myFamily
static void init(const ROCCHGraph *graph, ROCCHGraph::EffortOperation effort, SUMOTime begin, SUMOTime weightPeriod)
install the shared graph, effort function and weight-period grid (call once, before routing); weightP...
static const RoutingKit::CustomizableContractionHierarchyMetric * get(SUMOVehicleClass vClass, SUMOTime time, const ROVehicle *veh)
the metric for the vehicle's type at a query time, built on first use; matches CCHRouter::MetricProvi...
A basic edge for routing applications.
Definition ROEdge.h:73
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
Definition ROEdge.cpp:375
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition RORoutable.h:89
A vehicle as used by router.
Definition ROVehicle.h:51
std::vector< double > paramRestrictions
cached value of parameters which may restrict access to certain edges
const Graph * graph