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