Eclipse SUMO - Simulation of Urban MObility
RODFNet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A DFROUTER-network
18 /****************************************************************************/
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include <cassert>
25 #include <iostream>
26 #include <map>
27 #include <queue>
28 #include <vector>
29 #include <iterator>
30 #include "RODFNet.h"
31 #include "RODFDetector.h"
32 #include "RODFRouteDesc.h"
33 #include "RODFDetectorFlow.h"
34 #include "RODFEdge.h"
35 #include <cmath>
37 #include <utils/common/ToString.h>
39 #include <utils/geom/GeomHelper.h>
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
45 RODFNet::RODFNet(bool amInHighwayMode) :
46  RONet(), myAmInHighwayMode(amInHighwayMode),
47  mySourceNumber(0), mySinkNumber(0), myInBetweenNumber(0), myInvalidNumber(0),
48  myMaxSpeedFactorPKW(1),
49  myMaxSpeedFactorLKW(1),
50  myAvgSpeedFactorPKW(1),
51  myAvgSpeedFactorLKW(1) {
53  myKeepTurnarounds = OptionsCont::getOptions().getBool("keep-turnarounds");
54 }
55 
56 
58 }
59 
60 
61 void
63  for (const auto& rit : getEdgeMap()) {
64  ROEdge* ce = rit.second;
65  if (ce->isInternal()) {
66  continue;
67  }
68  const ROEdgeVector& successors = ce->getSuccessors();
69  for (ROEdgeVector::const_iterator it = successors.begin(); it != successors.end(); ++it) {
70  ROEdge* help = *it;
71  if (find(myDisallowedEdges.begin(), myDisallowedEdges.end(), help->getID()) != myDisallowedEdges.end()) {
72  // edges in sinks will not be used
73  continue;
74  }
75  if (!myKeepTurnarounds && help->getToJunction() == ce->getFromJunction()) {
76  // do not use turnarounds
77  continue;
78  }
79  // add the connection help->ce to myApproachingEdges
80  if (myApproachingEdges.find(help) == myApproachingEdges.end()) {
82  }
83  myApproachingEdges[help].push_back(ce);
84  // add the connection ce->help to myApproachingEdges
85  if (myApproachedEdges.find(ce) == myApproachedEdges.end()) {
87  }
88  myApproachedEdges[ce].push_back(help);
89  }
90  }
91 }
92 
93 
94 void
96  myDetectorsOnEdges.clear();
97  myDetectorEdges.clear();
98  const std::vector<RODFDetector*>& dets = detcont.getDetectors();
99  for (std::vector<RODFDetector*>::const_iterator i = dets.begin(); i != dets.end(); ++i) {
100  ROEdge* e = getDetectorEdge(**i);
101  myDetectorsOnEdges[e].push_back((*i)->getID());
102  myDetectorEdges[(*i)->getID()] = e;
103  }
104 }
105 
106 
107 void
109  bool sourcesStrict) const {
110  PROGRESS_BEGIN_MESSAGE("Computing detector types");
111  const std::vector< RODFDetector*>& dets = detcont.getDetectors();
112  // build needed information. first
114  // compute detector types then
115  for (std::vector< RODFDetector*>::const_iterator i = dets.begin(); i != dets.end(); ++i) {
116  if (isSource(**i, detcont, sourcesStrict)) {
117  (*i)->setType(SOURCE_DETECTOR);
118  mySourceNumber++;
119  }
120  if (isDestination(**i, detcont)) {
121  (*i)->setType(SINK_DETECTOR);
122  mySinkNumber++;
123  }
124  if ((*i)->getType() == TYPE_NOT_DEFINED) {
125  (*i)->setType(BETWEEN_DETECTOR);
127  }
128  }
129  // recheck sources
130  for (std::vector< RODFDetector*>::const_iterator i = dets.begin(); i != dets.end(); ++i) {
131  if ((*i)->getType() == SOURCE_DETECTOR && isFalseSource(**i, detcont)) {
132  (*i)->setType(DISCARDED_DETECTOR);
133  myInvalidNumber++;
134  mySourceNumber--;
135  }
136  }
137  // print results
139  WRITE_MESSAGE("Computed detector types:");
140  WRITE_MESSAGE(" " + toString(mySourceNumber) + " source detectors");
141  WRITE_MESSAGE(" " + toString(mySinkNumber) + " sink detectors");
142  WRITE_MESSAGE(" " + toString(myInBetweenNumber) + " in-between detectors");
143  WRITE_MESSAGE(" " + toString(myInvalidNumber) + " invalid detectors");
144 }
145 
146 
147 bool
149  const RODFDetectorCon& detectors) const {
150  assert(myDetectorsOnEdges.find(edge) != myDetectorsOnEdges.end());
151  const std::vector<std::string>& detIDs = myDetectorsOnEdges.find(edge)->second;
152  std::vector<std::string>::const_iterator i;
153  for (i = detIDs.begin(); i != detIDs.end(); ++i) {
154  const RODFDetector& det = detectors.getDetector(*i);
155  if (det.getType() != BETWEEN_DETECTOR) {
156  return false;
157  }
158  }
159  return true;
160 }
161 
162 
163 bool
165  const RODFDetectorCon& detectors) const {
166  assert(myDetectorsOnEdges.find(edge) != myDetectorsOnEdges.end());
167  const std::vector<std::string>& detIDs = myDetectorsOnEdges.find(edge)->second;
168  std::vector<std::string>::const_iterator i;
169  for (i = detIDs.begin(); i != detIDs.end(); ++i) {
170  const RODFDetector& det = detectors.getDetector(*i);
171  if (det.getType() == SOURCE_DETECTOR) {
172  return true;
173  }
174  }
175  return false;
176 }
177 
178 
179 
180 void
182  bool keepUnfoundEnds,
183  bool keepShortestOnly,
184  ROEdgeVector& /*visited*/,
185  const RODFDetector& det, RODFRouteCont& into,
186  const RODFDetectorCon& detectors,
187  int maxFollowingLength,
188  ROEdgeVector& seen) const {
189  std::vector<RODFRouteDesc> unfoundEnds;
190  std::priority_queue<RODFRouteDesc, std::vector<RODFRouteDesc>, DFRouteDescByTimeComperator> toSolve;
191  std::map<ROEdge*, ROEdgeVector > dets2Follow;
192  dets2Follow[edge] = ROEdgeVector();
193  base.passedNo = 0;
194  double minDist = OptionsCont::getOptions().getFloat("min-route-length");
195  toSolve.push(base);
196  while (!toSolve.empty()) {
197  RODFRouteDesc current = toSolve.top();
198  toSolve.pop();
199  ROEdge* last = *(current.edges2Pass.end() - 1);
200  if (hasDetector(last)) {
201  if (dets2Follow.find(last) == dets2Follow.end()) {
202  dets2Follow[last] = ROEdgeVector();
203  }
204  for (ROEdgeVector::reverse_iterator i = current.edges2Pass.rbegin() + 1; i != current.edges2Pass.rend(); ++i) {
205  if (hasDetector(*i)) {
206  dets2Follow[*i].push_back(last);
207  break;
208  }
209  }
210  }
211 
212  // do not process an edge twice
213  if (find(seen.begin(), seen.end(), last) != seen.end() && keepShortestOnly) {
214  continue;
215  }
216  seen.push_back(last);
217  // end if the edge has no further connections
218  if (!hasApproached(last)) {
219  // ok, no further connections to follow
220  current.factor = 1.;
221  double cdist = current.edges2Pass[0]->getFromJunction()->getPosition().distanceTo(current.edges2Pass.back()->getToJunction()->getPosition());
222  if (minDist < cdist) {
223  into.addRouteDesc(current);
224  }
225  continue;
226  }
227  // check for passing detectors:
228  // if the current last edge is not the one the detector is placed on ...
229  bool addNextNoFurther = false;
230  if (last != getDetectorEdge(det)) {
231  // ... if there is a detector ...
232  if (hasDetector(last)) {
233  if (!hasInBetweenDetectorsOnly(last, detectors)) {
234  // ... and it's not an in-between-detector
235  // -> let's add this edge and the following, but not any further
236  addNextNoFurther = true;
237  current.lastDetectorEdge = last;
238  current.duration2Last = (SUMOTime) current.duration_2;
239  current.distance2Last = current.distance;
240  current.endDetectorEdge = last;
241  if (hasSourceDetector(last, detectors)) {
243  }
244  current.factor = 1.;
245  double cdist = current.edges2Pass[0]->getFromJunction()->getPosition().distanceTo(current.edges2Pass.back()->getToJunction()->getPosition());
246  if (minDist < cdist) {
247  into.addRouteDesc(current);
248  }
249  continue;
250  } else {
251  // ... if it's an in-between-detector
252  // -> mark the current route as to be continued
253  current.passedNo = 0;
254  current.duration2Last = (SUMOTime) current.duration_2;
255  current.distance2Last = current.distance;
256  current.lastDetectorEdge = last;
257  }
258  }
259  }
260  // check for highway off-ramps
261  if (myAmInHighwayMode) {
262  // if it's beside the highway...
263  if (last->getSpeedLimit() < 19.4 && last != getDetectorEdge(det)) {
264  // ... and has more than one following edge
265  if (myApproachedEdges.find(last)->second.size() > 1) {
266  // -> let's add this edge and the following, but not any further
267  addNextNoFurther = true;
268  }
269 
270  }
271  }
272  // check for missing end connections
273  if (!addNextNoFurther) {
274  // ... if this one would be processed, but already too many edge
275  // without a detector occurred
276  if (current.passedNo > maxFollowingLength) {
277  // mark not to process any further
278  WRITE_WARNING("Could not close route for '" + det.getID() + "'");
279  unfoundEnds.push_back(current);
280  current.factor = 1.;
281  double cdist = current.edges2Pass[0]->getFromJunction()->getPosition().distanceTo(current.edges2Pass.back()->getToJunction()->getPosition());
282  if (minDist < cdist) {
283  into.addRouteDesc(current);
284  }
285  continue;
286  }
287  }
288  // ... else: loop over the next edges
289  const ROEdgeVector& appr = myApproachedEdges.find(last)->second;
290  bool hadOne = false;
291  for (int i = 0; i < (int)appr.size(); i++) {
292  if (find(current.edges2Pass.begin(), current.edges2Pass.end(), appr[i]) != current.edges2Pass.end()) {
293  // do not append an edge twice (do not build loops)
294  continue;
295  }
296  RODFRouteDesc t(current);
297  t.duration_2 += (appr[i]->getLength() / appr[i]->getSpeedLimit());
298  t.distance += appr[i]->getLength();
299  t.edges2Pass.push_back(appr[i]);
300  if (!addNextNoFurther) {
301  t.passedNo = t.passedNo + 1;
302  toSolve.push(t);
303  } else {
304  if (!hadOne) {
305  t.factor = (double) 1. / (double) appr.size();
306  double cdist = current.edges2Pass[0]->getFromJunction()->getPosition().distanceTo(current.edges2Pass.back()->getToJunction()->getPosition());
307  if (minDist < cdist) {
308  into.addRouteDesc(t);
309  }
310  hadOne = true;
311  }
312  }
313  }
314  }
315  //
316  if (!keepUnfoundEnds) {
317  std::vector<RODFRouteDesc>::iterator i;
318  ConstROEdgeVector lastDetEdges;
319  for (i = unfoundEnds.begin(); i != unfoundEnds.end(); ++i) {
320  if (find(lastDetEdges.begin(), lastDetEdges.end(), (*i).lastDetectorEdge) == lastDetEdges.end()) {
321  lastDetEdges.push_back((*i).lastDetectorEdge);
322  } else {
323  bool ok = into.removeRouteDesc(*i);
324  assert(ok);
325  UNUSED_PARAMETER(ok); // ony used for assertion
326  }
327  }
328  } else {
329  // !!! patch the factors
330  }
331  while (!toSolve.empty()) {
332 // RODFRouteDesc d = toSolve.top();
333  toSolve.pop();
334 // delete d;
335  }
336 }
337 
338 
339 void
340 RODFNet::buildRoutes(RODFDetectorCon& detcont, bool keepUnfoundEnds, bool includeInBetween,
341  bool keepShortestOnly, int maxFollowingLength) const {
342  // build needed information first
344  // then build the routes
345  std::map<ROEdge*, RODFRouteCont* > doneEdges;
346  const std::vector< RODFDetector*>& dets = detcont.getDetectors();
347  for (std::vector< RODFDetector*>::const_iterator i = dets.begin(); i != dets.end(); ++i) {
348  ROEdge* e = getDetectorEdge(**i);
349  if (doneEdges.find(e) != doneEdges.end()) {
350  // use previously build routes
351  (*i)->addRoutes(new RODFRouteCont(*doneEdges[e]));
352  continue;
353  }
354  ROEdgeVector seen;
355  RODFRouteCont* routes = new RODFRouteCont();
356  doneEdges[e] = routes;
357  RODFRouteDesc rd;
358  rd.edges2Pass.push_back(e);
359  rd.duration_2 = (e->getLength() / e->getSpeedLimit());
360  rd.endDetectorEdge = nullptr;
361  rd.lastDetectorEdge = nullptr;
362  rd.distance = e->getLength();
363  rd.distance2Last = 0;
364  rd.duration2Last = 0;
365 
366  rd.overallProb = 0;
367 
368  ROEdgeVector visited;
369  visited.push_back(e);
370  computeRoutesFor(e, rd, 0, keepUnfoundEnds, keepShortestOnly,
371  visited, **i, *routes, detcont, maxFollowingLength, seen);
373  (*i)->addRoutes(routes);
374 
375  // add routes to in-between detectors if wished
376  if (includeInBetween) {
377  // go through the routes
378  const std::vector<RODFRouteDesc>& r = routes->get();
379  for (std::vector<RODFRouteDesc>::const_iterator j = r.begin(); j != r.end(); ++j) {
380  const RODFRouteDesc& mrd = *j;
381  double duration = mrd.duration_2;
382  double distance = mrd.distance;
383  // go through each route's edges
384  ROEdgeVector::const_iterator routeend = mrd.edges2Pass.end();
385  for (ROEdgeVector::const_iterator k = mrd.edges2Pass.begin(); k != routeend; ++k) {
386  // check whether any detectors lies on the current edge
387  if (myDetectorsOnEdges.find(*k) == myDetectorsOnEdges.end()) {
388  duration -= (*k)->getLength() / (*k)->getSpeedLimit();
389  distance -= (*k)->getLength();
390  continue;
391  }
392  // get the detectors
393  const std::vector<std::string>& dets = myDetectorsOnEdges.find(*k)->second;
394  // go through the detectors
395  for (std::vector<std::string>::const_iterator l = dets.begin(); l != dets.end(); ++l) {
396  const RODFDetector& m = detcont.getDetector(*l);
397  if (m.getType() == BETWEEN_DETECTOR) {
398  RODFRouteDesc nrd;
399  copy(k, routeend, back_inserter(nrd.edges2Pass));
400  nrd.duration_2 = duration;
403  nrd.distance = distance;
404  nrd.distance2Last = mrd.distance2Last;
405  nrd.duration2Last = mrd.duration2Last;
406  nrd.overallProb = mrd.overallProb;
407  nrd.factor = mrd.factor;
408  ((RODFDetector&) m).addRoute(nrd);
409  }
410  }
411  duration -= (*k)->getLength() / (*k)->getSpeedLimit();
412  distance -= (*k)->getLength();
413  }
414  }
415  }
416 
417  }
418 }
419 
420 
421 void
423  RODFDetectorFlows& flows,
424  SUMOTime startTime, SUMOTime endTime,
425  SUMOTime stepOffset) {
426  {
427  if (flows.knows(detector->getID())) {
428  const std::vector<FlowDef>& detFlows = flows.getFlowDefs(detector->getID());
429  for (std::vector<FlowDef>::const_iterator j = detFlows.begin(); j != detFlows.end(); ++j) {
430  if ((*j).qPKW > 0 || (*j).qLKW > 0) {
431  return;
432  }
433  }
434  }
435  }
436  // ok, there is no information for the whole time;
437  // lets find preceding detectors and rebuild the flows if possible
438  WRITE_WARNING("Detector '" + detector->getID() + "' has no flows.\n Trying to rebuild.");
439  // go back and collect flows
440  ROEdgeVector previous;
441  {
442  std::vector<IterationEdge> missing;
443  IterationEdge ie;
444  ie.depth = 0;
445  ie.edge = getDetectorEdge(*detector);
446  missing.push_back(ie);
447  bool maxDepthReached = false;
448  while (!missing.empty() && !maxDepthReached) {
449  IterationEdge last = missing.back();
450  missing.pop_back();
451  ROEdgeVector approaching = myApproachingEdges[last.edge];
452  for (ROEdgeVector::const_iterator j = approaching.begin(); j != approaching.end(); ++j) {
453  if (hasDetector(*j)) {
454  previous.push_back(*j);
455  } else {
456  ie.depth = last.depth + 1;
457  ie.edge = *j;
458  missing.push_back(ie);
459  if (ie.depth > 5) {
460  maxDepthReached = true;
461  }
462  }
463  }
464  }
465  if (maxDepthReached) {
466  WRITE_WARNING(" Could not build list of previous flows.");
467  }
468  }
469  // Edges with previous detectors are now in "previous";
470  // compute following
471  ROEdgeVector latter;
472  {
473  std::vector<IterationEdge> missing;
474  for (ROEdgeVector::const_iterator k = previous.begin(); k != previous.end(); ++k) {
475  IterationEdge ie;
476  ie.depth = 0;
477  ie.edge = *k;
478  missing.push_back(ie);
479  }
480  bool maxDepthReached = false;
481  while (!missing.empty() && !maxDepthReached) {
482  IterationEdge last = missing.back();
483  missing.pop_back();
484  ROEdgeVector approached = myApproachedEdges[last.edge];
485  for (ROEdgeVector::const_iterator j = approached.begin(); j != approached.end(); ++j) {
486  if (*j == getDetectorEdge(*detector)) {
487  continue;
488  }
489  if (hasDetector(*j)) {
490  latter.push_back(*j);
491  } else {
492  IterationEdge ie;
493  ie.depth = last.depth + 1;
494  ie.edge = *j;
495  missing.push_back(ie);
496  if (ie.depth > 5) {
497  maxDepthReached = true;
498  }
499  }
500  }
501  }
502  if (maxDepthReached) {
503  WRITE_WARNING(" Could not build list of latter flows.");
504  return;
505  }
506  }
507  // Edges with latter detectors are now in "latter";
508 
509  // lets not validate them by now - surely this should be done
510  // for each time step: collect incoming flows; collect outgoing;
511  std::vector<FlowDef> mflows;
512  int index = 0;
513  for (SUMOTime t = startTime; t < endTime; t += stepOffset, index++) {
514  FlowDef inFlow;
515  inFlow.qLKW = 0;
516  inFlow.qPKW = 0;
517  inFlow.vLKW = 0;
518  inFlow.vPKW = 0;
519  // collect incoming
520  {
521  // !! time difference is missing
522  for (ROEdgeVector::iterator i = previous.begin(); i != previous.end(); ++i) {
523  const std::vector<FlowDef>& flows = static_cast<const RODFEdge*>(*i)->getFlows();
524  if (flows.size() != 0) {
525  const FlowDef& srcFD = flows[index];
526  inFlow.qLKW += srcFD.qLKW;
527  inFlow.qPKW += srcFD.qPKW;
528  inFlow.vLKW += srcFD.vLKW;
529  inFlow.vPKW += srcFD.vPKW;
530  }
531  }
532  }
533  inFlow.vLKW /= (double) previous.size();
534  inFlow.vPKW /= (double) previous.size();
535  // collect outgoing
536  FlowDef outFlow;
537  outFlow.qLKW = 0;
538  outFlow.qPKW = 0;
539  outFlow.vLKW = 0;
540  outFlow.vPKW = 0;
541  {
542  // !! time difference is missing
543  for (ROEdgeVector::iterator i = latter.begin(); i != latter.end(); ++i) {
544  const std::vector<FlowDef>& flows = static_cast<const RODFEdge*>(*i)->getFlows();
545  if (flows.size() != 0) {
546  const FlowDef& srcFD = flows[index];
547  outFlow.qLKW += srcFD.qLKW;
548  outFlow.qPKW += srcFD.qPKW;
549  outFlow.vLKW += srcFD.vLKW;
550  outFlow.vPKW += srcFD.vPKW;
551  }
552  }
553  }
554  outFlow.vLKW /= (double) latter.size();
555  outFlow.vPKW /= (double) latter.size();
556  //
557  FlowDef mFlow;
558  mFlow.qLKW = inFlow.qLKW - outFlow.qLKW;
559  mFlow.qPKW = inFlow.qPKW - outFlow.qPKW;
560  mFlow.vLKW = (inFlow.vLKW + outFlow.vLKW) / (double) 2.;
561  mFlow.vPKW = (inFlow.vPKW + outFlow.vPKW) / (double) 2.;
562  mflows.push_back(mFlow);
563  }
564  static_cast<RODFEdge*>(getDetectorEdge(*detector))->setFlows(mflows);
565  flows.setFlows(detector->getID(), mflows);
566 }
567 
568 
569 void
571  RODFDetectorFlows& flows,
572  SUMOTime startTime, SUMOTime endTime,
573  SUMOTime stepOffset) {
574  const std::vector<RODFDetector*>& dets = detectors.getDetectors();
575  for (std::vector<RODFDetector*>::const_iterator i = dets.begin(); i != dets.end(); ++i) {
576  // check whether there is at least one entry with a flow larger than zero
577  revalidateFlows(*i, flows, startTime, endTime, stepOffset);
578  }
579 }
580 
581 
582 
583 void
585  RODFDetectorFlows& flows) {
586  const std::vector<RODFDetector*>& dets = detectors.getDetectors();
587  for (std::vector<RODFDetector*>::const_iterator i = dets.begin(); i != dets.end();) {
588  bool remove = true;
589  // check whether there is at least one entry with a flow larger than zero
590  if (flows.knows((*i)->getID())) {
591  remove = false;
592  }
593  if (remove) {
594  WRITE_MESSAGE("Removed detector '" + (*i)->getID() + "' because no flows for him exist.");
595  flows.removeFlow((*i)->getID());
596  detectors.removeDetector((*i)->getID());
597  i = dets.begin();
598  } else {
599  i++;
600  }
601  }
602 }
603 
604 
605 
606 void
608  RODFDetectorFlows& flows) {
609  const std::vector<RODFDetector*>& dets = detectors.getDetectors();
610  for (std::vector<RODFDetector*>::const_iterator i = dets.begin(); i != dets.end(); ++i) {
611  bool remove = true;
612  // check whether there is at least one entry with a flow larger than zero
613  if (flows.knows((*i)->getID())) {
614  remove = false;
615  }
616  if (remove) {
617  WRITE_MESSAGE("Detector '" + (*i)->getID() + "' has no flow.");
618  }
619  }
620 }
621 
622 
623 
624 ROEdge*
626  std::string edgeName = det.getLaneID();
627  edgeName = edgeName.substr(0, edgeName.rfind('_'));
628  ROEdge* ret = getEdge(edgeName);
629  if (ret == nullptr) {
630  throw ProcessError("Edge '" + edgeName + "' used by detector '" + det.getID() + "' is not known.");
631  }
632  return ret;
633 }
634 
635 
636 bool
638  return
639  myApproachingEdges.find(edge) != myApproachingEdges.end()
640  &&
641  myApproachingEdges.find(edge)->second.size() != 0;
642 }
643 
644 
645 bool
647  return
648  myApproachedEdges.find(edge) != myApproachedEdges.end()
649  &&
650  myApproachedEdges.find(edge)->second.size() != 0;
651 }
652 
653 
654 bool
656  return
657  myDetectorsOnEdges.find(edge) != myDetectorsOnEdges.end()
658  &&
659  myDetectorsOnEdges.find(edge)->second.size() != 0;
660 }
661 
662 
663 const std::vector<std::string>&
665  return myDetectorsOnEdges.find(edge)->second;
666 }
667 
668 
669 double
670 RODFNet::getAbsPos(const RODFDetector& det) const {
671  if (det.getPos() >= 0) {
672  return det.getPos();
673  }
674  return getDetectorEdge(det)->getLength() + det.getPos();
675 }
676 
677 bool
678 RODFNet::isSource(const RODFDetector& det, const RODFDetectorCon& detectors,
679  bool strict) const {
680  ROEdgeVector seen;
681  return
682  isSource(det, getDetectorEdge(det), seen, detectors, strict);
683 }
684 
685 bool
686 RODFNet::isFalseSource(const RODFDetector& det, const RODFDetectorCon& detectors) const {
687  ROEdgeVector seen;
688  return
689  isFalseSource(det, getDetectorEdge(det), seen, detectors);
690 }
691 
692 bool
693 RODFNet::isDestination(const RODFDetector& det, const RODFDetectorCon& detectors) const {
694  ROEdgeVector seen;
695  return isDestination(det, getDetectorEdge(det), seen, detectors);
696 }
697 
698 
699 bool
701  ROEdgeVector& seen,
702  const RODFDetectorCon& detectors,
703  bool strict) const {
704  if (seen.size() == 1000) { // !!!
705  WRITE_WARNING("Quitting checking for being a source for detector '" + det.getID() + "' due to seen edge limit.");
706  return false;
707  }
708  if (edge == getDetectorEdge(det)) {
709  // maybe there is another detector at the same edge
710  // get the list of this/these detector(s)
711  const std::vector<std::string>& detsOnEdge = myDetectorsOnEdges.find(edge)->second;
712  for (std::vector<std::string>::const_iterator i = detsOnEdge.begin(); i != detsOnEdge.end(); ++i) {
713  if ((*i) == det.getID()) {
714  continue;
715  }
716  const RODFDetector& sec = detectors.getDetector(*i);
717  if (getAbsPos(sec) < getAbsPos(det)) {
718  // ok, there is another detector on the same edge and it is
719  // before this one -> no source
720  return false;
721  }
722  }
723  }
724  // it's a source if no edges are approaching the edge
725  if (!hasApproaching(edge)) {
726  if (edge != getDetectorEdge(det)) {
727  if (hasDetector(edge)) {
728  return false;
729  }
730  }
731  return true;
732  }
733  if (edge != getDetectorEdge(det)) {
734  // ok, we are at one of the edges in front
735  if (myAmInHighwayMode) {
736  if (edge->getSpeedLimit() >= 19.4) {
737  if (hasDetector(edge)) {
738  // we are still on the highway and there is another detector
739  return false;
740  }
741  // the next is a hack for the A100 scenario...
742  // We have to look into further edges herein edges
743  const ROEdgeVector& appr = myApproachingEdges.find(edge)->second;
744  int noOk = 0;
745  int noFalse = 0;
746  int noSkipped = 0;
747  for (int i = 0; i < (int)appr.size(); i++) {
748  if (!hasDetector(appr[i])) {
749  noOk++;
750  } else {
751  noFalse++;
752  }
753  }
754  if (noFalse + noSkipped == (int)appr.size()) {
755  return false;
756  }
757  }
758  }
759  }
760 
761  if (myAmInHighwayMode) {
762  if (edge->getSpeedLimit() < 19.4 && edge != getDetectorEdge(det)) {
763  // we have left the highway already
764  // -> the detector will be a highway source
765  if (!hasDetector(edge)) {
766  return true;
767  }
768  }
769  }
770  if (myDetectorsOnEdges.find(edge) != myDetectorsOnEdges.end()
771  &&
772  myDetectorEdges.find(det.getID())->second != edge) {
773  return false;
774  }
775 
776  // let's check the edges in front
777  const ROEdgeVector& appr = myApproachingEdges.find(edge)->second;
778  int numOk = 0;
779  int numFalse = 0;
780  int numSkipped = 0;
781  seen.push_back(edge);
782  for (int i = 0; i < (int)appr.size(); i++) {
783  bool had = std::find(seen.begin(), seen.end(), appr[i]) != seen.end();
784  if (!had) {
785  if (isSource(det, appr[i], seen, detectors, strict)) {
786  numOk++;
787  } else {
788  numFalse++;
789  }
790  } else {
791  numSkipped++;
792  }
793  }
794  if (strict) {
795  return numOk + numSkipped == (int)appr.size();
796  }
797  return numFalse + numSkipped != (int)appr.size();
798 }
799 
800 
801 bool
803  const RODFDetectorCon& detectors) const {
804  if (seen.size() == 1000) { // !!!
805  WRITE_WARNING("Quitting checking for being a destination for detector '" + det.getID() + "' due to seen edge limit.");
806  return false;
807  }
808  if (edge == getDetectorEdge(det)) {
809  // maybe there is another detector at the same edge
810  // get the list of this/these detector(s)
811  const std::vector<std::string>& detsOnEdge = myDetectorsOnEdges.find(edge)->second;
812  for (std::vector<std::string>::const_iterator i = detsOnEdge.begin(); i != detsOnEdge.end(); ++i) {
813  if ((*i) == det.getID()) {
814  continue;
815  }
816  const RODFDetector& sec = detectors.getDetector(*i);
817  if (getAbsPos(sec) > getAbsPos(det)) {
818  // ok, there is another detector on the same edge and it is
819  // after this one -> no destination
820  return false;
821  }
822  }
823  }
824  if (!hasApproached(edge)) {
825  if (edge != getDetectorEdge(det)) {
826  if (hasDetector(edge)) {
827  return false;
828  }
829  }
830  return true;
831  }
832  if (edge != getDetectorEdge(det)) {
833  // ok, we are at one of the edges coming behind
834  if (myAmInHighwayMode) {
835  if (edge->getSpeedLimit() >= 19.4) {
836  if (hasDetector(edge)) {
837  // we are still on the highway and there is another detector
838  return false;
839  }
840  }
841  }
842  }
843 
844  if (myAmInHighwayMode) {
845  if (edge->getSpeedLimit() < 19.4 && edge != getDetectorEdge(det)) {
846  if (hasDetector(edge)) {
847  return true;
848  }
849  if (myApproachedEdges.find(edge)->second.size() > 1) {
850  return true;
851  }
852 
853  }
854  }
855 
856  if (myDetectorsOnEdges.find(edge) != myDetectorsOnEdges.end()
857  &&
858  myDetectorEdges.find(det.getID())->second != edge) {
859  return false;
860  }
861  const ROEdgeVector& appr = myApproachedEdges.find(edge)->second;
862  bool isall = true;
863  int no = 0;
864  seen.push_back(edge);
865  for (int i = 0; i < (int)appr.size() && isall; i++) {
866  bool had = std::find(seen.begin(), seen.end(), appr[i]) != seen.end();
867  if (!had) {
868  if (!isDestination(det, appr[i], seen, detectors)) {
869  no++;
870  isall = false;
871  }
872  }
873  }
874  return isall;
875 }
876 
877 bool
879  const RODFDetectorCon& detectors) const {
880  if (seen.size() == 1000) { // !!!
881  WRITE_WARNING("Quitting checking for being a false source for detector '" + det.getID() + "' due to seen edge limit.");
882  return false;
883  }
884  seen.push_back(edge);
885  if (edge != getDetectorEdge(det)) {
886  // ok, we are at one of the edges coming behind
887  if (hasDetector(edge)) {
888  const std::vector<std::string>& dets = myDetectorsOnEdges.find(edge)->second;
889  for (std::vector<std::string>::const_iterator i = dets.begin(); i != dets.end(); ++i) {
890  if (detectors.getDetector(*i).getType() == SINK_DETECTOR) {
891  return false;
892  }
893  if (detectors.getDetector(*i).getType() == BETWEEN_DETECTOR) {
894  return false;
895  }
896  if (detectors.getDetector(*i).getType() == SOURCE_DETECTOR) {
897  return true;
898  }
899  }
900  } else {
901  if (myAmInHighwayMode && edge->getSpeedLimit() < 19.) {
902  return false;
903  }
904  }
905  }
906 
907  if (myApproachedEdges.find(edge) == myApproachedEdges.end()) {
908  return false;
909  }
910 
911  const ROEdgeVector& appr = myApproachedEdges.find(edge)->second;
912  bool isall = false;
913  for (int i = 0; i < (int)appr.size() && !isall; i++) {
914  //printf("checking %s->\n", appr[i].c_str());
915  bool had = std::find(seen.begin(), seen.end(), appr[i]) != seen.end();
916  if (!had) {
917  if (isFalseSource(det, appr[i], seen, detectors)) {
918  isall = true;
919  }
920  }
921  }
922  return isall;
923 }
924 
925 
926 void
928  const RODFDetectorCon& detectors,
929  SUMOTime startTime, SUMOTime endTime,
930  SUMOTime stepOffset) {
931  std::map<ROEdge*, std::vector<std::string>, idComp>::iterator i;
932  double speedFactorSumPKW = 0;
933  double speedFactorSumLKW = 0;
934  double speedFactorCountPKW = 0;
935  double speedFactorCountLKW = 0;
936  for (i = myDetectorsOnEdges.begin(); i != myDetectorsOnEdges.end(); ++i) {
937  ROEdge* into = (*i).first;
938  const double maxSpeedPKW = into->getVClassMaxSpeed(SVC_PASSENGER);
939  const double maxSpeedLKW = into->getVClassMaxSpeed(SVC_TRUCK);
940 
941  const std::vector<std::string>& dets = (*i).second;
942  std::map<double, std::vector<std::string> > cliques;
943  std::vector<std::string>* maxClique = nullptr;
944  for (std::vector<std::string>::const_iterator j = dets.begin(); j != dets.end(); ++j) {
945  if (!flows.knows(*j)) {
946  continue;
947  }
948  const RODFDetector& det = detectors.getDetector(*j);
949  bool found = false;
950  for (std::map<double, std::vector<std::string> >::iterator k = cliques.begin(); !found && k != cliques.end(); ++k) {
951  if (fabs((*k).first - det.getPos()) < 1) {
952  (*k).second.push_back(*j);
953  if ((*k).second.size() > maxClique->size()) {
954  maxClique = &(*k).second;
955  }
956  found = true;
957  }
958  }
959  if (!found) {
960  cliques[det.getPos()].push_back(*j);
961  maxClique = &cliques[det.getPos()];
962  }
963  }
964  if (maxClique == nullptr) {
965  continue;
966  }
967  std::vector<FlowDef> mflows; // !!! reserve
968  for (SUMOTime t = startTime; t < endTime; t += stepOffset) {
969  FlowDef fd;
970  fd.qPKW = 0;
971  fd.qLKW = 0;
972  fd.vLKW = 0;
973  fd.vPKW = 0;
974  fd.fLKW = 0;
975  fd.isLKW = 0;
976  mflows.push_back(fd);
977  }
978  for (std::vector<std::string>::iterator l = maxClique->begin(); l != maxClique->end(); ++l) {
979  bool didWarn = false;
980  const std::vector<FlowDef>& dflows = flows.getFlowDefs(*l);
981  int index = 0;
982  for (SUMOTime t = startTime; t < endTime; t += stepOffset, index++) {
983  const FlowDef& srcFD = dflows[index];
984  FlowDef& fd = mflows[index];
985  fd.qPKW += srcFD.qPKW;
986  fd.qLKW += srcFD.qLKW;
987  fd.vLKW += srcFD.vLKW / (double) maxClique->size();
988  fd.vPKW += srcFD.vPKW / (double) maxClique->size();
989  fd.fLKW += srcFD.fLKW / (double) maxClique->size();
990  fd.isLKW += srcFD.isLKW / (double) maxClique->size();
991  const double speedFactorPKW = srcFD.vPKW / 3.6 / maxSpeedPKW;
992  const double speedFactorLKW = srcFD.vLKW / 3.6 / maxSpeedLKW;
993  myMaxSpeedFactorPKW = MAX2(myMaxSpeedFactorPKW, speedFactorPKW);
994  myMaxSpeedFactorLKW = MAX2(myMaxSpeedFactorLKW, speedFactorLKW);
995  speedFactorCountPKW += srcFD.qPKW;
996  speedFactorCountLKW += srcFD.qLKW;
997  speedFactorSumPKW += srcFD.qPKW * speedFactorPKW;
998  speedFactorSumLKW += srcFD.qLKW * speedFactorLKW;
999  if (!didWarn && srcFD.vPKW > 0 && srcFD.vPKW < 255 && srcFD.vPKW / 3.6 > into->getSpeedLimit()) {
1000  WRITE_MESSAGE("Detected PKW speed (" + toString(srcFD.vPKW / 3.6, 3) + ") higher than allowed speed (" + toString(into->getSpeedLimit(), 3) + ") at '" + (*l) + "' on edge '" + into->getID() + "'.");
1001  didWarn = true;
1002  }
1003  if (!didWarn && srcFD.vLKW > 0 && srcFD.vLKW < 255 && srcFD.vLKW / 3.6 > into->getSpeedLimit()) {
1004  WRITE_MESSAGE("Detected LKW speed (" + toString(srcFD.vLKW / 3.6, 3) + ") higher than allowed speed (" + toString(into->getSpeedLimit(), 3) + ") at '" + (*l) + "' on edge '" + into->getID() + "'.");
1005  didWarn = true;
1006  }
1007  }
1008  }
1009  static_cast<RODFEdge*>(into)->setFlows(mflows);
1010  }
1011  // @note: this assumes that the speedFactors are independent of location and time
1012  if (speedFactorCountPKW > 0) {
1013  myAvgSpeedFactorPKW = speedFactorSumPKW / speedFactorCountPKW;
1014  WRITE_MESSAGE("Average speedFactor for PKW is " + toString(myAvgSpeedFactorPKW) + " maximum speedFactor is " + toString(myMaxSpeedFactorPKW) + ".");
1015  }
1016  if (speedFactorCountLKW > 0) {
1017  myAvgSpeedFactorLKW = speedFactorSumLKW / speedFactorCountLKW;
1018  WRITE_MESSAGE("Average speedFactor for LKW is " + toString(myAvgSpeedFactorLKW) + " maximum speedFactor is " + toString(myMaxSpeedFactorLKW) + ".");
1019  }
1020 
1021 }
1022 
1023 
1024 void
1026  // !!! this will not work when several detectors are lying on the same edge on different positions
1027 
1028 
1029  buildDetectorEdgeDependencies(detectors);
1030  // for each detector, compute the lists of predecessor and following detectors
1031  std::map<std::string, ROEdge*>::const_iterator i;
1032  for (i = myDetectorEdges.begin(); i != myDetectorEdges.end(); ++i) {
1033  const RODFDetector& det = detectors.getDetector((*i).first);
1034  if (!det.hasRoutes()) {
1035  continue;
1036  }
1037  // mark current detectors
1038  std::vector<RODFDetector*> last;
1039  {
1040  const std::vector<std::string>& detNames = myDetectorsOnEdges.find((*i).second)->second;
1041  for (std::vector<std::string>::const_iterator j = detNames.begin(); j != detNames.end(); ++j) {
1042  last.push_back(&detectors.getModifiableDetector(*j));
1043  }
1044  }
1045  // iterate over the current detector's routes
1046  const std::vector<RODFRouteDesc>& routes = det.getRouteVector();
1047  for (std::vector<RODFRouteDesc>::const_iterator j = routes.begin(); j != routes.end(); ++j) {
1048  const ROEdgeVector& edges2Pass = (*j).edges2Pass;
1049  for (ROEdgeVector::const_iterator k = edges2Pass.begin() + 1; k != edges2Pass.end(); ++k) {
1050  if (myDetectorsOnEdges.find(*k) != myDetectorsOnEdges.end()) {
1051  const std::vector<std::string>& detNames = myDetectorsOnEdges.find(*k)->second;
1052  // ok, consecutive detector found
1053  for (std::vector<RODFDetector*>::iterator l = last.begin(); l != last.end(); ++l) {
1054  // mark as follower of current
1055  for (std::vector<std::string>::const_iterator m = detNames.begin(); m != detNames.end(); ++m) {
1056  detectors.getModifiableDetector(*m).addPriorDetector(*l);
1057  (*l)->addFollowingDetector(&detectors.getDetector(*m));
1058  }
1059  }
1060  last.clear();
1061  for (std::vector<std::string>::const_iterator m = detNames.begin(); m != detNames.end(); ++m) {
1062  last.push_back(&detectors.getModifiableDetector(*m));
1063  }
1064  }
1065  }
1066  }
1067  }
1068 }
1069 
1070 
1071 void
1073  buildDetectorEdgeDependencies(detectors);
1074  std::map<ROEdge*, std::vector<std::string>, idComp>::iterator i;
1075  for (i = myDetectorsOnEdges.begin(); i != myDetectorsOnEdges.end(); ++i) {
1076  const std::vector<std::string>& dets = (*i).second;
1077  std::map<double, std::vector<std::string> > cliques;
1078  // compute detector cliques
1079  for (std::vector<std::string>::const_iterator j = dets.begin(); j != dets.end(); ++j) {
1080  const RODFDetector& det = detectors.getDetector(*j);
1081  bool found = false;
1082  for (std::map<double, std::vector<std::string> >::iterator k = cliques.begin(); !found && k != cliques.end(); ++k) {
1083  if (fabs((*k).first - det.getPos()) < 10.) {
1084  (*k).second.push_back(*j);
1085  found = true;
1086  }
1087  }
1088  if (!found) {
1089  cliques[det.getPos()] = std::vector<std::string>();
1090  cliques[det.getPos()].push_back(*j);
1091  }
1092  }
1093  // join detector cliques
1094  for (std::map<double, std::vector<std::string> >::iterator m = cliques.begin(); m != cliques.end(); ++m) {
1095  std::vector<std::string> clique = (*m).second;
1096  // do not join if only one
1097  if (clique.size() == 1) {
1098  continue;
1099  }
1100  std::string nid;
1101  for (std::vector<std::string>::iterator n = clique.begin(); n != clique.end(); ++n) {
1102  std::cout << *n << " ";
1103  if (n != clique.begin()) {
1104  nid = nid + "_";
1105  }
1106  nid = nid + *n;
1107  }
1108  std::cout << ":" << nid << std::endl;
1109  flows.mesoJoin(nid, (*m).second);
1110  detectors.mesoJoin(nid, (*m).second);
1111  }
1112  }
1113 }
1114 
1115 
1116 
1117 /****************************************************************************/
1118 
RODFNet::myDetectorsOnEdges
std::map< ROEdge *, std::vector< std::string >, idComp > myDetectorsOnEdges
Definition: RODFNet.h:174
SINK_DETECTOR
Definition: RODFDetector.h:70
RODFDetectorFlows
A container for flows.
Definition: RODFDetectorFlow.h:67
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:31
RODFNet::hasInBetweenDetectorsOnly
bool hasInBetweenDetectorsOnly(ROEdge *edge, const RODFDetectorCon &detectors) const
Definition: RODFNet.cpp:148
ROEdge::isInternal
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:147
RODFNet::isFalseSource
bool isFalseSource(const RODFDetector &det, const RODFDetectorCon &detectors) const
Definition: RODFNet.cpp:686
ToString.h
RODFNet::RODFNet
RODFNet(bool amInHighwayMode)
Constructor.
Definition: RODFNet.cpp:45
RODFDetector
Class representing a detector within the DFROUTER.
Definition: RODFDetector.h:81
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
FlowDef::fLKW
double fLKW
Definition: RODFDetectorFlow.h:52
RODFNet::getDetectorEdge
ROEdge * getDetectorEdge(const RODFDetector &det) const
Definition: RODFNet.cpp:625
RODFNet::buildApproachList
void buildApproachList()
Definition: RODFNet.cpp:62
RODFNet::mySourceNumber
int mySourceNumber
Definition: RODFNet.h:178
RODFNet::buildDetectorEdgeDependencies
void buildDetectorEdgeDependencies(RODFDetectorCon &dets) const
Definition: RODFNet.cpp:95
RODFDetector::addPriorDetector
void addPriorDetector(const RODFDetector *det)
Definition: RODFDetector.cpp:226
RODFNet::getAbsPos
double getAbsPos(const RODFDetector &det) const
Definition: RODFNet.cpp:670
FlowDef::qLKW
double qLKW
Definition: RODFDetectorFlow.h:44
RODFDetectorCon::removeDetector
void removeDetector(const std::string &id)
Definition: RODFDetector.cpp:872
RONet::getEdge
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:152
ROEdge::getSuccessors
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: ROEdge.cpp:358
RODFRouteDesc::endDetectorEdge
const ROEdge * endDetectorEdge
Definition: RODFRouteDesc.h:54
MsgHandler.h
RODFNet::mesoJoin
void mesoJoin(RODFDetectorCon &detectors, RODFDetectorFlows &flows)
Definition: RODFNet.cpp:1072
RODFNet::revalidateFlows
void revalidateFlows(const RODFDetectorCon &detectors, RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
Definition: RODFNet.cpp:570
RODFNet::myMaxSpeedFactorPKW
double myMaxSpeedFactorPKW
maximum speed factor in measurements
Definition: RODFNet.h:187
RODFDetectorFlows::removeFlow
void removeFlow(const std::string &detector_id)
Definition: RODFDetectorFlow.cpp:99
RODFNet::buildRoutes
void buildRoutes(RODFDetectorCon &det, bool keepUnfoundEnds, bool includeInBetween, bool keepShortestOnly, int maxFollowingLength) const
Definition: RODFNet.cpp:340
RODFEdge.h
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
RODFNet::myApproachingEdges
std::map< ROEdge *, ROEdgeVector > myApproachingEdges
Map of edge name->list of names of this edge approaching edges.
Definition: RODFNet.h:169
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:222
RODFDetector.h
RODFNet::DFRouteDescByTimeComperator
Definition: RODFNet.h:146
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
RODFNet::hasSourceDetector
bool hasSourceDetector(ROEdge *edge, const RODFDetectorCon &detectors) const
Definition: RODFNet.cpp:164
RONet
The router's network representation.
Definition: RONet.h:63
RODFRouteCont::addRouteDesc
void addRouteDesc(RODFRouteDesc &desc)
Adds a route to the container.
Definition: RODFRouteCont.cpp:46
RODFDetector::getRouteVector
const std::vector< RODFRouteDesc > & getRouteVector() const
Definition: RODFDetector.cpp:220
RODFNet::IterationEdge::depth
int depth
Definition: RODFNet.h:141
RODFDetectorFlows::knows
bool knows(const std::string &det_id) const
Definition: RODFDetectorFlow.cpp:105
RODFDetectorCon
A container for RODFDetectors.
Definition: RODFDetector.h:220
RODFNet::hasApproaching
bool hasApproaching(ROEdge *edge) const
Definition: RODFNet.cpp:637
RODFNet::computeRoutesFor
void computeRoutesFor(ROEdge *edge, RODFRouteDesc &base, int no, bool keepUnfoundEnds, bool keepShortestOnly, ROEdgeVector &visited, const RODFDetector &det, RODFRouteCont &into, const RODFDetectorCon &detectors, int maxFollowingLength, ROEdgeVector &seen) const
Definition: RODFNet.cpp:181
RODFRouteCont::removeRouteDesc
bool removeRouteDesc(RODFRouteDesc &desc)
Removes the given route description from the container.
Definition: RODFRouteCont.cpp:60
RODFNet::buildDetectorDependencies
void buildDetectorDependencies(RODFDetectorCon &detectors)
Definition: RODFNet.cpp:1025
RODFRouteDesc::overallProb
double overallProb
Definition: RODFRouteDesc.h:59
fd
static double fd[10]
Definition: odrSpiral.cpp:94
OptionsCont::getStringVector
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
Definition: OptionsCont.cpp:235
RODFDetector::getType
RODFDetectorType getType() const
Returns the type of the detector.
Definition: RODFDetector.h:143
RODFNet::getDetectorList
const std::vector< std::string > & getDetectorList(ROEdge *edge) const
Definition: RODFNet.cpp:664
RODFRouteDesc::lastDetectorEdge
const ROEdge * lastDetectorEdge
Definition: RODFRouteDesc.h:55
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
RODFDetector::hasRoutes
bool hasRoutes() const
Definition: RODFDetector.cpp:267
RODFDetectorCon::getDetector
const RODFDetector & getDetector(const std::string &id) const
Definition: RODFDetector.cpp:607
RODFNet::myKeepTurnarounds
bool myKeepTurnarounds
Definition: RODFNet.h:184
RODFDetectorFlows::setFlows
void setFlows(const std::string &detector_id, std::vector< FlowDef > &)
Definition: RODFDetectorFlow.cpp:84
FlowDef
Definition of the traffic during a certain time containing the flows and speeds.
Definition: RODFDetectorFlow.h:40
RODFNet::computeTypes
void computeTypes(RODFDetectorCon &dets, bool sourcesStrict) const
Definition: RODFNet.cpp:108
FlowDef::qPKW
double qPKW
Definition: RODFDetectorFlow.h:42
SVC_TRUCK
vehicle is a large transport vehicle
Definition: SUMOVehicleClass.h:171
RODFNet::hasDetector
bool hasDetector(ROEdge *edge) const
Definition: RODFNet.cpp:655
RODFRouteDesc::duration_2
double duration_2
Definition: RODFRouteDesc.h:51
FlowDef::vPKW
double vPKW
Definition: RODFDetectorFlow.h:46
RODFRouteDesc
A route within the DFROUTER.
Definition: RODFRouteDesc.h:46
RODFNet::~RODFNet
~RODFNet()
Destructor.
Definition: RODFNet.cpp:57
RODFDetectorCon::mesoJoin
void mesoJoin(const std::string &nid, const std::vector< std::string > &oldids)
Definition: RODFDetector.cpp:963
SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Definition: SUMOVehicleClass.h:159
RODFNet::myInBetweenNumber
int myInBetweenNumber
Definition: RODFNet.h:178
ProcessError
Definition: UtilExceptions.h:39
RODFNet::hasApproached
bool hasApproached(ROEdge *edge) const
Definition: RODFNet.cpp:646
RODFNet::myDisallowedEdges
std::vector< std::string > myDisallowedEdges
List of ids of edges that shall not be used.
Definition: RODFNet.h:181
UtilExceptions.h
RODFNet::myAvgSpeedFactorLKW
double myAvgSpeedFactorLKW
Definition: RODFNet.h:190
RODFRouteDesc::factor
double factor
Definition: RODFRouteDesc.h:60
RODFNet::myInvalidNumber
int myInvalidNumber
Definition: RODFNet.h:178
FlowDef::vLKW
double vLKW
Definition: RODFDetectorFlow.h:48
RODFRouteDesc::distance2Last
double distance2Last
Definition: RODFRouteDesc.h:56
ROEdgeVector
std::vector< ROEdge * > ROEdgeVector
Definition: RODFRouteDesc.h:35
RODFRouteDesc::passedNo
int passedNo
Definition: RODFRouteDesc.h:53
RODFNet::myDetectorEdges
std::map< std::string, ROEdge * > myDetectorEdges
Definition: RODFNet.h:175
RODFNet::IterationEdge
Definition: RODFNet.h:140
RODFNet::isSource
bool isSource(const RODFDetector &det, const RODFDetectorCon &detectors, bool strict) const
Definition: RODFNet.cpp:678
RODFNet::isDestination
bool isDestination(const RODFDetector &det, const RODFDetectorCon &detectors) const
Definition: RODFNet.cpp:693
ROEdge::getFromJunction
const RONode * getFromJunction() const
Definition: ROEdge.h:478
RODFNet::reportEmptyDetectors
void reportEmptyDetectors(RODFDetectorCon &detectors, RODFDetectorFlows &flows)
Definition: RODFNet.cpp:607
RONet::getEdgeMap
const NamedObjectCont< ROEdge * > & getEdgeMap() const
Definition: RONet.h:392
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:208
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
RODFRouteDesc::edges2Pass
ROEdgeVector edges2Pass
The edges the route is made of.
Definition: RODFRouteDesc.h:48
RODFDetectorCon::getDetectors
const std::vector< RODFDetector * > & getDetectors() const
Definition: RODFDetector.cpp:523
FlowDef::isLKW
double isLKW
Definition: RODFDetectorFlow.h:54
RODFNet::removeEmptyDetectors
void removeEmptyDetectors(RODFDetectorCon &detectors, RODFDetectorFlows &flows)
Definition: RODFNet.cpp:584
RODFNet::mySinkNumber
int mySinkNumber
Definition: RODFNet.h:178
PROGRESS_BEGIN_MESSAGE
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition: MsgHandler.h:278
RODFDetectorFlow.h
RODFNet::myAmInHighwayMode
bool myAmInHighwayMode
Definition: RODFNet.h:177
ROEdge::getVClassMaxSpeed
double getVClassMaxSpeed(SUMOVehicleClass vclass) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: ROEdge.h:231
ROEdge::getLength
double getLength() const
Returns the length of the edge.
Definition: ROEdge.h:204
RODFNet::myApproachedEdges
std::map< ROEdge *, ROEdgeVector > myApproachedEdges
Map of edge name->list of names of edges approached by this edge.
Definition: RODFNet.h:172
RODFRouteDesc.h
PROGRESS_DONE_MESSAGE
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:279
RODFDetectorFlows::getFlowDefs
const std::vector< FlowDef > & getFlowDefs(const std::string &id) const
Definition: RODFDetectorFlow.cpp:111
RODFRouteDesc::duration2Last
SUMOTime duration2Last
Definition: RODFRouteDesc.h:57
ROEdge
A basic edge for routing applications.
Definition: ROEdge.h:72
RODFDetector::getPos
double getPos() const
Returns the position at which the detector lies.
Definition: RODFDetector.h:134
TYPE_NOT_DEFINED
A not yet defined detector.
Definition: RODFDetector.h:60
RODFNet::IterationEdge::edge
ROEdge * edge
Definition: RODFNet.h:142
SOURCE_DETECTOR
A source detector.
Definition: RODFDetector.h:69
config.h
RODFDetector::getLaneID
const std::string & getLaneID() const
Returns the id of the lane this detector is placed on.
Definition: RODFDetector.h:118
GeomHelper.h
ROEdge::getSpeedLimit
double getSpeedLimit() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:219
BETWEEN_DETECTOR
An in-between detector.
Definition: RODFDetector.h:66
RODFRouteCont
A container for DFROUTER-routes.
Definition: RODFRouteCont.h:55
RODFNet.h
DISCARDED_DETECTOR
A detector which had to be discarded (!!!)
Definition: RODFDetector.h:63
RODFNet::myMaxSpeedFactorLKW
double myMaxSpeedFactorLKW
Definition: RODFNet.h:188
RODFNet::myAvgSpeedFactorPKW
double myAvgSpeedFactorPKW
Definition: RODFNet.h:189
RODFRouteCont::get
std::vector< RODFRouteDesc > & get()
Returns the container of stored routes.
Definition: RODFRouteCont.h:105
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
RODFNet::buildEdgeFlowMap
void buildEdgeFlowMap(const RODFDetectorFlows &flows, const RODFDetectorCon &detectors, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
Definition: RODFNet.cpp:927
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
RODFNet::idComp
comparator for maps using edges as key, used only in myDetectorsOnEdges to make tests comparable
Definition: RODFNet.h:162
RODFRouteDesc::distance
double distance
Definition: RODFRouteDesc.h:52
ConstROEdgeVector
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:56
RODFDetectorCon::getModifiableDetector
RODFDetector & getModifiableDetector(const std::string &id) const
Definition: RODFDetector.cpp:613
ROEdge::getToJunction
const RONode * getToJunction() const
Definition: ROEdge.h:482
RODFDetectorFlows::mesoJoin
void mesoJoin(const std::string &nid, const std::vector< std::string > &oldids)
Definition: RODFDetectorFlow.cpp:155