|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // Computes routes using junction turning percentages 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 00023 00024 // =========================================================================== 00025 // included modules 00026 // =========================================================================== 00027 #ifdef _MSC_VER 00028 #include <windows_config.h> 00029 #else 00030 #include <config.h> 00031 #endif 00032 00033 #include <router/RONet.h> 00034 #include "ROJTRRouter.h" 00035 #include "ROJTREdge.h" 00036 #include <utils/common/MsgHandler.h> 00037 00038 #ifdef CHECK_MEMORY_LEAKS 00039 #include <foreign/nvwa/debug_new.h> 00040 #endif // CHECK_MEMORY_LEAKS 00041 00042 00043 // =========================================================================== 00044 // method definitions 00045 // =========================================================================== 00046 ROJTRRouter::ROJTRRouter(RONet& net, bool unbuildIsWarningOnly, bool acceptAllDestinations, 00047 int maxEdges, bool ignoreClasses, bool allowLoops) 00048 : myNet(net), myUnbuildIsWarningOnly(unbuildIsWarningOnly), 00049 myAcceptAllDestination(acceptAllDestinations), myMaxEdges(maxEdges), 00050 myIgnoreClasses(ignoreClasses), myAllowLoops(allowLoops) { 00051 } 00052 00053 00054 ROJTRRouter::~ROJTRRouter() {} 00055 00056 00057 void 00058 ROJTRRouter::compute(const ROEdge* from, const ROEdge* /*to*/, 00059 const ROVehicle* const vehicle, 00060 SUMOTime time, std::vector<const ROEdge*> &into) { 00061 const ROJTREdge* current = static_cast<const ROJTREdge*>(from); 00062 // route until a sinks has been found 00063 while (current != 0 00064 && 00065 current->getType() != ROEdge::ET_SINK 00066 && 00067 (int) into.size() < myMaxEdges) { 00068 00069 into.push_back(current); 00070 time += (SUMOTime) current->getTravelTime(vehicle, time); 00071 current = current->chooseNext(myIgnoreClasses ? 0 : vehicle, time); 00072 assert(myIgnoreClasses || current == 0 || !current->prohibits(vehicle)); 00073 } 00074 // check whether no valid ending edge was found 00075 if ((int) into.size() >= myMaxEdges) { 00076 if (myAcceptAllDestination) { 00077 return; 00078 } else { 00079 MsgHandler* mh = 0; 00080 if (myUnbuildIsWarningOnly) { 00081 mh = MsgHandler::getWarningInstance(); 00082 } else { 00083 mh = MsgHandler::getErrorInstance(); 00084 } 00085 mh->inform("The route starting at edge '" + from->getID() + "' could not be closed."); 00086 } 00087 } 00088 // append the sink 00089 if (current != 0) { 00090 into.push_back(current); 00091 } 00092 } 00093 00094 00095 SUMOReal 00096 ROJTRRouter::recomputeCosts(const std::vector<const ROEdge*> &edges, const ROVehicle* const v, SUMOTime time) const { 00097 SUMOReal costs = 0; 00098 for (std::vector<const ROEdge*>::const_iterator i = edges.begin(); i != edges.end(); i++) { 00099 /* 00100 if (PF::operator()(*i, v)) { 00101 return -1; 00102 } 00103 */ 00104 costs += (*i)->getTravelTime(v, time); 00105 } 00106 return costs; 00107 } 00108 00109 00110 00111 /****************************************************************************/ 00112