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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Class representing a detector within the DFROUTER
20 /****************************************************************************/
21 #ifndef RODFDetector_h
22 #define RODFDetector_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <map>
35 #include <string>
36 #include <vector>
37 #include <set>
38 #include <utils/common/SUMOTime.h>
40 #include <utils/common/Named.h>
41 #include "RODFRouteCont.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class RODFRouteCont;
48 class RODFDetectorFlows;
49 class ROEdge;
50 class RODFEdge;
51 class RODFDetectorCon;
52 class RODFNet;
53 struct RODFRouteDesc;
54 class OutputDevice;
55 class SUMOVTypeParameter;
56 
57 
58 // ===========================================================================
59 // enumerations
60 // ===========================================================================
68 
71 
74 
78 };
79 
80 
81 // ===========================================================================
82 // class definitions
83 // ===========================================================================
88 class RODFDetector : public Named {
89 public:
100  RODFDetector(const std::string& id, const std::string& laneID,
101  double pos, const RODFDetectorType type);
102 
103 
111  RODFDetector(const std::string& id, const RODFDetector& f);
112 
113 
115  ~RODFDetector();
116 
117 
118 
121 
125  const std::string& getLaneID() const {
126  return myLaneID;
127  };
128 
129 
133  std::string getEdgeID() const {
134  return myLaneID.substr(0, myLaneID.rfind('_'));
135  }
136 
137 
141  double getPos() const {
142  return myPosition;
143  };
144 
145 
151  return myType;
152  };
154 
155 
156  void setType(RODFDetectorType type);
157  void addRoute(RODFRouteDesc& nrd);
158  void addRoutes(RODFRouteCont* routes);
159  bool hasRoutes() const;
160  const std::vector<RODFRouteDesc>& getRouteVector() const;
161  void addPriorDetector(const RODFDetector* det);
162  void addFollowingDetector(const RODFDetector* det);
163  const std::set<const RODFDetector*>& getPriorDetectors() const;
164  const std::set<const RODFDetector*>& getFollowerDetectors() const;
165 
166 
169 
170  bool writeEmitterDefinition(const std::string& file,
171  const std::map<SUMOTime, RandomDistributor<int>* >& dists,
172  const RODFDetectorFlows& flows,
173  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
174  bool includeUnusedRoutes, double scale,
175  bool insertionsOnly, double defaultSpeed) const;
176  bool writeRoutes(std::vector<std::string>& saved,
177  OutputDevice& out);
178  void writeSingleSpeedTrigger(const std::string& file,
179  const RODFDetectorFlows& flows,
180  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
181  double defaultSpeed);
182  void writeEndRerouterDetectors(const std::string& file);
184 
185  void buildDestinationDistribution(const RODFDetectorCon& detectors,
186  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
187  const RODFNet& net,
188  std::map<SUMOTime, RandomDistributor<int>* >& into) const;
189 
190  void computeSplitProbabilities(const RODFNet* net, const RODFDetectorCon& detectors,
191  const RODFDetectorFlows& flows,
192  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
193 
194  const std::vector<std::map<RODFEdge*, double> >& getSplitProbabilities() const {
195  return mySplitProbabilities;
196  }
197 
198 protected:
199  int getFlowFor(const ROEdge* edge, SUMOTime time) const;
200  double computeDistanceFactor(const RODFRouteDesc& rd) const;
201 
202 
203 protected:
204  std::string myLaneID;
205  double myPosition;
208  std::set<const RODFDetector*> myPriorDetectors, myFollowingDetectors;
209  std::vector<std::map<RODFEdge*, double> > mySplitProbabilities;
210  std::map<std::string, RODFEdge*> myRoute2Edge;
211 
212 
213 private:
215  RODFDetector(const RODFDetector& src);
216 
218  RODFDetector& operator=(const RODFDetector& src);
219 
220 };
221 
222 
228 public:
229  RODFDetectorCon();
230  ~RODFDetectorCon();
231  bool addDetector(RODFDetector* dfd);
232  void removeDetector(const std::string& id);
233  bool detectorsHaveCompleteTypes() const;
234  bool detectorsHaveRoutes() const;
235  const std::vector<RODFDetector*>& getDetectors() const;
236  void save(const std::string& file) const;
237  void saveAsPOIs(const std::string& file) const;
238  void saveRoutes(const std::string& file) const;
239 
240  const RODFDetector& getDetector(const std::string& id) const;
241  RODFDetector& getModifiableDetector(const std::string& id) const;
242  const RODFDetector& getAnyDetectorForEdge(const RODFEdge* const edge) const;
243 
244  bool knows(const std::string& id) const;
245  void writeEmitters(const std::string& file,
246  const RODFDetectorFlows& flows,
247  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
248  const RODFNet& net,
249  bool writeCalibrators, bool includeUnusedRoutes,
250  double scale,
251  bool insertionsOnly);
252 
253  void writeEmitterPOIs(const std::string& file,
254  const RODFDetectorFlows& flows);
255 
256  void writeSpeedTrigger(const RODFNet* const net, const std::string& file,
257  const RODFDetectorFlows& flows,
258  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
259 
260  void writeValidationDetectors(const std::string& file,
261  bool includeSources, bool singleFile, bool friendly);
262  void writeEndRerouterDetectors(const std::string& file);
263 
264  int getAggFlowFor(const ROEdge* edge, SUMOTime time, SUMOTime period,
265  const RODFDetectorFlows& flows) const;
266 
267  void guessEmptyFlows(RODFDetectorFlows& flows);
268 
269  void mesoJoin(const std::string& nid, const std::vector<std::string>& oldids);
270 
271  void setSpeedFactorAndDev(SUMOVTypeParameter& type, double maxFactor, double avgFactor, double dev, bool forceDev);
272 
273 protected:
277  void clearDists(std::map<SUMOTime, RandomDistributor<int>* >& dists) const;
278 
279 
280 protected:
281  std::vector<RODFDetector*> myDetectors;
282  std::map<std::string, RODFDetector*> myDetectorMap;
283  std::map<std::string, std::vector<RODFDetector*> > myDetectorEdgeMap;
284 
285 private:
287  RODFDetectorCon(const RODFDetectorCon& src);
288 
291 
292 };
293 
294 
295 #endif
296 
297 /****************************************************************************/
298 
std::vector< RODFDetector * > myDetectors
Definition: RODFDetector.h:281
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:133
RODFDetectorType
Numerical representation of different detector types.
Definition: RODFDetector.h:65
std::map< std::string, RODFDetector * > myDetectorMap
Definition: RODFDetector.h:282
Structure representing possible vehicle parameter.
void addRoutes(RODFRouteCont *routes)
A source detector.
Definition: RODFDetector.h:76
void writeEndRerouterDetectors(const std::string &file)
void addPriorDetector(const RODFDetector *det)
RODFDetectorType getType() const
Returns the type of the detector.
Definition: RODFDetector.h:150
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:227
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:207
A not yet defined detector.
Definition: RODFDetector.h:67
std::map< std::string, std::vector< RODFDetector * > > myDetectorEdgeMap
Definition: RODFDetector.h:283
bool hasRoutes() const
bool writeRoutes(std::vector< std::string > &saved, OutputDevice &out)
std::vector< std::map< RODFEdge *, double > > mySplitProbabilities
Definition: RODFDetector.h:209
An in-between detector.
Definition: RODFDetector.h:73
const std::vector< std::map< RODFEdge *, double > > & getSplitProbabilities() const
Definition: RODFDetector.h:194
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:70
A DFROUTER-network.
Definition: RODFNet.h:51
~RODFDetector()
Destructor.
std::string myLaneID
Definition: RODFDetector.h:204
A route within the DFROUTER.
Definition: RODFRouteDesc.h:53
A basic edge for routing applications.
Definition: ROEdge.h:77
Base class for objects which have an id.
Definition: Named.h:54
const std::string & getLaneID() const
Returns the id of the lane this detector is placed on.
Definition: RODFDetector.h:125
void writeSingleSpeedTrigger(const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, double defaultSpeed)
RODFDetectorType myType
Definition: RODFDetector.h:206
std::map< std::string, RODFEdge * > myRoute2Edge
Definition: RODFDetector.h:210
Class representing a detector within the DFROUTER.
Definition: RODFDetector.h:88
A container for DFROUTER-routes.
Definition: RODFRouteCont.h:62
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:208
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
long long int SUMOTime
Definition: TraCIDefs.h:51
std::set< const RODFDetector * > myFollowingDetectors
Definition: RODFDetector.h:208
double myPosition
Definition: RODFDetector.h:205
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:141