SUMO - Simulation of Urban MObility
MSE2Collector.cpp
Go to the documentation of this file.
1 /****************************************************************************/
13 // An areal (along a single lane) detector
14 /****************************************************************************/
15 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
16 // Copyright (C) 2014 DLR (http://www.dlr.de/) and contributors
17 /****************************************************************************/
18 //
19 // This file is part of SUMO.
20 // SUMO is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 /****************************************************************************/
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <cassert>
38 #include <algorithm>
39 #include "MSE2Collector.h"
40 #include <microsim/MSLane.h>
41 #include <microsim/MSVehicle.h>
42 #include <microsim/MSVehicleType.h>
43 
44 #ifdef CHECK_MEMORY_LEAKS
45 #include <foreign/nvwa/debug_new.h>
46 #endif // CHECK_MEMORY_LEAKS
47 
48 
49 // ===========================================================================
50 // method definitions
51 // ===========================================================================
52 MSE2Collector::MSE2Collector(const std::string& id, DetectorUsage usage,
53  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
54  SUMOTime haltingTimeThreshold,
55  SUMOReal haltingSpeedThreshold,
56  SUMOReal jamDistThreshold) :
57  MSMoveReminder(id, lane),
59  myJamHaltingSpeedThreshold(haltingSpeedThreshold),
60  myJamHaltingTimeThreshold(haltingTimeThreshold),
61  myJamDistanceThreshold(jamDistThreshold),
62  myStartPos(startPos), myEndPos(startPos + detLength),
63  myUsage(usage),
64  myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
65  myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
66  myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
67  myCurrentHaltingsNumber(0), myPassedVeh(0)
68 
69 {
70  assert(myLane != 0);
71  assert(myStartPos >= 0 && myStartPos < myLane->getLength());
72  assert(myEndPos - myStartPos > 0 && myEndPos <= myLane->getLength());
73  reset();
74 }
75 
76 
78  myKnownVehicles.clear();
79 }
80 
81 
82 bool
84  SUMOReal newPos, SUMOReal) {
85  if (newPos <= myStartPos) {
86  // detector not yet reached
87  return true;
88  }
89  if (newPos > myStartPos && oldPos <= myStartPos) {
90  if (find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh) == myKnownVehicles.end()) {
91  std::string type = veh.getVehicleType().getID(); // get vehicle's type
92  if (type.find("COLOMBO_undetectable") == std::string::npos) {
93  myKnownVehicles.push_back(&veh);
94  //Detection entering the sensor
95  myPassedVeh++;
96  DBG(
97  std::ostringstream str;
98  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
99  << " MSE2Collector::notifyMove::"
100  << " lane " << myLane->getID()
101  << " passedVeh " << myPassedVeh ;
102  WRITE_MESSAGE(str.str());
103  )
104  }
105  }
106  }
107  if (newPos - veh.getVehicleType().getLength() > myEndPos) {
108  std::list<SUMOVehicle*>::iterator i = find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh);
109  if (i != myKnownVehicles.end()) {
110  myKnownVehicles.erase(i);
111  }
112  return false;
113  }
114  return true;
115 }
116 
117 
118 bool
120  if (reason != MSMoveReminder::NOTIFICATION_JUNCTION || (lastPos > myStartPos && lastPos - veh.getVehicleType().getLength() < myEndPos)) {
121  std::list<SUMOVehicle*>::iterator i = find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh);
122  if (i != myKnownVehicles.end()) {
123  myKnownVehicles.erase(i);
124  }
125  return false;
126  }
127  return true;
128 }
129 
130 
131 bool
133  if (!veh.isOnRoad()) {
134  // vehicle is teleporting over the edge
135  return false;
136  }
137  if (veh.getPositionOnLane() - veh.getVehicleType().getLength() >= myEndPos) {
138  // vehicle is beyond the detector
139  return false;
140  }
142  // the junction case is handled in the notifyMove
143  // vehicle is on the detector, being already beyond was checked before
144  std::string type = veh.getVehicleType().getID(); // get vehicle's type
145  if (type.find("COLOMBO_undetectable") == std::string::npos) {
146  myKnownVehicles.push_back(&veh);
147  //Detection entering the sensor
148  myPassedVeh++;
149  DBG(
150  std::ostringstream str;
151  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
152  << " MSE2Collector::notifyEnter::"
153  << " lane " << myLane->getID()
154  << " passedVeh " << myPassedVeh ;
155  WRITE_MESSAGE(str.str());
156  )
157  return true;
158  }
159  }
160  if (veh.getPositionOnLane() - veh.getVehicleType().getLength() > myEndPos) {
161  // vehicle is beyond detector
162  return false;
163  }
164  // vehicle is in front of the detector
165  return true;
166 }
167 
168 
169 void
171  mySpeedSum = 0;
172  myStartedHalts = 0;
175  myVehicleSamples = 0;
176  myOccupancySum = 0;
177  myMaxOccupancy = 0;
180  myMaxJamInVehicles = 0;
181  myMaxJamInMeters = 0;
182  myTimeSamples = 0;
184  myMaxVehicleNumber = 0;
185  for (std::map<const SUMOVehicle*, SUMOTime>::iterator i = myIntervalHaltingVehicleDurations.begin(); i != myIntervalHaltingVehicleDurations.end(); ++i) {
186  (*i).second = 0;
187  }
188  myPastStandingDurations.clear();
190  myPassedVeh = 0;
191 }
192 
193 
194 
195 void
197  JamInfo* currentJam = 0;
198  std::map<const SUMOVehicle*, SUMOTime> haltingVehicles;
199  std::map<const SUMOVehicle*, SUMOTime> intervalHaltingVehicles;
200  std::vector<JamInfo*> jams;
201 
202  SUMOReal lengthSum = 0;
203  myCurrentMeanSpeed = 0;
207 
208  // go through the (sorted) list of vehicles positioned on the detector
209  // sum up values and prepare the list of jams
211  for (std::list<SUMOVehicle*>::const_iterator i = myKnownVehicles.begin(); i != myKnownVehicles.end(); ++i) {
212  const MSVehicle* const veh = static_cast<MSVehicle*>(*i);
213 
214  SUMOReal length = veh->getVehicleType().getLength();
215  if (veh->getLane() == getLane()) {
216  if (veh->getPositionOnLane() - veh->getVehicleType().getLength() < myStartPos) {
217  // vehicle entered detector partially
218  length -= (veh->getVehicleType().getLength() - (veh->getPositionOnLane() - myStartPos));
219  }
220  if (veh->getPositionOnLane() > myEndPos && veh->getPositionOnLane() - veh->getVehicleType().getLength() <= myEndPos) {
221  // vehicle left detector partially
222  length -= (veh->getPositionOnLane() - myEndPos);
223  }
224  } else {
225  // ok, the vehicle is only partially still on the detector, has already moved to the
226  // next lane; still, we do not know how far away it is
227  assert(veh == myLane->getPartialOccupator());
228  length = myEndPos - myLane->getPartialOccupatorEnd();
229  }
230  assert(length >= 0);
231 
232  mySpeedSum += veh->getSpeed();
233  myCurrentMeanSpeed += veh->getSpeed();
234  lengthSum += length;
235  myCurrentMeanLength += length;
236 
237  // jam-checking begins
238  bool isInJam = false;
239  // first, check whether the vehicle is slow enough to be states as halting
240  if (veh->getSpeed() < myJamHaltingSpeedThreshold) {
242  // we have to track the time it was halting;
243  // so let's look up whether it was halting before and compute the overall halting time
244  bool wasHalting = myHaltingVehicleDurations.find(veh) != myHaltingVehicleDurations.end();
245  if (wasHalting) {
246  haltingVehicles[veh] = myHaltingVehicleDurations[veh] + DELTA_T;
247  intervalHaltingVehicles[veh] = myIntervalHaltingVehicleDurations[veh] + DELTA_T;
248  } else {
249  haltingVehicles[veh] = DELTA_T;
250  intervalHaltingVehicles[veh] = DELTA_T;
252  myStartedHalts++;
253  }
254  // we now check whether the halting time is large enough
255  if (haltingVehicles[veh] > myJamHaltingTimeThreshold) {
256  // yep --> the vehicle is a part of a jam
257  isInJam = true;
258  }
259  } else {
260  // is not standing anymore; keep duration information
261  std::map<const SUMOVehicle*, SUMOTime>::iterator v = myHaltingVehicleDurations.find(veh);
262  if (v != myHaltingVehicleDurations.end()) {
263  myPastStandingDurations.push_back((*v).second);
264  myHaltingVehicleDurations.erase(v);
265  }
266  v = myIntervalHaltingVehicleDurations.find(veh);
267  if (v != myIntervalHaltingVehicleDurations.end()) {
268  myPastIntervalStandingDurations.push_back((*v).second);
270  }
271  }
272 
273  // jam-building
274  if (isInJam) {
275  // the vehicle is in a jam;
276  // it may be a new one or already an existing one
277  if (currentJam == 0) {
278  // the vehicle is the first vehicle in a jam
279  currentJam = new JamInfo();
280  currentJam->firstStandingVehicle = i;
281  } else {
282  // ok, we have a jam already. But - maybe it is too far away
283  // ... honestly, I can hardly find a reason for doing this,
284  // but jams were defined this way in an earlier version...
285  if (veh->getPositionOnLane() - (*currentJam->lastStandingVehicle)->getPositionOnLane() > myJamDistanceThreshold) {
286  // yep, yep, yep - it's a new one...
287  // close the frist, build a new
288  jams.push_back(currentJam);
289  currentJam = new JamInfo;
290  currentJam->firstStandingVehicle = i;
291  }
292  }
293  currentJam->lastStandingVehicle = i;
294  } else {
295  // the vehicle is not part of a jam...
296  // maybe we have to close an already computed jam
297  if (currentJam != 0) {
298  jams.push_back(currentJam);
299  currentJam = 0;
300  }
301  }
302  }
303  if (currentJam != 0) {
304  jams.push_back(currentJam);
305  currentJam = 0;
306  }
307 
312  // process jam information
313  for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
314  // compute current jam's values
315  SUMOReal jamLengthInMeters =
316  (*(*i)->firstStandingVehicle)->getPositionOnLane()
317  - (*(*i)->lastStandingVehicle)->getPositionOnLane()
318  + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
319  const MSVehicle* const occ = myLane->getPartialOccupator();
320  if (occ && occ == *(*i)->firstStandingVehicle && occ != *(*i)->lastStandingVehicle) {
321  jamLengthInMeters = myLane->getPartialOccupatorEnd() + occ->getVehicleType().getLengthWithGap()
322  - (*(*i)->lastStandingVehicle)->getPositionOnLane()
323  + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
324  }
325  unsigned jamLengthInVehicles = (unsigned) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
326  // apply them to the statistics
329  myJamLengthInMetersSum += jamLengthInMeters;
330  myJamLengthInVehiclesSum += jamLengthInVehicles;
331  myCurrentJamLengthInMeters += jamLengthInMeters;
332  myCurrentJamLengthInVehicles += jamLengthInVehicles;
333  }
334  myCurrentJamNo = (unsigned) jams.size();
335 
336  const unsigned numVehicles = (unsigned) myKnownVehicles.size();
337  myVehicleSamples += numVehicles;
338  myTimeSamples += 1;
339  // compute occupancy values
340  SUMOReal currentOccupancy = lengthSum / (myEndPos - myStartPos) * (SUMOReal) 100.;
341  myCurrentOccupancy = currentOccupancy;
342  myOccupancySum += currentOccupancy;
343  myMaxOccupancy = MAX2(myMaxOccupancy, currentOccupancy);
344  // compute jam values
349  // save information about halting vehicles
350  myHaltingVehicleDurations = haltingVehicles;
351  myIntervalHaltingVehicleDurations = intervalHaltingVehicles;
352  // compute information about vehicle numbers
353  myMeanVehicleNumber += numVehicles;
355  // norm current values
356  myCurrentMeanSpeed = numVehicles != 0 ? myCurrentMeanSpeed / (SUMOReal) numVehicles : -1;
357  myCurrentMeanLength = numVehicles != 0 ? myCurrentMeanLength / (SUMOReal) numVehicles : -1;
358 
359  // clean up
360  for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
361  delete *i;
362  }
363  jams.clear();
364 }
365 
366 
367 
368 void
370  dev << " <interval begin=\"" << time2string(startTime) << "\" end=\"" << time2string(stopTime) << "\" " << "id=\"" << getID() << "\" ";
371 
372  const SUMOReal meanSpeed = myVehicleSamples != 0 ? mySpeedSum / (SUMOReal) myVehicleSamples : -1;
373  const SUMOReal meanOccupancy = myTimeSamples != 0 ? myOccupancySum / (SUMOReal) myTimeSamples : 0;
374  const SUMOReal meanJamLengthInMeters = myTimeSamples != 0 ? myMeanMaxJamInMeters / (SUMOReal) myTimeSamples : 0;
375  const SUMOReal meanJamLengthInVehicles = myTimeSamples != 0 ? myMeanMaxJamInVehicles / (SUMOReal) myTimeSamples : 0;
376  const SUMOReal meanVehicleNumber = myTimeSamples != 0 ? (SUMOReal) myMeanVehicleNumber / (SUMOReal) myTimeSamples : 0;
377 
378  SUMOTime haltingDurationSum = 0;
379  SUMOTime maxHaltingDuration = 0;
380  unsigned haltingNo = 0;
381  for (std::vector<SUMOTime>::iterator i = myPastStandingDurations.begin(); i != myPastStandingDurations.end(); ++i) {
382  haltingDurationSum += (*i);
383  maxHaltingDuration = MAX2(maxHaltingDuration, (*i));
384  haltingNo++;
385  }
386  for (std::map<const SUMOVehicle*, SUMOTime> ::iterator i = myHaltingVehicleDurations.begin(); i != myHaltingVehicleDurations.end(); ++i) {
387  haltingDurationSum += (*i).second;
388  maxHaltingDuration = MAX2(maxHaltingDuration, (*i).second);
389  haltingNo++;
390  }
391  const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
392 
393  SUMOTime intervalHaltingDurationSum = 0;
394  SUMOTime intervalMaxHaltingDuration = 0;
395  unsigned intervalHaltingNo = 0;
396  for (std::vector<SUMOTime>::iterator i = myPastIntervalStandingDurations.begin(); i != myPastIntervalStandingDurations.end(); ++i) {
397  intervalHaltingDurationSum += (*i);
398  intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i));
399  intervalHaltingNo++;
400  }
401  for (std::map<const SUMOVehicle*, SUMOTime> ::iterator i = myIntervalHaltingVehicleDurations.begin(); i != myIntervalHaltingVehicleDurations.end(); ++i) {
402  intervalHaltingDurationSum += (*i).second;
403  intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i).second);
404  intervalHaltingNo++;
405  }
406  const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
407 
408  dev << "nSamples=\"" << myVehicleSamples << "\" "
409  << "meanSpeed=\"" << meanSpeed << "\" "
410  << "meanOccupancy=\"" << meanOccupancy << "\" "
411  << "maxOccupancy=\"" << myMaxOccupancy << "\" "
412  << "meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles << "\" "
413  << "meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters << "\" "
414  << "maxJamLengthInVehicles=\"" << myMaxJamInVehicles << "\" "
415  << "maxJamLengthInMeters=\"" << myMaxJamInMeters << "\" "
416  << "jamLengthInVehiclesSum=\"" << myJamLengthInVehiclesSum << "\" "
417  << "jamLengthInMetersSum=\"" << myJamLengthInMetersSum << "\" "
418  << "meanHaltingDuration=\"" << STEPS2TIME(meanHaltingDuration) << "\" "
419  << "maxHaltingDuration=\"" << STEPS2TIME(maxHaltingDuration) << "\" "
420  << "haltingDurationSum=\"" << STEPS2TIME(haltingDurationSum) << "\" "
421  << "meanIntervalHaltingDuration=\"" << STEPS2TIME(intervalMeanHaltingDuration) << "\" "
422  << "maxIntervalHaltingDuration=\"" << STEPS2TIME(intervalMaxHaltingDuration) << "\" "
423  << "intervalHaltingDurationSum=\"" << STEPS2TIME(intervalHaltingDurationSum) << "\" "
424  << "startedHalts=\"" << myStartedHalts << "\" "
425  << "meanVehicleNumber=\"" << meanVehicleNumber << "\" "
426  << "maxVehicleNumber=\"" << myMaxVehicleNumber << "\" "
427  << "/>\n";
428  reset();
429 }
430 
431 
432 void
434  dev.writeXMLHeader("detector", "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/det_e2_file.xsd\"");
435 }
436 
437 
438 unsigned
440  return (unsigned) myKnownVehicles.size();
441 }
442 
443 int
445 
446  SUMOReal distance = 0;
447  SUMOReal thresholdSpeed = myLane->getSpeedLimit() / speedThreshold;
448 
449  int count = 0;
450  for (std::list<SUMOVehicle*>::const_iterator it = myKnownVehicles.begin();
451  it != myKnownVehicles.end(); it++) {
452  MSVehicle* veh = static_cast<MSVehicle*>(*it);
453  SUMOReal acceleration = veh->getAcceleration();
454  if (distance == 0) {
455  distance = veh->getPositionOnLane();
456  }
457  if (veh->getPositionOnLane() < distance) {
458  distance = veh->getPositionOnLane();
459  }
460  SUMOReal carLength = veh->getVehicleType().getLengthWithGap();
461  SUMOReal vel = veh->getSpeed();
462  SUMOReal realDistance = myLane->getLength() - distance; // the closer vehicle get to the light the greater is the distance
463  if (vel <= thresholdSpeed || acceleration > 0) { //TODO speed less than half of the maximum speed for the lane NEED TUNING
464  count = (int)(realDistance / carLength) + 1;
465  }
466  }
467 
468  return count;
469 }
470 
471 SUMOReal
473 
474  if (myKnownVehicles.empty()) {
475  return -1;
476  }
477 
478  SUMOReal distance = 0;
479  SUMOReal realDistance = 0;
480  bool flowing = true;
481  for (std::list<SUMOVehicle*>::const_iterator it = myKnownVehicles.begin();
482  it != myKnownVehicles.end(); it++) {
483  MSVehicle* veh = static_cast<MSVehicle*>(*it);
484  if (distance == 0) {
485  distance = veh->getPositionOnLane();
486  }
487  if (veh->getPositionOnLane() < distance) {
488  distance = veh->getPositionOnLane();
489  }
490  SUMOReal carLength = veh->getVehicleType().getLengthWithGap();
491  SUMOReal vel = veh->getSpeed();
492  // SUMOReal distanceTemp = myLane->getLength() - distance;
493  if (vel <= 0.5) {
494  realDistance = distance - carLength;
495  flowing = false;
496  }
497  DBG(
498  std::ostringstream str;
499  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
500  << " MSE2Collector::getEstimateQueueLength::"
501  << " lane " << myLane->getID()
502  << " vehicle " << veh->getID()
503  << " positionOnLane " << veh->getPositionOnLane()
504  << " vel " << veh->getSpeed()
505  << " realDistance " << realDistance;
506  WRITE_MESSAGE(str.str());
507  )
508  }
509  if (flowing) {
510  return 0;
511  } else {
512  return myLane->getLength() - realDistance;
513  }
514 }
515 
516 
517 SUMOReal
519  return myCurrentOccupancy;
520 }
521 
522 
523 SUMOReal
525  return myCurrentMeanSpeed;
526 }
527 
528 
529 SUMOReal
531  return myCurrentMeanLength;
532 }
533 
534 
535 unsigned
537  return myCurrentJamNo;
538 }
539 
540 
541 unsigned
544 }
545 
546 
547 SUMOReal
550 }
551 
552 
553 unsigned
556 }
557 
558 
559 SUMOReal
562 }
563 
564 
565 unsigned
567  return myCurrentStartedHalts;
568 }
569 
570 
571 int
573  const MSVehicle* const occ = myLane->getPartialOccupator();
574  if (v1 == occ) {
575  return true;
576  }
577  if (v2 == occ) {
578  return false;
579  }
580  return v1->getPositionOnLane() > v2->getPositionOnLane();
581 }
582 
583 int
586 }
587 
588 
589 std::vector<std::string>
591  std::vector<std::string> ret;
592  for (std::list<SUMOVehicle*>::const_iterator i = myKnownVehicles.begin(); i != myKnownVehicles.end(); ++i) {
593  MSVehicle* veh = static_cast<MSVehicle*>(*i);
594  ret.push_back(veh->getID());
595  }
596  std::sort(ret.begin(), ret.end());
597  return ret;
598 }
599 
600 const std::list<SUMOVehicle*>& MSE2Collector::getCurrentVehicles() const {
601  return myKnownVehicles;
602 }
603 
604 /****************************************************************************/
605 
std::map< const SUMOVehicle *, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
std::vector< SUMOTime > myPastIntervalStandingDurations
Halting durations of ended halts for the current interval [s].
std::vector< std::string > getCurrentVehicleIDs() const
Returns the IDs of the vehicles within the area.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
long long int SUMOTime
Definition: SUMOTime.h:43
unsigned myCurrentJamNo
The current jam number.
unsigned getCurrentJamNumber() const
Returns the current number of jams.
SUMOReal myMaxJamInMeters
The max jam length [m].
unsigned getCurrentStartedHalts() const
Returns the length of all jams in meters.
virtual ~MSE2Collector()
Destructor.
SUMOReal getLengthWithGap() const
Get vehicle&#39;s length including the minimum gap [m].
SUMOReal getCurrentMeanLength() const
Returns the mean vehicle length of vehicles currently on the detector.
The vehicle arrived at a junction.
Internal representation of a jam.
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:375
MSLane *const myLane
Lane on which the reminder works.
unsigned getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
unsigned int myPassedVeh
The number of vehicles passed on the sensor.
SUMOReal myStartedHalts
The number of started halts [#].
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
SUMOReal getLength() const
Get vehicle&#39;s length [m].
A class used to sort known vehicles by their position.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:160
T MAX2(T a, T b)
Definition: StdDefs.h:75
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
unsigned myMaxVehicleNumber
The max number of vehicles [#veh].
SUMOReal getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
SUMOReal getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:340
SUMOReal myCurrentMeanLength
The current mean length.
unsigned myCurrentStartedHalts
The number of started halts in the last step.
const MSLane * getLane() const
Returns the lane the reminder works on.
SUMOReal getPartialOccupatorEnd() const
Returns the position of the in-lapping vehicle&#39;s end.
Definition: MSLane.h:260
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
const std::string & getID() const
Returns the id.
Definition: Named.h:65
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Adds the vehicle to known vehicles if not beyond the dector.
unsigned myVehicleSamples
The number of collected samples [#].
Representation of a vehicle.
Definition: SUMOVehicle.h:65
std::list< SUMOVehicle * > myKnownVehicles
List of known vehicles.
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
SUMOReal getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:367
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
Something on a lane to be noticed about vehicle movement.
#define DBG(X)
Definition: SwarmDebug.h:30
SUMOReal myJamHaltingSpeedThreshold
A vehicle must driver slower than this to be counted as a part of a jam.
unsigned myCurrentJamLengthInVehicles
The overall jam length in vehicles.
SUMOTime myJamHaltingTimeThreshold
A vehicle must be that long beyond myJamHaltingSpeedThreshold to be counted as a part of a jam...
SUMOReal getEstimateQueueLength() const
Returns an estimate of the lenght of the queue of vehicles currently stopped on the detector...
const std::list< SUMOVehicle * > & getCurrentVehicles() const
Returns the vehicles within the area.
SUMOReal mySpeedSum
The sum of collected vehicle speeds [m/s].
unsigned myMeanVehicleNumber
The mean number of vehicles [#veh].
SUMOReal myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
unsigned myMeanMaxJamInVehicles
The mean jam length [#veh].
SUMOReal myCurrentJamLengthInMeters
The overall jam length in meters.
std::list< SUMOVehicle * >::const_iterator firstStandingVehicle
The first standing vehicle.
SUMOReal myStartPos
The position the detector starts at.
unsigned myMaxJamInVehicles
The max jam length [#veh].
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
SUMOReal myEndPos
The position the detector ends at.
SUMOReal myCurrentOccupancy
The current occupancy.
SUMOReal myMaxOccupancy
The maximum occupancy [%].
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
SUMOReal getAcceleration() const
Returns the vehicle&#39;s acceleration in m/s.
Definition: MSVehicle.h:356
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
SUMOReal getCurrentOccupancy() const
Returns the curent detector occupancy.
SUMOReal myCurrentMeanSpeed
The current mean speed.
void reset()
Resets all values.
unsigned myTimeSamples
The current aggregation duration [#steps].
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:93
unsigned getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
SUMOReal myMeanMaxJamInMeters
The mean jam length [m].
SUMOReal myOccupancySum
The sum of occupancies [%].
const std::string & getID() const
Returns the name of the vehicle type.
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:348
MSE2Collector(const std::string &id, DetectorUsage usage, MSLane *const lane, SUMOReal startPos, SUMOReal detLength, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold)
Constructor.
std::list< SUMOVehicle * >::const_iterator lastStandingVehicle
The last standing vehicle.
unsigned myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
SUMOReal myJamLengthInMetersSum
The sum of jam lengths [m].
SUMOReal getCurrentMaxJamLengthInMeters() const
Returns the length in meters of the currently largest jam.
MSVehicle * getPartialOccupator() const
Returns the vehicle which laps into this lane.
Definition: MSLane.h:252
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
int myCurrentHaltingsNumber
The number of halted vehicles [#].
unsigned getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
#define SUMOReal
Definition: config.h:213
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes a known vehicle due to its lane-change.
std::map< const SUMOVehicle *, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:385
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
int operator()(const SUMOVehicle *v1, const SUMOVehicle *v2)
Comparison funtcion.
Base of value-generating classes (detectors)
const std::string & getID() const
Returns the name of the vehicle.
SUMOReal myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
unsigned myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.