Eclipse SUMO - Simulation of Urban MObility
RODFDetector.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2006-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 /****************************************************************************/
20 // Class representing a detector within the DFROUTER
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <cassert>
30 #include "RODFDetector.h"
34 #include <utils/common/ToString.h>
35 #include <router/ROEdge.h>
36 #include "RODFEdge.h"
37 #include "RODFRouteDesc.h"
38 #include "RODFRouteCont.h"
39 #include "RODFDetectorFlow.h"
42 #include <utils/common/StdDefs.h>
44 #include <utils/geom/GeomHelper.h>
45 #include "RODFNet.h"
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 RODFDetector::RODFDetector(const std::string& id, const std::string& laneID,
55  double pos, const RODFDetectorType type)
56  : Named(id), myLaneID(laneID), myPosition(pos), myType(type), myRoutes(nullptr) {}
57 
58 
59 RODFDetector::RODFDetector(const std::string& id, const RODFDetector& f)
60  : Named(id), myLaneID(f.myLaneID), myPosition(f.myPosition),
61  myType(f.myType), myRoutes(nullptr) {
62  if (f.myRoutes != nullptr) {
63  myRoutes = new RODFRouteCont(*(f.myRoutes));
64  }
65 }
66 
67 
69  delete myRoutes;
70 }
71 
72 
73 void
75  myType = type;
76 }
77 
78 
79 double
81  double distance = rd.edges2Pass[0]->getFromJunction()->getPosition().distanceTo(rd.edges2Pass.back()->getToJunction()->getPosition());
82  double length = 0;
83  for (ROEdgeVector::const_iterator i = rd.edges2Pass.begin(); i != rd.edges2Pass.end(); ++i) {
84  length += (*i)->getLength();
85  }
86  return (distance / length);
87 }
88 
89 
90 void
92  const RODFDetectorFlows& flows,
93  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset) {
94  if (myRoutes == nullptr) {
95  return;
96  }
97  // compute edges to determine split probabilities
98  const std::vector<RODFRouteDesc>& routes = myRoutes->get();
99  std::vector<RODFEdge*> nextDetEdges;
100  std::set<ROEdge*> preSplitEdges;
101  for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
102  const RODFRouteDesc& rd = *i;
103  bool hadSplit = false;
104  for (ROEdgeVector::const_iterator j = rd.edges2Pass.begin(); j != rd.edges2Pass.end(); ++j) {
105  if (hadSplit && net->hasDetector(*j)) {
106  if (find(nextDetEdges.begin(), nextDetEdges.end(), *j) == nextDetEdges.end()) {
107  nextDetEdges.push_back(static_cast<RODFEdge*>(*j));
108  }
109  myRoute2Edge[rd.routename] = static_cast<RODFEdge*>(*j);
110  break;
111  }
112  if (!hadSplit) {
113  preSplitEdges.insert(*j);
114  }
115  if ((*j)->getNumSuccessors() > 1) {
116  hadSplit = true;
117  }
118  }
119  }
120  std::map<ROEdge*, double> inFlows;
121  if (OptionsCont::getOptions().getBool("respect-concurrent-inflows")) {
122  for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
123  std::set<ROEdge*> seen(preSplitEdges);
124  ROEdgeVector pending;
125  pending.push_back(*i);
126  seen.insert(*i);
127  while (!pending.empty()) {
128  ROEdge* e = pending.back();
129  pending.pop_back();
130  for (ROEdgeVector::const_iterator it = e->getPredecessors().begin(); it != e->getPredecessors().end(); it++) {
131  ROEdge* e2 = *it;
132  if (e2->getNumSuccessors() == 1 && seen.count(e2) == 0) {
133  if (net->hasDetector(e2)) {
134  inFlows[*i] += detectors.getAggFlowFor(e2, 0, 0, flows);
135  } else {
136  pending.push_back(e2);
137  }
138  seen.insert(e2);
139  }
140  }
141  }
142  }
143  }
144  // compute the probabilities to use a certain direction
145  int index = 0;
146  for (SUMOTime time = startTime; time < endTime; time += stepOffset, ++index) {
147  mySplitProbabilities.push_back(std::map<RODFEdge*, double>());
148  double overallProb = 0;
149  // retrieve the probabilities
150  for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
151  double flow = detectors.getAggFlowFor(*i, time, 60, flows) - inFlows[*i];
152  overallProb += flow;
153  mySplitProbabilities[index][*i] = flow;
154  }
155  // norm probabilities
156  if (overallProb > 0) {
157  for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
158  mySplitProbabilities[index][*i] = mySplitProbabilities[index][*i] / overallProb;
159  }
160  }
161  }
162 }
163 
164 
165 void
167  SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset,
168  const RODFNet& net,
169  std::map<SUMOTime, RandomDistributor<int>* >& into) const {
170  if (myRoutes == nullptr) {
172  WRITE_ERROR("Missing routes for detector '" + myID + "'.");
173  }
174  return;
175  }
176  std::vector<RODFRouteDesc>& descs = myRoutes->get();
177  // iterate through time (in output interval steps)
178  for (SUMOTime time = startTime; time < endTime; time += stepOffset) {
179  into[time] = new RandomDistributor<int>();
180  std::map<ROEdge*, double> flowMap;
181  // iterate through the routes
182  int index = 0;
183  for (std::vector<RODFRouteDesc>::iterator ri = descs.begin(); ri != descs.end(); ++ri, index++) {
184  double prob = 1.;
185  for (ROEdgeVector::iterator j = (*ri).edges2Pass.begin(); j != (*ri).edges2Pass.end() && prob > 0;) {
186  if (!net.hasDetector(*j)) {
187  ++j;
188  continue;
189  }
190  const RODFDetector& det = detectors.getAnyDetectorForEdge(static_cast<RODFEdge*>(*j));
191  const std::vector<std::map<RODFEdge*, double> >& probs = det.getSplitProbabilities();
192  if (probs.size() == 0) {
193  prob = 0;
194  ++j;
195  continue;
196  }
197  const std::map<RODFEdge*, double>& tprobs = probs[(int)((time - startTime) / stepOffset)];
198  RODFEdge* splitEdge = nullptr;
199  for (std::map<RODFEdge*, double>::const_iterator k = tprobs.begin(); k != tprobs.end(); ++k) {
200  if (find(j, (*ri).edges2Pass.end(), (*k).first) != (*ri).edges2Pass.end()) {
201  prob *= (*k).second;
202  splitEdge = (*k).first;
203  break;
204  }
205  }
206  if (splitEdge != nullptr) {
207  j = std::find(j, (*ri).edges2Pass.end(), splitEdge);
208  } else {
209  ++j;
210  }
211  }
212  into[time]->add(index, prob);
213  (*ri).overallProb = prob;
214  }
215  }
216 }
217 
218 
219 const std::vector<RODFRouteDesc>&
221  return myRoutes->get();
222 }
223 
224 
225 void
227  myPriorDetectors.insert(det);
228 }
229 
230 
231 void
233  myFollowingDetectors.insert(det);
234 }
235 
236 
237 const std::set<const RODFDetector*>&
239  return myPriorDetectors;
240 }
241 
242 
243 const std::set<const RODFDetector*>&
245  return myFollowingDetectors;
246 }
247 
248 
249 
250 void
252  delete myRoutes;
253  myRoutes = routes;
254 }
255 
256 
257 void
259  if (myRoutes == nullptr) {
260  myRoutes = new RODFRouteCont();
261  }
262  myRoutes->addRouteDesc(nrd);
263 }
264 
265 
266 bool
268  return myRoutes != nullptr && myRoutes->get().size() != 0;
269 }
270 
271 
272 bool
273 RODFDetector::writeEmitterDefinition(const std::string& file,
274  const std::map<SUMOTime, RandomDistributor<int>* >& dists,
275  const RODFDetectorFlows& flows,
276  SUMOTime startTime, SUMOTime endTime,
277  SUMOTime stepOffset,
278  bool includeUnusedRoutes,
279  double scale,
280  bool insertionsOnly,
281  double defaultSpeed) const {
284  if (getType() != SOURCE_DETECTOR) {
285  out.writeXMLHeader("additional", "additional_file.xsd");
286  }
287  // routes
288  if (myRoutes != nullptr && myRoutes->get().size() != 0) {
289  const std::vector<RODFRouteDesc>& routes = myRoutes->get();
291  bool isEmptyDist = true;
292  for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
293  if ((*i).overallProb > 0) {
294  isEmptyDist = false;
295  }
296  }
297  for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
298  if (isEmptyDist) {
300  } else if ((*i).overallProb > 0 || includeUnusedRoutes) {
301  out.openTag(SUMO_TAG_ROUTE).writeAttr(SUMO_ATTR_REFID, (*i).routename).writeAttr(SUMO_ATTR_PROB, (*i).overallProb).closeTag();
302  }
303  }
304  out.closeTag(); // routeDistribution
305  } else {
306  WRITE_ERROR("Detector '" + getID() + "' has no routes!?");
307  return false;
308  }
309  // insertions
310  int vehicleIndex = 0;
311  if (insertionsOnly || flows.knows(myID)) {
312  // get the flows for this detector
313  const std::vector<FlowDef>& mflows = flows.getFlowDefs(myID);
314  // go through the simulation seconds
315  int index = 0;
316  for (SUMOTime time = startTime; time < endTime; time += stepOffset, index++) {
317  // get own (departure flow)
318  assert(index < (int)mflows.size());
319  const FlowDef& srcFD = mflows[index]; // !!! check stepOffset
320  // get flows at end
321  RandomDistributor<int>* destDist = dists.find(time) != dists.end() ? dists.find(time)->second : 0;
322  // go through the cars
323  const int numCars = (int)((srcFD.qPKW + srcFD.qLKW) * scale);
324 
325 
326  std::vector<SUMOTime> departures;
327  if (oc.getBool("randomize-flows")) {
328  for (int i = 0; i < numCars; ++i) {
329  departures.push_back(time + RandHelper::rand(stepOffset));
330  }
331  std::sort(departures.begin(), departures.end());
332  } else {
333  for (int i = 0; i < numCars; ++i) {
334  departures.push_back(time + (SUMOTime)(stepOffset * i / (double)numCars));
335  }
336  }
337 
338  for (int car = 0; car < numCars; ++car) {
339  // get the vehicle parameter
340  double v = -1;
341  std::string vtype;
342  int destIndex = -1;
343  if (destDist != nullptr) {
344  if (destDist->getOverallProb() > 0) {
345  destIndex = destDist->get();
346  } else if (myRoutes->get().size() > 0) {
347  // equal probabilities. see writeEmitterDefinition()
348  destIndex = RandHelper::rand((int)myRoutes->get().size());
349  }
350  }
351  if (srcFD.isLKW >= 1) {
352  srcFD.isLKW = srcFD.isLKW - 1.;
353  v = srcFD.vLKW;
354  vtype = "LKW";
355  } else {
356  v = srcFD.vPKW;
357  vtype = "PKW";
358  }
359  // compute insertion speed
360  if (v <= 0 || v > 250) {
361  v = defaultSpeed;
362  } else {
363  v /= 3.6;
364  }
365  // compute the departure time
366  const SUMOTime ctime = departures[car];
367 
368  // write
370  out.writeAttr(SUMO_ATTR_ID, myID + "." + toString(vehicleIndex));
371  if (oc.getBool("vtype")) {
372  out.writeAttr(SUMO_ATTR_TYPE, vtype);
373  }
375  if (oc.isSet("departlane")) {
376  out.writeNonEmptyAttr(SUMO_ATTR_DEPARTLANE, oc.getString("departlane"));
377  } else {
378  out.writeAttr(SUMO_ATTR_DEPARTLANE, StringUtils::toInt(myLaneID.substr(myLaneID.rfind("_") + 1)));
379  }
380  if (oc.isSet("departpos")) {
381  std::string posDesc = oc.getString("departpos");
382  if (posDesc.substr(0, 8) == "detector") {
383  double position = myPosition;
384  if (posDesc.length() > 8) {
385  if (posDesc[8] == '+') {
386  position += StringUtils::toDouble(posDesc.substr(9));
387  } else if (posDesc[8] == '-') {
388  position -= StringUtils::toDouble(posDesc.substr(9));
389  } else {
390  throw NumberFormatException("");
391  }
392  }
393  out.writeAttr(SUMO_ATTR_DEPARTPOS, position);
394  } else {
396  }
397  } else {
399  }
400  if (oc.isSet("departspeed")) {
401  out.writeNonEmptyAttr(SUMO_ATTR_DEPARTSPEED, oc.getString("departspeed"));
402  } else {
404  }
405  if (oc.isSet("arrivallane")) {
406  out.writeNonEmptyAttr(SUMO_ATTR_ARRIVALLANE, oc.getString("arrivallane"));
407  }
408  if (oc.isSet("arrivalpos")) {
409  out.writeNonEmptyAttr(SUMO_ATTR_ARRIVALPOS, oc.getString("arrivalpos"));
410  }
411  if (oc.isSet("arrivalspeed")) {
412  out.writeNonEmptyAttr(SUMO_ATTR_ARRIVALSPEED, oc.getString("arrivalspeed"));
413  }
414  if (destIndex >= 0) {
415  out.writeAttr(SUMO_ATTR_ROUTE, myRoutes->get()[destIndex].routename);
416  } else {
418  }
419  out.closeTag();
420  srcFD.isLKW += srcFD.fLKW;
421  vehicleIndex++;
422  }
423  }
424  }
425  if (getType() != SOURCE_DETECTOR) {
426  out.close();
427  }
428  return true;
429 }
430 
431 
432 bool
433 RODFDetector::writeRoutes(std::vector<std::string>& saved,
434  OutputDevice& out) {
435  if (myRoutes != nullptr) {
436  return myRoutes->save(saved, "", out);
437  }
438  return false;
439 }
440 
441 
442 void
444  const RODFDetectorFlows& flows,
445  SUMOTime startTime, SUMOTime endTime,
446  SUMOTime stepOffset, double defaultSpeed) {
448  out.writeXMLHeader("additional", "additional_file.xsd");
449  const std::vector<FlowDef>& mflows = flows.getFlowDefs(myID);
450  int index = 0;
451  for (SUMOTime t = startTime; t < endTime; t += stepOffset, index++) {
452  assert(index < (int)mflows.size());
453  const FlowDef& srcFD = mflows[index];
454  double speed = MAX2(srcFD.vLKW, srcFD.vPKW);
455  if (speed <= 0 || speed > 250) {
456  speed = defaultSpeed;
457  } else {
458  speed = (double)(speed / 3.6);
459  }
461  }
462  out.close();
463 }
464 
465 
466 
467 
468 
469 
470 
471 
472 
473 
475 
476 
478  for (std::vector<RODFDetector*>::iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
479  delete *i;
480  }
481 }
482 
483 
484 bool
486  if (myDetectorMap.find(dfd->getID()) != myDetectorMap.end()) {
487  return false;
488  }
489  myDetectorMap[dfd->getID()] = dfd;
490  myDetectors.push_back(dfd);
491  std::string edgeid = dfd->getLaneID().substr(0, dfd->getLaneID().rfind('_'));
492  if (myDetectorEdgeMap.find(edgeid) == myDetectorEdgeMap.end()) {
493  myDetectorEdgeMap[edgeid] = std::vector<RODFDetector*>();
494  }
495  myDetectorEdgeMap[edgeid].push_back(dfd);
496  return true; // !!!
497 }
498 
499 
500 bool
502  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
503  if ((*i)->getType() == TYPE_NOT_DEFINED) {
504  return false;
505  }
506  }
507  return true;
508 }
509 
510 
511 bool
513  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
514  if ((*i)->hasRoutes()) {
515  return true;
516  }
517  }
518  return false;
519 }
520 
521 
522 const std::vector< RODFDetector*>&
524  return myDetectors;
525 }
526 
527 
528 void
529 RODFDetectorCon::save(const std::string& file) const {
531  out.writeXMLHeader("detectors", "detectors_file.xsd");
532  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
533  out.openTag(SUMO_TAG_DETECTOR_DEFINITION).writeAttr(SUMO_ATTR_ID, StringUtils::escapeXML((*i)->getID())).writeAttr(SUMO_ATTR_LANE, (*i)->getLaneID()).writeAttr(SUMO_ATTR_POSITION, (*i)->getPos());
534  switch ((*i)->getType()) {
535  case BETWEEN_DETECTOR:
536  out.writeAttr(SUMO_ATTR_TYPE, "between");
537  break;
538  case SOURCE_DETECTOR:
539  out.writeAttr(SUMO_ATTR_TYPE, "source");
540  break;
541  case SINK_DETECTOR:
542  out.writeAttr(SUMO_ATTR_TYPE, "sink");
543  break;
544  case DISCARDED_DETECTOR:
545  out.writeAttr(SUMO_ATTR_TYPE, "discarded");
546  break;
547  default:
548  throw 1;
549  }
550  out.closeTag();
551  }
552  out.close();
553 }
554 
555 
556 void
557 RODFDetectorCon::saveAsPOIs(const std::string& file) const {
559  out.writeXMLHeader("additional", "additional_file.xsd");
560  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
562  switch ((*i)->getType()) {
563  case BETWEEN_DETECTOR:
564  out.writeAttr(SUMO_ATTR_TYPE, "between_detector_position").writeAttr(SUMO_ATTR_COLOR, RGBColor::BLUE);
565  break;
566  case SOURCE_DETECTOR:
567  out.writeAttr(SUMO_ATTR_TYPE, "source_detector_position").writeAttr(SUMO_ATTR_COLOR, RGBColor::GREEN);
568  break;
569  case SINK_DETECTOR:
570  out.writeAttr(SUMO_ATTR_TYPE, "sink_detector_position").writeAttr(SUMO_ATTR_COLOR, RGBColor::RED);
571  break;
572  case DISCARDED_DETECTOR:
573  out.writeAttr(SUMO_ATTR_TYPE, "discarded_detector_position").writeAttr(SUMO_ATTR_COLOR, RGBColor(51, 51, 51, 255));
574  break;
575  default:
576  throw 1;
577  }
578  out.writeAttr(SUMO_ATTR_LANE, (*i)->getLaneID()).writeAttr(SUMO_ATTR_POSITION, (*i)->getPos()).closeTag();
579  }
580  out.close();
581 }
582 
583 
584 void
585 RODFDetectorCon::saveRoutes(const std::string& file) const {
587  out.writeXMLHeader("routes", "routes_file.xsd");
588  std::vector<std::string> saved;
589  // write for source detectors
590  bool lastWasSaved = true;
591  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
592  if ((*i)->getType() != SOURCE_DETECTOR) {
593  // do not build routes for other than sources
594  continue;
595  }
596  if (lastWasSaved) {
597  out << "\n";
598  }
599  lastWasSaved = (*i)->writeRoutes(saved, out);
600  }
601  out << "\n";
602  out.close();
603 }
604 
605 
606 const RODFDetector&
607 RODFDetectorCon::getDetector(const std::string& id) const {
608  return *(myDetectorMap.find(id)->second);
609 }
610 
611 
613 RODFDetectorCon::getModifiableDetector(const std::string& id) const {
614  return *(myDetectorMap.find(id)->second);
615 }
616 
617 
618 bool
619 RODFDetectorCon::knows(const std::string& id) const {
620  return myDetectorMap.find(id) != myDetectorMap.end();
621 }
622 
623 
624 void
625 RODFDetectorCon::writeEmitters(const std::string& file,
626  const RODFDetectorFlows& flows,
627  SUMOTime startTime, SUMOTime endTime,
628  SUMOTime stepOffset, const RODFNet& net,
629  bool writeCalibrators,
630  bool includeUnusedRoutes,
631  double scale,
632  bool insertionsOnly) {
633  // compute turn probabilities at detector
634  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
635  (*i)->computeSplitProbabilities(&net, *this, flows, startTime, endTime, stepOffset);
636  }
637  //
639  out.writeXMLHeader("additional", "additional_file.xsd");
640  // write vType(s)
641  const bool separateVTypeOutput = OptionsCont::getOptions().getString("vtype-output") != "";
642  OutputDevice& vTypeOut = separateVTypeOutput ? OutputDevice::getDevice(OptionsCont::getOptions().getString("vtype-output")) : out;
643  if (separateVTypeOutput) {
644  vTypeOut.writeXMLHeader("additional", "additional_file.xsd");
645  }
646  const bool forceDev = !OptionsCont::getOptions().isDefault("speeddev");
647  const double speedDev = OptionsCont::getOptions().getFloat("speeddev");
648  if (OptionsCont::getOptions().getBool("vtype")) {
649  // write separate types
651  setSpeedFactorAndDev(pkwType, net.getMaxSpeedFactorPKW(), net.getAvgSpeedFactorPKW(), speedDev, forceDev);
653  pkwType.write(vTypeOut);
655  setSpeedFactorAndDev(lkwType, net.getMaxSpeedFactorLKW(), net.getAvgSpeedFactorLKW(), speedDev, forceDev);
657  lkwType.write(vTypeOut);
658  } else {
659  // patch default type
661  setSpeedFactorAndDev(type, MAX2(net.getMaxSpeedFactorPKW(), net.getMaxSpeedFactorLKW()), net.getAvgSpeedFactorPKW(), speedDev, forceDev);
662  if (type.parametersSet != 0) {
663  type.write(vTypeOut);
664  }
665  }
666 
667 
668  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
669  RODFDetector* det = *i;
670  // get file name for values (emitter/calibrator definition)
671  std::string escapedID = StringUtils::escapeXML(det->getID());
672  std::string defFileName;
673  if (det->getType() == SOURCE_DETECTOR) {
674  defFileName = file;
675  } else if (writeCalibrators && det->getType() == BETWEEN_DETECTOR) {
676  defFileName = FileHelpers::getFilePath(file) + "calibrator_" + escapedID + ".def.xml";
677  } else {
678  defFileName = FileHelpers::getFilePath(file) + "other_" + escapedID + ".def.xml";
679  continue;
680  }
681  // try to write the definition
682  double defaultSpeed = net.getEdge(det->getEdgeID())->getSpeedLimit();
683  // ... compute routes' distribution over time
684  std::map<SUMOTime, RandomDistributor<int>* > dists;
685  if (!insertionsOnly && flows.knows(det->getID())) {
686  det->buildDestinationDistribution(*this, startTime, endTime, stepOffset, net, dists);
687  }
688  // ... write the definition
689  if (!det->writeEmitterDefinition(defFileName, dists, flows, startTime, endTime, stepOffset, includeUnusedRoutes, scale, insertionsOnly, defaultSpeed)) {
690  // skip if something failed... (!!!)
691  continue;
692  }
693  // ... clear temporary values
694  clearDists(dists);
695  // write the declaration into the file
696  if (writeCalibrators && det->getType() == BETWEEN_DETECTOR) {
697  out.openTag(SUMO_TAG_CALIBRATOR).writeAttr(SUMO_ATTR_ID, "calibrator_" + escapedID).writeAttr(SUMO_ATTR_POSITION, det->getPos());
698  out.writeAttr(SUMO_ATTR_LANE, det->getLaneID()).writeAttr(SUMO_ATTR_FRIENDLY_POS, true).writeAttr(SUMO_ATTR_FILE, defFileName).closeTag();
699  }
700  }
701  out.close();
702  if (separateVTypeOutput) {
703  vTypeOut.close();
704  }
705 }
706 
707 void
708 RODFDetectorCon::setSpeedFactorAndDev(SUMOVTypeParameter& type, double maxFactor, double avgFactor, double dev, bool forceDev) {
709  if (avgFactor > 1) {
710  // systematically low speeds can easily be caused by traffic
711  // conditions. Whereas elevated speeds probably reflect speeding
712  type.speedFactor.getParameter()[0] = avgFactor;
714  }
715  if (forceDev || (maxFactor > 1 && maxFactor > type.speedFactor.getParameter()[0] + NUMERICAL_EPS)) {
716  // setting a non-zero speed deviation causes the simulation to recompute
717  // individual speedFactors to match departSpeed (MSEdge::insertVehicle())
718  type.speedFactor.getParameter()[1] = dev;
720  } else {
721  type.speedFactor.getParameter()[1] = -1; // do not write speedDev, only simple speedFactor
722  }
723 }
724 
725 
726 void
727 RODFDetectorCon::writeEmitterPOIs(const std::string& file,
728  const RODFDetectorFlows& flows) {
730  out.writeXMLHeader("additional", "additional_file.xsd");
731  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
732  RODFDetector* det = *i;
733  double flow = flows.getFlowSumSecure(det->getID());
734  const unsigned char col = static_cast<unsigned char>(128 * flow / flows.getMaxDetectorFlow() + 128);
735  out.openTag(SUMO_TAG_POI).writeAttr(SUMO_ATTR_ID, StringUtils::escapeXML((*i)->getID()) + ":" + toString(flow));
736  switch ((*i)->getType()) {
737  case BETWEEN_DETECTOR:
738  out.writeAttr(SUMO_ATTR_TYPE, "between_detector_position").writeAttr(SUMO_ATTR_COLOR, RGBColor(0, 0, col, 255));
739  break;
740  case SOURCE_DETECTOR:
741  out.writeAttr(SUMO_ATTR_TYPE, "source_detector_position").writeAttr(SUMO_ATTR_COLOR, RGBColor(0, col, 0, 255));
742  break;
743  case SINK_DETECTOR:
744  out.writeAttr(SUMO_ATTR_TYPE, "sink_detector_position").writeAttr(SUMO_ATTR_COLOR, RGBColor(col, 0, 0, 255));
745  break;
746  case DISCARDED_DETECTOR:
747  out.writeAttr(SUMO_ATTR_TYPE, "discarded_detector_position").writeAttr(SUMO_ATTR_COLOR, RGBColor(51, 51, 51, 255));
748  break;
749  default:
750  throw 1;
751  }
752  out.writeAttr(SUMO_ATTR_LANE, (*i)->getLaneID()).writeAttr(SUMO_ATTR_POSITION, (*i)->getPos()).closeTag();
753  }
754  out.close();
755 }
756 
757 
758 int
760  const RODFDetectorFlows&) const {
761  UNUSED_PARAMETER(period);
762  UNUSED_PARAMETER(time);
763  if (edge == nullptr) {
764  return 0;
765  }
766 // double stepOffset = 60; // !!!
767 // double startTime = 0; // !!!
768 // cout << edge->getID() << endl;
769  assert(myDetectorEdgeMap.find(edge->getID()) != myDetectorEdgeMap.end());
770  const std::vector<FlowDef>& flows = static_cast<const RODFEdge*>(edge)->getFlows();
771  double agg = 0;
772  for (std::vector<FlowDef>::const_iterator i = flows.begin(); i != flows.end(); ++i) {
773  const FlowDef& srcFD = *i;
774  if (srcFD.qLKW >= 0) {
775  agg += srcFD.qLKW;
776  }
777  if (srcFD.qPKW >= 0) {
778  agg += srcFD.qPKW;
779  }
780  }
781  return (int) agg;
782  /* !!! make this time variable
783  if (flows.size()!=0) {
784  double agg = 0;
785  int beginIndex = (int)((time/stepOffset) - startTime); // !!! falsch!!!
786  for (SUMOTime t=0; t<period&&beginIndex<flows.size(); t+=(SUMOTime) stepOffset) {
787  const FlowDef &srcFD = flows[beginIndex++];
788  if (srcFD.qLKW>=0) {
789  agg += srcFD.qLKW;
790  }
791  if (srcFD.qPKW>=0) {
792  agg += srcFD.qPKW;
793  }
794  }
795  return (int) agg;
796  }
797  */
798 // return -1;
799 }
800 
801 
802 void
804  const std::string& file,
805  const RODFDetectorFlows& flows,
806  SUMOTime startTime, SUMOTime endTime,
807  SUMOTime stepOffset) {
809  out.writeXMLHeader("additional", "additional_file.xsd");
810  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
811  RODFDetector* det = *i;
812  // write the declaration into the file
813  if (det->getType() == SINK_DETECTOR && flows.knows(det->getID())) {
814  std::string filename = FileHelpers::getFilePath(file) + "vss_" + det->getID() + ".def.xml";
816  double defaultSpeed = net != nullptr ? net->getEdge(det->getEdgeID())->getSpeedLimit() : (double) 200.;
817  det->writeSingleSpeedTrigger(filename, flows, startTime, endTime, stepOffset, defaultSpeed);
818  }
819  }
820  out.close();
821 }
822 
823 
824 void
827  out.writeXMLHeader("additional", "additional_file.xsd");
828  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
829  RODFDetector* det = *i;
830  // write the declaration into the file
831  if (det->getType() == SINK_DETECTOR) {
833  out.writeAttr(SUMO_ATTR_POSITION, 0.).writeAttr(SUMO_ATTR_FILE, "endrerouter_" + det->getID() + ".def.xml").closeTag();
834  }
835  }
836  out.close();
837 }
838 
839 
840 void
842  bool includeSources,
843  bool singleFile, bool friendly) {
845  out.writeXMLHeader("additional", "additional_file.xsd");
846  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
847  RODFDetector* det = *i;
848  // write the declaration into the file
849  if (det->getType() != SOURCE_DETECTOR || includeSources) {
850  double pos = det->getPos();
851  if (det->getType() == SOURCE_DETECTOR) {
852  pos += 1;
853  }
856  if (friendly) {
858  }
859  if (!singleFile) {
860  out.writeAttr(SUMO_ATTR_FILE, "validation_det_" + StringUtils::escapeXML(det->getID()) + ".xml");
861  } else {
862  out.writeAttr(SUMO_ATTR_FILE, "validation_dets.xml");
863  }
864  out.closeTag();
865  }
866  }
867  out.close();
868 }
869 
870 
871 void
872 RODFDetectorCon::removeDetector(const std::string& id) {
873  //
874  std::map<std::string, RODFDetector*>::iterator ri1 = myDetectorMap.find(id);
875  RODFDetector* oldDet = (*ri1).second;
876  myDetectorMap.erase(ri1);
877  //
878  std::vector<RODFDetector*>::iterator ri2 =
879  std::find(myDetectors.begin(), myDetectors.end(), oldDet);
880  myDetectors.erase(ri2);
881  //
882  bool found = false;
883  for (std::map<std::string, std::vector<RODFDetector*> >::iterator rr3 = myDetectorEdgeMap.begin(); !found && rr3 != myDetectorEdgeMap.end(); ++rr3) {
884  std::vector<RODFDetector*>& dets = (*rr3).second;
885  for (std::vector<RODFDetector*>::iterator ri3 = dets.begin(); !found && ri3 != dets.end();) {
886  if (*ri3 == oldDet) {
887  found = true;
888  ri3 = dets.erase(ri3);
889  } else {
890  ++ri3;
891  }
892  }
893  }
894  delete oldDet;
895 }
896 
897 
898 void
900  // routes must be built (we have ensured this in main)
901  // detector followers/prior must be build (we have ensured this in main)
902  //
903  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
904  RODFDetector* det = *i;
905  const std::set<const RODFDetector*>& prior = det->getPriorDetectors();
906  const std::set<const RODFDetector*>& follower = det->getFollowerDetectors();
907  int noFollowerWithRoutes = 0;
908  int noPriorWithRoutes = 0;
909  // count occurences of detectors with/without routes
910  std::set<const RODFDetector*>::const_iterator j;
911  for (j = prior.begin(); j != prior.end(); ++j) {
912  if (flows.knows((*j)->getID())) {
913  ++noPriorWithRoutes;
914  }
915  }
916  for (j = follower.begin(); j != follower.end(); ++j) {
917  if (flows.knows((*j)->getID())) {
918  ++noFollowerWithRoutes;
919  }
920  }
921 
922  // do not process detectors which have no routes
923  if (!flows.knows(det->getID())) {
924  continue;
925  }
926 
927  // plain case: all of the prior detectors have routes
928  if (noPriorWithRoutes == (int)prior.size()) {
929  // the number of vehicles is the sum of all vehicles on prior
930  continue;
931  }
932 
933  // plain case: all of the follower detectors have routes
934  if (noFollowerWithRoutes == (int)follower.size()) {
935  // the number of vehicles is the sum of all vehicles on follower
936  continue;
937  }
938 
939  }
940 }
941 
942 
943 const RODFDetector&
945  for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
946  if ((*i)->getEdgeID() == edge->getID()) {
947  return **i;
948  }
949  }
950  throw 1;
951 }
952 
953 
954 void
956  for (std::map<SUMOTime, RandomDistributor<int>* >::iterator i = dists.begin(); i != dists.end(); ++i) {
957  delete (*i).second;
958  }
959 }
960 
961 
962 void
963 RODFDetectorCon::mesoJoin(const std::string& nid,
964  const std::vector<std::string>& oldids) {
965  // build the new detector
966  const RODFDetector& first = getDetector(*(oldids.begin()));
967  RODFDetector* newDet = new RODFDetector(nid, first);
968  addDetector(newDet);
969  // delete previous
970  for (std::vector<std::string>::const_iterator i = oldids.begin(); i != oldids.end(); ++i) {
971  removeDetector(*i);
972  }
973 }
974 
975 
976 /****************************************************************************/
RODFDetector::addRoutes
void addRoutes(RODFRouteCont *routes)
Definition: RODFDetector.cpp:251
SINK_DETECTOR
Definition: RODFDetector.h:70
RODFDetectorFlows
A container for flows.
Definition: RODFDetectorFlow.h:67
OptionsCont::isSet
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Definition: OptionsCont.cpp:135
SUMO_ATTR_TYPE
Definition: SUMOXMLDefinitions.h:381
RODFDetectorCon::detectorsHaveRoutes
bool detectorsHaveRoutes() const
Definition: RODFDetector.cpp:512
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:31
RODFDetector::myFollowingDetectors
std::set< const RODFDetector * > myFollowingDetectors
Definition: RODFDetector.h:201
RODFDetector::addRoute
void addRoute(RODFRouteDesc &nrd)
Definition: RODFDetector.cpp:258
ToString.h
RODFDetector::getEdgeID
std::string getEdgeID() const
Returns the id of the edge this detector is placed on.
Definition: RODFDetector.h:126
SUMO_ATTR_DEPART
Definition: SUMOXMLDefinitions.h:431
RODFDetectorCon::getAggFlowFor
int getAggFlowFor(const ROEdge *edge, SUMOTime time, SUMOTime period, const RODFDetectorFlows &flows) const
Definition: RODFDetector.cpp:759
RODFEdge
Definition: RODFEdge.h:47
RODFDetector
Class representing a detector within the DFROUTER.
Definition: RODFDetector.h:81
RODFDetectorCon::myDetectorMap
std::map< std::string, RODFDetector * > myDetectorMap
Definition: RODFDetector.h:275
RODFDetectorCon::knows
bool knows(const std::string &id) const
Definition: RODFDetector.cpp:619
Named
Base class for objects which have an id.
Definition: Named.h:56
RODFDetector::addPriorDetector
void addPriorDetector(const RODFDetector *det)
Definition: RODFDetector.cpp:226
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
RODFDetector::writeEmitterDefinition
bool writeEmitterDefinition(const std::string &file, const std::map< SUMOTime, RandomDistributor< int > * > &dists, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, bool includeUnusedRoutes, double scale, bool insertionsOnly, double defaultSpeed) const
Definition: RODFDetector.cpp:273
FlowDef::qLKW
double qLKW
Definition: RODFDetectorFlow.h:44
NUMERICAL_EPS
#define NUMERICAL_EPS
Definition: config.h:148
RODFDetectorCon::removeDetector
void removeDetector(const std::string &id)
Definition: RODFDetector.cpp:872
SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
Definition: SUMOXMLDefinitions.h:214
OptionsCont.h
RODFDetectorCon::writeSpeedTrigger
void writeSpeedTrigger(const RODFNet *const net, const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
Definition: RODFDetector.cpp:803
RONet::getEdge
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:152
RODFDetectorCon::saveRoutes
void saveRoutes(const std::string &file) const
Definition: RODFDetector.cpp:585
StringUtils::toDouble
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
Definition: StringUtils.cpp:345
RODFDetectorFlows::getFlowSumSecure
double getFlowSumSecure(const std::string &id) const
Definition: RODFDetectorFlow.cpp:119
MsgHandler.h
RODFDetectorCon::getAnyDetectorForEdge
const RODFDetector & getAnyDetectorForEdge(const RODFEdge *const edge) const
Definition: RODFDetector.cpp:944
RODFDetector::getFollowerDetectors
const std::set< const RODFDetector * > & getFollowerDetectors() const
Definition: RODFDetector.cpp:244
OptionsCont::getString
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Definition: OptionsCont.cpp:201
RODFDetectorCon::RODFDetectorCon
RODFDetectorCon()
Definition: RODFDetector.cpp:474
FileHelpers.h
RODFEdge.h
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
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
SUMO_ATTR_COLOR
A color information.
Definition: SUMOXMLDefinitions.h:704
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
RODFDetectorCon::myDetectors
std::vector< RODFDetector * > myDetectors
Definition: RODFDetector.h:274
SUMO_TAG_POI
begin/end of the description of a Point of interest
Definition: SUMOXMLDefinitions.h:53
RODFRouteCont::addRouteDesc
void addRouteDesc(RODFRouteDesc &desc)
Adds a route to the container.
Definition: RODFRouteCont.cpp:46
SUMO_ATTR_SPEED
Definition: SUMOXMLDefinitions.h:384
RODFDetector::getRouteVector
const std::vector< RODFRouteDesc > & getRouteVector() const
Definition: RODFDetector.cpp:220
RODFDetectorFlows::getMaxDetectorFlow
double getMaxDetectorFlow() const
Definition: RODFDetectorFlow.cpp:133
SUMO_ATTR_ARRIVALPOS
Definition: SUMOXMLDefinitions.h:437
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
RODFDetectorFlows::knows
bool knows(const std::string &det_id) const
Definition: RODFDetectorFlow.cpp:105
RODFDetectorCon
A container for RODFDetectors.
Definition: RODFDetector.h:220
SUMO_ATTR_LANE
Definition: SUMOXMLDefinitions.h:637
RODFDetector::RODFDetector
RODFDetector(const std::string &id, const std::string &laneID, double pos, const RODFDetectorType type)
Constructor.
Definition: RODFDetector.cpp:54
SUMO_TAG_DETECTOR_DEFINITION
definition of a detector
Definition: SUMOXMLDefinitions.h:212
OutputDevice::close
void close()
Closes the device and removes it from the dictionary.
Definition: OutputDevice.cpp:207
RODFDetectorCon::writeEmitters
void writeEmitters(const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, const RODFNet &net, bool writeCalibrators, bool includeUnusedRoutes, double scale, bool insertionsOnly)
Definition: RODFDetector.cpp:625
RODFDetector::mySplitProbabilities
std::vector< std::map< RODFEdge *, double > > mySplitProbabilities
Definition: RODFDetector.h:202
SUMO_ATTR_FILE
Definition: SUMOXMLDefinitions.h:664
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:253
FileHelpers::getFilePath
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
Definition: FileHelpers.cpp:76
RODFDetector::getType
RODFDetectorType getType() const
Returns the type of the detector.
Definition: RODFDetector.h:143
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
ROEdge::getPredecessors
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
Definition: ROEdge.h:355
RODFDetector::hasRoutes
bool hasRoutes() const
Definition: RODFDetector.cpp:267
SUMOVTypeParameter::parametersSet
int parametersSet
Information for the router which parameter were set.
Definition: SUMOVTypeParameter.h:307
RODFDetectorCon::getDetector
const RODFDetector & getDetector(const std::string &id) const
Definition: RODFDetector.cpp:607
NumberFormatException
Definition: UtilExceptions.h:95
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
RandomDistributor::get
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
Definition: RandomDistributor.h:113
RGBColor
Definition: RGBColor.h:39
SUMO_ATTR_ARRIVALSPEED
Definition: SUMOXMLDefinitions.h:439
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:53
Distribution_Parameterized::getParameter
std::vector< double > & getParameter()
Returns the parameters of this distribution.
Definition: Distribution_Parameterized.cpp:110
RandomDistributor.h
FlowDef
Definition of the traffic during a certain time containing the flows and speeds.
Definition: RODFDetectorFlow.h:40
SUMO_ATTR_PROB
Definition: SUMOXMLDefinitions.h:629
FlowDef::qPKW
double qPKW
Definition: RODFDetectorFlow.h:42
SVC_TRUCK
vehicle is a large transport vehicle
Definition: SUMOVehicleClass.h:171
RODFDetector::~RODFDetector
~RODFDetector()
Destructor.
Definition: RODFDetector.cpp:68
RODFNet::hasDetector
bool hasDetector(ROEdge *edge) const
Definition: RODFNet.cpp:655
RODFDetector::myLaneID
std::string myLaneID
Definition: RODFDetector.h:197
RODFDetectorCon::writeEmitterPOIs
void writeEmitterPOIs(const std::string &file, const RODFDetectorFlows &flows)
Definition: RODFDetector.cpp:727
RODFDetector::getPriorDetectors
const std::set< const RODFDetector * > & getPriorDetectors() const
Definition: RODFDetector.cpp:238
SUMO_TAG_VSS
A variable speed sign.
Definition: SUMOXMLDefinitions.h:89
RODFNet::getMaxSpeedFactorPKW
double getMaxSpeedFactorPKW() const
Definition: RODFNet.h:86
SUMOVTypeParameter
Structure representing possible vehicle parameter.
Definition: SUMOVTypeParameter.h:86
RODFRouteDesc
A route within the DFROUTER.
Definition: RODFRouteDesc.h:46
DEFAULT_VTYPE_ID
const std::string DEFAULT_VTYPE_ID
RODFDetectorCon::mesoJoin
void mesoJoin(const std::string &nid, const std::vector< std::string > &oldids)
Definition: RODFDetector.cpp:963
SUMO_ATTR_REFID
Definition: SUMOXMLDefinitions.h:379
SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Definition: SUMOVehicleClass.h:159
StringUtils::escapeXML
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
Definition: StringUtils.cpp:190
SUMO_ATTR_DEPARTSPEED
Definition: SUMOXMLDefinitions.h:435
SUMO_ATTR_ROUTE
Definition: SUMOXMLDefinitions.h:440
SUMO_ATTR_EDGES
the edges of a route
Definition: SUMOXMLDefinitions.h:427
SUMO_ATTR_DEPARTLANE
Definition: SUMOXMLDefinitions.h:432
RODFDetector::computeSplitProbabilities
void computeSplitProbabilities(const RODFNet *net, const RODFDetectorCon &detectors, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
Definition: RODFDetector.cpp:91
OutputDevice.h
RODFDetector::myRoutes
RODFRouteCont * myRoutes
Definition: RODFDetector.h:200
RGBColor::BLUE
static const RGBColor BLUE
Definition: RGBColor.h:191
SUMO_TAG_STEP
trigger: a step description
Definition: SUMOXMLDefinitions.h:157
RODFDetector::getSplitProbabilities
const std::vector< std::map< RODFEdge *, double > > & getSplitProbabilities() const
Definition: RODFDetector.h:187
RODFRouteCont::save
bool save(std::vector< std::string > &saved, const std::string &prependix, OutputDevice &out)
Saves routes.
Definition: RODFRouteCont.cpp:70
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:67
RODFDetector::writeSingleSpeedTrigger
void writeSingleSpeedTrigger(const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, double defaultSpeed)
Definition: RODFDetector.cpp:443
RODFDetectorCon::detectorsHaveCompleteTypes
bool detectorsHaveCompleteTypes() const
Definition: RODFDetector.cpp:501
UtilExceptions.h
RGBColor::RED
static const RGBColor RED
named colors
Definition: RGBColor.h:189
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
SUMO_TAG_REROUTER
A rerouter.
Definition: SUMOXMLDefinitions.h:95
RODFDetector::computeDistanceFactor
double computeDistanceFactor(const RODFRouteDesc &rd) const
Definition: RODFDetector.cpp:80
RODFDetector::writeRoutes
bool writeRoutes(std::vector< std::string > &saved, OutputDevice &out)
Definition: RODFDetector.cpp:433
ROEdgeVector
std::vector< ROEdge * > ROEdgeVector
Definition: RODFRouteDesc.h:35
VTYPEPARS_SPEEDFACTOR_SET
const int VTYPEPARS_SPEEDFACTOR_SET
Definition: SUMOVTypeParameter.h:49
SUMOVTypeParameter::write
void write(OutputDevice &dev) const
Writes the vtype.
Definition: SUMOVTypeParameter.cpp:348
SUMO_TAG_VEHICLE
description of a vehicle
Definition: SUMOXMLDefinitions.h:119
SUMO_ATTR_TIME
trigger: the time of the step
Definition: SUMOXMLDefinitions.h:676
SUMO_ATTR_FRIENDLY_POS
Definition: SUMOXMLDefinitions.h:765
ROEdge::getNumSuccessors
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:244
SUMO_ATTR_FREQUENCY
Definition: SUMOXMLDefinitions.h:662
SUMO_ATTR_POSITION
Definition: SUMOXMLDefinitions.h:660
RandomDistributor< int >
OutputDevice::writeNonEmptyAttr
OutputDevice & writeNonEmptyAttr(const SumoXMLAttr attr, const std::string &val)
writes a string attribute only if it is not the empty string and not the string "default"
Definition: OutputDevice.h:288
OptionsCont::isDefault
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
Definition: OptionsCont.cpp:163
SUMO_ATTR_LANES
Definition: SUMOXMLDefinitions.h:638
SUMOVTypeParameter::speedFactor
Distribution_Parameterized speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street.
Definition: SUMOVTypeParameter.h:231
RODFRouteDesc::routename
std::string routename
The name of the route.
Definition: RODFRouteDesc.h:50
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
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
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
StringUtils.h
RODFDetector::buildDestinationDistribution
void buildDestinationDistribution(const RODFDetectorCon &detectors, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, const RODFNet &net, std::map< SUMOTime, RandomDistributor< int > * > &into) const
Definition: RODFDetector.cpp:166
RODFDetector::myPriorDetectors
std::set< const RODFDetector * > myPriorDetectors
Definition: RODFDetector.h:201
StringUtils::toInt
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
Definition: StringUtils.cpp:278
RODFDetector::myRoute2Edge
std::map< std::string, RODFEdge * > myRoute2Edge
Definition: RODFDetector.h:203
OutputDevice::getDevice
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
Definition: OutputDevice.cpp:54
RODFDetectorFlow.h
RODFDetectorType
RODFDetectorType
Numerical representation of different detector types.
Definition: RODFDetector.h:58
RODFNet::getAvgSpeedFactorPKW
double getAvgSpeedFactorPKW() const
Definition: RODFNet.h:94
RODFDetectorCon::clearDists
void clearDists(std::map< SUMOTime, RandomDistributor< int > * > &dists) const
Clears the given distributions map, deleting the timed distributions.
Definition: RODFDetector.cpp:955
RODFRouteDesc.h
RODFDetectorFlows::getFlowDefs
const std::vector< FlowDef > & getFlowDefs(const std::string &id) const
Definition: RODFDetectorFlow.cpp:111
RODFDetector::myType
RODFDetectorType myType
Definition: RODFDetector.h:199
RODFNet
A DFROUTER-network.
Definition: RODFNet.h:44
ROEdge
A basic edge for routing applications.
Definition: ROEdge.h:72
RODFNet::getAvgSpeedFactorLKW
double getAvgSpeedFactorLKW() const
Definition: RODFNet.h:98
RODFDetectorCon::guessEmptyFlows
void guessEmptyFlows(RODFDetectorFlows &flows)
Definition: RODFDetector.cpp:899
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
SOURCE_DETECTOR
A source detector.
Definition: RODFDetector.h:69
SUMO_TAG_ROUTE
begin/end of the description of a route
Definition: SUMOXMLDefinitions.h:125
RODFDetector::myPosition
double myPosition
Definition: RODFDetector.h:198
config.h
RODFDetector::getLaneID
const std::string & getLaneID() const
Returns the id of the lane this detector is placed on.
Definition: RODFDetector.h:118
RODFDetectorCon::saveAsPOIs
void saveAsPOIs(const std::string &file) const
Definition: RODFDetector.cpp:557
GeomHelper.h
StdDefs.h
RODFDetectorCon::~RODFDetectorCon
~RODFDetectorCon()
Definition: RODFDetector.cpp:477
RGBColor::GREEN
static const RGBColor GREEN
Definition: RGBColor.h:190
SUMO_ATTR_DEPARTPOS
Definition: SUMOXMLDefinitions.h:433
BETWEEN_DETECTOR
An in-between detector.
Definition: RODFDetector.h:66
RODFRouteCont
A container for DFROUTER-routes.
Definition: RODFRouteCont.h:55
OutputDevice::writeXMLHeader
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
Definition: OutputDevice.cpp:227
RODFNet.h
RODFDetector::setType
void setType(RODFDetectorType type)
Definition: RODFDetector.cpp:74
DISCARDED_DETECTOR
A detector which had to be discarded (!!!)
Definition: RODFDetector.h:63
RODFDetector::addFollowingDetector
void addFollowingDetector(const RODFDetector *det)
Definition: RODFDetector.cpp:232
RODFNet::getMaxSpeedFactorLKW
double getMaxSpeedFactorLKW() const
Definition: RODFNet.h:90
SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
Definition: SUMOXMLDefinitions.h:91
RODFDetectorCon::setSpeedFactorAndDev
void setSpeedFactorAndDev(SUMOVTypeParameter &type, double maxFactor, double avgFactor, double dev, bool forceDev)
Definition: RODFDetector.cpp:708
Named::myID
std::string myID
The name of the object.
Definition: Named.h:133
RandomDistributor::getOverallProb
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
Definition: RandomDistributor.h:133
RODFDetectorCon::writeEndRerouterDetectors
void writeEndRerouterDetectors(const std::string &file)
Definition: RODFDetector.cpp:825
RODFDetectorCon::save
void save(const std::string &file) const
Definition: RODFDetector.cpp:529
SUMOVTypeParameter.h
SUMO_TAG_E1DETECTOR
an e1 detector
Definition: SUMOXMLDefinitions.h:63
RODFDetectorCon::addDetector
bool addDetector(RODFDetector *dfd)
Definition: RODFDetector.cpp:485
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
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283
ROEdge.h
SUMO_ATTR_ARRIVALLANE
Definition: SUMOXMLDefinitions.h:436
RODFRouteCont.h
RODFDetectorCon::writeValidationDetectors
void writeValidationDetectors(const std::string &file, bool includeSources, bool singleFile, bool friendly)
Definition: RODFDetector.cpp:841
VTYPEPARS_VEHICLECLASS_SET
const int VTYPEPARS_VEHICLECLASS_SET
Definition: SUMOVTypeParameter.h:52
RODFDetectorCon::getModifiableDetector
RODFDetector & getModifiableDetector(const std::string &id) const
Definition: RODFDetector.cpp:613
RODFDetectorCon::myDetectorEdgeMap
std::map< std::string, std::vector< RODFDetector * > > myDetectorEdgeMap
Definition: RODFDetector.h:276