Eclipse SUMO - Simulation of Urban MObility
RODFDetector.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Class representing a detector within the DFROUTER
18 /****************************************************************************/
19 #ifndef RODFDetector_h
20 #define RODFDetector_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <map>
29 #include <string>
30 #include <vector>
31 #include <set>
32 #include <utils/common/SUMOTime.h>
34 #include <utils/common/Named.h>
35 #include "RODFRouteCont.h"
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class RODFRouteCont;
42 class RODFDetectorFlows;
43 class ROEdge;
44 class RODFEdge;
45 class RODFDetectorCon;
46 class RODFNet;
47 struct RODFRouteDesc;
48 class OutputDevice;
49 class SUMOVTypeParameter;
50 
51 
52 // ===========================================================================
53 // enumerations
54 // ===========================================================================
62 
65 
68 
72 };
73 
74 
75 // ===========================================================================
76 // class definitions
77 // ===========================================================================
82 class RODFDetector : public Named {
83 public:
94  RODFDetector(const std::string& id, const std::string& laneID,
95  double pos, const RODFDetectorType type);
96 
97 
105  RODFDetector(const std::string& id, const RODFDetector& f);
106 
107 
109  ~RODFDetector();
110 
111 
112 
115 
119  const std::string& getLaneID() const {
120  return myLaneID;
121  };
122 
123 
127  std::string getEdgeID() const {
128  return myLaneID.substr(0, myLaneID.rfind('_'));
129  }
130 
131 
135  double getPos() const {
136  return myPosition;
137  };
138 
139 
145  return myType;
146  };
148 
149 
150  void setType(RODFDetectorType type);
151  void addRoute(RODFRouteDesc& nrd);
152  void addRoutes(RODFRouteCont* routes);
153  bool hasRoutes() const;
154  const std::vector<RODFRouteDesc>& getRouteVector() const;
155  void addPriorDetector(const RODFDetector* det);
156  void addFollowingDetector(const RODFDetector* det);
157  const std::set<const RODFDetector*>& getPriorDetectors() const;
158  const std::set<const RODFDetector*>& getFollowerDetectors() const;
159 
160 
163 
164  bool writeEmitterDefinition(const std::string& file,
165  const std::map<SUMOTime, RandomDistributor<int>* >& dists,
166  const RODFDetectorFlows& flows,
167  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
168  bool includeUnusedRoutes, double scale,
169  bool insertionsOnly, double defaultSpeed) const;
170  bool writeRoutes(std::vector<std::string>& saved,
171  OutputDevice& out);
172  void writeSingleSpeedTrigger(const std::string& file,
173  const RODFDetectorFlows& flows,
174  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
175  double defaultSpeed);
176  void writeEndRerouterDetectors(const std::string& file);
178 
179  void buildDestinationDistribution(const RODFDetectorCon& detectors,
180  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
181  const RODFNet& net,
182  std::map<SUMOTime, RandomDistributor<int>* >& into) const;
183 
184  void computeSplitProbabilities(const RODFNet* net, const RODFDetectorCon& detectors,
185  const RODFDetectorFlows& flows,
186  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
187 
188  const std::vector<std::map<RODFEdge*, double> >& getSplitProbabilities() const {
189  return mySplitProbabilities;
190  }
191 
192 protected:
193  int getFlowFor(const ROEdge* edge, SUMOTime time) const;
194  double computeDistanceFactor(const RODFRouteDesc& rd) const;
195 
196 
197 protected:
198  std::string myLaneID;
199  double myPosition;
202  std::set<const RODFDetector*> myPriorDetectors, myFollowingDetectors;
203  std::vector<std::map<RODFEdge*, double> > mySplitProbabilities;
204  std::map<std::string, RODFEdge*> myRoute2Edge;
205 
206 
207 private:
209  RODFDetector(const RODFDetector& src);
210 
212  RODFDetector& operator=(const RODFDetector& src);
213 
214 };
215 
216 
222 public:
223  RODFDetectorCon();
224  ~RODFDetectorCon();
225  bool addDetector(RODFDetector* dfd);
226  void removeDetector(const std::string& id);
227  bool detectorsHaveCompleteTypes() const;
228  bool detectorsHaveRoutes() const;
229  const std::vector<RODFDetector*>& getDetectors() const;
230  void save(const std::string& file) const;
231  void saveAsPOIs(const std::string& file) const;
232  void saveRoutes(const std::string& file) const;
233 
234  const RODFDetector& getDetector(const std::string& id) const;
235  RODFDetector& getModifiableDetector(const std::string& id) const;
236  const RODFDetector& getAnyDetectorForEdge(const RODFEdge* const edge) const;
237 
238  bool knows(const std::string& id) const;
239  void writeEmitters(const std::string& file,
240  const RODFDetectorFlows& flows,
241  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
242  const RODFNet& net,
243  bool writeCalibrators, bool includeUnusedRoutes,
244  double scale,
245  bool insertionsOnly);
246 
247  void writeEmitterPOIs(const std::string& file,
248  const RODFDetectorFlows& flows);
249 
250  void writeSpeedTrigger(const RODFNet* const net, const std::string& file,
251  const RODFDetectorFlows& flows,
252  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
253 
254  void writeValidationDetectors(const std::string& file,
255  bool includeSources, bool singleFile, bool friendly);
256  void writeEndRerouterDetectors(const std::string& file);
257 
258  int getAggFlowFor(const ROEdge* edge, SUMOTime time, SUMOTime period,
259  const RODFDetectorFlows& flows) const;
260 
261  void guessEmptyFlows(RODFDetectorFlows& flows);
262 
263  void mesoJoin(const std::string& nid, const std::vector<std::string>& oldids);
264 
265  void setSpeedFactorAndDev(SUMOVTypeParameter& type, double maxFactor, double avgFactor, double dev, bool forceDev);
266 
267 protected:
271  void clearDists(std::map<SUMOTime, RandomDistributor<int>* >& dists) const;
272 
273 
274 protected:
275  std::vector<RODFDetector*> myDetectors;
276  std::map<std::string, RODFDetector*> myDetectorMap;
277  std::map<std::string, std::vector<RODFDetector*> > myDetectorEdgeMap;
278 
279 private:
281  RODFDetectorCon(const RODFDetectorCon& src);
282 
285 
286 };
287 
288 
289 #endif
290 
291 /****************************************************************************/
292 
std::vector< RODFDetector * > myDetectors
Definition: RODFDetector.h:275
long long int SUMOTime
Definition: SUMOTime.h:35
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
void addRoute(RODFRouteDesc &nrd)
std::string getEdgeID() const
Returns the id of the edge this detector is placed on.
Definition: RODFDetector.h:127
RODFDetectorType
Numerical representation of different detector types.
Definition: RODFDetector.h:59
std::map< std::string, RODFDetector * > myDetectorMap
Definition: RODFDetector.h:276
Structure representing possible vehicle parameter.
void addRoutes(RODFRouteCont *routes)
A source detector.
Definition: RODFDetector.h:70
void writeEndRerouterDetectors(const std::string &file)
void addPriorDetector(const RODFDetector *det)
RODFDetectorType getType() const
Returns the type of the detector.
Definition: RODFDetector.h:144
const std::vector< RODFRouteDesc > & getRouteVector() const
RODFDetector(const std::string &id, const std::string &laneID, double pos, const RODFDetectorType type)
Constructor.
A container for flows.
A container for RODFDetectors.
Definition: RODFDetector.h:221
const std::set< const RODFDetector * > & getFollowerDetectors() const
void computeSplitProbabilities(const RODFNet *net, const RODFDetectorCon &detectors, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
RODFRouteCont * myRoutes
Definition: RODFDetector.h:201
A not yet defined detector.
Definition: RODFDetector.h:61
std::map< std::string, std::vector< RODFDetector * > > myDetectorEdgeMap
Definition: RODFDetector.h:277
bool hasRoutes() const
bool writeRoutes(std::vector< std::string > &saved, OutputDevice &out)
std::vector< std::map< RODFEdge *, double > > mySplitProbabilities
Definition: RODFDetector.h:203
An in-between detector.
Definition: RODFDetector.h:67
const std::vector< std::map< RODFEdge *, double > > & getSplitProbabilities() const
Definition: RODFDetector.h:188
const std::set< const RODFDetector * > & getPriorDetectors() const
RODFDetector & operator=(const RODFDetector &src)
Invalidated assignment operator.
double computeDistanceFactor(const RODFRouteDesc &rd) const
A detector which had to be discarded (!!!)
Definition: RODFDetector.h:64
A DFROUTER-network.
Definition: RODFNet.h:45
~RODFDetector()
Destructor.
std::string myLaneID
Definition: RODFDetector.h:198
A route within the DFROUTER.
Definition: RODFRouteDesc.h:47
A basic edge for routing applications.
Definition: ROEdge.h:73
Base class for objects which have an id.
Definition: Named.h:57
const std::string & getLaneID() const
Returns the id of the lane this detector is placed on.
Definition: RODFDetector.h:119
void writeSingleSpeedTrigger(const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, double defaultSpeed)
RODFDetectorType myType
Definition: RODFDetector.h:200
std::map< std::string, RODFEdge * > myRoute2Edge
Definition: RODFDetector.h:204
Class representing a detector within the DFROUTER.
Definition: RODFDetector.h:82
A container for DFROUTER-routes.
Definition: RODFRouteCont.h:56
void buildDestinationDistribution(const RODFDetectorCon &detectors, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, const RODFNet &net, std::map< SUMOTime, RandomDistributor< int > * > &into) const
void setType(RODFDetectorType type)
std::set< const RODFDetector * > myPriorDetectors
Definition: RODFDetector.h:202
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
std::set< const RODFDetector * > myFollowingDetectors
Definition: RODFDetector.h:202
double myPosition
Definition: RODFDetector.h:199
int getFlowFor(const ROEdge *edge, SUMOTime time) const
void addFollowingDetector(const RODFDetector *det)
double getPos() const
Returns the position at which the detector lies.
Definition: RODFDetector.h:135