Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/dfrouter/RODFNet.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file RODFNet.h
15
/// @author Daniel Krajzewicz
16
/// @author Eric Nicolay
17
/// @author Michael Behrisch
18
/// @date Thu, 16.03.2006
19
///
20
// A DFROUTER-network
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <utils/options/OptionsCont.h>
26
#include <utils/common/StdDefs.h>
27
#include <utils/common/SUMOTime.h>
28
#include <router/ROEdge.h>
29
#include <router/RONet.h>
30
#include "RODFDetector.h"
31
#include "RODFRouteDesc.h"
32
#include "RODFRouteCont.h"
33
34
35
// ===========================================================================
36
// class definitions
37
// ===========================================================================
38
/**
39
* @class RODFNet
40
* @brief A DFROUTER-network
41
*/
42
class RODFNet : public RONet {
43
public:
44
/** @brief Constructor
45
* @param[in] amInHighwayMode Whether search for following edges shall stop at slow edges
46
*/
47
RODFNet(bool amInHighwayMode);
48
49
50
/// @brief Destructor
51
~RODFNet();
52
53
54
void buildApproachList();
55
56
void computeTypes(RODFDetectorCon& dets,
57
bool sourcesStrict) const;
58
void buildRoutes(RODFDetectorCon& det, bool keepUnfoundEnds, bool includeInBetween,
59
bool keepShortestOnly, int maxFollowingLength) const;
60
double getAbsPos(const RODFDetector& det) const;
61
62
void buildEdgeFlowMap(const RODFDetectorFlows& flows,
63
const RODFDetectorCon& detectors,
64
SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
65
66
void revalidateFlows(const RODFDetectorCon& detectors,
67
RODFDetectorFlows& flows,
68
SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
69
70
71
void removeEmptyDetectors(RODFDetectorCon& detectors,
72
RODFDetectorFlows& flows);
73
74
void reportEmptyDetectors(RODFDetectorCon& detectors,
75
RODFDetectorFlows& flows);
76
77
void buildDetectorDependencies(RODFDetectorCon& detectors);
78
79
void mesoJoin(RODFDetectorCon& detectors, RODFDetectorFlows& flows);
80
81
bool hasDetector(ROEdge* edge) const;
82
const std::vector<std::string>& getDetectorList(ROEdge* edge) const;
83
84
double getMaxSpeedFactorPKW() const {
85
return myMaxSpeedFactorPKW;
86
}
87
88
double getMaxSpeedFactorLKW() const {
89
return myMaxSpeedFactorLKW;
90
}
91
92
double getAvgSpeedFactorPKW() const {
93
return myAvgSpeedFactorPKW;
94
}
95
96
double getAvgSpeedFactorLKW() const {
97
return myAvgSpeedFactorLKW;
98
}
99
100
protected:
101
void revalidateFlows(const RODFDetector* detector,
102
RODFDetectorFlows& flows,
103
SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
104
bool isSource(const RODFDetector& det,
105
const RODFDetectorCon& detectors, bool strict) const;
106
bool isFalseSource(const RODFDetector& det,
107
const RODFDetectorCon& detectors) const;
108
bool isDestination(const RODFDetector& det,
109
const RODFDetectorCon& detectors) const;
110
111
ROEdge* getDetectorEdge(const RODFDetector& det) const;
112
bool isSource(const RODFDetector& det, ROEdge* edge,
113
ROEdgeVector& seen, const RODFDetectorCon& detectors,
114
bool strict) const;
115
bool isFalseSource(const RODFDetector& det, ROEdge* edge,
116
ROEdgeVector& seen, const RODFDetectorCon& detectors) const;
117
bool isDestination(const RODFDetector& det, ROEdge* edge, ROEdgeVector& seen,
118
const RODFDetectorCon& detectors) const;
119
120
void computeRoutesFor(ROEdge* edge, RODFRouteDesc& base, int no,
121
bool keepUnfoundEnds,
122
bool keepShortestOnly,
123
ROEdgeVector& visited, const RODFDetector& det,
124
RODFRouteCont& into, const RODFDetectorCon& detectors,
125
int maxFollowingLength,
126
ROEdgeVector& seen) const;
127
128
void buildDetectorEdgeDependencies(RODFDetectorCon& dets) const;
129
130
bool hasApproaching(ROEdge* edge) const;
131
bool hasApproached(ROEdge* edge) const;
132
133
bool hasInBetweenDetectorsOnly(ROEdge* edge,
134
const RODFDetectorCon& detectors) const;
135
bool hasSourceDetector(ROEdge* edge,
136
const RODFDetectorCon& detectors) const;
137
138
bool isAllowed(const ROEdge* const edge) const;
139
140
struct IterationEdge {
141
int depth;
142
ROEdge* edge;
143
};
144
145
protected:
146
class DFRouteDescByTimeComperator {
147
public:
148
/// Constructor
149
explicit DFRouteDescByTimeComperator() { }
150
151
/// Destructor
152
~DFRouteDescByTimeComperator() { }
153
154
/// Comparing method
155
bool operator()(const RODFRouteDesc& nod1, const RODFRouteDesc& nod2) const {
156
return nod1.duration_2 > nod2.duration_2;
157
}
158
};
159
160
private:
161
/// @brief comparator for maps using edges as key, used only in myDetectorsOnEdges to make tests comparable
162
struct idComp {
163
bool operator()(ROEdge* const lhs, ROEdge* const rhs) const {
164
return lhs->getID() < rhs->getID();
165
}
166
};
167
168
/// @brief Map of edge name->list of names of this edge approaching edges
169
std::map<ROEdge*, ROEdgeVector > myApproachingEdges;
170
171
/// @brief Map of edge name->list of names of edges approached by this edge
172
std::map<ROEdge*, ROEdgeVector > myApproachedEdges;
173
174
mutable std::map<ROEdge*, std::vector<std::string>, idComp> myDetectorsOnEdges;
175
mutable std::map<std::string, ROEdge*> myDetectorEdges;
176
177
bool myAmInHighwayMode;
178
mutable int mySourceNumber, mySinkNumber, myInBetweenNumber, myInvalidNumber;
179
180
/// @brief List of ids of edges that shall not be used
181
std::vector<std::string> myDisallowedEdges;
182
183
SUMOVehicleClass myAllowedVClass;
184
185
bool myKeepTurnarounds;
186
187
/// @brief maximum speed factor in measurements
188
double myMaxSpeedFactorPKW;
189
double myMaxSpeedFactorLKW;
190
double myAvgSpeedFactorPKW;
191
double myAvgSpeedFactorLKW;
192
193
};
194
195