#include <RODFNet.h>

Definition at line 48 of file RODFNet.h.
Public Member Functions | |
| void | buildApproachList () |
| void | buildDetectorDependencies (RODFDetectorCon &detectors) |
| void | buildEdgeFlowMap (const RODFDetectorFlows &flows, const RODFDetectorCon &detectors, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset) |
| void | buildRoutes (RODFDetectorCon &det, bool allEndFollower, bool keepUnfoundEnds, bool includeInBetween, bool keepShortestOnly, int maxFollowingLength) const |
| void | closeOutput () throw () |
| closes the file output for computed routes | |
| void | computeTypes (RODFDetectorCon &dets, bool sourcesStrict) const |
| SUMOReal | getAbsPos (const RODFDetector &det) const |
| const std::vector< std::string > & | getDetectorList (ROEdge *edge) const |
| const std::map< std::string, ROEdge * > & | getEdgeMap () const |
| unsigned int | getEdgeNo () const |
| Returns the number of edges thenetwork contains. | |
| const ROEdge * | getRandomDestination () const throw () |
| Returns a random edge which may be used as an ending point. | |
| ROEdge * | getRandomDestination () throw () |
| Returns a random edge which may be used as an ending point. | |
| const ROEdge * | getRandomSource () const throw () |
| Returns a random edge which may be used as a starting point. | |
| ROEdge * | getRandomSource () throw () |
| Returns a random edge which may be used as a starting point. | |
| bool | hasDetector (ROEdge *edge) const |
| bool | hasRestrictions () const |
| void | mesoJoin (RODFDetectorCon &detectors, RODFDetectorFlows &flows) |
| void | openOutput (const std::string &filename, bool useAlternatives) throw (IOError) |
| Opens the output for computed routes. | |
| void | removeEmptyDetectors (RODFDetectorCon &detectors, RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset) |
| void | reportEmptyDetectors (RODFDetectorCon &detectors, RODFDetectorFlows &flows) |
| void | revalidateFlows (const RODFDetectorCon &detectors, RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset) |
| RODFNet (bool amInHighwayMode) throw () | |
| Constructor. | |
| void | setRestrictionFound () |
| ~RODFNet () throw () | |
| Destructor. | |
Insertion and retrieval of graph parts | |
| virtual void | addEdge (ROEdge *edge) throw () |
| void | addNode (RONode *node) throw () |
| ROEdge * | getEdge (const std::string &name) const throw () |
| Retrieves an edge from the network. | |
| RONode * | getNode (const std::string &id) const throw () |
| Retrieves an node from the network. | |
Insertion and retrieval of vehicle types, vehicles, routes, and route definitions | |
| bool | addRouteDef (RORouteDef *def) throw () |
| virtual bool | addVehicle (const std::string &id, ROVehicle *veh) throw () |
| virtual bool | addVehicleType (SUMOVTypeParameter *type) throw () |
| RORouteDef * | getRouteDef (const std::string &name) const throw () |
| Returns the named route definition. | |
| SUMOVTypeParameter * | getVehicleTypeSecure (const std::string &id) throw () |
| Retrieves the named vehicle type. | |
Processing stored vehicle definitions | |
| virtual bool | furtherStored () |
| Returns the information whether further vehicles are stored. | |
| SUMOTime | saveAndRemoveRoutesUntil (OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime time) |
| Computes routes described by their definitions and saves them. | |
Protected Member Functions | |
| void | buildDetectorEdgeDependencies (RODFDetectorCon &dets) const |
| void | checkSourceAndDestinations () const |
| Initialises the lists of source and destination edges. | |
| bool | computeRoute (OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const veh) |
| void | computeRoutesFor (ROEdge *edge, RODFRouteDesc &base, int no, bool keepUnfoundEnds, bool keepShortestOnly, std::vector< ROEdge * > &visited, const RODFDetector &det, RODFRouteCont &into, const RODFDetectorCon &detectors, int maxFollowingLength, std::vector< ROEdge * > &seen) const |
| ROEdge * | getDetectorEdge (const RODFDetector &det) const |
| bool | hasApproached (ROEdge *edge) const |
| bool | hasApproaching (ROEdge *edge) const |
| bool | hasInBetweenDetectorsOnly (ROEdge *edge, const RODFDetectorCon &detectors) const |
| bool | hasSourceDetector (ROEdge *edge, const RODFDetectorCon &detectors) const |
| bool | isDestination (const RODFDetector &det, ROEdge *edge, std::vector< ROEdge * > &seen, const RODFDetectorCon &detectors) const |
| bool | isDestination (const RODFDetector &det, const RODFDetectorCon &detectors) const |
| bool | isFalseSource (const RODFDetector &det, ROEdge *edge, std::vector< ROEdge * > &seen, const RODFDetectorCon &detectors) const |
| bool | isFalseSource (const RODFDetector &det, const RODFDetectorCon &detectors) const |
| bool | isSource (const RODFDetector &det, ROEdge *edge, std::vector< ROEdge * > &seen, const RODFDetectorCon &detectors, bool strict) const |
| bool | isSource (const RODFDetector &det, const RODFDetectorCon &detectors, bool strict) const |
| void | revalidateFlows (const RODFDetector *detector, RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset) |
Protected Attributes | |
| std::vector< ROEdge * > | myDestinationEdges |
| List of destination edges. | |
| unsigned int | myDiscardedRouteNo |
| The number of discarded routes. | |
| NamedObjectCont< ROEdge * > | myEdges |
| Known edges. | |
| bool | myHaveRestrictions |
| Whether the network contains edges which not all vehicles may pass. | |
| NamedObjectCont< RONode * > | myNodes |
| Known nodes. | |
| unsigned int | myReadRouteNo |
| The number of read routes. | |
| OutputDevice * | myRouteAlternativesOutput |
| The file to write the computed route alternatives into. | |
| NamedObjectCont< RORouteDef * > | myRoutes |
| Known routes. | |
| OutputDevice * | myRoutesOutput |
| The file to write the computed routes into. | |
| std::vector< ROEdge * > | mySourceEdges |
| List of source edges. | |
| ROVehicleCont | myVehicles |
| Known vehicles. | |
| NamedObjectCont < SUMOVTypeParameter * > | myVehicleTypes |
| Known vehicle types. | |
| std::set< std::string > | myVehIDs |
| Known vehicle ids. | |
| unsigned int | myWrittenRouteNo |
| The number of written routes. | |
Private Attributes | |
| bool | myAmInHighwayMode |
| std::map< ROEdge *, std::vector< ROEdge * > > | myApproachedEdges |
| Map of edge name->list of names of edges approached by this edge. | |
| std::map< ROEdge *, std::vector< ROEdge * > > | myApproachingEdges |
| Map of edge name->list of names of this edge approaching edges. | |
| std::map< std::string, ROEdge * > | myDetectorEdges |
| std::map< ROEdge *, std::vector< std::string > > | myDetectorsOnEdges |
| std::vector< std::string > | myDisallowedEdges |
| List of ids of edges that shall not be used. | |
| size_t | myInBetweenNumber |
| size_t | myInvalidNumber |
| bool | myKeepTurnarounds |
| size_t | mySinkNumber |
| size_t | mySourceNumber |
Data Structures | |
| class | DFRouteDescByTimeComperator |
| struct | IterationEdge |
| RODFNet::RODFNet | ( | bool | amInHighwayMode | ) | throw () |
Constructor.
| [in] | amInHighwayMode | Whether search for following edges shall stop at slow edges |
Definition at line 50 of file RODFNet.cpp.
References OptionsCont::getBool(), OptionsCont::getOptions(), and OptionsCont::getStringVector().
00051 : RONet(), myAmInHighwayMode(amInHighwayMode), 00052 mySourceNumber(0), mySinkNumber(0), myInBetweenNumber(0), myInvalidNumber(0) { 00053 myDisallowedEdges = OptionsCont::getOptions().getStringVector("disallowed-edges"); 00054 myKeepTurnarounds = OptionsCont::getOptions().getBool("keep-turnarounds"); 00055 }
| RODFNet::~RODFNet | ( | ) | throw () |
| void RONet::addEdge | ( | ROEdge * | edge | ) | throw () [virtual, inherited] |
Definition at line 76 of file RONet.cpp.
References NamedObjectCont< T >::add(), MsgHandler::getErrorInstance(), MsgHandler::inform(), and RONet::myEdges.
Referenced by RONetHandler::parseDistrict(), and RONetHandler::parseEdge().
00076 { 00077 if (!myEdges.add(edge->getID(), edge)) { 00078 MsgHandler::getErrorInstance()->inform("The edge '" + edge->getID() + "' occurs at least twice."); 00079 delete edge; 00080 } 00081 }
| void RONet::addNode | ( | RONode * | node | ) | throw () [inherited] |
Definition at line 85 of file RONet.cpp.
References NamedObjectCont< T >::add(), MsgHandler::getErrorInstance(), MsgHandler::inform(), and RONet::myNodes.
Referenced by RONetHandler::parseEdge(), and RONetHandler::parseJunction().
00085 { 00086 if (!myNodes.add(node->getID(), node)) { 00087 MsgHandler::getErrorInstance()->inform("The node '" + node->getID() + "' occurs at least twice."); 00088 delete node; 00089 } 00090 }
| bool RONet::addRouteDef | ( | RORouteDef * | def | ) | throw () [inherited] |
Definition at line 94 of file RONet.cpp.
References NamedObjectCont< T >::add(), and RONet::myRoutes.
Referenced by RORDGenerator_ODAmounts::FlowDef::addSingleRoute(), RORDLoader_TripDefs::myEndElement(), RORDLoader_SUMOBase::myEndElement(), and RORDGenerator_ODAmounts::myEndFlowAmountDef().
Definition at line 163 of file RONet.cpp.
References ROVehicleCont::add(), MsgHandler::getErrorInstance(), MsgHandler::inform(), RONet::myReadRouteNo, RONet::myVehicles, and RONet::myVehIDs.
Referenced by RORDGenerator_ODAmounts::FlowDef::addSingleRoute(), RORDLoader_SUMOBase::closeVehicle(), and RORDLoader_TripDefs::myEndElement().
00163 { 00164 if (myVehIDs.find(id)==myVehIDs.end()&&myVehicles.add(id, veh)) { 00165 myVehIDs.insert(id); 00166 myReadRouteNo++; 00167 return true; 00168 } 00169 MsgHandler::getErrorInstance()->inform("The vehicle '" + id + "' occurs at least twice."); 00170 return false; 00171 }
| bool RONet::addVehicleType | ( | SUMOVTypeParameter * | type | ) | throw () [virtual, inherited] |
Definition at line 152 of file RONet.cpp.
References NamedObjectCont< T >::add(), MsgHandler::getErrorInstance(), MsgHandler::inform(), and RONet::myVehicleTypes.
Referenced by RONet::getVehicleTypeSecure(), RORDLoader_TripDefs::myEndElement(), and RORDLoader_SUMOBase::myEndElement().
00152 { 00153 if (!myVehicleTypes.add(type->id, type)) { 00154 MsgHandler::getErrorInstance()->inform("The vehicle type '" + type->id + "' occurs at least twice."); 00155 delete type; 00156 return false; 00157 } 00158 return true; 00159 }
| void RODFNet::buildApproachList | ( | ) |
Definition at line 63 of file RODFNet.cpp.
References RONet::getEdgeMap(), ROEdge::getFollower(), ROEdge::getFromNode(), ROEdge::getID(), ROEdge::getNoFollowing(), ROEdge::getToNode(), myApproachedEdges, myApproachingEdges, myDisallowedEdges, and myKeepTurnarounds.
Referenced by main().
00063 { 00064 const std::map<std::string, ROEdge*> &edges = getEdgeMap(); 00065 for (std::map<std::string, ROEdge*>::const_iterator rit = edges.begin(); rit != edges.end(); ++rit) { 00066 ROEdge *ce = (*rit).second; 00067 unsigned int i = 0; 00068 unsigned int length_size = ce->getNoFollowing(); 00069 for (i=0; i<length_size; i++) { 00070 ROEdge *help = ce->getFollower(i); 00071 if (find(myDisallowedEdges.begin(), myDisallowedEdges.end(), help->getID())!=myDisallowedEdges.end()) { 00072 // edges in sinks will not be used 00073 continue; 00074 } 00075 if (!myKeepTurnarounds && help->getToNode()==ce->getFromNode()) { 00076 // do not use turnarounds 00077 continue; 00078 } 00079 // add the connection help->ce to myApproachingEdges 00080 if (myApproachingEdges.find(help)==myApproachingEdges.end()) { 00081 myApproachingEdges[help] = std::vector<ROEdge*>(); 00082 } 00083 myApproachingEdges[help].push_back(ce); 00084 // add the connection ce->help to myApproachingEdges 00085 if (myApproachedEdges.find(ce)==myApproachedEdges.end()) { 00086 myApproachedEdges[ce] = std::vector<ROEdge*>(); 00087 } 00088 myApproachedEdges[ce].push_back(help); 00089 } 00090 } 00091 }
| void RODFNet::buildDetectorDependencies | ( | RODFDetectorCon & | detectors | ) |
Definition at line 1052 of file RODFNet.cpp.
References buildDetectorEdgeDependencies(), RODFDetectorCon::getDetector(), RODFDetector::getRouteVector(), RODFDetector::hasRoutes(), myDetectorEdges, and myDetectorsOnEdges.
Referenced by startComputation().
01052 { 01053 // !!! this will not work when several detectors are lying on the same edge on different positions 01054 01055 01056 buildDetectorEdgeDependencies(detectors); 01057 // for each detector, compute the lists of predecessor and following detectors 01058 std::map<std::string, ROEdge*>::const_iterator i; 01059 for (i=myDetectorEdges.begin(); i!=myDetectorEdges.end(); ++i) { 01060 const RODFDetector &det = detectors.getDetector((*i).first); 01061 if (!det.hasRoutes()) { 01062 continue; 01063 } 01064 // mark current detectors 01065 std::vector<RODFDetector*> last; 01066 { 01067 const std::vector<std::string> &detNames = myDetectorsOnEdges.find((*i).second)->second; 01068 for (std::vector<std::string>::const_iterator j=detNames.begin(); j!=detNames.end(); ++j) { 01069 last.push_back((RODFDetector*) &detectors.getDetector(*j)); 01070 } 01071 } 01072 // iterate over the current detector's routes 01073 const std::vector<RODFRouteDesc> &routes = det.getRouteVector(); 01074 for (std::vector<RODFRouteDesc>::const_iterator j=routes.begin(); j!=routes.end(); ++j) { 01075 const std::vector<ROEdge*> &edges2Pass = (*j).edges2Pass; 01076 for (std::vector<ROEdge*>::const_iterator k=edges2Pass.begin()+1; k!=edges2Pass.end(); ++k) { 01077 if (myDetectorsOnEdges.find(*k)!=myDetectorsOnEdges.end()) { 01078 const std::vector<std::string> &detNames = myDetectorsOnEdges.find(*k)->second; 01079 // ok, consecutive detector found 01080 for (std::vector<RODFDetector*>::iterator l=last.begin(); l!=last.end(); ++l) { 01081 // mark as follower of current 01082 for (std::vector<std::string>::const_iterator m=detNames.begin(); m!=detNames.end(); ++m) { 01083 ((RODFDetector*) &detectors.getDetector(*m))->addPriorDetector((RODFDetector*) &(*l)); 01084 (*l)->addFollowingDetector((RODFDetector*) &detectors.getDetector(*m)); 01085 } 01086 } 01087 last.clear(); 01088 for (std::vector<std::string>::const_iterator m=detNames.begin(); m!=detNames.end(); ++m) { 01089 last.push_back((RODFDetector*) &detectors.getDetector(*m)); 01090 } 01091 } 01092 } 01093 } 01094 } 01095 }
| void RODFNet::buildDetectorEdgeDependencies | ( | RODFDetectorCon & | dets | ) | const [protected] |
Definition at line 95 of file RODFNet.cpp.
References getDetectorEdge(), RODFDetectorCon::getDetectors(), myDetectorEdges, and myDetectorsOnEdges.
Referenced by buildDetectorDependencies(), buildRoutes(), computeTypes(), and mesoJoin().
00095 { 00096 myDetectorsOnEdges.clear(); 00097 myDetectorEdges.clear(); 00098 const std::vector<RODFDetector*> &dets = detcont.getDetectors(); 00099 { 00100 for (std::vector<RODFDetector*>::const_iterator i=dets.begin(); i!=dets.end(); ++i) { 00101 ROEdge *e = getDetectorEdge(**i); 00102 00103 if (myDetectorsOnEdges.find(e)==myDetectorsOnEdges.end()) { 00104 myDetectorsOnEdges[e] = std::vector<std::string>(); 00105 } 00106 myDetectorsOnEdges[e].push_back((*i)->getID()); 00107 00108 myDetectorEdges[(*i)->getID()] = e; 00109 } 00110 } 00111 }
| void RODFNet::buildEdgeFlowMap | ( | const RODFDetectorFlows & | flows, | |
| const RODFDetectorCon & | detectors, | |||
| SUMOTime | startTime, | |||
| SUMOTime | endTime, | |||
| SUMOTime | stepOffset | |||
| ) |
Definition at line 986 of file RODFNet.cpp.
References FlowDef::fLKW, RODFDetectorCon::getDetector(), RODFDetectorFlows::getFlowDefs(), RODFDetector::getPos(), FlowDef::isLKW, RODFDetectorFlows::knows(), MAX2(), myDetectorsOnEdges, FlowDef::qLKW, FlowDef::qPKW, SUMOReal, FlowDef::vLKW, and FlowDef::vPKW.
Referenced by startComputation().
00989 { 00990 std::map<ROEdge*, std::vector<std::string> >::iterator i; 00991 for (i=myDetectorsOnEdges.begin(); i!=myDetectorsOnEdges.end(); ++i) { 00992 ROEdge *into = (*i).first; 00993 const std::vector<std::string> &dets = (*i).second; 00994 std::map<SUMOReal, std::vector<std::string> > cliques; 00995 size_t maxCliqueSize = 0; 00996 for (std::vector<std::string>::const_iterator j=dets.begin(); j!=dets.end(); ++j) { 00997 if (!flows.knows(*j)) { 00998 continue; 00999 } 01000 const RODFDetector &det = detectors.getDetector(*j); 01001 bool found = false; 01002 for (std::map<SUMOReal, std::vector<std::string> >::iterator k=cliques.begin(); !found&&k!=cliques.end(); ++k) { 01003 if (fabs((*k).first-det.getPos())<1) { 01004 (*k).second.push_back(*j); 01005 maxCliqueSize = MAX2(maxCliqueSize, (*k).second.size()); 01006 found = true; 01007 } 01008 } 01009 if (!found) { 01010 cliques[det.getPos()] = std::vector<std::string>(); 01011 cliques[det.getPos()].push_back(*j); 01012 maxCliqueSize = MAX2(maxCliqueSize, (size_t) 1); 01013 } 01014 } 01015 std::vector<std::string> firstClique; 01016 for (std::map<SUMOReal, std::vector<std::string> >::iterator m=cliques.begin(); firstClique.size()==0&&m!=cliques.end(); ++m) { 01017 if ((*m).second.size()==maxCliqueSize) { 01018 firstClique = (*m).second; 01019 } 01020 } 01021 std::vector<FlowDef> mflows; // !!! reserve 01022 SUMOTime t; 01023 for (t=startTime; t<endTime; t+=stepOffset) { 01024 FlowDef fd; 01025 fd.qPKW = 0; 01026 fd.qLKW = 0; 01027 fd.vLKW = 0; 01028 fd.vPKW = 0; 01029 fd.fLKW = 0; 01030 fd.isLKW = 0; 01031 mflows.push_back(fd); 01032 } 01033 for (std::vector<std::string>::iterator l=firstClique.begin(); l!=firstClique.end(); ++l) { 01034 const std::vector<FlowDef> &dflows = flows.getFlowDefs(*l); 01035 for (t=startTime; t<endTime; t+=stepOffset) { 01036 const FlowDef &srcFD = dflows[(int)(t/stepOffset) - startTime]; 01037 FlowDef &fd = mflows[(int)(t/stepOffset) - startTime]; 01038 fd.qPKW += srcFD.qPKW; 01039 fd.qLKW += srcFD.qLKW; 01040 fd.vLKW += (srcFD.vLKW / (SUMOReal) firstClique.size()); 01041 fd.vPKW += (srcFD.vPKW / (SUMOReal) firstClique.size()); 01042 fd.fLKW += (srcFD.fLKW / (SUMOReal) firstClique.size()); 01043 fd.isLKW += (srcFD.isLKW / (SUMOReal) firstClique.size()); 01044 } 01045 } 01046 static_cast<RODFEdge*>(into)->setFlows(mflows); 01047 } 01048 }
| void RODFNet::buildRoutes | ( | RODFDetectorCon & | det, | |
| bool | allEndFollower, | |||
| bool | keepUnfoundEnds, | |||
| bool | includeInBetween, | |||
| bool | keepShortestOnly, | |||
| int | maxFollowingLength | |||
| ) | const |
!!;
!!routes->removeIllegal(illegals);
!!;
Definition at line 350 of file RODFNet.cpp.
References RODFRouteCont::addAllEndFollower(), BETWEEN_DETECTOR, buildDetectorEdgeDependencies(), computeRoutesFor(), RODFRouteDesc::distance, RODFRouteDesc::distance2Last, RODFRouteDesc::duration2Last, RODFRouteDesc::duration_2, RODFRouteDesc::edges2Pass, RODFRouteDesc::endDetectorEdge, RODFRouteDesc::factor, RODFRouteCont::get(), RODFDetectorCon::getDetector(), getDetectorEdge(), RODFDetectorCon::getDetectors(), ROEdge::getLength(), ROEdge::getSpeed(), RODFDetector::getType(), RODFRouteDesc::lastDetectorEdge, myDetectorsOnEdges, RODFRouteDesc::overallProb, SOURCE_DETECTOR, and SUMOReal.
Referenced by startComputation().
00352 { 00353 /* 00354 std::vector<std::vector<ROEdge*> > illegals; 00355 std::vector<ROEdge*> i1; 00356 i1.push_back(getEdge("-51140604")); 00357 i1.push_back(getEdge("-51140594")); 00358 i1.push_back(getEdge("51140072")); 00359 i1.push_back(getEdge("51140612")); 00360 illegals.push_back(i1); 00361 std::vector<ROEdge*> i2; 00362 i2.push_back(getEdge("-51047761")); 00363 i2.push_back(getEdge("-51047760")); 00364 i2.push_back(getEdge("51047759")); 00365 i2.push_back(getEdge("51047758")); 00366 illegals.push_back(i2); 00367 std::vector<ROEdge*> i3; 00368 i3.push_back(getEdge("-51049672")); 00369 i3.push_back(getEdge("-51049675")); 00370 i3.push_back(getEdge("51049662")); 00371 i3.push_back(getEdge("51049676")); 00372 illegals.push_back(i3); 00373 std::vector<ROEdge*> i4; 00374 i4.push_back(getEdge("-51069817")); 00375 i4.push_back(getEdge("-51069812")); 00376 i4.push_back(getEdge("51069813")); 00377 i4.push_back(getEdge("51069815")); 00378 illegals.push_back(i4); 00379 std::vector<ROEdge*> i5; 00380 i5.push_back(getEdge("50872831")); 00381 i5.push_back(getEdge("-50872833")); 00382 i5.push_back(getEdge("-50872829")); 00383 i5.push_back(getEdge("572267133")); 00384 illegals.push_back(i5); 00385 std::vector<ROEdge*> i6; 00386 i6.push_back(getEdge("-51066847")); 00387 i6.push_back(getEdge("-51066836")); 00388 i6.push_back(getEdge("51066830")); 00389 i6.push_back(getEdge("51066846")); 00390 illegals.push_back(i6); 00391 */ 00392 // build needed information first 00393 buildDetectorEdgeDependencies(detcont); 00394 // then build the routes 00395 std::map<ROEdge*, RODFRouteCont * > doneEdges; 00396 const std::vector< RODFDetector*> &dets = detcont.getDetectors(); 00397 for (std::vector< RODFDetector*>::const_iterator i=dets.begin(); i!=dets.end(); ++i) { 00398 if ((*i)->getType()!=SOURCE_DETECTOR) { 00399 // do not build routes for other than sources 00400 //continue; 00401 } 00402 ROEdge *e = getDetectorEdge(**i); 00403 if (doneEdges.find(e)!=doneEdges.end()) { 00404 // use previously build routes 00405 (*i)->addRoutes(new RODFRouteCont(*doneEdges[e])); 00406 continue; 00407 } 00408 std::vector<ROEdge*> seen; 00409 RODFRouteCont *routes = new RODFRouteCont(); 00410 doneEdges[e] = routes; 00411 RODFRouteDesc rd; 00412 rd.edges2Pass.push_back(e); 00413 rd.duration_2 = (e->getLength()/e->getSpeed()); 00414 rd.endDetectorEdge = 0; 00415 rd.lastDetectorEdge = 0; 00416 rd.distance = e->getLength(); 00417 rd.distance2Last = 0; 00418 rd.duration2Last = 0; 00419 00420 rd.overallProb = 0; 00421 00422 std::vector<ROEdge*> visited; 00423 visited.push_back(e); 00424 computeRoutesFor(e, rd, 0, keepUnfoundEnds, keepShortestOnly, 00425 visited, **i, *routes, detcont, maxFollowingLength, seen); 00426 if (allEndFollower) { 00427 routes->addAllEndFollower(); 00428 } 00430 (*i)->addRoutes(routes); 00431 00432 // add routes to in-between detectors if wished 00433 if (includeInBetween) { 00434 // go through the routes 00435 const std::vector<RODFRouteDesc> &r = routes->get(); 00436 for (std::vector<RODFRouteDesc>::const_iterator j=r.begin(); j!=r.end(); ++j) { 00437 const RODFRouteDesc &mrd = *j; 00438 SUMOReal duration = mrd.duration_2; 00439 SUMOReal distance = mrd.distance; 00440 // go through each route's edges 00441 std::vector<ROEdge*>::const_iterator routeend = mrd.edges2Pass.end(); 00442 for (std::vector<ROEdge*>::const_iterator k=mrd.edges2Pass.begin(); k!=routeend; ++k) { 00443 // check whether any detectors lies on the current edge 00444 if (myDetectorsOnEdges.find(*k)==myDetectorsOnEdges.end()) { 00445 duration -= (*k)->getLength()/(*k)->getSpeed(); 00446 distance -= (*k)->getLength(); 00447 continue; 00448 } 00449 // get the detectors 00450 const std::vector<std::string> &dets = myDetectorsOnEdges.find(*k)->second; 00451 // go through the detectors 00452 for (std::vector<std::string>::const_iterator l=dets.begin(); l!=dets.end(); ++l) { 00453 const RODFDetector &m = detcont.getDetector(*l); 00454 if (m.getType()==BETWEEN_DETECTOR) { 00455 RODFRouteDesc nrd; 00456 copy(k, routeend, back_inserter(nrd.edges2Pass)); 00457 nrd.duration_2 = duration; 00458 nrd.endDetectorEdge = mrd.endDetectorEdge; 00459 nrd.lastDetectorEdge = mrd.lastDetectorEdge; 00460 nrd.distance = distance; 00461 nrd.distance2Last = mrd.distance2Last; 00462 nrd.duration2Last = mrd.duration2Last; 00463 nrd.overallProb = mrd.overallProb; 00464 nrd.factor = mrd.factor; 00465 ((RODFDetector&) m).addRoute(nrd); 00466 } 00467 } 00468 duration -= (*k)->getLength()/(*k)->getSpeed(); 00469 distance -= (*k)->getLength(); 00470 } 00471 } 00472 } 00473 00474 } 00475 }
| void RONet::checkSourceAndDestinations | ( | ) | const [protected, inherited] |
Initialises the lists of source and destination edges.
Definition at line 313 of file RONet.cpp.
References ROEdge::ET_SINK, ROEdge::ET_SOURCE, NamedObjectCont< T >::getMyMap(), ROEdge::getType(), RONet::myDestinationEdges, RONet::myEdges, and RONet::mySourceEdges.
Referenced by RONet::getRandomDestination(), and RONet::getRandomSource().
00313 { 00314 if (myDestinationEdges.size()!=0||mySourceEdges.size()!=0) { 00315 return; 00316 } 00317 const std::map<std::string, ROEdge*> &edges = myEdges.getMyMap(); 00318 for (std::map<std::string, ROEdge*>::const_iterator i=edges.begin(); i!=edges.end(); ++i) { 00319 ROEdge *e = (*i).second; 00320 ROEdge::EdgeType type = e->getType(); 00321 // !!! add something like "classified edges only" for using only sources or sinks 00322 if (type!=ROEdge::ET_SOURCE) { 00323 myDestinationEdges.push_back(e); 00324 } 00325 if (type!=ROEdge::ET_SINK) { 00326 mySourceEdges.push_back(e); 00327 } 00328 } 00329 }
| void RONet::closeOutput | ( | ) | throw () [inherited] |
closes the file output for computed routes
Definition at line 116 of file RONet.cpp.
References OutputDevice::close(), RONet::myRouteAlternativesOutput, and RONet::myRoutesOutput.
Referenced by computeRoutes().
00116 { 00117 // end writing 00118 if (myRoutesOutput!= 0) { 00119 myRoutesOutput->close(); 00120 } 00121 // only if opened 00122 if (myRouteAlternativesOutput!=0) { 00123 myRouteAlternativesOutput->close(); 00124 } 00125 }
| bool RONet::computeRoute | ( | OptionsCont & | options, | |
| SUMOAbstractRouter< ROEdge, ROVehicle > & | router, | |||
| const ROVehicle *const | veh | |||
| ) | [protected, inherited] |
Definition at line 175 of file RONet.cpp.
References RORouteDef::addAlternative(), RORouteDef::buildCurrentRoute(), OptionsCont::getBool(), ROVehicle::getDepartureTime(), MsgHandler::getErrorInstance(), ROVehicle::getID(), ROVehicle::getRouteDefinition(), MsgHandler::getWarningInstance(), MsgHandler::inform(), ReferencedItem::isSaved(), RORoute::recheckForLoops(), and RORoute::size().
Referenced by RONet::saveAndRemoveRoutesUntil().
00176 { 00177 MsgHandler *mh = MsgHandler::getErrorInstance(); 00178 if (options.getBool("continue-on-unbuild")) { 00179 mh = MsgHandler::getWarningInstance(); 00180 } 00181 RORouteDef * const routeDef = veh->getRouteDefinition(); 00182 // check if the route definition is valid 00183 if (routeDef==0) { 00184 mh->inform("The vehicle '" + veh->getID() + "' has no valid route."); 00185 return false; 00186 } 00187 // check whether the route was already saved 00188 if (routeDef->isSaved()) { 00189 return true; 00190 } 00191 // 00192 RORoute *current = 00193 routeDef->buildCurrentRoute(router, veh->getDepartureTime(), *veh); 00194 if (current==0||current->size()==0) { 00195 delete current; 00196 return false; 00197 } 00198 // check whether we have to evaluate the route for not containing loops 00199 if (options.getBool("remove-loops")) { 00200 current->recheckForLoops(); 00201 } 00202 // check whether the route is still valid 00203 if (current->size()==0) { 00204 delete current; 00205 return false; 00206 } 00207 // add built route 00208 routeDef->addAlternative(router, veh, current, veh->getDepartureTime()); 00209 return true; 00210 }
| void RODFNet::computeRoutesFor | ( | ROEdge * | edge, | |
| RODFRouteDesc & | base, | |||
| int | no, | |||
| bool | keepUnfoundEnds, | |||
| bool | keepShortestOnly, | |||
| std::vector< ROEdge * > & | visited, | |||
| const RODFDetector & | det, | |||
| RODFRouteCont & | into, | |||
| const RODFDetectorCon & | detectors, | |||
| int | maxFollowingLength, | |||
| std::vector< ROEdge * > & | seen | |||
| ) | const [protected] |
!!! //toDiscard.push_back(current);
!!
Definition at line 192 of file RODFNet.cpp.
References RODFRouteCont::addRouteDesc(), RODFRouteDesc::distance, RODFRouteDesc::distance2Last, RODFRouteDesc::duration2Last, RODFRouteDesc::duration_2, RODFRouteDesc::edges2Pass, RODFRouteDesc::endDetectorEdge, RODFRouteDesc::factor, getDetectorEdge(), OptionsCont::getFloat(), RODFDetector::getID(), OptionsCont::getOptions(), ROEdge::getSpeed(), MsgHandler::getWarningInstance(), hasApproached(), hasDetector(), hasInBetweenDetectorsOnly(), hasSourceDetector(), MsgHandler::inform(), RODFRouteDesc::lastDetectorEdge, myAmInHighwayMode, myApproachedEdges, RODFRouteDesc::passedNo, RODFRouteCont::removeRouteDesc(), and SUMOReal.
Referenced by buildRoutes().
00199 { 00200 std::vector<RODFRouteDesc> unfoundEnds; 00201 std::priority_queue<RODFRouteDesc, std::vector<RODFRouteDesc>, DFRouteDescByTimeComperator> toSolve; 00202 std::map<ROEdge*, std::vector<ROEdge*> > dets2Follow; 00203 dets2Follow[edge] = std::vector<ROEdge*>(); 00204 base.passedNo = 0; 00205 SUMOReal minDist = OptionsCont::getOptions().getFloat("min-distance"); 00206 toSolve.push(base); 00207 while (!toSolve.empty()) { 00208 RODFRouteDesc current = toSolve.top(); 00209 toSolve.pop(); 00210 ROEdge *last = *(current.edges2Pass.end()-1); 00211 if (hasDetector(last)) { 00212 if (dets2Follow.find(last)==dets2Follow.end()) { 00213 dets2Follow[last] = std::vector<ROEdge*>(); 00214 } 00215 for (std::vector<ROEdge*>::reverse_iterator i=current.edges2Pass.rbegin()+1; i!=current.edges2Pass.rend(); ++i) { 00216 if (hasDetector(*i)) { 00217 dets2Follow[*i].push_back(last); 00218 break; 00219 } 00220 } 00221 } 00222 00223 // do not process an edge twice 00224 if (find(seen.begin(), seen.end(), last)!=seen.end() && keepShortestOnly) { 00225 continue; 00226 } 00227 seen.push_back(last); 00228 // end if the edge has no further connections 00229 if (!hasApproached(last)) { 00230 // ok, no further connections to follow 00231 current.factor = 1.; 00232 SUMOReal cdist = current.edges2Pass[0]->getFromNode()->getPosition().distanceTo(current.edges2Pass.back()->getToNode()->getPosition()); 00233 if (minDist<cdist) { 00234 into.addRouteDesc(current); 00235 } 00236 continue; 00237 } 00238 // check for passing detectors: 00239 // if the current last edge is not the one the detector is placed on ... 00240 bool addNextNoFurther = false; 00241 if (last!=getDetectorEdge(det)) { 00242 // ... if there is a detector ... 00243 if (hasDetector(last)) { 00244 if (!hasInBetweenDetectorsOnly(last, detectors)) { 00245 // ... and it's not an in-between-detector 00246 // -> let's add this edge and the following, but not any further 00247 addNextNoFurther = true; 00248 current.lastDetectorEdge = last; 00249 current.duration2Last = (SUMOTime) current.duration_2; 00250 current.distance2Last = current.distance; 00251 current.endDetectorEdge = last; 00252 if (hasSourceDetector(last, detectors)) { 00254 } 00255 current.factor = 1.; 00256 SUMOReal cdist = current.edges2Pass[0]->getFromNode()->getPosition().distanceTo(current.edges2Pass.back()->getToNode()->getPosition()); 00257 if (minDist<cdist) { 00258 into.addRouteDesc(current); 00259 } 00260 continue; 00261 } else { 00262 // ... if it's an in-between-detector 00263 // -> mark the current route as to be continued 00264 current.passedNo = 0; 00265 current.duration2Last = (SUMOTime) current.duration_2; 00266 current.distance2Last = current.distance; 00267 current.lastDetectorEdge = last; 00268 } 00269 } 00270 } 00271 // check for highway off-ramps 00272 if (myAmInHighwayMode) { 00273 // if it's beside the highway... 00274 if (last->getSpeed()<19.4&&last!=getDetectorEdge(det)) { 00275 // ... and has more than one following edge 00276 if (myApproachedEdges.find(last)->second.size()>1) { 00277 // -> let's add this edge and the following, but not any further 00278 addNextNoFurther = true; 00279 } 00280 00281 } 00282 } 00283 // check for missing end connections 00284 if (!addNextNoFurther) { 00285 // ... if this one would be processed, but already too many edge 00286 // without a detector occured 00287 if (current.passedNo>maxFollowingLength) { 00288 // mark not to process any further 00289 MsgHandler::getWarningInstance()->inform("Could not close route for '" + det.getID() + "'"); 00290 unfoundEnds.push_back(current); 00291 current.factor = 1.; 00292 SUMOReal cdist = current.edges2Pass[0]->getFromNode()->getPosition().distanceTo(current.edges2Pass.back()->getToNode()->getPosition()); 00293 if (minDist<cdist) { 00294 into.addRouteDesc(current); 00295 } 00296 continue; 00297 } 00298 } 00299 // ... else: loop over the next edges 00300 const std::vector<ROEdge*> &appr = myApproachedEdges.find(last)->second; 00301 bool hadOne = false; 00302 for (size_t i=0; i<appr.size(); i++) { 00303 if (find(current.edges2Pass.begin(), current.edges2Pass.end(), appr[i])!=current.edges2Pass.end()) { 00304 // do not append an edge twice (do not build loops) 00305 continue; 00306 } 00307 RODFRouteDesc t(current); 00308 t.duration_2 += (appr[i]->getLength()/appr[i]->getSpeed()); 00309 t.distance += appr[i]->getLength(); 00310 t.edges2Pass.push_back(appr[i]); 00311 if (!addNextNoFurther) { 00312 t.passedNo = t.passedNo + 1; 00313 toSolve.push(t); 00314 } else { 00315 if (!hadOne) { 00316 t.factor = (SUMOReal) 1. / (SUMOReal) appr.size(); 00317 SUMOReal cdist = current.edges2Pass[0]->getFromNode()->getPosition().distanceTo(current.edges2Pass.back()->getToNode()->getPosition()); 00318 if (minDist<cdist) { 00319 into.addRouteDesc(t); 00320 } 00321 hadOne = true; 00322 } 00323 } 00324 } 00325 } 00326 // 00327 if (!keepUnfoundEnds) { 00328 std::vector<RODFRouteDesc>::iterator i; 00329 std::vector<const ROEdge*> lastDetEdges; 00330 for (i=unfoundEnds.begin(); i!=unfoundEnds.end(); ++i) { 00331 if (find(lastDetEdges.begin(), lastDetEdges.end(), (*i).lastDetectorEdge)==lastDetEdges.end()) { 00332 lastDetEdges.push_back((*i).lastDetectorEdge); 00333 } else { 00334 bool ok = into.removeRouteDesc(*i); 00335 assert(ok); 00336 } 00337 } 00338 } else { 00339 // !!! patch the factors 00340 } 00341 while (!toSolve.empty()) { 00342 // RODFRouteDesc d = toSolve.top(); 00343 toSolve.pop(); 00344 // delete d; 00345 } 00346 }
| void RODFNet::computeTypes | ( | RODFDetectorCon & | dets, | |
| bool | sourcesStrict | |||
| ) | const |
Definition at line 115 of file RODFNet.cpp.
References MsgHandler::beginProcessMsg(), BETWEEN_DETECTOR, buildDetectorEdgeDependencies(), DISCARDED_DETECTOR, MsgHandler::endProcessMsg(), RODFDetectorCon::getDetectors(), MsgHandler::getMessageInstance(), MsgHandler::inform(), isDestination(), isFalseSource(), isSource(), myInBetweenNumber, myInvalidNumber, mySinkNumber, mySourceNumber, SINK_DETECTOR, SOURCE_DETECTOR, toString(), and TYPE_NOT_DEFINED.
Referenced by startComputation().
00116 { 00117 MsgHandler::getMessageInstance()->beginProcessMsg("Computing detector types..."); 00118 const std::vector< RODFDetector*> &dets = detcont.getDetectors(); 00119 // build needed information. first 00120 buildDetectorEdgeDependencies(detcont); 00121 // compute detector types then 00122 { 00123 for (std::vector< RODFDetector*>::const_iterator i=dets.begin(); i!=dets.end(); ++i) { 00124 if (isSource(**i, detcont, sourcesStrict)) { 00125 (*i)->setType(SOURCE_DETECTOR); 00126 mySourceNumber++; 00127 } 00128 if (isDestination(**i, detcont)) { 00129 (*i)->setType(SINK_DETECTOR); 00130 mySinkNumber++; 00131 } 00132 if ((*i)->getType()==TYPE_NOT_DEFINED) { 00133 (*i)->setType(BETWEEN_DETECTOR); 00134 myInBetweenNumber++; 00135 } 00136 } 00137 } 00138 // recheck sources 00139 { 00140 for (std::vector< RODFDetector*>::const_iterator i=dets.begin(); i!=dets.end(); ++i) { 00141 if ((*i)->getType()==SOURCE_DETECTOR&&isFalseSource(**i, detcont)) { 00142 (*i)->setType(DISCARDED_DETECTOR); 00143 myInvalidNumber++; 00144 mySourceNumber--; 00145 } 00146 } 00147 } 00148 // print results 00149 MsgHandler::getMessageInstance()->endProcessMsg("done."); 00150 MsgHandler::getMessageInstance()->inform("Computed detector types:"); 00151 MsgHandler::getMessageInstance()->inform(" " + toString(mySourceNumber) + " source detectors"); 00152 MsgHandler::getMessageInstance()->inform(" " + toString(mySinkNumber) + " sink detectors"); 00153 MsgHandler::getMessageInstance()->inform(" " + toString(myInBetweenNumber) + " in-between detectors"); 00154 MsgHandler::getMessageInstance()->inform(" " + toString(myInvalidNumber) + " invalid detectors"); 00155 }
| bool RONet::furtherStored | ( | ) | [virtual, inherited] |
Returns the information whether further vehicles are stored.
Definition at line 258 of file RONet.cpp.
References RONet::myVehicles, and NamedObjectCont< T >::size().
Referenced by ROLoader::processRoutesStepWise().
00258 { 00259 return myVehicles.size()>0; 00260 }
| SUMOReal RODFNet::getAbsPos | ( | const RODFDetector & | det | ) | const |
Definition at line 728 of file RODFNet.cpp.
References getDetectorEdge(), ROEdge::getLength(), and RODFDetector::getPos().
Referenced by isDestination(), and isSource().
00728 { 00729 if (det.getPos()>=0) { 00730 return det.getPos(); 00731 } 00732 return getDetectorEdge(det)->getLength() + det.getPos(); 00733 }
| ROEdge * RODFNet::getDetectorEdge | ( | const RODFDetector & | det | ) | const [protected] |
Definition at line 683 of file RODFNet.cpp.
References RONet::getEdge(), RODFDetector::getID(), and RODFDetector::getLaneID().
Referenced by buildDetectorEdgeDependencies(), buildRoutes(), computeRoutesFor(), getAbsPos(), isDestination(), isFalseSource(), isSource(), and revalidateFlows().
00683 { 00684 std::string edgeName = det.getLaneID(); 00685 edgeName = edgeName.substr(0, edgeName.rfind('_')); 00686 ROEdge *ret = getEdge(edgeName); 00687 if (ret==0) { 00688 throw ProcessError("Edge '" + edgeName + "' used by detector '" + det.getID() + "' is not known."); 00689 } 00690 return ret; 00691 }
| const std::vector< std::string > & RODFNet::getDetectorList | ( | ROEdge * | edge | ) | const |
Definition at line 722 of file RODFNet.cpp.
References myDetectorsOnEdges.
00722 { 00723 return myDetectorsOnEdges.find(edge)->second; 00724 }
| ROEdge* RONet::getEdge | ( | const std::string & | name | ) | const throw () [inline, inherited] |
Retrieves an edge from the network.
This is not very pretty, but necessary, though, as routes run over instances, not over ids.
| [in] | name | The name of the edge to retrieve |
Definition at line 99 of file RONet.h.
References NamedObjectCont< T >::get(), and RONet::myEdges.
Referenced by ROJTRTurnDefLoader::addToEdge(), ROJTRTurnDefLoader::beginFromEdge(), getDetectorEdge(), RORDLoader_TripDefs::getEdge(), loadJTRDefinitions(), RORDLoader_SUMOBase::myCharacters(), ROJTRTurnDefLoader::myCharacters(), ROJTRTurnDefLoader::myStartElement(), RODFDetectorHandler::myStartElement(), RONetHandler::parseConnectedEdge(), RONetHandler::parseConnectingEdge(), RONetHandler::parseDistrict(), RONetHandler::parseDistrictEdge(), RODFDetectorCon::writeEmitters(), and RODFDetectorCon::writeSpeedTrigger().
| const std::map< std::string, ROEdge * > & RONet::getEdgeMap | ( | ) | const [inherited] |
Definition at line 339 of file RONet.cpp.
References NamedObjectCont< T >::getMyMap(), and RONet::myEdges.
Referenced by buildApproachList(), initNet(), and ROLoader::loadWeights().
| unsigned int RONet::getEdgeNo | ( | ) | const [inherited] |
Returns the number of edges thenetwork contains.
Definition at line 333 of file RONet.cpp.
References RONet::myEdges, and NamedObjectCont< T >::size().
Referenced by computeRoutes(), and ROJTRRouter::ROJTRRouter().
| RONode* RONet::getNode | ( | const std::string & | id | ) | const throw () [inline, inherited] |
Retrieves an node from the network.
| [in] | name | The name of the node to retrieve |
Definition at line 121 of file RONet.h.
References NamedObjectCont< T >::get(), and RONet::myNodes.
Referenced by RONetHandler::parseEdge(), and RONetHandler::parseJunction().
| const ROEdge * RONet::getRandomDestination | ( | ) | const throw () [inherited] |
Returns a random edge which may be used as an ending point.
If the list of possible destinations (roads with no successor, "myDestinationEdges") is empty, it is tried to be built, first.
Definition at line 301 of file RONet.cpp.
References RONet::checkSourceAndDestinations(), RandHelper::getRandomFrom(), and RONet::myDestinationEdges.
00301 { 00302 // check whether an edge may be returned 00303 checkSourceAndDestinations(); 00304 if (myDestinationEdges.size()==0) { 00305 return 0; 00306 } 00307 // choose a random edge 00308 return RandHelper::getRandomFrom(myDestinationEdges); 00309 }
| ROEdge * RONet::getRandomDestination | ( | ) | throw () [inherited] |
Returns a random edge which may be used as an ending point.
If the list of possible destinations (roads with no successor, "myDestinationEdges") is empty, it is tried to be built, first.
Definition at line 289 of file RONet.cpp.
References RONet::checkSourceAndDestinations(), RandHelper::getRandomFrom(), and RONet::myDestinationEdges.
00289 { 00290 // check whether an edge may be returned 00291 checkSourceAndDestinations(); 00292 if (myDestinationEdges.size()==0) { 00293 return 0; 00294 } 00295 // choose a random edge 00296 return RandHelper::getRandomFrom(myDestinationEdges); 00297 }
| const ROEdge * RONet::getRandomSource | ( | ) | const throw () [inherited] |
Returns a random edge which may be used as a starting point.
If the list of possible sources (roads with no predecessor, "mySourceEdges") is empty, it is tried to be built, first.
Definition at line 276 of file RONet.cpp.
References RONet::checkSourceAndDestinations(), RandHelper::getRandomFrom(), and RONet::mySourceEdges.
00276 { 00277 // check whether an edge may be returned 00278 checkSourceAndDestinations(); 00279 if (mySourceEdges.size()==0) { 00280 return 0; 00281 } 00282 // choose a random edge 00283 return RandHelper::getRandomFrom(mySourceEdges); 00284 }
| ROEdge * RONet::getRandomSource | ( | ) | throw () [inherited] |
Returns a random edge which may be used as a starting point.
If the list of possible source (roads with no predecessor, "mySourceEdges") is empty, it is tried to be built, first.
Definition at line 264 of file RONet.cpp.
References RONet::checkSourceAndDestinations(), RandHelper::getRandomFrom(), and RONet::mySourceEdges.
00264 { 00265 // check whether an edge may be returned 00266 checkSourceAndDestinations(); 00267 if (mySourceEdges.size()==0) { 00268 return 0; 00269 } 00270 // choose a random edge 00271 return RandHelper::getRandomFrom(mySourceEdges); 00272 }
| RORouteDef* RONet::getRouteDef | ( | const std::string & | name | ) | const throw () [inline, inherited] |
Returns the named route definition.
| [in] | name | The name of the route definition to retrieve |
Definition at line 178 of file RONet.h.
References NamedObjectCont< T >::get(), and RONet::myRoutes.
Referenced by RORDLoader_SUMOBase::closeVehicle().
| SUMOVTypeParameter * RONet::getVehicleTypeSecure | ( | const std::string & | id | ) | throw () [inherited] |
Retrieves the named vehicle type.
If the named vehicle type was not added to the net before, a default vehicle type which consists of the id only is generated, added to the net and returned.
Only if the name is "", 0 is returned.
| [in] | id | The id of the vehicle type to return |
Definition at line 130 of file RONet.cpp.
References RONet::addVehicleType(), NamedObjectCont< T >::get(), SUMOVTypeParameter::id, RONet::myVehicleTypes, and SUMOVTypeParameter::onlyReferenced.
Referenced by RORDLoader_SUMOBase::closeVehicle(), RORDLoader_TripDefs::myEndElement(), and RORDGenerator_ODAmounts::myEndFlowAmountDef().
00130 { 00131 // check whether the type was already known 00132 SUMOVTypeParameter *type = myVehicleTypes.get(id); 00133 if (type!=0) { 00134 return type; 00135 } 00136 if (id=="") { 00137 // ok, no vehicle type was given within the user input 00138 // return the default type 00139 return 0; 00140 } 00141 // Assume, the user will define the type somewhere else 00142 // return a type which contains the id only 00143 type = new SUMOVTypeParameter(); 00144 type->id = id; 00145 type->onlyReferenced = true; 00146 addVehicleType(type); 00147 return type; 00148 }
Definition at line 704 of file RODFNet.cpp.
References myApproachedEdges.
Referenced by computeRoutesFor(), and isDestination().
00704 { 00705 return 00706 myApproachedEdges.find(edge)!=myApproachedEdges.end() 00707 && 00708 myApproachedEdges.find(edge)->second.size()!=0; 00709 }
Definition at line 695 of file RODFNet.cpp.
References myApproachingEdges.
Referenced by isSource().
00695 { 00696 return 00697 myApproachingEdges.find(edge)!=myApproachingEdges.end() 00698 && 00699 myApproachingEdges.find(edge)->second.size()!=0; 00700 }
Definition at line 713 of file RODFNet.cpp.
References myDetectorsOnEdges.
Referenced by RODFDetector::buildDestinationDistribution(), computeRoutesFor(), RODFDetector::computeSplitProbabilities(), isDestination(), isFalseSource(), isSource(), and revalidateFlows().
00713 { 00714 return 00715 myDetectorsOnEdges.find(edge)!=myDetectorsOnEdges.end() 00716 && 00717 myDetectorsOnEdges.find(edge)->second.size()!=0; 00718 }
| bool RODFNet::hasInBetweenDetectorsOnly | ( | ROEdge * | edge, | |
| const RODFDetectorCon & | detectors | |||
| ) | const [protected] |
Definition at line 159 of file RODFNet.cpp.
References BETWEEN_DETECTOR, RODFDetectorCon::getDetector(), RODFDetector::getType(), and myDetectorsOnEdges.
Referenced by computeRoutesFor().
00160 { 00161 assert(myDetectorsOnEdges.find(edge)!=myDetectorsOnEdges.end()); 00162 const std::vector<std::string> &detIDs = myDetectorsOnEdges.find(edge)->second; 00163 std::vector<std::string>::const_iterator i; 00164 for (i=detIDs.begin(); i!=detIDs.end(); ++i) { 00165 const RODFDetector &det = detectors.getDetector(*i); 00166 if (det.getType()!=BETWEEN_DETECTOR) { 00167 return false; 00168 } 00169 } 00170 return true; 00171 }
| bool RONet::hasRestrictions | ( | ) | const [inherited] |
Definition at line 345 of file RONet.cpp.
References RONet::myHaveRestrictions.
Referenced by computeRoutes().
00345 { 00346 return myHaveRestrictions; 00347 }
| bool RODFNet::hasSourceDetector | ( | ROEdge * | edge, | |
| const RODFDetectorCon & | detectors | |||
| ) | const [protected] |
Definition at line 175 of file RODFNet.cpp.
References RODFDetectorCon::getDetector(), RODFDetector::getType(), myDetectorsOnEdges, and SOURCE_DETECTOR.
Referenced by computeRoutesFor().
00176 { 00177 assert(myDetectorsOnEdges.find(edge)!=myDetectorsOnEdges.end()); 00178 const std::vector<std::string> &detIDs = myDetectorsOnEdges.find(edge)->second; 00179 std::vector<std::string>::const_iterator i; 00180 for (i=detIDs.begin(); i!=detIDs.end(); ++i) { 00181 const RODFDetector &det = detectors.getDetector(*i); 00182 if (det.getType()==SOURCE_DETECTOR) { 00183 return true; 00184 } 00185 } 00186 return false; 00187 }
| bool RODFNet::isDestination | ( | const RODFDetector & | det, | |
| ROEdge * | edge, | |||
| std::vector< ROEdge * > & | seen, | |||
| const RODFDetectorCon & | detectors | |||
| ) | const [protected] |
Definition at line 861 of file RODFNet.cpp.
References getAbsPos(), RODFDetectorCon::getDetector(), getDetectorEdge(), RODFDetector::getID(), ROEdge::getSpeed(), MsgHandler::getWarningInstance(), hasApproached(), hasDetector(), MsgHandler::inform(), isDestination(), myAmInHighwayMode, myApproachedEdges, myDetectorEdges, and myDetectorsOnEdges.
00862 { 00863 if (seen.size()==1000) { // !!! 00864 MsgHandler::getWarningInstance()->inform("Quitting checking for being a destination for detector '" + det.getID() + "' due to seen edge limit."); 00865 return false; 00866 } 00867 if (edge==getDetectorEdge(det)) { 00868 // maybe there is another detector at the same edge 00869 // get the list of this/these detector(s) 00870 const std::vector<std::string> &detsOnEdge = myDetectorsOnEdges.find(edge)->second; 00871 for (std::vector<std::string>::const_iterator i=detsOnEdge.begin(); i!=detsOnEdge.end(); ++i) { 00872 if ((*i)==det.getID()) { 00873 continue; 00874 } 00875 const RODFDetector &sec = detectors.getDetector(*i); 00876 if (getAbsPos(sec)>getAbsPos(det)) { 00877 // ok, there is another detector on the same edge and it is 00878 // after this one -> no destination 00879 return false; 00880 } 00881 } 00882 } 00883 if (!hasApproached(edge)) { 00884 if (edge!=getDetectorEdge(det)) { 00885 if (hasDetector(edge)) { 00886 return false; 00887 } 00888 } 00889 return true; 00890 } 00891 if (edge!=getDetectorEdge(det)) { 00892 // ok, we are at one of the edges coming behind 00893 if (myAmInHighwayMode) { 00894 if (edge->getSpeed()>=19.4) { 00895 if (hasDetector(edge)) { 00896 // we are still on the highway and there is another detector 00897 return false; 00898 } 00899 } 00900 } 00901 } 00902 00903 if (myAmInHighwayMode) { 00904 if (edge->getSpeed()<19.4&&edge!=getDetectorEdge(det)) { 00905 if (hasDetector(edge)) { 00906 return true; 00907 } 00908 if (myApproachedEdges.find(edge)->second.size()>1) { 00909 return true; 00910 } 00911 00912 } 00913 } 00914 00915 if (myDetectorsOnEdges.find(edge)!=myDetectorsOnEdges.end() 00916 && 00917 myDetectorEdges.find(det.getID())->second!=edge) { 00918 return false; 00919 } 00920 const std::vector<ROEdge*> &appr = myApproachedEdges.find(edge)->second; 00921 bool isall = true; 00922 size_t no = 0; 00923 seen.push_back(edge); 00924 for (size_t i=0; i<appr.size()&&isall; i++) { 00925 bool had = std::find(seen.begin(), seen.end(), appr[i])!=seen.end(); 00926 if (!had) { 00927 if (!isDestination(det, appr[i], seen, detectors)) { 00928 no++; 00929 isall = false; 00930 } 00931 } 00932 } 00933 return isall; 00934 }
| bool RODFNet::isDestination | ( | const RODFDetector & | det, | |
| const RODFDetectorCon & | detectors | |||
| ) | const [protected] |
Definition at line 751 of file RODFNet.cpp.
References getDetectorEdge().
Referenced by computeTypes(), and isDestination().
00751 { 00752 std::vector<ROEdge*> seen; 00753 return isDestination(det, getDetectorEdge(det), seen, detectors); 00754 }
| bool RODFNet::isFalseSource | ( | const RODFDetector & | det, | |
| ROEdge * | edge, | |||
| std::vector< ROEdge * > & | seen, | |||
| const RODFDetectorCon & | detectors | |||
| ) | const [protected] |
Definition at line 937 of file RODFNet.cpp.
References BETWEEN_DETECTOR, RODFDetectorCon::getDetector(), getDetectorEdge(), RODFDetector::getID(), ROEdge::getSpeed(), RODFDetector::getType(), MsgHandler::getWarningInstance(), hasDetector(), MsgHandler::inform(), isFalseSource(), myAmInHighwayMode, myApproachedEdges, myDetectorsOnEdges, SINK_DETECTOR, and SOURCE_DETECTOR.
00938 { 00939 if (seen.size()==1000) { // !!! 00940 MsgHandler::getWarningInstance()->inform("Quitting checking for being a false source for detector '" + det.getID() + "' due to seen edge limit."); 00941 return false; 00942 } 00943 seen.push_back(edge); 00944 if (edge!=getDetectorEdge(det)) { 00945 // ok, we are at one of the edges coming behind 00946 if (hasDetector(edge)) { 00947 const std::vector<std::string> &dets = myDetectorsOnEdges.find(edge)->second; 00948 for (std::vector<std::string>::const_iterator i=dets.begin(); i!=dets.end(); ++i) { 00949 if (detectors.getDetector(*i).getType()==SINK_DETECTOR) { 00950 return false; 00951 } 00952 if (detectors.getDetector(*i).getType()==BETWEEN_DETECTOR) { 00953 return false; 00954 } 00955 if (detectors.getDetector(*i).getType()==SOURCE_DETECTOR) { 00956 return true; 00957 } 00958 } 00959 } else { 00960 if (myAmInHighwayMode&&edge->getSpeed()<19.) { 00961 return false; 00962 } 00963 } 00964 } 00965 00966 if (myApproachedEdges.find(edge)==myApproachedEdges.end()) { 00967 return false; 00968 } 00969 00970 const std::vector<ROEdge*> &appr = myApproachedEdges.find(edge)->second; 00971 bool isall = false; 00972 for (size_t i=0; i<appr.size()&&!isall; i++) { 00973 //printf("checking %s->\n", appr[i].c_str()); 00974 bool had = std::find(seen.begin(), seen.end(), appr[i])!=seen.end(); 00975 if (!had) { 00976 if (isFalseSource(det, appr[i], seen, detectors)) { 00977 isall = true; 00978 } 00979 } 00980 } 00981 return isall; 00982 }
| bool RODFNet::isFalseSource | ( | const RODFDetector & | det, | |
| const RODFDetectorCon & | detectors | |||
| ) | const [protected] |
Definition at line 744 of file RODFNet.cpp.
References getDetectorEdge().
Referenced by computeTypes(), and isFalseSource().
00744 { 00745 std::vector<ROEdge*> seen; 00746 return 00747 isFalseSource(det, getDetectorEdge(det), seen, detectors); 00748 }
| bool RODFNet::isSource | ( | const RODFDetector & | det, | |
| ROEdge * | edge, | |||
| std::vector< ROEdge * > & | seen, | |||
| const RODFDetectorCon & | detectors, | |||
| bool | strict | |||
| ) | const [protected] |
Definition at line 758 of file RODFNet.cpp.
References getAbsPos(), RODFDetectorCon::getDetector(), getDetectorEdge(), RODFDetector::getID(), ROEdge::getSpeed(), MsgHandler::getWarningInstance(), hasApproaching(), hasDetector(), MsgHandler::inform(), isSource(), myAmInHighwayMode, myApproachingEdges, myDetectorEdges, and myDetectorsOnEdges.
00761 { 00762 if (seen.size()==1000) { // !!! 00763 MsgHandler::getWarningInstance()->inform("Quitting checking for being a source for detector '" + det.getID() + "' due to seen edge limit."); 00764 return false; 00765 } 00766 if (edge==getDetectorEdge(det)) { 00767 // maybe there is another detector at the same edge 00768 // get the list of this/these detector(s) 00769 const std::vector<std::string> &detsOnEdge = myDetectorsOnEdges.find(edge)->second; 00770 for (std::vector<std::string>::const_iterator i=detsOnEdge.begin(); i!=detsOnEdge.end(); ++i) { 00771 if ((*i)==det.getID()) { 00772 continue; 00773 } 00774 const RODFDetector &sec = detectors.getDetector(*i); 00775 if (getAbsPos(sec)<getAbsPos(det)) { 00776 // ok, there is another detector on the same edge and it is 00777 // before this one -> no source 00778 return false; 00779 } 00780 } 00781 } 00782 // it's a source if no edges are approaching the edge 00783 if (!hasApproaching(edge)) { 00784 if (edge!=getDetectorEdge(det)) { 00785 if (hasDetector(edge)) { 00786 return false; 00787 } 00788 } 00789 return true; 00790 } 00791 if (edge!=getDetectorEdge(det)) { 00792 // ok, we are at one of the edges in front 00793 if (myAmInHighwayMode) { 00794 if (edge->getSpeed()>=19.4) { 00795 if (hasDetector(edge)) { 00796 // we are still on the highway and there is another detector 00797 return false; 00798 } 00799 // the next is a hack for the A100 scenario... 00800 // We have to look into further edges herein edges 00801 const std::vector<ROEdge*> &appr = myApproachingEdges.find(edge)->second; 00802 size_t noOk = 0; 00803 size_t noFalse = 0; 00804 size_t noSkipped = 0; 00805 for (size_t i=0; i<appr.size(); i++) { 00806 if (!hasDetector(appr[i])) { 00807 noOk++; 00808 } else { 00809 noFalse++; 00810 } 00811 } 00812 if ((noFalse+noSkipped)==appr.size()) { 00813 return false; 00814 } 00815 } 00816 } 00817 } 00818 00819 if (myAmInHighwayMode) { 00820 if (edge->getSpeed()<19.4&&edge!=getDetectorEdge(det)) { 00821 // we have left the highway already 00822 // -> the detector will be a highway source 00823 if (!hasDetector(edge)) { 00824 return true; 00825 } 00826 } 00827 } 00828 if (myDetectorsOnEdges.find(edge)!=myDetectorsOnEdges.end() 00829 && 00830 myDetectorEdges.find(det.getID())->second!=edge) { 00831 return false; 00832 } 00833 00834 // let's check the edges in front 00835 const std::vector<ROEdge*> &appr = myApproachingEdges.find(edge)->second; 00836 size_t noOk = 0; 00837 size_t noFalse = 0; 00838 size_t noSkipped = 0; 00839 seen.push_back(edge); 00840 for (size_t i=0; i<appr.size(); i++) { 00841 bool had = std::find(seen.begin(), seen.end(), appr[i])!=seen.end(); 00842 if (!had) { 00843 if (isSource(det, appr[i], seen, detectors, strict)) { 00844 noOk++; 00845 } else { 00846 noFalse++; 00847 } 00848 } else { 00849 noSkipped++; 00850 } 00851 } 00852 if (!strict) { 00853 return (noFalse+noSkipped)!=appr.size(); 00854 } else { 00855 return (noOk+noSkipped)==appr.size(); 00856 } 00857 }
| bool RODFNet::isSource | ( | const RODFDetector & | det, | |
| const RODFDetectorCon & | detectors, | |||
| bool | strict | |||
| ) | const [protected] |
Definition at line 736 of file RODFNet.cpp.
References getDetectorEdge().
Referenced by computeTypes(), and isSource().
00737 { 00738 std::vector<ROEdge*> seen; 00739 return 00740 isSource(det, getDetectorEdge(det), seen, detectors, strict); 00741 }
| void RODFNet::mesoJoin | ( | RODFDetectorCon & | detectors, | |
| RODFDetectorFlows & | flows | |||
| ) |
Definition at line 1099 of file RODFNet.cpp.
References buildDetectorEdgeDependencies(), RODFDetectorCon::getDetector(), RODFDetector::getPos(), RODFDetectorCon::mesoJoin(), RODFDetectorFlows::mesoJoin(), myDetectorsOnEdges, and SUMOReal.
01099 { 01100 buildDetectorEdgeDependencies(detectors); 01101 std::map<ROEdge*, std::vector<std::string> >::iterator i; 01102 for (i=myDetectorsOnEdges.begin(); i!=myDetectorsOnEdges.end(); ++i) { 01103 ROEdge *into = (*i).first; 01104 const std::vector<std::string> &dets = (*i).second; 01105 std::map<SUMOReal, std::vector<std::string> > cliques; 01106 // compute detector cliques 01107 for (std::vector<std::string>::const_iterator j=dets.begin(); j!=dets.end(); ++j) { 01108 const RODFDetector &det = detectors.getDetector(*j); 01109 bool found = false; 01110 for (std::map<SUMOReal, std::vector<std::string> >::iterator k=cliques.begin(); !found&&k!=cliques.end(); ++k) { 01111 if (fabs((*k).first-det.getPos())<10.) { 01112 (*k).second.push_back(*j); 01113 found = true; 01114 } 01115 } 01116 if (!found) { 01117 cliques[det.getPos()] = std::vector<std::string>(); 01118 cliques[det.getPos()].push_back(*j); 01119 } 01120 } 01121 // join detector cliques 01122 for (std::map<SUMOReal, std::vector<std::string> >::iterator m=cliques.begin(); m!=cliques.end(); ++m) { 01123 std::vector<std::string> clique = (*m).second; 01124 // do not join if only one 01125 if (clique.size()==1) { 01126 continue; 01127 } 01128 std::string nid; 01129 for (std::vector<std::string>::iterator n=clique.begin(); n!=clique.end(); ++n) { 01130 std::cout << *n << " "; 01131 if (n!=clique.begin()) { 01132 nid = nid + "_"; 01133 } 01134 nid = nid + *n; 01135 } 01136 std::cout << ":" << nid << std::endl; 01137 flows.mesoJoin(nid, (*m).second); 01138 detectors.mesoJoin(nid, (*m).second); 01139 } 01140 } 01141 }
| void RONet::openOutput | ( | const std::string & | filename, | |
| bool | useAlternatives | |||
| ) | throw (IOError) [inherited] |
Opens the output for computed routes.
If the second parameter is true, a second file for route alternatives will be opened. The route alternatives files is simply the given name with ".alt" appended (before the ".xml"-suffix). If one of the file outputs can not be build, an IOError is thrown
| [in] | filename | The (base) name of the file(s) to create |
| [in] | useAlternatives | Whether a file for writing alternatives shall be created |
Definition at line 100 of file RONet.cpp.
References OutputDevice::getDevice(), RONet::myRouteAlternativesOutput, RONet::myRoutesOutput, and OutputDevice::writeXMLHeader().
Referenced by computeRoutes().
00100 { 00101 myRoutesOutput = &OutputDevice::getDevice(filename); 00102 myRoutesOutput->writeXMLHeader("routes"); 00103 if (useAlternatives) { 00104 size_t len = filename.length(); 00105 if (len > 4 && filename.substr(len - 4) == ".xml") { 00106 myRouteAlternativesOutput = &OutputDevice::getDevice(filename.substr(0, len-4)+".alt.xml"); 00107 } else { 00108 myRouteAlternativesOutput = &OutputDevice::getDevice(filename+".alt"); 00109 } 00110 myRouteAlternativesOutput->writeXMLHeader("route-alternatives"); 00111 } 00112 }
| void RODFNet::removeEmptyDetectors | ( | RODFDetectorCon & | detectors, | |
| RODFDetectorFlows & | flows, | |||
| SUMOTime | startTime, | |||
| SUMOTime | endTime, | |||
| SUMOTime | stepOffset | |||
| ) |
Definition at line 640 of file RODFNet.cpp.
References RODFDetectorCon::getDetectors(), MsgHandler::getMessageInstance(), MsgHandler::inform(), RODFDetectorFlows::knows(), RODFDetectorCon::removeDetector(), and RODFDetectorFlows::removeFlow().
Referenced by startComputation().
00643 { 00644 const std::vector<RODFDetector*> &dets = detectors.getDetectors(); 00645 for (std::vector<RODFDetector*>::const_iterator i=dets.begin(); i!=dets.end();) { 00646 bool remove = true; 00647 // check whether there is at least one entry with a flow larger than zero 00648 if (flows.knows((*i)->getID())) { 00649 remove = false; 00650 } 00651 if (remove) { 00652 MsgHandler::getMessageInstance()->inform("Removed detector '" + (*i)->getID() + "' because no flows for him exist."); 00653 flows.removeFlow((*i)->getID()); 00654 detectors.removeDetector((*i)->getID()); 00655 i = dets.begin(); 00656 } else { 00657 i++; 00658 } 00659 } 00660 }
| void RODFNet::reportEmptyDetectors | ( | RODFDetectorCon & | detectors, | |
| RODFDetectorFlows & | flows | |||
| ) |
Definition at line 665 of file RODFNet.cpp.
References RODFDetectorCon::getDetectors(), MsgHandler::getMessageInstance(), MsgHandler::inform(), and RODFDetectorFlows::knows().
Referenced by startComputation().
00666 { 00667 const std::vector<RODFDetector*> &dets = detectors.getDetectors(); 00668 for (std::vector<RODFDetector*>::const_iterator i=dets.begin(); i!=dets.end(); ++i) { 00669 bool remove = true; 00670 // check whether there is at least one entry with a flow larger than zero 00671 if (flows.knows((*i)->getID())) { 00672 remove = false; 00673 } 00674 if (remove) { 00675 MsgHandler::getMessageInstance()->inform("Detector '" + (*i)->getID() + "' has no flow."); 00676 } 00677 } 00678 }
| void RODFNet::revalidateFlows | ( | const RODFDetector * | detector, | |
| RODFDetectorFlows & | flows, | |||
| SUMOTime | startTime, | |||
| SUMOTime | endTime, | |||
| SUMOTime | stepOffset | |||
| ) | [protected] |
Definition at line 479 of file RODFNet.cpp.
References RODFNet::IterationEdge::depth, RODFNet::IterationEdge::edge, getDetectorEdge(), RODFDetectorFlows::getFlowDefs(), RODFDetector::getID(), hasDetector(), RODFDetectorFlows::knows(), myApproachedEdges, myApproachingEdges, FlowDef::qLKW, FlowDef::qPKW, RODFDetectorFlows::setFlows(), SUMOReal, FlowDef::vLKW, FlowDef::vPKW, and WRITE_WARNING.
00482 { 00483 { 00484 if (flows.knows(detector->getID())) { 00485 const std::vector<FlowDef> &detFlows = flows.getFlowDefs(detector->getID()); 00486 for (std::vector<FlowDef>::const_iterator j=detFlows.begin(); j!=detFlows.end(); ++j) { 00487 if ((*j).qPKW>0||(*j).qLKW>0) { 00488 return; 00489 } 00490 } 00491 } 00492 } 00493 // ok, there is no information for the whole time; 00494 // lets find preceding detectors and rebuild the flows if possible 00495 WRITE_WARNING("Detector '" + detector->getID() + "' has no flows.\n Trying to rebuild."); 00496 // go back and collect flows 00497 std::vector<ROEdge*> previous; 00498 { 00499 std::vector<IterationEdge> missing; 00500 IterationEdge ie; 00501 ie.depth = 0; 00502 ie.edge = getDetectorEdge(*detector); 00503 missing.push_back(ie); 00504 bool maxDepthReached = false; 00505 while (!missing.empty()&&!maxDepthReached) { 00506 IterationEdge last = missing.back(); 00507 missing.pop_back(); 00508 std::vector<ROEdge*> approaching = myApproachingEdges[last.edge]; 00509 for (std::vector<ROEdge*>::const_iterator j=approaching.begin(); j!=approaching.end(); ++j) { 00510 if (hasDetector(*j)) { 00511 previous.push_back(*j); 00512 } else { 00513 ie.depth = last.depth + 1; 00514 ie.edge = *j; 00515 missing.push_back(ie); 00516 if (ie.depth>5) { 00517 maxDepthReached = true; 00518 } 00519 } 00520 } 00521 } 00522 if (maxDepthReached) { 00523 WRITE_WARNING(" Could not build list of previous flows."); 00524 } 00525 } 00526 // Edges with previous detectors are now in "previous"; 00527 // compute following 00528 std::vector<ROEdge*> latter; 00529 { 00530 std::vector<IterationEdge> missing; 00531 for (std::vector<ROEdge*>::const_iterator k=previous.begin(); k!=previous.end(); ++k) { 00532 IterationEdge ie; 00533 ie.depth = 0; 00534 ie.edge = *k; 00535 missing.push_back(ie); 00536 } 00537 bool maxDepthReached = false; 00538 while (!missing.empty()&&!maxDepthReached) { 00539 IterationEdge last = missing.back(); 00540 missing.pop_back(); 00541 std::vector<ROEdge*> approached = myApproachedEdges[last.edge]; 00542 for (std::vector<ROEdge*>::const_iterator j=approached.begin(); j!=approached.end(); ++j) { 00543 if (*j==getDetectorEdge(*detector)) { 00544 continue; 00545 } 00546 if (hasDetector(*j)) { 00547 latter.push_back(*j); 00548 } else { 00549 IterationEdge ie; 00550 ie.depth = last.depth + 1; 00551 ie.edge = *j; 00552 missing.push_back(ie); 00553 if (ie.depth>5) { 00554 maxDepthReached = true; 00555 } 00556 } 00557 } 00558 } 00559 if (maxDepthReached) { 00560 WRITE_WARNING(" Could not build list of latter flows."); 00561 return; 00562 } 00563 } 00564 // Edges with latter detectors are now in "latter"; 00565 00566 // lets not validate them by now - surely this should be done 00567 // for each time step: collect incoming flows; collect outgoing; 00568 std::vector<FlowDef> mflows; 00569 for (SUMOTime t=startTime; t<endTime; t+=stepOffset) { 00570 FlowDef inFlow; 00571 inFlow.qLKW = 0; 00572 inFlow.qPKW = 0; 00573 inFlow.vLKW = 0; 00574 inFlow.vPKW = 0; 00575 // collect incoming 00576 { 00577 // !! time difference is missing 00578 for (std::vector<ROEdge*>::iterator i=previous.begin(); i!=previous.end(); ++i) { 00579 const std::vector<FlowDef> &flows = static_cast<const RODFEdge*>(*i)->getFlows(); 00580 if (flows.size()!=0) { 00581 const FlowDef &srcFD = flows[(int)(t/stepOffset) - startTime]; 00582 inFlow.qLKW += srcFD.qLKW; 00583 inFlow.qPKW += srcFD.qPKW; 00584 inFlow.vLKW += srcFD.vLKW; 00585 inFlow.vPKW += srcFD.vPKW; 00586 } 00587 } 00588 } 00589 inFlow.vLKW /= (SUMOReal) previous.size(); 00590 inFlow.vPKW /= (SUMOReal) previous.size(); 00591 // collect outgoing 00592 FlowDef outFlow; 00593 outFlow.qLKW = 0; 00594 outFlow.qPKW = 0; 00595 outFlow.vLKW = 0; 00596 outFlow.vPKW = 0; 00597 { 00598 // !! time difference is missing 00599 for (std::vector<ROEdge*>::iterator i=latter.begin(); i!=latter.end(); ++i) { 00600 const std::vector<FlowDef> &flows = static_cast<const RODFEdge*>(*i)->getFlows(); 00601 if (flows.size()!=0) { 00602 const FlowDef &srcFD = flows[(int)(t/stepOffset) - startTime]; 00603 outFlow.qLKW += srcFD.qLKW; 00604 outFlow.qPKW += srcFD.qPKW; 00605 outFlow.vLKW += srcFD.vLKW; 00606 outFlow.vPKW += srcFD.vPKW; 00607 } 00608 } 00609 } 00610 outFlow.vLKW /= (SUMOReal) latter.size(); 00611 outFlow.vPKW /= (SUMOReal) latter.size(); 00612 // 00613 FlowDef mFlow; 00614 mFlow.qLKW = inFlow.qLKW - outFlow.qLKW; 00615 mFlow.qPKW = inFlow.qPKW - outFlow.qPKW; 00616 mFlow.vLKW = (inFlow.vLKW + outFlow.vLKW) / (SUMOReal) 2.; 00617 mFlow.vPKW = (inFlow.vPKW + outFlow.vPKW) / (SUMOReal) 2.; 00618 mflows.push_back(mFlow); 00619 } 00620 static_cast<RODFEdge*>(getDetectorEdge(*detector))->setFlows(mflows); 00621 flows.setFlows(detector->getID(), mflows); 00622 }
| void RODFNet::revalidateFlows | ( | const RODFDetectorCon & | detectors, | |
| RODFDetectorFlows & | flows, | |||
| SUMOTime | startTime, | |||
| SUMOTime | endTime, | |||
| SUMOTime | stepOffset | |||
| ) |
Definition at line 626 of file RODFNet.cpp.
References RODFDetectorCon::getDetectors().
Referenced by startComputation().
00629 { 00630 const std::vector<RODFDetector*> &dets = detectors.getDetectors(); 00631 for (std::vector<RODFDetector*>::const_iterator i=dets.begin(); i!=dets.end(); ++i) { 00632 // check whether there is at least one entry with a flow larger than zero 00633 revalidateFlows(*i, flows, startTime, endTime, stepOffset); 00634 } 00635 }
| SUMOTime RONet::saveAndRemoveRoutesUntil | ( | OptionsCont & | options, | |
| SUMOAbstractRouter< ROEdge, ROVehicle > & | router, | |||
| SUMOTime | time | |||
| ) | [inherited] |
Computes routes described by their definitions and saves them.
As long a vehicle with a departure time not larger than the given exists, its route is computed and it is written and removed from the internal container.
| [in] | options | The options used during this process |
| [in] | router | The router to use for routes computation |
| [in] | options | The time until which route definitions shall be processed |
Definition at line 214 of file RONet.cpp.
References RONet::computeRoute(), ROVehicleCont::erase(), OptionsCont::getBool(), ROVehicle::getDepartureTime(), ROVehicle::getID(), OptionsCont::getInt(), ROVehicleCont::getTopVehicle(), RONet::myDiscardedRouteNo, RONet::myReadRouteNo, RONet::myRouteAlternativesOutput, RONet::myRoutesOutput, RONet::myVehicles, RONet::myWrittenRouteNo, ROVehicle::saveAllAsXML(), NamedObjectCont< T >::size(), toString(), and WRITE_MESSAGE.
Referenced by ROLoader::makeSingleStep(), and ROLoader::processAllRoutes().
00215 { 00216 SUMOTime lastTime = -1; 00217 // write all vehicles (and additional structures) 00218 while (myVehicles.size()!=0) { 00219 // get the next vehicle 00220 const ROVehicle * const veh = myVehicles.getTopVehicle(); 00221 SUMOTime currentTime = veh->getDepartureTime(); 00222 // check whether it shall not yet be computed 00223 if (currentTime>time) { 00224 lastTime = currentTime; 00225 break; 00226 } 00227 // check whether to print the output 00228 if (lastTime!=currentTime&&lastTime!=-1) { 00229 // report writing progress 00230 if (options.getInt("stats-period")>=0 && ((int) currentTime%options.getInt("stats-period"))==0) { 00231 WRITE_MESSAGE("Read: " + toString(myReadRouteNo) + ", Discarded: " + toString(myDiscardedRouteNo) + ", Written: " + toString(myWrittenRouteNo)); 00232 } 00233 } 00234 lastTime = currentTime; 00235 00236 // ok, compute the route (try it) 00237 if (computeRoute(options, router, veh)) { 00238 // write the route 00239 veh->saveAllAsXML(router, *myRoutesOutput, myRouteAlternativesOutput, options.getBool("exit-times")); 00240 myWrittenRouteNo++; 00241 // remove the route if it is not longer used 00242 /* 00243 if (!myRoutes.erase(route->getID())) { 00244 MsgHandler::getWarningInstance()->inform("Could not remove " + route->getID()); 00245 } 00246 */ 00247 } else { 00248 myDiscardedRouteNo++; 00249 } 00250 // and the vehicle 00251 myVehicles.erase(veh->getID()); 00252 } 00253 return lastTime; 00254 }
| void RONet::setRestrictionFound | ( | ) | [inherited] |
Definition at line 351 of file RONet.cpp.
References RONet::myHaveRestrictions.
Referenced by RONetHandler::parseLane().
00351 { 00352 myHaveRestrictions = true; 00353 }
bool RODFNet::myAmInHighwayMode [private] |
Definition at line 161 of file RODFNet.h.
Referenced by computeRoutesFor(), isDestination(), isFalseSource(), and isSource().
std::map<ROEdge*, std::vector<ROEdge*> > RODFNet::myApproachedEdges [private] |
Map of edge name->list of names of edges approached by this edge.
Definition at line 156 of file RODFNet.h.
Referenced by buildApproachList(), computeRoutesFor(), hasApproached(), isDestination(), isFalseSource(), and revalidateFlows().
std::map<ROEdge*, std::vector<ROEdge*> > RODFNet::myApproachingEdges [private] |
Map of edge name->list of names of this edge approaching edges.
Definition at line 153 of file RODFNet.h.
Referenced by buildApproachList(), hasApproaching(), isSource(), and revalidateFlows().
std::vector<ROEdge*> RONet::myDestinationEdges [mutable, protected, inherited] |
List of destination edges.
Definition at line 320 of file RONet.h.
Referenced by RONet::checkSourceAndDestinations(), and RONet::getRandomDestination().
std::map<std::string, ROEdge*> RODFNet::myDetectorEdges [mutable, private] |
Definition at line 159 of file RODFNet.h.
Referenced by buildDetectorDependencies(), buildDetectorEdgeDependencies(), isDestination(), and isSource().
std::map<ROEdge*, std::vector<std::string> > RODFNet::myDetectorsOnEdges [mutable, private] |
Definition at line 158 of file RODFNet.h.
Referenced by buildDetectorDependencies(), buildDetectorEdgeDependencies(), buildEdgeFlowMap(), buildRoutes(), getDetectorList(), hasDetector(), hasInBetweenDetectorsOnly(), hasSourceDetector(), isDestination(), isFalseSource(), isSource(), and mesoJoin().
std::vector<std::string> RODFNet::myDisallowedEdges [private] |
List of ids of edges that shall not be used.
Definition at line 165 of file RODFNet.h.
Referenced by buildApproachList().
unsigned int RONet::myDiscardedRouteNo [protected, inherited] |
The number of discarded routes.
Definition at line 332 of file RONet.h.
Referenced by RONet::saveAndRemoveRoutesUntil().
NamedObjectCont<ROEdge*> RONet::myEdges [protected, inherited] |
Known edges.
Definition at line 305 of file RONet.h.
Referenced by RONet::addEdge(), RONet::checkSourceAndDestinations(), RONet::getEdge(), RONet::getEdgeMap(), RONet::getEdgeNo(), and RONet::~RONet().
bool RONet::myHaveRestrictions [protected, inherited] |
Whether the network contains edges which not all vehicles may pass.
Definition at line 338 of file RONet.h.
Referenced by RONet::hasRestrictions(), and RONet::setRestrictionFound().
size_t RODFNet::myInBetweenNumber [mutable, private] |
size_t RODFNet::myInvalidNumber [mutable, private] |
bool RODFNet::myKeepTurnarounds [private] |
NamedObjectCont<RONode*> RONet::myNodes [protected, inherited] |
Known nodes.
Definition at line 302 of file RONet.h.
Referenced by RONet::addNode(), RONet::getNode(), and RONet::~RONet().
unsigned int RONet::myReadRouteNo [protected, inherited] |
The number of read routes.
Definition at line 329 of file RONet.h.
Referenced by RONet::addVehicle(), and RONet::saveAndRemoveRoutesUntil().
OutputDevice* RONet::myRouteAlternativesOutput [protected, inherited] |
The file to write the computed route alternatives into.
Definition at line 326 of file RONet.h.
Referenced by RONet::closeOutput(), RONet::openOutput(), and RONet::saveAndRemoveRoutesUntil().
NamedObjectCont<RORouteDef*> RONet::myRoutes [protected, inherited] |
Known routes.
Definition at line 311 of file RONet.h.
Referenced by RONet::addRouteDef(), RONet::getRouteDef(), and RONet::~RONet().
OutputDevice* RONet::myRoutesOutput [protected, inherited] |
The file to write the computed routes into.
Definition at line 323 of file RONet.h.
Referenced by RONet::closeOutput(), RONet::openOutput(), and RONet::saveAndRemoveRoutesUntil().
size_t RODFNet::mySinkNumber [mutable, private] |
std::vector<ROEdge*> RONet::mySourceEdges [mutable, protected, inherited] |
List of source edges.
Definition at line 317 of file RONet.h.
Referenced by RONet::checkSourceAndDestinations(), and RONet::getRandomSource().
size_t RODFNet::mySourceNumber [mutable, private] |
ROVehicleCont RONet::myVehicles [protected, inherited] |
Known vehicles.
Definition at line 314 of file RONet.h.
Referenced by RONet::addVehicle(), RONet::furtherStored(), RONet::saveAndRemoveRoutesUntil(), and RONet::~RONet().
NamedObjectCont<SUMOVTypeParameter*> RONet::myVehicleTypes [protected, inherited] |
Known vehicle types.
Definition at line 308 of file RONet.h.
Referenced by RONet::addVehicleType(), RONet::getVehicleTypeSecure(), and RONet::~RONet().
std::set<std::string> RONet::myVehIDs [protected, inherited] |
unsigned int RONet::myWrittenRouteNo [protected, inherited] |
The number of written routes.
Definition at line 335 of file RONet.h.
Referenced by RONet::saveAndRemoveRoutesUntil().
1.5.6