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) 2001-2016 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/MSNet.h>
42 #include <microsim/MSVehicle.h>
43 #include <microsim/MSVehicleType.h>
44 
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 MSE2Collector::MSE2Collector(const std::string& id, DetectorUsage usage,
54  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
55  SUMOTime haltingTimeThreshold,
56  SUMOReal haltingSpeedThreshold,
57  SUMOReal jamDistThreshold,
58  const std::string& vTypes) :
59  MSMoveReminder(id, lane),
60  MSDetectorFileOutput(id, vTypes),
61  myJamHaltingSpeedThreshold(haltingSpeedThreshold),
62  myJamHaltingTimeThreshold(haltingTimeThreshold),
63  myJamDistanceThreshold(jamDistThreshold),
64  myStartPos(startPos), myEndPos(startPos + detLength),
65  myUsage(usage),
66  myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
67  myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
68  myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
69  myCurrentHaltingsNumber(0), myPassedVeh(0) {
70  assert(myLane != 0);
71  assert(myStartPos >= 0 && myStartPos < myLane->getLength());
72  assert(myEndPos - myStartPos > 0 && myEndPos <= myLane->getLength());
73  reset();
74 }
75 
76 
77 MSE2Collector::MSE2Collector(const std::string& id, DetectorUsage usage,
78  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
79  SUMOTime haltingTimeThreshold,
80  SUMOReal haltingSpeedThreshold,
81  SUMOReal jamDistThreshold,
82  const std::set<std::string>& vTypes) :
83  MSMoveReminder(id, lane),
84  MSDetectorFileOutput(id, vTypes),
85  myJamHaltingSpeedThreshold(haltingSpeedThreshold),
86  myJamHaltingTimeThreshold(haltingTimeThreshold),
87  myJamDistanceThreshold(jamDistThreshold),
88  myStartPos(startPos), myEndPos(startPos + detLength),
89  myUsage(usage),
94  assert(myLane != 0);
95  assert(myStartPos >= 0 && myStartPos < myLane->getLength());
96  assert(myEndPos - myStartPos > 0 && myEndPos <= myLane->getLength());
97  reset();
98 }
99 
100 
102  myKnownVehicles.clear();
103 }
104 
105 
106 bool
108  SUMOReal newPos, SUMOReal newSpeed) {
109  if (newPos <= myStartPos) {
110  // detector not yet reached
111  return true;
112  }
113 
114 
115  const SUMOReal oldSpeed = veh.getPreviousSpeed();
116  SUMOReal enterSpeed = MSGlobals::gSemiImplicitEulerUpdate ? newSpeed : oldSpeed; // NOTE: For the euler update, the vehicle is assumed to travel at constant speed for the whole time step
117  SUMOReal leaveSpeed = newSpeed;
118 
119  SUMOReal lengthOnDet = MIN2(veh.getVehicleType().getLength(), newPos - myStartPos);
120  if (newPos > myEndPos) {
121  lengthOnDet = MAX2(SUMOReal(0), lengthOnDet - (newPos - myEndPos));
122  }
123 
124  SUMOReal timeOnDet = TS;
125 
126  // Treat the case that the vehicle entered the lane in the last step
127  if (newPos > myStartPos && oldPos <= myStartPos) {
128  // Vehicle was not on this lane in the last time step
129  const SUMOReal timeBeforeEnter = MSCFModel::passingTime(oldPos, myStartPos, newPos, oldSpeed, newSpeed);
130  timeOnDet -= timeBeforeEnter;
131  enterSpeed = MSCFModel::speedAfterTime(timeBeforeEnter, oldSpeed, newPos - oldPos);
132  myPassedVeh++;
133  }
134 
135  // Treat the case that the vehicle's back left the lane in the last step
136  const SUMOReal oldBackPos = oldPos - veh.getVehicleType().getLength();
137  const SUMOReal newBackPos = newPos - veh.getVehicleType().getLength();
138  if (newBackPos > myEndPos) {
139  assert(oldBackPos <= myEndPos);
140  const SUMOReal timeBeforeLeave = MSCFModel::passingTime(oldBackPos, myEndPos, newBackPos, oldSpeed, newSpeed);
141  const SUMOReal timeAfterLeave = TS - timeBeforeLeave;
142  timeOnDet -= timeAfterLeave;
143  leaveSpeed = MSCFModel::speedAfterTime(timeBeforeLeave, oldSpeed, newPos - oldPos);
144  // XXX: Do we really need this? Why would this "reduce rounding errors"? (Leo) Refs. #2579
145  if (fabs(timeOnDet) < NUMERICAL_EPS) { // reduce rounding errors
146  timeOnDet = 0.;
147  } else {
148  const SUMOReal averageSpeedOnDetector = (enterSpeed + leaveSpeed) / 2.;
149  myKnownVehicles.push_back(VehicleInfo(veh.getID(), veh.getVehicleType().getID(), averageSpeedOnDetector,
150  timeOnDet, lengthOnDet, newPos,
151  veh.getVehicleType().getLengthWithGap(), veh.getAcceleration(), false));
152  }
153  return false;
154  }
155  const SUMOReal averageSpeedOnDetector = (enterSpeed + leaveSpeed) / 2.;
156  myKnownVehicles.push_back(VehicleInfo(veh.getID(), veh.getVehicleType().getID(), averageSpeedOnDetector,
157  timeOnDet, lengthOnDet, newPos,
158  veh.getVehicleType().getLengthWithGap(), veh.getAcceleration(), true));
159  DBG(
160  std::ostringstream str;
161  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
162  << " MSE2Collector::notifyMove::"
163  << " lane " << myLane->getID()
164  << " passedVeh " << myPassedVeh;
165  WRITE_MESSAGE(str.str());
166  )
167  return true;
168 }
169 
170 
171 bool
174  return false;
175  }
176  return true;
177 }
178 
179 
180 bool
182  if (!vehicleApplies(veh)) {
183  return false;
184  }
185  if (!veh.isOnRoad()) {
186  // vehicle is teleporting over the edge
187  return false;
188  }
189  // is vehicle beyond detector?
190  return veh.getBackPositionOnLane(myLane) < myEndPos;
191 }
192 
193 
194 void
196  mySpeedSum = 0;
197  myStartedHalts = 0;
200  myVehicleSamples = 0;
201  myOccupancySum = 0;
202  myMaxOccupancy = 0;
205  myMaxJamInVehicles = 0;
206  myMaxJamInMeters = 0;
207  myTimeSamples = 0;
209  myMaxVehicleNumber = 0;
210  for (std::map<const std::string, SUMOTime>::iterator i = myIntervalHaltingVehicleDurations.begin(); i != myIntervalHaltingVehicleDurations.end(); ++i) {
211  (*i).second = 0;
212  }
213  myPastStandingDurations.clear();
215  myPassedVeh = 0;
216 }
217 
218 
219 
220 void
222  JamInfo* currentJam = 0;
223  std::map<const std::string, SUMOTime> haltingVehicles;
224  std::map<const std::string, SUMOTime> intervalHaltingVehicles;
225  std::vector<JamInfo*> jams;
226 
227  SUMOReal lengthSum = 0;
228  myCurrentMeanSpeed = 0;
232 
233  // go through the (sorted) list of vehicles positioned on the detector
234  // sum up values and prepare the list of jams
235  const int numVehicles = (int)myKnownVehicles.size();
236  for (std::vector<VehicleInfo>::const_iterator i = myKnownVehicles.begin(); i != myKnownVehicles.end(); ++i) {
237  myVehicleSamples += i->timeOnDet;
238  mySpeedSum += i->speed * i->timeOnDet;
239  myCurrentMeanSpeed += i->speed * i->timeOnDet;
240  lengthSum += i->lengthOnDet;
241  myCurrentMeanLength += i->lengthOnDet;
242 
243  // jam-checking begins
244  bool isInJam = false;
245  // first, check whether the vehicle is slow enough to be states as halting
246  if (i->speed < myJamHaltingSpeedThreshold) {
248  // we have to track the time it was halting;
249  // so let's look up whether it was halting before and compute the overall halting time
250  bool wasHalting = myHaltingVehicleDurations.count(i->id) > 0;
251  if (wasHalting) {
252  haltingVehicles[i->id] = myHaltingVehicleDurations[i->id] + DELTA_T;
253  intervalHaltingVehicles[i->id] = myIntervalHaltingVehicleDurations[i->id] + DELTA_T;
254  } else {
255  haltingVehicles[i->id] = DELTA_T;
256  intervalHaltingVehicles[i->id] = DELTA_T;
258  myStartedHalts++;
259  }
260  // we now check whether the halting time is large enough
261  if (haltingVehicles[i->id] > myJamHaltingTimeThreshold) {
262  // yep --> the vehicle is a part of a jam
263  isInJam = true;
264  }
265  } else {
266  // is not standing anymore; keep duration information
267  std::map<const std::string, SUMOTime>::iterator v = myHaltingVehicleDurations.find(i->id);
268  if (v != myHaltingVehicleDurations.end()) {
269  myPastStandingDurations.push_back((*v).second);
270  myHaltingVehicleDurations.erase(v);
271  }
272  v = myIntervalHaltingVehicleDurations.find(i->id);
273  if (v != myIntervalHaltingVehicleDurations.end()) {
274  myPastIntervalStandingDurations.push_back((*v).second);
276  }
277  }
278 
279  // jam-building
280  if (isInJam) {
281  // the vehicle is in a jam;
282  // it may be a new one or already an existing one
283  if (currentJam == 0) {
284  // the vehicle is the first vehicle in a jam
285  currentJam = new JamInfo();
286  currentJam->firstStandingVehicle = i;
287  } else {
288  // ok, we have a jam already. But - maybe it is too far away
289  // ... honestly, I can hardly find a reason for doing this,
290  // but jams were defined this way in an earlier version...
291  if (i->position - currentJam->lastStandingVehicle->position > myJamDistanceThreshold) {
292  // yep, yep, yep - it's a new one...
293  // close the frist, build a new
294  jams.push_back(currentJam);
295  currentJam = new JamInfo();
296  currentJam->firstStandingVehicle = i;
297  }
298  }
299  currentJam->lastStandingVehicle = i;
300  } else {
301  // the vehicle is not part of a jam...
302  // maybe we have to close an already computed jam
303  if (currentJam != 0) {
304  jams.push_back(currentJam);
305  currentJam = 0;
306  }
307  }
308  }
309  if (currentJam != 0) {
310  jams.push_back(currentJam);
311  currentJam = 0;
312  }
313 
318  // process jam information
319  for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
320  // compute current jam's values
321  const SUMOReal jamLengthInMeters = (*i)->firstStandingVehicle->position
322  - (*i)->lastStandingVehicle->position
323  + (*i)->lastStandingVehicle->lengthOnDet;
324  const int jamLengthInVehicles = (int)distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
325  // apply them to the statistics
328  myJamLengthInMetersSum += jamLengthInMeters;
329  myJamLengthInVehiclesSum += jamLengthInVehicles;
330  myCurrentJamLengthInMeters += jamLengthInMeters;
331  myCurrentJamLengthInVehicles += jamLengthInVehicles;
332  }
333  myCurrentJamNo = (int) jams.size();
334 
335  myTimeSamples += 1;
336  // compute occupancy values
337  SUMOReal currentOccupancy = lengthSum / (myEndPos - myStartPos) * (SUMOReal) 100.;
338  myCurrentOccupancy = currentOccupancy;
339  myOccupancySum += currentOccupancy;
340  myMaxOccupancy = MAX2(myMaxOccupancy, currentOccupancy);
341  // compute jam values
346  // save information about halting vehicles
347  myHaltingVehicleDurations = haltingVehicles;
348  myIntervalHaltingVehicleDurations = intervalHaltingVehicles;
349  // compute information about vehicle numbers
350  myMeanVehicleNumber += numVehicles;
352  // norm current values
353  myCurrentMeanSpeed = numVehicles != 0 ? myCurrentMeanSpeed / (SUMOReal) numVehicles : -1;
354  myCurrentMeanLength = numVehicles != 0 ? myCurrentMeanLength / (SUMOReal) numVehicles : -1;
355 
356  // clean up
357  for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
358  delete *i;
359  }
361  myKnownVehicles.clear();
362 }
363 
364 
365 
366 void
368  dev << " <interval begin=\"" << time2string(startTime) << "\" end=\"" << time2string(stopTime) << "\" " << "id=\"" << getID() << "\" ";
369 
370  const SUMOReal meanSpeed = myVehicleSamples != 0 ? mySpeedSum / myVehicleSamples : -1;
371  const SUMOReal meanOccupancy = myTimeSamples != 0 ? myOccupancySum / (SUMOReal) myTimeSamples : 0;
372  const SUMOReal meanJamLengthInMeters = myTimeSamples != 0 ? myMeanMaxJamInMeters / (SUMOReal) myTimeSamples : 0;
373  const SUMOReal meanJamLengthInVehicles = myTimeSamples != 0 ? myMeanMaxJamInVehicles / (SUMOReal) myTimeSamples : 0;
374  const SUMOReal meanVehicleNumber = myTimeSamples != 0 ? (SUMOReal) myMeanVehicleNumber / (SUMOReal) myTimeSamples : 0;
375 
376  SUMOTime haltingDurationSum = 0;
377  SUMOTime maxHaltingDuration = 0;
378  int haltingNo = 0;
379  for (std::vector<SUMOTime>::iterator i = myPastStandingDurations.begin(); i != myPastStandingDurations.end(); ++i) {
380  haltingDurationSum += (*i);
381  maxHaltingDuration = MAX2(maxHaltingDuration, (*i));
382  haltingNo++;
383  }
384  for (std::map<const std::string, SUMOTime> ::iterator i = myHaltingVehicleDurations.begin(); i != myHaltingVehicleDurations.end(); ++i) {
385  haltingDurationSum += (*i).second;
386  maxHaltingDuration = MAX2(maxHaltingDuration, (*i).second);
387  haltingNo++;
388  }
389  const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
390 
391  SUMOTime intervalHaltingDurationSum = 0;
392  SUMOTime intervalMaxHaltingDuration = 0;
393  int intervalHaltingNo = 0;
394  for (std::vector<SUMOTime>::iterator i = myPastIntervalStandingDurations.begin(); i != myPastIntervalStandingDurations.end(); ++i) {
395  intervalHaltingDurationSum += (*i);
396  intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i));
397  intervalHaltingNo++;
398  }
399  for (std::map<const std::string, SUMOTime> ::iterator i = myIntervalHaltingVehicleDurations.begin(); i != myIntervalHaltingVehicleDurations.end(); ++i) {
400  intervalHaltingDurationSum += (*i).second;
401  intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i).second);
402  intervalHaltingNo++;
403  }
404  const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
405 
406  dev << "sampledSeconds=\"" << myVehicleSamples << "\" "
407  << "nVehEntered=\"" << myPassedVeh << "\" "
408  << "meanSpeed=\"" << meanSpeed << "\" "
409  << "meanOccupancy=\"" << meanOccupancy << "\" "
410  << "maxOccupancy=\"" << myMaxOccupancy << "\" "
411  << "meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles << "\" "
412  << "meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters << "\" "
413  << "maxJamLengthInVehicles=\"" << myMaxJamInVehicles << "\" "
414  << "maxJamLengthInMeters=\"" << myMaxJamInMeters << "\" "
415  << "jamLengthInVehiclesSum=\"" << myJamLengthInVehiclesSum << "\" "
416  << "jamLengthInMetersSum=\"" << myJamLengthInMetersSum << "\" "
417  << "meanHaltingDuration=\"" << STEPS2TIME(meanHaltingDuration) << "\" "
418  << "maxHaltingDuration=\"" << STEPS2TIME(maxHaltingDuration) << "\" "
419  << "haltingDurationSum=\"" << STEPS2TIME(haltingDurationSum) << "\" "
420  << "meanIntervalHaltingDuration=\"" << STEPS2TIME(intervalMeanHaltingDuration) << "\" "
421  << "maxIntervalHaltingDuration=\"" << STEPS2TIME(intervalMaxHaltingDuration) << "\" "
422  << "intervalHaltingDurationSum=\"" << STEPS2TIME(intervalHaltingDurationSum) << "\" "
423  << "startedHalts=\"" << myStartedHalts << "\" "
424  << "meanVehicleNumber=\"" << meanVehicleNumber << "\" "
425  << "maxVehicleNumber=\"" << myMaxVehicleNumber << "\" "
426  << "/>\n";
427  reset();
428 }
429 
430 
431 void
433  dev.writeXMLHeader("detector", "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/det_e2_file.xsd\"");
434 }
435 
436 
437 int
439  int result = 0;
440  for (std::vector<VehicleInfo>::const_iterator it = myPreviousKnownVehicles.begin();
441  it != myPreviousKnownVehicles.end(); it++) {
442  if (it->stillOnDet) {
443  result++;
444  }
445  }
446  return result;
447 }
448 
449 int
451 
453  SUMOReal thresholdSpeed = myLane->getSpeedLimit() / speedThreshold;
454 
455  int count = 0;
456  for (std::vector<VehicleInfo>::const_iterator it = myPreviousKnownVehicles.begin();
457  it != myKnownVehicles.end(); it++) {
458  if (it->stillOnDet) {
459  if (it->position < distance) {
460  distance = it->position;
461  }
462  const SUMOReal realDistance = myLane->getLength() - distance; // the closer vehicle get to the light the greater is the distance
463  if (it->speed <= thresholdSpeed || it->accel > 0) { //TODO speed less than half of the maximum speed for the lane NEED TUNING
464  count = (int)(realDistance / it->lengthWithGap) + 1;
465  }
466  }
467  }
468 
469  return count;
470 }
471 
472 SUMOReal
474 
475  if (myPreviousKnownVehicles.empty()) {
476  return -1;
477  }
478 
480  SUMOReal realDistance = 0;
481  bool flowing = true;
482  for (std::vector<VehicleInfo>::const_iterator it = myPreviousKnownVehicles.begin();
483  it != myPreviousKnownVehicles.end(); it++) {
484  if (it->stillOnDet) {
485  if (it->position < distance) {
486  distance = it->position;
487  }
488  // SUMOReal distanceTemp = myLane->getLength() - distance;
489  if (it->speed <= 0.5) {
490  realDistance = distance - it->lengthWithGap;
491  flowing = false;
492  }
493  DBG(
494  std::ostringstream str;
495  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
496  << " MSE2Collector::getEstimateQueueLength::"
497  << " lane " << myLane->getID()
498  << " vehicle " << it->id
499  << " positionOnLane " << it->position
500  << " vel " << it->speed
501  << " realDistance " << realDistance;
502  WRITE_MESSAGE(str.str());
503  )
504  }
505  }
506  if (flowing) {
507  return 0;
508  } else {
509  return myLane->getLength() - realDistance;
510  }
511 }
512 
513 
514 SUMOReal
516  return myCurrentOccupancy;
517 }
518 
519 
520 SUMOReal
522  return myCurrentMeanSpeed;
523 }
524 
525 
526 SUMOReal
528  return myCurrentMeanLength;
529 }
530 
531 
532 int
534  return myCurrentJamNo;
535 }
536 
537 
538 int
541 }
542 
543 
544 SUMOReal
547 }
548 
549 
550 int
553 }
554 
555 
556 SUMOReal
559 }
560 
561 
562 int
564  return myCurrentStartedHalts;
565 }
566 
567 
568 int
571 }
572 
573 
574 std::vector<std::string>
576  std::vector<std::string> ret;
577  for (std::vector<VehicleInfo>::const_iterator i = myPreviousKnownVehicles.begin(); i != myPreviousKnownVehicles.end(); ++i) {
578  ret.push_back(i->id);
579  }
580  std::sort(ret.begin(), ret.end());
581  return ret;
582 }
583 
584 
585 const std::vector<MSE2Collector::VehicleInfo>&
588 }
589 
590 /****************************************************************************/
591 
int myMaxVehicleNumber
The max number of vehicles [#veh].
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:480
int myMeanMaxJamInVehicles
The mean jam length [#veh].
std::vector< SUMOTime > myPastIntervalStandingDurations
Halting durations of ended halts for the current interval [s].
SUMOReal getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
long long int SUMOTime
Definition: SUMOTime.h:43
SUMOReal myMaxJamInMeters
The max jam length [m].
std::vector< std::string > getCurrentVehicleIDs() const
Returns the IDs of the vehicles within the area.
int getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
virtual ~MSE2Collector()
Destructor.
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
std::map< const std::string, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
The vehicle arrived at a junction.
Internal representation of a jam.
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
MSLane *const myLane
Lane on which the reminder works.
SUMOReal myStartedHalts
The number of started halts [#].
SUMOReal getEstimateQueueLength() const
Returns an estimate of the lenght of the queue of vehicles currently stopped on the detector...
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
SUMOReal getLength() const
Get vehicle&#39;s length [m].
virtual SUMOReal getPreviousSpeed() const =0
Returns the vehicle&#39;s previous speed.
SUMOReal getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:472
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
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
std::map< const std::string, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
int myMeanVehicleNumber
The mean number of vehicles [#veh].
const std::string & getID() const
Returns the id.
Definition: Named.h:66
int myCurrentStartedHalts
The number of started halts in the last step.
SUMOReal myCurrentMeanLength
The current mean length.
#define TS
Definition: SUMOTime.h:52
SUMOReal myVehicleSamples
The number of collected samples [#].
SUMOReal getCurrentMaxJamLengthInMeters() const
Returns the length in meters of the currently largest jam.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
int myTimeSamples
The current aggregation duration [#steps].
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Adds the vehicle to known vehicles if not beyond the dector.
int getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
static SUMOReal speedAfterTime(const SUMOReal t, const SUMOReal oldSpeed, const SUMOReal dist)
Calculates the speed after a time t [0,TS] given the initial speed and the distance traveled in an i...
Definition: MSCFModel.cpp:439
Internal representation of a vehicle.
Definition: MSE2Collector.h:87
std::vector< VehicleInfo > myKnownVehicles
List of known vehicles.
#define max(a, b)
Definition: polyfonts.c:65
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.
Representation of a vehicle.
Definition: SUMOVehicle.h:66
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
std::vector< VehicleInfo >::const_iterator firstStandingVehicle
The first standing vehicle.
int getCurrentJamNumber() const
Returns the current number of jams.
SUMOReal getCurrentOccupancy() const
Returns the curent detector occupancy.
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
std::vector< VehicleInfo >::const_iterator lastStandingVehicle
The last standing vehicle.
int myCurrentJamNo
The current jam number.
T MIN2(T a, T b)
Definition: StdDefs.h:69
static SUMOReal passingTime(const SUMOReal lastPos, const SUMOReal passedPos, const SUMOReal currentPos, const SUMOReal lastSpeed, const SUMOReal currentSpeed)
Calculates the time at which the position passedPosition has been passed In case of a ballistic updat...
Definition: MSCFModel.cpp:367
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
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.
SUMOTime myJamHaltingTimeThreshold
A vehicle must be that long beyond myJamHaltingSpeedThreshold to be counted as a part of a jam...
SUMOReal mySpeedSum
The sum of collected vehicle speeds [m/s].
SUMOReal myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
const std::vector< VehicleInfo > & getCurrentVehicles() const
Returns the vehicles within the area.
SUMOReal myCurrentJamLengthInMeters
The overall jam length in meters.
SUMOReal myStartPos
The position the detector starts at.
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 [%].
std::vector< VehicleInfo > myPreviousKnownVehicles
List of previously known vehicles.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
MSE2Collector(const std::string &id, DetectorUsage usage, MSLane *const lane, SUMOReal startPos, SUMOReal detLength, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, const std::string &vTypes)
Constructor.
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
DetectorUsage myUsage
Information about how this detector is used.
SUMOReal myCurrentMeanSpeed
The current mean speed.
void reset()
Resets all values.
virtual SUMOReal getAcceleration() const =0
Returns the vehicle&#39;s acceleration.
int getCurrentStartedHalts() const
Returns the length of all jams in meters.
const std::string & getID() const
Returns the name of the vehicle type.
int myMaxJamInVehicles
The max jam length [#veh].
SUMOReal myMeanMaxJamInMeters
The mean jam length [m].
SUMOReal myOccupancySum
The sum of occupancies [%].
virtual SUMOReal getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle&#39;s back position along the given lane.
int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
SUMOReal myJamLengthInMetersSum
The sum of jam lengths [m].
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
int myCurrentHaltingsNumber
The number of halted vehicles [#].
#define SUMOReal
Definition: config.h:213
static bool gSemiImplicitEulerUpdate
Definition: MSGlobals.h:63
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes a known vehicle due to its lane-change.
#define NUMERICAL_EPS
Definition: config.h:160
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
int myPassedVeh
The number of vehicles passed on the sensor.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
Base of value-generating classes (detectors)
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.
SUMOReal myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.