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