SUMO - Simulation of Urban MObility
RODFDetector.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Class representing a detector within the DFROUTER
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef RODFDetector_h
23 #define RODFDetector_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <map>
36 #include <string>
37 #include <vector>
38 #include <set>
39 #include <utils/common/SUMOTime.h>
41 #include <utils/common/Named.h>
42 #include "RODFRouteCont.h"
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class RODFRouteCont;
49 class RODFDetectorFlows;
50 class ROEdge;
51 class RODFEdge;
52 class RODFDetectorCon;
53 class RODFNet;
54 struct RODFRouteDesc;
55 class OutputDevice;
56 class SUMOVTypeParameter;
57 
58 
59 // ===========================================================================
60 // enumerations
61 // ===========================================================================
69 
72 
75 
79 };
80 
81 
82 // ===========================================================================
83 // class definitions
84 // ===========================================================================
89 class RODFDetector : public Named {
90 public:
101  RODFDetector(const std::string& id, const std::string& laneID,
102  SUMOReal pos, const RODFDetectorType type);
103 
104 
112  RODFDetector(const std::string& id, const RODFDetector& f);
113 
114 
116  ~RODFDetector();
117 
118 
119 
122 
126  const std::string& getLaneID() const {
127  return myLaneID;
128  };
129 
130 
134  std::string getEdgeID() const {
135  return myLaneID.substr(0, myLaneID.rfind('_'));
136  }
137 
138 
142  SUMOReal getPos() const {
143  return myPosition;
144  };
145 
146 
152  return myType;
153  };
155 
156 
157  void setType(RODFDetectorType type);
158  void addRoute(RODFRouteDesc& nrd);
159  void addRoutes(RODFRouteCont* routes);
160  bool hasRoutes() const;
161  const std::vector<RODFRouteDesc>& getRouteVector() const;
162  void addPriorDetector(const RODFDetector* det);
163  void addFollowingDetector(const RODFDetector* det);
164  const std::set<const RODFDetector*>& getPriorDetectors() const;
165  const std::set<const RODFDetector*>& getFollowerDetectors() const;
166 
167 
170 
171  bool writeEmitterDefinition(const std::string& file,
172  const std::map<SUMOTime, RandomDistributor<int>* >& dists,
173  const RODFDetectorFlows& flows,
174  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
175  bool includeUnusedRoutes, SUMOReal scale,
176  bool insertionsOnly, SUMOReal defaultSpeed) const;
177  bool writeRoutes(std::vector<std::string>& saved,
178  OutputDevice& out);
179  void writeSingleSpeedTrigger(const std::string& file,
180  const RODFDetectorFlows& flows,
181  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
182  SUMOReal defaultSpeed);
183  void writeEndRerouterDetectors(const std::string& file);
185 
186  void buildDestinationDistribution(const RODFDetectorCon& detectors,
187  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
188  const RODFNet& net,
189  std::map<SUMOTime, RandomDistributor<int>* >& into) const;
190 
191  void computeSplitProbabilities(const RODFNet* net, const RODFDetectorCon& detectors,
192  const RODFDetectorFlows& flows,
193  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
194 
195  const std::vector<std::map<RODFEdge*, SUMOReal> >& getSplitProbabilities() const {
196  return mySplitProbabilities;
197  }
198 
199 protected:
200  int getFlowFor(const ROEdge* edge, SUMOTime time) const;
202 
203 
204 protected:
205  std::string myLaneID;
209  std::set<const RODFDetector*> myPriorDetectors, myFollowingDetectors;
210  std::vector<std::map<RODFEdge*, SUMOReal> > mySplitProbabilities;
211  std::map<std::string, RODFEdge*> myRoute2Edge;
212 
213 
214 private:
216  RODFDetector(const RODFDetector& src);
217 
219  RODFDetector& operator=(const RODFDetector& src);
220 
221 };
222 
223 
229 public:
230  RODFDetectorCon();
231  ~RODFDetectorCon();
232  bool addDetector(RODFDetector* dfd);
233  void removeDetector(const std::string& id);
234  bool detectorsHaveCompleteTypes() const;
235  bool detectorsHaveRoutes() const;
236  const std::vector<RODFDetector*>& getDetectors() const;
237  void save(const std::string& file) const;
238  void saveAsPOIs(const std::string& file) const;
239  void saveRoutes(const std::string& file) const;
240 
241  const RODFDetector& getDetector(const std::string& id) const;
242  RODFDetector& getModifiableDetector(const std::string& id) const;
243  const RODFDetector& getAnyDetectorForEdge(const RODFEdge* const edge) const;
244 
245  bool knows(const std::string& id) const;
246  void writeEmitters(const std::string& file,
247  const RODFDetectorFlows& flows,
248  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
249  const RODFNet& net,
250  bool writeCalibrators, bool includeUnusedRoutes,
251  SUMOReal scale,
252  bool insertionsOnly);
253 
254  void writeEmitterPOIs(const std::string& file,
255  const RODFDetectorFlows& flows);
256 
257  void writeSpeedTrigger(const RODFNet* const net, const std::string& file,
258  const RODFDetectorFlows& flows,
259  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
260 
261  void writeValidationDetectors(const std::string& file,
262  bool includeSources, bool singleFile, bool friendly);
263  void writeEndRerouterDetectors(const std::string& file);
264 
265  int getAggFlowFor(const ROEdge* edge, SUMOTime time, SUMOTime period,
266  const RODFDetectorFlows& flows) const;
267 
268  void guessEmptyFlows(RODFDetectorFlows& flows);
269 
270  void mesoJoin(const std::string& nid, const std::vector<std::string>& oldids);
271 
272  void setSpeedFactorAndDev(SUMOVTypeParameter& type, SUMOReal maxFactor, SUMOReal avgFactor, SUMOReal dev, bool forceDev);
273 
274 protected:
278  void clearDists(std::map<SUMOTime, RandomDistributor<int>* >& dists) const;
279 
280 
281 protected:
282  std::vector<RODFDetector*> myDetectors;
283  std::map<std::string, RODFDetector*> myDetectorMap;
284  std::map<std::string, std::vector<RODFDetector*> > myDetectorEdgeMap;
285 
286 private:
288  RODFDetectorCon(const RODFDetectorCon& src);
289 
292 
293 };
294 
295 
296 #endif
297 
298 /****************************************************************************/
299 
std::vector< RODFDetector * > myDetectors
Definition: RODFDetector.h:282
bool writeEmitterDefinition(const std::string &file, const std::map< SUMOTime, RandomDistributor< int > * > &dists, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, bool includeUnusedRoutes, SUMOReal scale, bool insertionsOnly, SUMOReal defaultSpeed) const
long long int SUMOTime
Definition: SUMOTime.h:43
void addRoute(RODFRouteDesc &nrd)
std::string getEdgeID() const
Returns the id of the edge this detector is placed on.
Definition: RODFDetector.h:134
RODFDetectorType
Numerical representation of different detector types.
Definition: RODFDetector.h:66
std::map< std::string, RODFDetector * > myDetectorMap
Definition: RODFDetector.h:283
Represents a generic random distribution.
Structure representing possible vehicle parameter.
void addRoutes(RODFRouteCont *routes)
A source detector.
Definition: RODFDetector.h:77
RODFDetector(const std::string &id, const std::string &laneID, SUMOReal pos, const RODFDetectorType type)
Constructor.
void writeEndRerouterDetectors(const std::string &file)
void addPriorDetector(const RODFDetector *det)
RODFDetectorType getType() const
Returns the type of the detector.
Definition: RODFDetector.h:151
const std::vector< RODFRouteDesc > & getRouteVector() const
A container for flows.
A container for RODFDetectors.
Definition: RODFDetector.h:228
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:208
A not yet defined detector.
Definition: RODFDetector.h:68
std::map< std::string, std::vector< RODFDetector * > > myDetectorEdgeMap
Definition: RODFDetector.h:284
bool hasRoutes() const
SUMOReal myPosition
Definition: RODFDetector.h:206
bool writeRoutes(std::vector< std::string > &saved, OutputDevice &out)
An in-between detector.
Definition: RODFDetector.h:74
SUMOReal getPos() const
Returns the position at which the detector lies.
Definition: RODFDetector.h:142
const std::set< const RODFDetector * > & getPriorDetectors() const
RODFDetector & operator=(const RODFDetector &src)
Invalidated assignment operator.
A detector which had to be discarded (!!!)
Definition: RODFDetector.h:71
A DFROUTER-network.
Definition: RODFNet.h:52
~RODFDetector()
Destructor.
std::string myLaneID
Definition: RODFDetector.h:205
void writeSingleSpeedTrigger(const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, SUMOReal defaultSpeed)
A route within the DFROUTER.
Definition: RODFRouteDesc.h:54
A basic edge for routing applications.
Definition: ROEdge.h:77
std::vector< std::map< RODFEdge *, SUMOReal > > mySplitProbabilities
Definition: RODFDetector.h:210
Base class for objects which have an id.
Definition: Named.h:46
SUMOReal computeDistanceFactor(const RODFRouteDesc &rd) const
const std::string & getLaneID() const
Returns the id of the lane this detector is placed on.
Definition: RODFDetector.h:126
const std::vector< std::map< RODFEdge *, SUMOReal > > & getSplitProbabilities() const
Definition: RODFDetector.h:195
RODFDetectorType myType
Definition: RODFDetector.h:207
std::map< std::string, RODFEdge * > myRoute2Edge
Definition: RODFDetector.h:211
Class representing a detector within the DFROUTER.
Definition: RODFDetector.h:89
A container for DFROUTER-routes.
Definition: RODFRouteCont.h:63
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:209
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:213
std::set< const RODFDetector * > myFollowingDetectors
Definition: RODFDetector.h:209
int getFlowFor(const ROEdge *edge, SUMOTime time) const
void addFollowingDetector(const RODFDetector *det)