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 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
112 bool hadSplit =
false;
113 bool hadDetectorAfterSplit =
false;
114 for (std::vector<ROEdge*>::const_iterator j = rd.
edges2Pass.begin(); !hadDetectorAfterSplit && j != rd.
edges2Pass.end(); ++j) {
115 if (hadSplit && !hadDetectorAfterSplit && net->
hasDetector(*j)) {
116 hadDetectorAfterSplit =
true;
117 if (find(nextDetEdges.begin(), nextDetEdges.end(), *j) == nextDetEdges.end()) {
118 nextDetEdges.push_back(static_cast<RODFEdge*>(*j));
122 if ((*j)->getNoFollowing() > 1) {
129 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, ++index) {
133 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
139 if (overallProb > 0) {
140 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
159 std::vector<RODFRouteDesc>& descs =
myRoutes->
get();
161 for (
SUMOTime time = startTime; time < endTime; time += stepOffset) {
163 std::map<ROEdge*, SUMOReal> flowMap;
166 for (std::vector<RODFRouteDesc>::iterator ri = descs.begin(); ri != descs.end(); ++ri, index++) {
168 for (std::vector<ROEdge*>::iterator j = (*ri).edges2Pass.begin(); j != (*ri).edges2Pass.end() && prob > 0; ++j) {
174 if (probs.size() == 0) {
178 const std::map<RODFEdge*, SUMOReal>& tprobs = probs[(time - startTime) / stepOffset];
179 for (std::map<RODFEdge*, SUMOReal>::const_iterator k = tprobs.begin(); k != tprobs.end(); ++k) {
180 if (find(j, (*ri).edges2Pass.end(), (*k).first) != (*ri).edges2Pass.end()) {
185 into[time]->add(prob, index);
186 (*ri).overallProb = prob;
192 const std::vector<RODFRouteDesc>&
210 const std::vector<RODFDetector*>&
216 const std::vector<RODFDetector*>&
251 bool includeUnusedRoutes,
262 const std::vector<RODFRouteDesc>& routes =
myRoutes->
get();
264 bool isEmptyDist =
true;
265 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
266 if ((*i).overallProb > 0) {
270 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
271 if ((*i).overallProb > 0 || includeUnusedRoutes) {
284 if (insertionsOnly || flows.
knows(
myID)) {
288 unsigned int index = 0;
289 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, index++) {
291 assert(index < mflows.size());
292 const FlowDef& srcFD = mflows[index];
296 size_t carNo = (size_t)((srcFD.qPKW + srcFD.qLKW) * scale);
297 for (
size_t car = 0; car < carNo; ++car) {
301 if (srcFD.isLKW >= 1) {
302 srcFD.isLKW = srcFD.isLKW - (
SUMOReal) 1.;
308 if (v <= 0 || v > 250) {
324 if (oc.
isSet(
"departlane")) {
329 if (oc.
isSet(
"departpos")) {
330 std::string posDesc = oc.
getString(
"departpos");
331 if (posDesc.substr(0, 8) ==
"detector") {
333 if (posDesc.length() > 8) {
334 if (posDesc[8] ==
'+') {
336 }
else if (posDesc[8] ==
'-') {
349 if (oc.
isSet(
"departspeed")) {
352 if (v > defaultSpeed) {
358 if (oc.
isSet(
"arrivallane")) {
361 if (oc.
isSet(
"arrivalpos")) {
364 if (oc.
isSet(
"arrivalspeed")) {
367 if (destIndex >= 0) {
373 srcFD.isLKW += srcFD.fLKW;
402 unsigned int index = 0;
403 for (
SUMOTime t = startTime; t < endTime; t += stepOffset, index++) {
404 assert(index < mflows.size());
405 const FlowDef& srcFD = mflows[index];
407 if (speed <= 0 || speed > 250) {
408 speed = defaultSpeed;
466 if ((*i)->hasRoutes()) {
474 const std::vector< RODFDetector*>&
486 switch ((*i)->getType()) {
514 switch ((*i)->getType()) {
540 std::vector<std::string> saved;
542 bool lastWasSaved =
true;
551 lastWasSaved = (*i)->writeRoutes(saved, out);
575 bool writeCalibrators,
576 bool includeUnusedRoutes,
578 bool insertionsOnly) {
581 (*i)->computeSplitProbabilities(&net, *
this, flows, startTime, endTime, stepOffset);
590 std::string defFileName;
602 std::map<size_t, RandomDistributor<size_t>* > dists;
603 if (!insertionsOnly && flows.
knows(det->
getID())) {
607 if (!det->
writeEmitterDefinition(defFileName, dists, flows, startTime, endTime, stepOffset, includeUnusedRoutes, scale, insertionsOnly, defaultSpeed)) {
631 const unsigned char col =
static_cast<unsigned char>(128 * flow / flows.
getMaxDetectorFlow() + 128);
633 switch ((*i)->getType()) {
667 const std::vector<FlowDef>& flows =
static_cast<const RODFEdge*
>(edge)->getFlows();
669 for (std::vector<FlowDef>::const_iterator i = flows.begin(); i != flows.end(); ++i) {
671 if (srcFD.
qLKW >= 0) {
674 if (srcFD.
qPKW >= 0) {
701 const std::string& file,
740 bool singleFile,
bool friendly) {
771 std::map<std::string, RODFDetector*>::iterator ri1 =
myDetectorMap.find(
id);
775 std::vector<RODFDetector*>::iterator ri2 =
781 std::vector<RODFDetector*>& dets = (*rr3).second;
782 for (std::vector<RODFDetector*>::iterator ri3 = dets.begin(); !found && ri3 != dets.end();) {
783 if (*ri3 == oldDet) {
785 ri3 = dets.erase(ri3);
806 size_t noFollowerWithRoutes = 0;
807 size_t noPriorWithRoutes = 0;
809 std::vector<RODFDetector*>::const_iterator j;
810 for (j = prior.begin(); j != prior.end(); ++j) {
811 if (flows.
knows((*j)->getID())) {
815 assert(noPriorWithRoutes <= prior.size());
816 for (j = follower.begin(); j != follower.end(); ++j) {
817 if (flows.
knows((*j)->getID())) {
818 ++noFollowerWithRoutes;
821 assert(noFollowerWithRoutes <= follower.size());
829 if (noFollowerWithRoutes == follower.size()) {
842 if ((*i)->getEdgeID() == edge->
getID()) {
860 const std::vector<std::string>& oldids) {
866 for (std::vector<std::string>::const_iterator i = oldids.begin(); i != oldids.end(); ++i) {