|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A DFROUTER-network 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef RODFNet_h 00020 #define RODFNet_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <router/RONet.h> 00033 #include <utils/options/OptionsCont.h> 00034 #include "RODFDetector.h" 00035 #include "RODFRouteDesc.h" 00036 #include "RODFRouteCont.h" 00037 #include <utils/common/StdDefs.h> 00038 #include <utils/common/SUMOTime.h> 00039 00040 00041 // =========================================================================== 00042 // class definitions 00043 // =========================================================================== 00048 class RODFNet : public RONet { 00049 public: 00053 RODFNet(bool amInHighwayMode) throw(); 00054 00055 00057 ~RODFNet() throw(); 00058 00059 00060 void buildApproachList(); 00061 00062 void computeTypes(RODFDetectorCon& dets, 00063 bool sourcesStrict) const; 00064 void buildRoutes(RODFDetectorCon& det, bool allEndFollower, 00065 bool keepUnfoundEnds, bool includeInBetween, 00066 bool keepShortestOnly, int maxFollowingLength) const; 00067 SUMOReal getAbsPos(const RODFDetector& det) const; 00068 00069 void buildEdgeFlowMap(const RODFDetectorFlows& flows, 00070 const RODFDetectorCon& detectors, 00071 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset); 00072 00073 void revalidateFlows(const RODFDetectorCon& detectors, 00074 RODFDetectorFlows& flows, 00075 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset); 00076 00077 00078 void removeEmptyDetectors(RODFDetectorCon& detectors, 00079 RODFDetectorFlows& flows); 00080 00081 void reportEmptyDetectors(RODFDetectorCon& detectors, 00082 RODFDetectorFlows& flows); 00083 00084 void buildDetectorDependencies(RODFDetectorCon& detectors); 00085 00086 void mesoJoin(RODFDetectorCon& detectors, RODFDetectorFlows& flows); 00087 00088 bool hasDetector(ROEdge* edge) const; 00089 const std::vector<std::string> &getDetectorList(ROEdge* edge) const; 00090 00091 00092 protected: 00093 void revalidateFlows(const RODFDetector* detector, 00094 RODFDetectorFlows& flows, 00095 SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset); 00096 bool isSource(const RODFDetector& det, 00097 const RODFDetectorCon& detectors, bool strict) const; 00098 bool isFalseSource(const RODFDetector& det, 00099 const RODFDetectorCon& detectors) const; 00100 bool isDestination(const RODFDetector& det, 00101 const RODFDetectorCon& detectors) const; 00102 00103 ROEdge* getDetectorEdge(const RODFDetector& det) const; 00104 bool isSource(const RODFDetector& det, ROEdge* edge, 00105 std::vector<ROEdge*> &seen, const RODFDetectorCon& detectors, 00106 bool strict) const; 00107 bool isFalseSource(const RODFDetector& det, ROEdge* edge, 00108 std::vector<ROEdge*> &seen, const RODFDetectorCon& detectors) const; 00109 bool isDestination(const RODFDetector& det, ROEdge* edge, std::vector<ROEdge*> &seen, 00110 const RODFDetectorCon& detectors) const; 00111 00112 void computeRoutesFor(ROEdge* edge, RODFRouteDesc& base, int no, 00113 bool keepUnfoundEnds, 00114 bool keepShortestOnly, 00115 std::vector<ROEdge*> &visited, const RODFDetector& det, 00116 RODFRouteCont& into, const RODFDetectorCon& detectors, 00117 int maxFollowingLength, 00118 std::vector<ROEdge*> &seen) const; 00119 00120 void buildDetectorEdgeDependencies(RODFDetectorCon& dets) const; 00121 00122 bool hasApproaching(ROEdge* edge) const; 00123 bool hasApproached(ROEdge* edge) const; 00124 00125 bool hasInBetweenDetectorsOnly(ROEdge* edge, 00126 const RODFDetectorCon& detectors) const; 00127 bool hasSourceDetector(ROEdge* edge, 00128 const RODFDetectorCon& detectors) const; 00129 00130 struct IterationEdge { 00131 int depth; 00132 ROEdge* edge; 00133 }; 00134 00135 protected: 00136 class DFRouteDescByTimeComperator { 00137 public: 00139 explicit DFRouteDescByTimeComperator() { } 00140 00142 ~DFRouteDescByTimeComperator() { } 00143 00145 bool operator()(const RODFRouteDesc& nod1, const RODFRouteDesc& nod2) const { 00146 return nod1.duration_2>nod2.duration_2; 00147 } 00148 }; 00149 00150 private: 00152 std::map<ROEdge*, std::vector<ROEdge*> > myApproachingEdges; 00153 00155 std::map<ROEdge*, std::vector<ROEdge*> > myApproachedEdges; 00156 00157 mutable std::map<ROEdge*, std::vector<std::string> > myDetectorsOnEdges; 00158 mutable std::map<std::string, ROEdge*> myDetectorEdges; 00159 00160 bool myAmInHighwayMode; 00161 mutable size_t mySourceNumber, mySinkNumber, myInBetweenNumber, myInvalidNumber; 00162 00164 std::vector<std::string> myDisallowedEdges; 00165 00166 00167 bool myKeepTurnarounds; 00168 00169 }; 00170 00171 00172 #endif 00173 00174 /****************************************************************************/ 00175