#include <RODFDetectorFlow.h>
Definition at line 72 of file RODFDetectorFlow.h.
Public Member Functions | |
| void | addFlow (const std::string &detector_id, int timestamp, const FlowDef &fd) |
| const std::vector< FlowDef > & | getFlowDefs (const std::string &id) const |
| SUMOReal | getFlowSumSecure (const std::string &id) const |
| SUMOReal | getMaxDetectorFlow () const |
| bool | knows (const std::string &det_id, SUMOTime time) const |
| bool | knows (const std::string &det_id) const |
| void | mesoJoin (const std::string &nid, const std::vector< std::string > &oldids) |
| void | printAbsolute () const |
| void | removeFlow (const std::string &detector_id) |
| RODFDetectorFlows (SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset) | |
| void | setFlows (const std::string &detector_id, std::vector< FlowDef > &) |
| ~RODFDetectorFlows () | |
Protected Attributes | |
| SUMOTime | myBeginTime |
| SUMOTime | myEndTime |
| std::map< std::string, std::vector< FlowDef > > | myFastAccessFlows |
| SUMOReal | myMaxDetectorFlow |
| SUMOTime | myStepOffset |
Private Member Functions | |
| RODFDetectorFlows & | operator= (const RODFDetectorFlows &src) |
| Invalidated assignment operator. | |
| RODFDetectorFlows (const RODFDetectorFlows &src) | |
| Invalidated copy constructor. | |
Definition at line 42 of file RODFDetectorFlow.cpp.
00044 : myBeginTime(startTime), myEndTime(endTime), myStepOffset(stepOffset), 00045 myMaxDetectorFlow(-1) {}
| RODFDetectorFlows::~RODFDetectorFlows | ( | ) |
| RODFDetectorFlows::RODFDetectorFlows | ( | const RODFDetectorFlows & | src | ) | [private] |
Invalidated copy constructor.
| void RODFDetectorFlows::addFlow | ( | const std::string & | detector_id, | |
| int | timestamp, | |||
| const FlowDef & | fd | |||
| ) |
Definition at line 52 of file RODFDetectorFlow.cpp.
References FlowDef::firstSet, FlowDef::fLKW, FlowDef::isLKW, myBeginTime, myEndTime, myFastAccessFlows, myStepOffset, FlowDef::qLKW, FlowDef::qPKW, size, FlowDef::vLKW, and FlowDef::vPKW.
Referenced by mesoJoin(), and RODFDetFlowLoader::read().
00052 { 00053 if (myFastAccessFlows.find(id)==myFastAccessFlows.end()) { 00054 size_t noItems = (size_t)((myEndTime-myBeginTime)/myStepOffset); 00055 myFastAccessFlows[id] = std::vector<FlowDef>(noItems); 00056 std::vector<FlowDef> &cflows = myFastAccessFlows.find(id)->second; 00057 // initialise 00058 for (std::vector<FlowDef>::iterator i=cflows.begin(); i<cflows.end(); ++i) { 00059 (*i).qPKW = 0; 00060 (*i).qLKW = 0; 00061 (*i).vPKW = 0; 00062 (*i).vLKW = 0; 00063 (*i).fLKW = 0; 00064 (*i).isLKW = 0; 00065 (*i).firstSet = true; 00066 } 00067 } 00068 assert(t<(int) myFastAccessFlows[id].size()); 00069 FlowDef &ofd = myFastAccessFlows[id][t]; 00070 if (ofd.firstSet) { 00071 ofd = fd; 00072 ofd.firstSet = false; 00073 } else { 00074 ofd.qLKW = ofd.qLKW + fd.qLKW; 00075 ofd.qPKW = ofd.qPKW + fd.qPKW; 00076 ofd.vLKW = ofd.vLKW + fd.vLKW; 00077 ofd.vPKW = ofd.vPKW + fd.vPKW; 00078 } 00079 if (ofd.qLKW!=0 && ofd.qPKW!=0) { 00080 ofd.fLKW = ofd.qLKW / ofd.qPKW ; 00081 } else if (ofd.qPKW!=0) { 00082 ofd.fLKW = 0; 00083 } else { 00084 ofd.fLKW = 1; 00085 ofd.isLKW = 1; 00086 } 00087 }
| const std::vector< FlowDef > & RODFDetectorFlows::getFlowDefs | ( | const std::string & | id | ) | const |
Definition at line 131 of file RODFDetectorFlow.cpp.
References myFastAccessFlows.
Referenced by RODFDetector::buildDestinationDistribution(), RODFNet::buildEdgeFlowMap(), getFlowSumSecure(), RODFNet::revalidateFlows(), RODFDetector::writeEmitterDefinition(), and RODFDetector::writeSingleSpeedTrigger().
00131 { 00132 assert(myFastAccessFlows.find(id)!=myFastAccessFlows.end()); 00133 assert(myFastAccessFlows.find(id)->second.size()!=0); 00134 return myFastAccessFlows.find(id)->second; 00135 }
| SUMOReal RODFDetectorFlows::getFlowSumSecure | ( | const std::string & | id | ) | const |
Definition at line 139 of file RODFDetectorFlow.cpp.
References getFlowDefs(), knows(), and SUMOReal.
Referenced by RODFDetectorCon::writeEmitterPOIs().
00139 { 00140 SUMOReal ret = 0; 00141 if (knows(id)) { 00142 const std::vector<FlowDef> &flows = getFlowDefs(id); 00143 for (std::vector<FlowDef>::const_iterator i=flows.begin(); i!=flows.end(); ++i) { 00144 ret += (*i).qPKW; 00145 ret += (*i).qLKW; 00146 } 00147 } 00148 return ret; 00149 }
| SUMOReal RODFDetectorFlows::getMaxDetectorFlow | ( | ) | const |
Definition at line 153 of file RODFDetectorFlow.cpp.
References max, myFastAccessFlows, myMaxDetectorFlow, and SUMOReal.
Referenced by RODFDetectorCon::writeEmitterPOIs().
00153 { 00154 if (myMaxDetectorFlow<0) { 00155 SUMOReal max = 0; 00156 std::map<std::string, std::vector<FlowDef> >::const_iterator j; 00157 for (j=myFastAccessFlows.begin(); j!=myFastAccessFlows.end(); ++j) { 00158 SUMOReal curr = 0; 00159 const std::vector<FlowDef> &flows = (*j).second; 00160 for (std::vector<FlowDef>::const_iterator i=flows.begin(); i!=flows.end(); ++i) { 00161 curr += (*i).qPKW; 00162 curr += (*i).qLKW; 00163 } 00164 if (max<curr) { 00165 max = curr; 00166 } 00167 } 00168 myMaxDetectorFlow = max; 00169 } 00170 return myMaxDetectorFlow; 00171 }
!!
Definition at line 122 of file RODFDetectorFlow.cpp.
References myFastAccessFlows.
00122 { 00123 if (myFastAccessFlows.find(det_id)==myFastAccessFlows.end()) { 00124 return false; 00125 } 00126 return true; 00127 }
| bool RODFDetectorFlows::knows | ( | const std::string & | det_id | ) | const |
Definition at line 116 of file RODFDetectorFlow.cpp.
References myFastAccessFlows.
Referenced by RODFNet::buildEdgeFlowMap(), getFlowSumSecure(), RODFDetectorCon::guessEmptyFlows(), mesoJoin(), RODFNet::removeEmptyDetectors(), RODFNet::reportEmptyDetectors(), RODFNet::revalidateFlows(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitters(), and RODFDetectorCon::writeSpeedTrigger().
00116 { 00117 return myFastAccessFlows.find(det_id)!=myFastAccessFlows.end(); 00118 }
| void RODFDetectorFlows::mesoJoin | ( | const std::string & | nid, | |
| const std::vector< std::string > & | oldids | |||
| ) |
Definition at line 175 of file RODFDetectorFlow.cpp.
References addFlow(), knows(), myBeginTime, myEndTime, myFastAccessFlows, and myStepOffset.
Referenced by RODFNet::mesoJoin().
00176 { 00177 for (std::vector<std::string>::const_iterator i=oldids.begin(); i!=oldids.end(); ++i) { 00178 if (!knows(*i)) { 00179 continue; 00180 } 00181 std::map<std::string, std::vector<FlowDef> >::iterator j = myFastAccessFlows.find(*i); 00182 std::vector<FlowDef> &flows = (*j).second; 00183 size_t index = 0; 00184 for (SUMOTime t=myBeginTime; t!=myEndTime; t+=myStepOffset) { 00185 addFlow(nid, t/myStepOffset, flows[index++]); // !!! 00186 } 00187 myFastAccessFlows.erase(j); 00188 } 00189 }
| RODFDetectorFlows& RODFDetectorFlows::operator= | ( | const RODFDetectorFlows & | src | ) | [private] |
Invalidated assignment operator.
| void RODFDetectorFlows::printAbsolute | ( | ) | const |
Definition at line 193 of file RODFDetectorFlow.cpp.
References myFastAccessFlows, and SUMOReal.
Referenced by startComputation().
00193 { 00194 for (std::map<std::string, std::vector<FlowDef> >::const_iterator i=myFastAccessFlows.begin(); i!=myFastAccessFlows.end(); ++i) { 00195 std::cout << (*i).first << ":"; 00196 const std::vector<FlowDef> &flows = (*i).second; 00197 SUMOReal qPKW = 0; 00198 SUMOReal qLKW = 0; 00199 for (std::vector<FlowDef>::const_iterator j=flows.begin(); j!=flows.end(); ++j) { 00200 qPKW += (*j).qPKW; 00201 qLKW += (*j).qLKW; 00202 } 00203 std::cout << qPKW << "/" << qLKW << std::endl; 00204 } 00205 }
| void RODFDetectorFlows::removeFlow | ( | const std::string & | detector_id | ) |
Definition at line 108 of file RODFDetectorFlow.cpp.
References myFastAccessFlows.
Referenced by RODFNet::removeEmptyDetectors().
00108 { 00109 if (myFastAccessFlows.find(detector_id)!=myFastAccessFlows.end()) { 00110 myFastAccessFlows.erase(myFastAccessFlows.find(detector_id)); 00111 } 00112 }
| void RODFDetectorFlows::setFlows | ( | const std::string & | detector_id, | |
| std::vector< FlowDef > & | flows | |||
| ) |
Definition at line 93 of file RODFDetectorFlow.cpp.
References FlowDef::fLKW, myFastAccessFlows, FlowDef::qLKW, and FlowDef::qPKW.
Referenced by RODFNet::revalidateFlows().
00094 { 00095 for (std::vector<FlowDef>::iterator i=flows.begin(); i<flows.end(); ++i) { 00096 FlowDef &ofd = *i; 00097 if (ofd.qLKW!=0 && ofd.qPKW!=0) { 00098 ofd.fLKW = ofd.qLKW / ofd.qPKW ; 00099 } else { 00100 ofd.fLKW = 0; 00101 } 00102 } 00103 myFastAccessFlows[detector_id] = flows; 00104 }
SUMOTime RODFDetectorFlows::myBeginTime [protected] |
SUMOTime RODFDetectorFlows::myEndTime [protected] |
std::map<std::string, std::vector<FlowDef> > RODFDetectorFlows::myFastAccessFlows [protected] |
Definition at line 92 of file RODFDetectorFlow.h.
Referenced by addFlow(), getFlowDefs(), getMaxDetectorFlow(), knows(), mesoJoin(), printAbsolute(), removeFlow(), and setFlows().
SUMOReal RODFDetectorFlows::myMaxDetectorFlow [mutable, protected] |
SUMOTime RODFDetectorFlows::myStepOffset [protected] |
1.5.6