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