SUMO - Simulation of Urban MObility
NBOwnTLDef.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // A traffic light logics which must be computed (only nodes/edges are given)
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 NBOwnTLDef_h
00023 #define NBOwnTLDef_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 <vector>
00036 #include <set>
00037 #include <utils/xml/SUMOXMLDefinitions.h>
00038 #include "NBTrafficLightDefinition.h"
00039 
00040 
00041 // ===========================================================================
00042 // class declarations
00043 // ===========================================================================
00044 class NBNode;
00045 
00046 
00047 // ===========================================================================
00048 // class definitions
00049 // ===========================================================================
00054 class NBOwnTLDef : public NBTrafficLightDefinition {
00055 public:
00060     NBOwnTLDef(const std::string& id,
00061                const std::vector<NBNode*> &junctions) ;
00062 
00063 
00068     NBOwnTLDef(const std::string& id, NBNode* junction) ;
00069 
00070 
00074     NBOwnTLDef(const std::string& id) ;
00075 
00076 
00078     ~NBOwnTLDef() ;
00079 
00080 
00084     void setParticipantsInformation() ;
00085 
00086 
00089 
00096     void remapRemoved(NBEdge* removed,
00097                       const EdgeVector& incoming, const EdgeVector& outgoing) ;
00098 
00099 
00104     void setTLControllingInformation(const NBEdgeCont& ec) const ;
00106 
00107 
00108 protected:
00111 
00118     NBTrafficLightLogic* myCompute(const NBEdgeCont& ec,
00119                                    unsigned int brakingTimeSeconds) ;
00120 
00121 
00125     void collectNodes() ;
00126 
00127 
00132     void collectLinks() ;
00133 
00134 
00142     void replaceRemoved(NBEdge* removed, int removedLane,
00143                         NBEdge* by, int byLane) ;
00145 
00146 
00147 protected:
00153     SUMOReal getDirectionalWeight(LinkDirection dir) ;
00154 
00155 
00160     int getToPrio(const NBEdge* const e) ;
00161 
00162 
00168     SUMOReal computeUnblockedWeightedStreamNumber(const NBEdge* const e1, const NBEdge* const e2) ;
00169 
00170 
00175     std::pair<NBEdge*, NBEdge*> getBestCombination(const EdgeVector& edges) ;
00176 
00177 
00185     std::pair<NBEdge*, NBEdge*> getBestPair(EdgeVector& incoming) ;
00186 
00187 
00191     class edge_by_incoming_priority_sorter {
00192     public:
00197         int operator()(const NBEdge* const e1, const NBEdge* const e2) const {
00198             if (e1->getJunctionPriority(e1->getToNode()) != e2->getJunctionPriority(e2->getToNode())) {
00199                 return e1->getJunctionPriority(e1->getToNode()) > e2->getJunctionPriority(e2->getToNode());
00200             }
00201             return e1->getID() > e2->getID();
00202         }
00203     };
00204 
00205 };
00206 
00207 
00208 #endif
00209 
00210 /****************************************************************************/
00211 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines