|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A traffic light logics which must be computed (only nodes/edges are given) 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 NBOwnTLDef_h 00020 #define NBOwnTLDef_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 <vector> 00033 #include <set> 00034 #include <utils/xml/SUMOXMLDefinitions.h> 00035 #include "NBTrafficLightDefinition.h" 00036 00037 00038 // =========================================================================== 00039 // class declarations 00040 // =========================================================================== 00041 class NBNode; 00042 00043 00044 // =========================================================================== 00045 // class definitions 00046 // =========================================================================== 00051 class NBOwnTLDef : public NBTrafficLightDefinition { 00052 public: 00057 NBOwnTLDef(const std::string& id, 00058 const std::vector<NBNode*> &junctions) throw(); 00059 00060 00065 NBOwnTLDef(const std::string& id, NBNode* junction) throw(); 00066 00067 00071 NBOwnTLDef(const std::string& id) throw(); 00072 00073 00075 ~NBOwnTLDef() throw(); 00076 00077 00081 void setParticipantsInformation() throw(); 00082 00083 00086 00093 void remapRemoved(NBEdge* removed, 00094 const EdgeVector& incoming, const EdgeVector& outgoing) throw(); 00095 00096 00101 void setTLControllingInformation(const NBEdgeCont& ec) const throw(); 00103 00104 00105 protected: 00108 00115 NBTrafficLightLogic* myCompute(const NBEdgeCont& ec, 00116 unsigned int brakingTimeSeconds) throw(); 00117 00118 00122 void collectNodes() throw(); 00123 00124 00129 void collectLinks() throw(ProcessError); 00130 00131 00139 void replaceRemoved(NBEdge* removed, int removedLane, 00140 NBEdge* by, int byLane) throw(); 00142 00143 00144 protected: 00150 SUMOReal getDirectionalWeight(LinkDirection dir) throw(); 00151 00152 00157 int getToPrio(const NBEdge* const e) throw(); 00158 00159 00165 SUMOReal computeUnblockedWeightedStreamNumber(const NBEdge* const e1, const NBEdge* const e2) throw(); 00166 00167 00172 std::pair<NBEdge*, NBEdge*> getBestCombination(const EdgeVector& edges) throw(); 00173 00174 00182 std::pair<NBEdge*, NBEdge*> getBestPair(EdgeVector& incoming) throw(); 00183 00184 00188 class edge_by_incoming_priority_sorter { 00189 public: 00194 int operator()(const NBEdge* const e1, const NBEdge* const e2) const { 00195 if (e1->getJunctionPriority(e1->getToNode())!=e2->getJunctionPriority(e2->getToNode())) { 00196 return e1->getJunctionPriority(e1->getToNode())> e2->getJunctionPriority(e2->getToNode()); 00197 } 00198 return e1->getID() > e2->getID(); 00199 } 00200 }; 00201 00202 }; 00203 00204 00205 #endif 00206 00207 /****************************************************************************/ 00208