Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RODFDetector.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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/****************************************************************************/
20// Class representing a detector within the DFROUTER
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <map>
26#include <string>
27#include <vector>
28#include <set>
31#include <utils/common/Named.h>
32#include "RODFRouteCont.h"
33
34
35// ===========================================================================
36// class declarations
37// ===========================================================================
38class RODFRouteCont;
40class ROEdge;
41class RODFEdge;
42class RODFDetectorCon;
43class RODFNet;
44struct RODFRouteDesc;
45class OutputDevice;
47
48
49// ===========================================================================
50// enumerations
51// ===========================================================================
70
71
72// ===========================================================================
73// class definitions
74// ===========================================================================
79class RODFDetector : public Named {
80public:
91 RODFDetector(const std::string& id, const std::string& laneID,
92 double pos, const RODFDetectorType type);
93
94
102 RODFDetector(const std::string& id, const RODFDetector& f);
103
104
107
108
109
112
116 const std::string& getLaneID() const {
117 return myLaneID;
118 };
119
120
124 std::string getEdgeID() const;
125
126
130 double getPos() const {
131 return myPosition;
132 };
133
134
140 return myType;
141 };
143
144
145 void setType(RODFDetectorType type);
146 void addRoute(RODFRouteDesc& nrd);
147 void addRoutes(RODFRouteCont* routes);
148 bool hasRoutes() const;
149 const std::vector<RODFRouteDesc>& getRouteVector() const;
150 void addPriorDetector(const RODFDetector* det);
151 void addFollowingDetector(const RODFDetector* det);
152 const std::set<const RODFDetector*>& getPriorDetectors() const;
153 const std::set<const RODFDetector*>& getFollowerDetectors() const;
154
155
158
159 bool writeEmitterDefinition(const std::string& file,
160 const std::map<SUMOTime, RandomDistributor<int>* >& dists,
161 const RODFDetectorFlows& flows,
162 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
163 bool includeUnusedRoutes, double scale,
164 bool insertionsOnly, double defaultSpeed) const;
165 bool writeRoutes(std::vector<std::string>& saved,
166 OutputDevice& out);
167 void writeSingleSpeedTrigger(const std::string& file,
168 const RODFDetectorFlows& flows,
169 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
170 double defaultSpeed);
171 void writeEndRerouterDetectors(const std::string& file);
173
174 void buildDestinationDistribution(const RODFDetectorCon& detectors,
175 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
176 const RODFNet& net,
177 std::map<SUMOTime, RandomDistributor<int>* >& into) const;
178
179 void computeSplitProbabilities(const RODFNet* net, const RODFDetectorCon& detectors,
180 const RODFDetectorFlows& flows,
181 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
182
183 const std::vector<std::map<RODFEdge*, double> >& getSplitProbabilities() const {
185 }
186
187protected:
188 int getFlowFor(const ROEdge* edge, SUMOTime time) const;
189 double computeDistanceFactor(const RODFRouteDesc& rd) const;
190
191
192protected:
193 std::string myLaneID;
197 std::set<const RODFDetector*> myPriorDetectors, myFollowingDetectors;
198 std::vector<std::map<RODFEdge*, double> > mySplitProbabilities;
199 std::map<std::string, RODFEdge*> myRoute2Edge;
200
201
202private:
205
208
209};
210
211
217public:
220 bool addDetector(RODFDetector* dfd);
221 void removeDetector(const std::string& id);
222 bool detectorsHaveCompleteTypes() const;
223 bool detectorsHaveRoutes() const;
224 const std::vector<RODFDetector*>& getDetectors() const;
225 void save(const std::string& file) const;
226 void saveAsPOIs(const std::string& file) const;
227 void saveRoutes(const std::string& file) const;
228
229 const RODFDetector& getDetector(const std::string& id) const;
230 RODFDetector& getModifiableDetector(const std::string& id) const;
231 const RODFDetector& getAnyDetectorForEdge(const RODFEdge* const edge) const;
232
233 bool knows(const std::string& id) const;
234 void writeEmitters(const std::string& file,
235 const RODFDetectorFlows& flows,
236 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
237 const RODFNet& net,
238 bool writeCalibrators, bool includeUnusedRoutes,
239 double scale,
240 bool insertionsOnly);
241
242 void writeEmitterPOIs(const std::string& file,
243 const RODFDetectorFlows& flows);
244
245 void writeSpeedTrigger(const RODFNet* const net, const std::string& file,
246 const RODFDetectorFlows& flows,
247 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
248
249 void writeValidationDetectors(const std::string& file,
250 bool includeSources, bool singleFile, bool friendly);
251 void writeEndRerouterDetectors(const std::string& file);
252
253 int getAggFlowFor(const ROEdge* edge, SUMOTime time, SUMOTime period,
254 const RODFDetectorFlows& flows) const;
255
257
258 void mesoJoin(const std::string& nid, const std::vector<std::string>& oldids);
259
260 void setSpeedFactorAndDev(SUMOVTypeParameter& type, double maxFactor, double avgFactor, double dev, bool forceDev);
261
262protected:
266 void clearDists(std::map<SUMOTime, RandomDistributor<int>* >& dists) const;
267
268
269protected:
270 std::vector<RODFDetector*> myDetectors;
271 std::map<std::string, RODFDetector*> myDetectorMap;
272 std::map<std::string, std::vector<RODFDetector*> > myDetectorEdgeMap;
273
274private:
277
280
281};
long long int SUMOTime
Definition GUI.h:36
RODFDetectorType
Numerical representation of different detector types.
@ BETWEEN_DETECTOR
An in-between detector.
@ SINK_DETECTOR
@ SOURCE_DETECTOR
A source detector.
@ DISCARDED_DETECTOR
A detector which had to be discarded (!!!)
@ TYPE_NOT_DEFINED
A not yet defined detector.
Base class for objects which have an id.
Definition Named.h:54
Static storage of an output device and its base (abstract) implementation.
A container for RODFDetectors.
bool detectorsHaveRoutes() const
const RODFDetector & getAnyDetectorForEdge(const RODFEdge *const edge) const
void clearDists(std::map< SUMOTime, RandomDistributor< int > * > &dists) const
Clears the given distributions map, deleting the timed distributions.
std::map< std::string, std::vector< RODFDetector * > > myDetectorEdgeMap
void save(const std::string &file) const
void writeEmitterPOIs(const std::string &file, const RODFDetectorFlows &flows)
bool knows(const std::string &id) const
void mesoJoin(const std::string &nid, const std::vector< std::string > &oldids)
void removeDetector(const std::string &id)
bool addDetector(RODFDetector *dfd)
void writeValidationDetectors(const std::string &file, bool includeSources, bool singleFile, bool friendly)
const RODFDetector & getDetector(const std::string &id) const
std::map< std::string, RODFDetector * > myDetectorMap
void guessEmptyFlows(RODFDetectorFlows &flows)
bool detectorsHaveCompleteTypes() const
void saveRoutes(const std::string &file) const
std::vector< RODFDetector * > myDetectors
void writeSpeedTrigger(const RODFNet *const net, const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
void setSpeedFactorAndDev(SUMOVTypeParameter &type, double maxFactor, double avgFactor, double dev, bool forceDev)
RODFDetectorCon(const RODFDetectorCon &src)
Invalidated copy constructor.
void writeEmitters(const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, const RODFNet &net, bool writeCalibrators, bool includeUnusedRoutes, double scale, bool insertionsOnly)
void saveAsPOIs(const std::string &file) const
RODFDetector & getModifiableDetector(const std::string &id) const
const std::vector< RODFDetector * > & getDetectors() const
RODFDetectorCon & operator=(const RODFDetectorCon &src)
Invalidated assignment operator.
void writeEndRerouterDetectors(const std::string &file)
int getAggFlowFor(const ROEdge *edge, SUMOTime time, SUMOTime period, const RODFDetectorFlows &flows) const
A container for flows.
Class representing a detector within the DFROUTER.
void computeSplitProbabilities(const RODFNet *net, const RODFDetectorCon &detectors, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
double getPos() const
Returns the position at which the detector lies.
void setType(RODFDetectorType type)
RODFDetector(const RODFDetector &src)
Invalidated copy constructor.
void addPriorDetector(const RODFDetector *det)
RODFDetector & operator=(const RODFDetector &src)
Invalidated assignment operator.
bool hasRoutes() const
int getFlowFor(const ROEdge *edge, SUMOTime time) const
double myPosition
const std::vector< RODFRouteDesc > & getRouteVector() const
void addRoute(RODFRouteDesc &nrd)
bool writeRoutes(std::vector< std::string > &saved, OutputDevice &out)
double computeDistanceFactor(const RODFRouteDesc &rd) const
void buildDestinationDistribution(const RODFDetectorCon &detectors, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, const RODFNet &net, std::map< SUMOTime, RandomDistributor< int > * > &into) const
const std::set< const RODFDetector * > & getPriorDetectors() const
void addRoutes(RODFRouteCont *routes)
const std::vector< std::map< RODFEdge *, double > > & getSplitProbabilities() const
RODFDetectorType getType() const
Returns the type of the detector.
std::vector< std::map< RODFEdge *, double > > mySplitProbabilities
void writeSingleSpeedTrigger(const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, double defaultSpeed)
std::map< std::string, RODFEdge * > myRoute2Edge
std::string getEdgeID() const
Returns the id of the edge this detector is placed on.
~RODFDetector()
Destructor.
std::string myLaneID
void writeEndRerouterDetectors(const std::string &file)
bool writeEmitterDefinition(const std::string &file, const std::map< SUMOTime, RandomDistributor< int > * > &dists, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, bool includeUnusedRoutes, double scale, bool insertionsOnly, double defaultSpeed) const
RODFRouteCont * myRoutes
const std::string & getLaneID() const
Returns the id of the lane this detector is placed on.
RODFDetectorType myType
std::set< const RODFDetector * > myPriorDetectors
void addFollowingDetector(const RODFDetector *det)
const std::set< const RODFDetector * > & getFollowerDetectors() const
std::set< const RODFDetector * > myFollowingDetectors
A DFROUTER-network.
Definition RODFNet.h:42
A container for DFROUTER-routes.
A basic edge for routing applications.
Definition ROEdge.h:72
Represents a generic random distribution.
Structure representing possible vehicle parameter.
A route within the DFROUTER.