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