00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef RODFDetector_h
00020 #define RODFDetector_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <map>
00033 #include <string>
00034 #include <vector>
00035 #include <map>
00036 #include <utils/common/SUMOTime.h>
00037 #include <utils/common/RandomDistributor.h>
00038 #include "RODFRouteCont.h"
00039
00040
00041
00042
00043
00044 class RODFRouteCont;
00045 class RODFDetectorFlows;
00046 class ROEdge;
00047 class RODFEdge;
00048 class RODFDetectorCon;
00049 class RODFNet;
00050 struct RODFRouteDesc;
00051 class OutputDevice;
00052
00053
00054
00055
00056
00061 enum RODFDetectorType {
00063 TYPE_NOT_DEFINED = 0,
00064
00066 DISCARDED_DETECTOR,
00067
00069 BETWEEN_DETECTOR,
00070
00072 SOURCE_DETECTOR,
00073 SINK_DETECTOR
00074 };
00075
00076
00077
00078
00079
00084 class RODFDetector {
00085 public:
00096 RODFDetector(const std::string &id, const std::string &laneID,
00097 SUMOReal pos, const RODFDetectorType type) throw();
00098
00099
00107 RODFDetector(const std::string &id, const RODFDetector &f) throw();
00108
00109
00111 ~RODFDetector() throw();
00112
00113
00114
00117
00121 const std::string &getID() const throw() {
00122 return myID;
00123 };
00124
00125
00129 const std::string &getLaneID() const throw() {
00130 return myLaneID;
00131 };
00132
00133
00137 std::string getEdgeID() const throw() {
00138 return myLaneID.substr(0, myLaneID.rfind('_'));
00139 }
00140
00141
00145 SUMOReal getPos() const throw() {
00146 return myPosition;
00147 };
00148
00149
00154 RODFDetectorType getType() const throw() {
00155 return myType;
00156 };
00158
00159
00160 void setType(RODFDetectorType type);
00161 void addRoute(RODFRouteDesc &nrd);
00162 void addRoutes(RODFRouteCont *routes);
00163 bool hasRoutes() const;
00164 const std::vector<RODFRouteDesc> &getRouteVector() const;
00165 void addPriorDetector(RODFDetector *det);
00166 void addFollowingDetector(RODFDetector *det);
00167 const std::vector<RODFDetector*> &getPriorDetectors() const;
00168 const std::vector<RODFDetector*> &getFollowerDetectors() const;
00169
00170
00173
00174 bool writeEmitterDefinition(const std::string &file,
00175 const std::map<size_t, RandomDistributor<size_t>* > &dists,
00176 const RODFDetectorFlows &flows,
00177 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
00178 bool includeUnusedRoutes, SUMOReal scale,
00179 bool emissionsOnly, SUMOReal defaultSpeed) const;
00180 bool writeRoutes(std::vector<std::string> &saved,
00181 OutputDevice& out);
00182 void writeSingleSpeedTrigger(const std::string &file,
00183 const RODFDetectorFlows &flows,
00184 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
00185 SUMOReal defaultSpeed);
00186 void writeEndRerouterDetectors(const std::string &file);
00188
00189 void buildDestinationDistribution(const RODFDetectorCon &detectors,
00190 const RODFDetectorFlows &flows,
00191 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
00192 const RODFNet &net,
00193 std::map<size_t, RandomDistributor<size_t>* > &into,
00194 int maxFollower) const;
00195
00196 void computeSplitProbabilities(const RODFNet *net, const RODFDetectorCon &detectors,
00197 const RODFDetectorFlows &flows,
00198 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
00199
00200 const std::vector<std::map<RODFEdge*, SUMOReal> > &getSplitProbabilities() const {
00201 return mySplitProbabilities;
00202 }
00203
00204 protected:
00205 int getFlowFor(const ROEdge *edge, SUMOTime time) const;
00206 SUMOReal computeDistanceFactor(const RODFRouteDesc &rd) const;
00207
00208
00209 protected:
00210 std::string myID;
00211 std::string myLaneID;
00212 SUMOReal myPosition;
00213 RODFDetectorType myType;
00214 RODFRouteCont *myRoutes;
00215 std::vector<RODFDetector*> myPriorDetectors, myFollowingDetectors;
00216 std::vector<std::map<RODFEdge*, SUMOReal> > mySplitProbabilities;
00217 std::map<std::string, RODFEdge*> myRoute2Edge;
00218
00219
00220 private:
00222 RODFDetector(const RODFDetector &src);
00223
00225 RODFDetector &operator=(const RODFDetector &src);
00226
00227 };
00228
00229
00234 class RODFDetectorCon {
00235 public:
00236 RODFDetectorCon();
00237 ~RODFDetectorCon();
00238 bool addDetector(RODFDetector *dfd);
00239 void removeDetector(const std::string &id);
00240 bool detectorsHaveCompleteTypes() const;
00241 bool detectorsHaveRoutes() const;
00242 const std::vector<RODFDetector*> &getDetectors() const;
00243 void save(const std::string &file) const;
00244 void saveAsPOIs(const std::string &file) const;
00245 void saveRoutes(const std::string &file) const;
00246
00247 const RODFDetector &getDetector(const std::string &id) const;
00248 const RODFDetector &getAnyDetectorForEdge(const RODFEdge * const edge) const;
00249
00250 bool knows(const std::string &id) const;
00251 void writeEmitters(const std::string &file,
00252 const RODFDetectorFlows &flows,
00253 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
00254 const RODFNet &net,
00255 bool writeCalibrators, bool includeUnusedRoutes,
00256 SUMOReal scale, int maxFollower,
00257 bool emissionsOnly);
00258
00259 void writeEmitterPOIs(const std::string &file,
00260 const RODFDetectorFlows &flows,
00261 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
00262
00263 void writeSpeedTrigger(const RODFNet * const net, const std::string &file,
00264 const RODFDetectorFlows &flows,
00265 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset);
00266
00267 void writeValidationDetectors(const std::string &file,
00268 bool includeSources, bool singleFile, bool friendly);
00269 void writeEndRerouterDetectors(const std::string &file);
00270
00271 int getFlowFor(const ROEdge *edge, SUMOTime time,
00272 const RODFDetectorFlows &flows) const;
00273
00274 int getAggFlowFor(const ROEdge *edge, SUMOTime time, SUMOTime period,
00275 const RODFDetectorFlows &flows) const;
00276
00277 void guessEmptyFlows(RODFDetectorFlows &flows);
00278
00279 void mesoJoin(const std::string &nid, const std::vector<std::string> &oldids);
00280
00281
00282 protected:
00286 void clearDists(std::map<size_t, RandomDistributor<size_t>* > &dists) const throw();
00287
00288
00289 protected:
00290 std::vector<RODFDetector*> myDetectors;
00291 std::map<std::string, RODFDetector*> myDetectorMap;
00292 std::map<std::string, std::vector<RODFDetector*> > myDetectorEdgeMap;
00293
00294 private:
00296 RODFDetectorCon(const RODFDetectorCon &src);
00297
00299 RODFDetectorCon &operator=(const RODFDetectorCon &src);
00300
00301 };
00302
00303
00304 #endif
00305
00306
00307