56 #ifdef CHECK_MEMORY_LEAKS
58 #endif // CHECK_MEMORY_LEAKS
66 :
Named(id), myLaneID(laneID), myPosition(pos), myType(type), myRoutes(0) {}
70 :
Named(id), myLaneID(f.myLaneID), myPosition(f.myPosition),
71 myType(f.myType), myRoutes(0) {
93 for (std::vector<ROEdge*>::const_iterator i = rd.
edges2Pass.begin(); i != rd.
edges2Pass.end(); ++i) {
94 length += (*i)->getLength();
96 return (distance / length);
108 const std::vector<RODFRouteDesc>& routes =
myRoutes->
get();
109 std::vector<RODFEdge*> nextDetEdges;
110 std::set<ROEdge*> preSplitEdges;
111 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
113 bool hadSplit =
false;
114 for (std::vector<ROEdge*>::const_iterator j = rd.
edges2Pass.begin(); j != rd.
edges2Pass.end(); ++j) {
116 if (find(nextDetEdges.begin(), nextDetEdges.end(), *j) == nextDetEdges.end()) {
117 nextDetEdges.push_back(static_cast<RODFEdge*>(*j));
123 preSplitEdges.insert(*j);
125 if ((*j)->getNoFollowing() > 1) {
130 std::map<ROEdge*, SUMOReal> inFlows;
132 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
133 std::set<ROEdge*> seen(preSplitEdges);
134 std::vector<ROEdge*> pending;
135 pending.push_back(*i);
137 while (!pending.empty()) {
138 ROEdge* e = pending.back();
141 for (
unsigned int j = 0; j < numAppr; j++) {
147 pending.push_back(e2);
157 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, ++index) {
161 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
167 if (overallProb > 0) {
168 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
187 std::vector<RODFRouteDesc>& descs =
myRoutes->
get();
189 for (
SUMOTime time = startTime; time < endTime; time += stepOffset) {
191 std::map<ROEdge*, SUMOReal> flowMap;
194 for (std::vector<RODFRouteDesc>::iterator ri = descs.begin(); ri != descs.end(); ++ri, index++) {
196 for (std::vector<ROEdge*>::iterator j = (*ri).edges2Pass.begin(); j != (*ri).edges2Pass.end() && prob > 0;) {
203 if (probs.size() == 0) {
208 const std::map<RODFEdge*, SUMOReal>& tprobs = probs[(time - startTime) / stepOffset];
210 for (std::map<RODFEdge*, SUMOReal>::const_iterator k = tprobs.begin(); k != tprobs.end(); ++k) {
211 if (find(j, (*ri).edges2Pass.end(), (*k).first) != (*ri).edges2Pass.end()) {
213 splitEdge = (*k).first;
217 if (splitEdge != 0) {
218 j = find(j, (*ri).edges2Pass.end(), splitEdge);
223 into[time]->add(prob, index);
224 (*ri).overallProb = prob;
230 const std::vector<RODFRouteDesc>&
248 const std::vector<RODFDetector*>&
254 const std::vector<RODFDetector*>&
289 bool includeUnusedRoutes,
300 const std::vector<RODFRouteDesc>& routes =
myRoutes->
get();
302 bool isEmptyDist =
true;
303 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
304 if ((*i).overallProb > 0) {
308 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
309 if ((*i).overallProb > 0 || includeUnusedRoutes) {
322 if (insertionsOnly || flows.
knows(
myID)) {
326 unsigned int index = 0;
327 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, index++) {
329 assert(index < mflows.size());
330 const FlowDef& srcFD = mflows[index];
334 size_t carNo = (size_t)((srcFD.qPKW + srcFD.qLKW) * scale);
335 for (
size_t car = 0; car < carNo; ++car) {
340 if (srcFD.isLKW >= 1) {
341 srcFD.isLKW = srcFD.isLKW - (
SUMOReal) 1.;
349 if (v <= 0 || v > 250) {
368 if (oc.
isSet(
"departlane")) {
373 if (oc.
isSet(
"departpos")) {
374 std::string posDesc = oc.
getString(
"departpos");
375 if (posDesc.substr(0, 8) ==
"detector") {
377 if (posDesc.length() > 8) {
378 if (posDesc[8] ==
'+') {
380 }
else if (posDesc[8] ==
'-') {
393 if (oc.
isSet(
"departspeed")) {
396 if (v > defaultSpeed) {
402 if (oc.
isSet(
"arrivallane")) {
405 if (oc.
isSet(
"arrivalpos")) {
408 if (oc.
isSet(
"arrivalspeed")) {
411 if (destIndex >= 0) {
417 srcFD.isLKW += srcFD.fLKW;
446 unsigned int index = 0;
447 for (
SUMOTime t = startTime; t < endTime; t += stepOffset, index++) {
448 assert(index < mflows.size());
449 const FlowDef& srcFD = mflows[index];
451 if (speed <= 0 || speed > 250) {
452 speed = defaultSpeed;
510 if ((*i)->hasRoutes()) {
518 const std::vector< RODFDetector*>&
530 switch ((*i)->getType()) {
558 switch ((*i)->getType()) {
584 std::vector<std::string> saved;
586 bool lastWasSaved =
true;
595 lastWasSaved = (*i)->writeRoutes(saved, out);
619 bool writeCalibrators,
620 bool includeUnusedRoutes,
622 bool insertionsOnly) {
625 (*i)->computeSplitProbabilities(&net, *
this, flows, startTime, endTime, stepOffset);
634 std::string defFileName;
646 std::map<size_t, RandomDistributor<size_t>* > dists;
647 if (!insertionsOnly && flows.
knows(det->
getID())) {
651 if (!det->
writeEmitterDefinition(defFileName, dists, flows, startTime, endTime, stepOffset, includeUnusedRoutes, scale, insertionsOnly, defaultSpeed)) {
675 const unsigned char col =
static_cast<unsigned char>(128 * flow / flows.
getMaxDetectorFlow() + 128);
677 switch ((*i)->getType()) {
711 const std::vector<FlowDef>& flows =
static_cast<const RODFEdge*
>(edge)->getFlows();
713 for (std::vector<FlowDef>::const_iterator i = flows.begin(); i != flows.end(); ++i) {
715 if (srcFD.
qLKW >= 0) {
718 if (srcFD.
qPKW >= 0) {
745 const std::string& file,
784 bool singleFile,
bool friendly) {
815 std::map<std::string, RODFDetector*>::iterator ri1 =
myDetectorMap.find(
id);
819 std::vector<RODFDetector*>::iterator ri2 =
825 std::vector<RODFDetector*>& dets = (*rr3).second;
826 for (std::vector<RODFDetector*>::iterator ri3 = dets.begin(); !found && ri3 != dets.end();) {
827 if (*ri3 == oldDet) {
829 ri3 = dets.erase(ri3);
850 size_t noFollowerWithRoutes = 0;
851 size_t noPriorWithRoutes = 0;
853 std::vector<RODFDetector*>::const_iterator j;
854 for (j = prior.begin(); j != prior.end(); ++j) {
855 if (flows.
knows((*j)->getID())) {
859 assert(noPriorWithRoutes <= prior.size());
860 for (j = follower.begin(); j != follower.end(); ++j) {
861 if (flows.
knows((*j)->getID())) {
862 ++noFollowerWithRoutes;
865 assert(noFollowerWithRoutes <= follower.size());
873 if (noFollowerWithRoutes == follower.size()) {
886 if ((*i)->getEdgeID() == edge->
getID()) {
904 const std::vector<std::string>& oldids) {
910 for (std::vector<std::string>::const_iterator i = oldids.begin(); i != oldids.end(); ++i) {