55 #ifdef CHECK_MEMORY_LEAKS
57 #endif // CHECK_MEMORY_LEAKS
65 : myID(id), myLaneID(laneID), myPosition(pos), myType(type), myRoutes(0) {}
69 : myID(id), myLaneID(f.myLaneID), myPosition(f.myPosition),
70 myType(f.myType), myRoutes(0) {
92 for (std::vector<ROEdge*>::const_iterator i = rd.
edges2Pass.begin(); i != rd.
edges2Pass.end(); ++i) {
93 length += (*i)->getLength();
95 return (distance / length);
107 const std::vector<RODFRouteDesc>& routes =
myRoutes->
get();
108 std::vector<RODFEdge*> nextDetEdges;
109 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
111 bool hadSplit =
false;
112 bool hadDetectorAfterSplit =
false;
113 for (std::vector<ROEdge*>::const_iterator j = rd.
edges2Pass.begin(); !hadDetectorAfterSplit && j != rd.
edges2Pass.end(); ++j) {
114 if (hadSplit && !hadDetectorAfterSplit && net->
hasDetector(*j)) {
115 hadDetectorAfterSplit =
true;
116 if (find(nextDetEdges.begin(), nextDetEdges.end(), *j) == nextDetEdges.end()) {
117 nextDetEdges.push_back(static_cast<RODFEdge*>(*j));
121 if ((*j)->getNoFollowing() > 1) {
128 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, ++index) {
132 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
138 if (overallProb > 0) {
139 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
158 std::vector<RODFRouteDesc>& descs =
myRoutes->
get();
160 for (
SUMOTime time = startTime; time < endTime; time += stepOffset) {
162 std::map<ROEdge*, SUMOReal> flowMap;
165 for (std::vector<RODFRouteDesc>::iterator ri = descs.begin(); ri != descs.end(); ++ri, index++) {
167 for (std::vector<ROEdge*>::iterator j = (*ri).edges2Pass.begin(); j != (*ri).edges2Pass.end() && prob > 0; ++j) {
173 if (probs.size() == 0) {
177 const std::map<RODFEdge*, SUMOReal>& tprobs = probs[(time - startTime) / stepOffset];
178 for (std::map<RODFEdge*, SUMOReal>::const_iterator k = tprobs.begin(); k != tprobs.end(); ++k) {
179 if (find(j, (*ri).edges2Pass.end(), (*k).first) != (*ri).edges2Pass.end()) {
184 into[time]->add(prob, index);
185 (*ri).overallProb = prob;
191 const std::vector<RODFRouteDesc>&
209 const std::vector<RODFDetector*>&
215 const std::vector<RODFDetector*>&
250 bool includeUnusedRoutes,
260 const std::vector<RODFRouteDesc>& routes =
myRoutes->
get();
262 bool isEmptyDist =
true;
263 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
264 if ((*i).overallProb > 0) {
268 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
269 if ((*i).overallProb > 0 || includeUnusedRoutes) {
282 if (insertionsOnly || flows.
knows(
myID)) {
286 unsigned int index = 0;
287 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, index++) {
289 assert(index < mflows.size());
290 const FlowDef& srcFD = mflows[index];
294 size_t carNo = (size_t)((srcFD.qPKW + srcFD.qLKW) * scale);
295 for (
size_t car = 0; car < carNo; ++car) {
299 if (srcFD.isLKW >= 1) {
300 srcFD.isLKW = srcFD.isLKW - (
SUMOReal) 1.;
306 if (v <= 0 || v > 250) {
322 if (v > defaultSpeed) {
328 if (destIndex >= 0) {
334 srcFD.isLKW += srcFD.fLKW;
363 unsigned int index = 0;
364 for (
SUMOTime t = startTime; t < endTime; t += stepOffset, index++) {
365 assert(index < mflows.size());
366 const FlowDef& srcFD = mflows[index];
368 if (speed <= 0 || speed > 250) {
369 speed = defaultSpeed;
427 if ((*i)->hasRoutes()) {
435 const std::vector< RODFDetector*>&
447 switch ((*i)->getType()) {
475 switch ((*i)->getType()) {
501 std::vector<std::string> saved;
503 bool lastWasSaved =
true;
512 lastWasSaved = (*i)->writeRoutes(saved, out);
536 bool writeCalibrators,
537 bool includeUnusedRoutes,
539 bool insertionsOnly) {
542 (*i)->computeSplitProbabilities(&net, *
this, flows, startTime, endTime, stepOffset);
551 std::string defFileName;
563 std::map<size_t, RandomDistributor<size_t>* > dists;
564 if (!insertionsOnly && flows.
knows(det->
getID())) {
568 if (!det->
writeEmitterDefinition(defFileName, dists, flows, startTime, endTime, stepOffset, includeUnusedRoutes, scale, insertionsOnly, defaultSpeed)) {
595 switch ((*i)->getType()) {
629 const std::vector<FlowDef>& flows =
static_cast<const RODFEdge*
>(edge)->getFlows();
631 for (std::vector<FlowDef>::const_iterator i = flows.begin(); i != flows.end(); ++i) {
633 if (srcFD.
qLKW >= 0) {
636 if (srcFD.
qPKW >= 0) {
663 const std::string& file,
702 bool singleFile,
bool friendly) {
733 std::map<std::string, RODFDetector*>::iterator ri1 =
myDetectorMap.find(
id);
737 std::vector<RODFDetector*>::iterator ri2 =
743 std::vector<RODFDetector*>& dets = (*rr3).second;
744 for (std::vector<RODFDetector*>::iterator ri3 = dets.begin(); !found && ri3 != dets.end();) {
745 if (*ri3 == oldDet) {
747 ri3 = dets.erase(ri3);
768 size_t noFollowerWithRoutes = 0;
769 size_t noPriorWithRoutes = 0;
771 std::vector<RODFDetector*>::const_iterator j;
772 for (j = prior.begin(); j != prior.end(); ++j) {
773 if (flows.
knows((*j)->getID())) {
777 assert(noPriorWithRoutes <= prior.size());
778 for (j = follower.begin(); j != follower.end(); ++j) {
779 if (flows.
knows((*j)->getID())) {
780 ++noFollowerWithRoutes;
783 assert(noFollowerWithRoutes <= follower.size());
791 if (noFollowerWithRoutes == follower.size()) {
804 if ((*i)->getEdgeID() == edge->
getID()) {
822 const std::vector<std::string>& oldids) {
828 for (std::vector<std::string>::const_iterator i = oldids.begin(); i != oldids.end(); ++i) {