57 #ifdef CHECK_MEMORY_LEAKS
59 #endif // CHECK_MEMORY_LEAKS
67 :
Named(id), myLaneID(laneID), myPosition(pos), myType(type), myRoutes(0) {}
71 :
Named(id), myLaneID(f.myLaneID), myPosition(f.myPosition),
72 myType(f.myType), myRoutes(0) {
94 for (std::vector<ROEdge*>::const_iterator i = rd.
edges2Pass.begin(); i != rd.
edges2Pass.end(); ++i) {
95 length += (*i)->getLength();
97 return (distance / length);
109 const std::vector<RODFRouteDesc>& routes =
myRoutes->
get();
110 std::vector<RODFEdge*> nextDetEdges;
111 std::set<ROEdge*> preSplitEdges;
112 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
114 bool hadSplit =
false;
115 for (std::vector<ROEdge*>::const_iterator j = rd.
edges2Pass.begin(); j != rd.
edges2Pass.end(); ++j) {
117 if (find(nextDetEdges.begin(), nextDetEdges.end(), *j) == nextDetEdges.end()) {
118 nextDetEdges.push_back(static_cast<RODFEdge*>(*j));
124 preSplitEdges.insert(*j);
126 if ((*j)->getNoFollowing() > 1) {
131 std::map<ROEdge*, SUMOReal> inFlows;
133 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
134 std::set<ROEdge*> seen(preSplitEdges);
135 std::vector<ROEdge*> pending;
136 pending.push_back(*i);
138 while (!pending.empty()) {
139 ROEdge* e = pending.back();
142 for (
unsigned int j = 0; j < numAppr; j++) {
148 pending.push_back(e2);
158 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, ++index) {
162 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
168 if (overallProb > 0) {
169 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
188 std::vector<RODFRouteDesc>& descs =
myRoutes->
get();
190 for (
SUMOTime time = startTime; time < endTime; time += stepOffset) {
192 std::map<ROEdge*, SUMOReal> flowMap;
195 for (std::vector<RODFRouteDesc>::iterator ri = descs.begin(); ri != descs.end(); ++ri, index++) {
197 for (std::vector<ROEdge*>::iterator j = (*ri).edges2Pass.begin(); j != (*ri).edges2Pass.end() && prob > 0;) {
204 if (probs.size() == 0) {
209 const std::map<RODFEdge*, SUMOReal>& tprobs = probs[(time - startTime) / stepOffset];
211 for (std::map<RODFEdge*, SUMOReal>::const_iterator k = tprobs.begin(); k != tprobs.end(); ++k) {
212 if (find(j, (*ri).edges2Pass.end(), (*k).first) != (*ri).edges2Pass.end()) {
214 splitEdge = (*k).first;
218 if (splitEdge != 0) {
219 j = find(j, (*ri).edges2Pass.end(), splitEdge);
224 into[time]->add(prob, index);
225 (*ri).overallProb = prob;
231 const std::vector<RODFRouteDesc>&
249 const std::set<const RODFDetector*>&
255 const std::set<const RODFDetector*>&
290 bool includeUnusedRoutes,
301 const std::vector<RODFRouteDesc>& routes =
myRoutes->
get();
303 bool isEmptyDist =
true;
304 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
305 if ((*i).overallProb > 0) {
309 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
310 if ((*i).overallProb > 0 || includeUnusedRoutes) {
323 if (insertionsOnly || flows.
knows(
myID)) {
327 unsigned int index = 0;
328 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, index++) {
330 assert(index < mflows.size());
331 const FlowDef& srcFD = mflows[index];
335 size_t carNo = (size_t)((srcFD.qPKW + srcFD.qLKW) * scale);
336 for (
size_t car = 0; car < carNo; ++car) {
341 if (srcFD.isLKW >= 1) {
342 srcFD.isLKW = srcFD.isLKW - (
SUMOReal) 1.;
350 if (v <= 0 || v > 250) {
369 if (oc.
isSet(
"departlane")) {
374 if (oc.
isSet(
"departpos")) {
375 std::string posDesc = oc.
getString(
"departpos");
376 if (posDesc.substr(0, 8) ==
"detector") {
378 if (posDesc.length() > 8) {
379 if (posDesc[8] ==
'+') {
381 }
else if (posDesc[8] ==
'-') {
394 if (oc.
isSet(
"departspeed")) {
397 if (v > defaultSpeed) {
403 if (oc.
isSet(
"arrivallane")) {
406 if (oc.
isSet(
"arrivalpos")) {
409 if (oc.
isSet(
"arrivalspeed")) {
412 if (destIndex >= 0) {
418 srcFD.isLKW += srcFD.fLKW;
447 unsigned int index = 0;
448 for (
SUMOTime t = startTime; t < endTime; t += stepOffset, index++) {
449 assert(index < mflows.size());
450 const FlowDef& srcFD = mflows[index];
452 if (speed <= 0 || speed > 250) {
453 speed = defaultSpeed;
511 if ((*i)->hasRoutes()) {
519 const std::vector< RODFDetector*>&
531 switch ((*i)->getType()) {
559 switch ((*i)->getType()) {
585 std::vector<std::string> saved;
587 bool lastWasSaved =
true;
596 lastWasSaved = (*i)->writeRoutes(saved, out);
626 bool writeCalibrators,
627 bool includeUnusedRoutes,
629 bool insertionsOnly) {
632 (*i)->computeSplitProbabilities(&net, *
this, flows, startTime, endTime, stepOffset);
636 out.
writeXMLHeader(
"additional",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/additional_file.xsd\"");
641 std::string defFileName;
653 std::map<size_t, RandomDistributor<size_t>* > dists;
654 if (!insertionsOnly && flows.
knows(det->
getID())) {
658 if (!det->
writeEmitterDefinition(defFileName, dists, flows, startTime, endTime, stepOffset, includeUnusedRoutes, scale, insertionsOnly, defaultSpeed)) {
678 out.
writeXMLHeader(
"additional",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/additional_file.xsd\"");
682 const unsigned char col =
static_cast<unsigned char>(128 * flow / flows.
getMaxDetectorFlow() + 128);
684 switch ((*i)->getType()) {
718 const std::vector<FlowDef>& flows =
static_cast<const RODFEdge*
>(edge)->getFlows();
720 for (std::vector<FlowDef>::const_iterator i = flows.begin(); i != flows.end(); ++i) {
722 if (srcFD.
qLKW >= 0) {
725 if (srcFD.
qPKW >= 0) {
752 const std::string& file,
757 out.
writeXMLHeader(
"additional",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/additional_file.xsd\"");
775 out.
writeXMLHeader(
"additional",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/additional_file.xsd\"");
791 bool singleFile,
bool friendly) {
822 std::map<std::string, RODFDetector*>::iterator ri1 =
myDetectorMap.find(
id);
826 std::vector<RODFDetector*>::iterator ri2 =
832 std::vector<RODFDetector*>& dets = (*rr3).second;
833 for (std::vector<RODFDetector*>::iterator ri3 = dets.begin(); !found && ri3 != dets.end();) {
834 if (*ri3 == oldDet) {
836 ri3 = dets.erase(ri3);
855 size_t noFollowerWithRoutes = 0;
856 size_t noPriorWithRoutes = 0;
858 std::set<const RODFDetector*>::const_iterator j;
859 for (j = prior.begin(); j != prior.end(); ++j) {
860 if (flows.
knows((*j)->getID())) {
864 for (j = follower.begin(); j != follower.end(); ++j) {
865 if (flows.
knows((*j)->getID())) {
866 ++noFollowerWithRoutes;
876 if (noPriorWithRoutes == prior.size()) {
882 if (noFollowerWithRoutes == follower.size()) {
894 if ((*i)->getEdgeID() == edge->
getID()) {
912 const std::vector<std::string>& oldids) {
918 for (std::vector<std::string>::const_iterator i = oldids.begin(); i != oldids.end(); ++i) {