SUMO - Simulation of Urban MObility
MSE2Collector.cpp
Go to the documentation of this file.
1 /****************************************************************************/
14 // An areal (along a single lane) detector
15 /****************************************************************************/
16 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
17 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
18 /****************************************************************************/
19 //
20 // This file is part of SUMO.
21 // SUMO is free software: you can redistribute it and/or modify
22 // it under the terms of the GNU General Public License as published by
23 // the Free Software Foundation, either version 3 of the License, or
24 // (at your option) any later version.
25 //
26 /****************************************************************************/
27 
28 
29 // ===========================================================================
30 // included modules
31 // ===========================================================================
32 #ifdef _MSC_VER
33 #include <windows_config.h>
34 #else
35 #include <config.h>
36 #endif
37 
38 #include <cassert>
39 #include <algorithm>
40 #include "MSE2Collector.h"
41 #include <microsim/MSLane.h>
42 #include <microsim/MSNet.h>
43 #include <microsim/MSVehicle.h>
44 #include <microsim/MSVehicleType.h>
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 //#define DEBUG_NOTIFY_MOVE
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
55 MSE2Collector::MSE2Collector(const std::string& id, DetectorUsage usage,
56  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
57  SUMOTime haltingTimeThreshold,
58  SUMOReal haltingSpeedThreshold,
59  SUMOReal jamDistThreshold,
60  const std::string& vTypes) :
61  MSMoveReminder(id, lane),
62  MSDetectorFileOutput(id, vTypes),
63  myJamHaltingSpeedThreshold(haltingSpeedThreshold),
64  myJamHaltingTimeThreshold(haltingTimeThreshold),
65  myJamDistanceThreshold(jamDistThreshold),
66  myStartPos(startPos), myEndPos(startPos + detLength),
67  myUsage(usage),
68  myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
69  myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
70  myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
71  myCurrentHaltingsNumber(0), myPassedVeh(0) {
72  assert(myLane != 0);
73  assert(myStartPos >= 0 && myStartPos < myLane->getLength());
74  assert(myEndPos - myStartPos > 0 && myEndPos <= myLane->getLength());
75  reset();
76 }
77 
78 
79 MSE2Collector::MSE2Collector(const std::string& id, DetectorUsage usage,
80  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
81  SUMOTime haltingTimeThreshold,
82  SUMOReal haltingSpeedThreshold,
83  SUMOReal jamDistThreshold,
84  const std::set<std::string>& vTypes) :
85  MSMoveReminder(id, lane),
86  MSDetectorFileOutput(id, vTypes),
87  myJamHaltingSpeedThreshold(haltingSpeedThreshold),
88  myJamHaltingTimeThreshold(haltingTimeThreshold),
89  myJamDistanceThreshold(jamDistThreshold),
90  myStartPos(startPos), myEndPos(startPos + detLength),
91  myUsage(usage),
96  assert(myLane != 0);
97  assert(myStartPos >= 0 && myStartPos < myLane->getLength());
98  assert(myEndPos - myStartPos > 0 && myEndPos <= myLane->getLength());
99  reset();
100 }
101 
102 
104  myKnownVehicles.clear();
105 }
106 
107 
108 bool
110  SUMOReal newPos, SUMOReal newSpeed) {
111  if (newPos <= myStartPos) {
112  // detector not yet reached
113  return true;
114  }
115 
116 
117  const SUMOReal oldSpeed = veh.getPreviousSpeed();
118  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
119  SUMOReal leaveSpeed = newSpeed;
120 
121  SUMOReal lengthOnDet = MIN2(veh.getVehicleType().getLength(), newPos - myStartPos);
122  if (newPos > myEndPos) {
123  lengthOnDet = MAX2(SUMOReal(0), lengthOnDet - (newPos - myEndPos));
124  }
125 
126  SUMOReal timeOnDet = TS;
127 
128  // Treat the case that the vehicle entered the lane in the last step
129  if (newPos > myStartPos && oldPos <= myStartPos) {
130  // Vehicle was not on this lane in the last time step
131  const SUMOReal timeBeforeEnter = MSCFModel::passingTime(oldPos, myStartPos, newPos, oldSpeed, newSpeed);
132  timeOnDet -= timeBeforeEnter;
133  enterSpeed = MSCFModel::speedAfterTime(timeBeforeEnter, oldSpeed, newPos - oldPos);
134  myPassedVeh++;
135  }
136 
137  // Treat the case that the vehicle's back left the lane in the last step
138  const SUMOReal oldBackPos = oldPos - veh.getVehicleType().getLength();
139  const SUMOReal newBackPos = newPos - veh.getVehicleType().getLength();
140  const SUMOReal vmax = myLane->getVehicleMaxSpeed(&veh);
141  if (newBackPos > myEndPos) {
142  assert(oldBackPos <= myEndPos);
143  const SUMOReal timeBeforeLeave = MSCFModel::passingTime(oldBackPos, myEndPos, newBackPos, oldSpeed, newSpeed);
144  const SUMOReal timeAfterLeave = TS - timeBeforeLeave;
145  timeOnDet -= timeAfterLeave;
146  leaveSpeed = MSCFModel::speedAfterTime(timeBeforeLeave, oldSpeed, newPos - oldPos);
147  // XXX: Do we really need this? Why would this "reduce rounding errors"? (Leo) Refs. #2579
148  if (fabs(timeOnDet) < NUMERICAL_EPS) { // reduce rounding errors
149  timeOnDet = 0.;
150  } else {
151  const SUMOReal averageSpeedOnDetector = (enterSpeed + leaveSpeed) / 2.;
152  myKnownVehicles.push_back(VehicleInfo(veh.getID(), veh.getVehicleType().getID(), averageSpeedOnDetector,
153  timeOnDet, lengthOnDet, newPos,
154  veh.getVehicleType().getLengthWithGap(), veh.getAcceleration(), vmax, false));
155  }
156  return false;
157  }
158  const SUMOReal averageSpeedOnDetector = (enterSpeed + leaveSpeed) / 2.;
159  myKnownVehicles.push_back(VehicleInfo(veh.getID(), veh.getVehicleType().getID(), averageSpeedOnDetector,
160  timeOnDet, lengthOnDet, newPos,
161  veh.getVehicleType().getLengthWithGap(), veh.getAcceleration(), vmax, true));
162 // DBG(
163 #ifdef DEBUG_NOTIFY_MOVE
164  std::ostringstream str;
165  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
166  << " MSE2Collector::notifyMove::"
167  << " lane " << myLane->getID()
168  << " passedVeh " << myPassedVeh
169  << " myKnownVehicles-length " << myPreviousKnownVehicles.size();
170 // WRITE_MESSAGE(str.str());
171  std::cout << str.str() << std::endl;
172 #endif
173 // )
174  return true;
175 }
176 
177 
178 bool
181  return false;
182  }
183  return true;
184 }
185 
186 
187 bool
189  if (!vehicleApplies(veh)) {
190  return false;
191  }
192  if (!veh.isOnRoad()) {
193  // vehicle is teleporting over the edge
194  return false;
195  }
196  // is vehicle beyond detector?
197  return veh.getBackPositionOnLane(myLane) < myEndPos;
198 }
199 
200 
201 void
203  mySpeedSum = 0;
204  myStartedHalts = 0;
207  myVehicleSamples = 0;
208  myTimeLossSum = 0;
209  myOccupancySum = 0;
210  myMaxOccupancy = 0;
213  myMaxJamInVehicles = 0;
214  myMaxJamInMeters = 0;
215  myTimeSamples = 0;
217  myMaxVehicleNumber = 0;
218  for (std::map<std::string, SUMOTime>::iterator i = myIntervalHaltingVehicleDurations.begin(); i != myIntervalHaltingVehicleDurations.end(); ++i) {
219  (*i).second = 0;
220  }
221  myPastStandingDurations.clear();
223  myPassedVeh = 0;
224 }
225 
226 
227 
228 void
230  JamInfo* currentJam = 0;
231  std::map<std::string, SUMOTime> haltingVehicles;
232  std::map<std::string, SUMOTime> intervalHaltingVehicles;
233  std::vector<JamInfo*> jams;
234 
235  SUMOReal lengthSum = 0;
236  myCurrentMeanSpeed = 0;
240 
241  // go through the (sorted) list of vehicles positioned on the detector
242  // sum up values and prepare the list of jams
243  std::vector<VehicleInfo>::const_iterator iv;
244  const int numVehicles = (int)myKnownVehicles.size();
245  for (std::vector<VehicleInfo>::const_iterator i = myKnownVehicles.begin(); i != myKnownVehicles.end(); ++i) {
246  myVehicleSamples += i->timeOnDet;
247  mySpeedSum += i->speed * i->timeOnDet;
248  myTimeLossSum += i->timeLoss;
249  myCurrentMeanSpeed += i->speed * i->timeOnDet;
250  lengthSum += i->lengthOnDet;
251  myCurrentMeanLength += i->lengthOnDet;
252 
253  // jam-checking begins
254  bool isInJam = false;
255  // first, check whether the vehicle is slow enough to be states as halting
256  if (i->speed < myJamHaltingSpeedThreshold) {
258  // we have to track the time it was halting;
259  // so let's look up whether it was halting before and compute the overall halting time
260  bool wasHalting = myHaltingVehicleDurations.count(i->id) > 0;
261  if (wasHalting) {
262  haltingVehicles[i->id] = myHaltingVehicleDurations[i->id] + DELTA_T;
263  intervalHaltingVehicles[i->id] = myIntervalHaltingVehicleDurations[i->id] + DELTA_T;
264  } else {
265  haltingVehicles[i->id] = DELTA_T;
266  intervalHaltingVehicles[i->id] = DELTA_T;
268  myStartedHalts++;
269  }
270  // we now check whether the halting time is large enough
271  if (haltingVehicles[i->id] > myJamHaltingTimeThreshold) {
272  // yep --> the vehicle is a part of a jam
273  isInJam = true;
274  }
275  } else {
276  // is not standing anymore; keep duration information
277  std::map<std::string, SUMOTime>::iterator v = myHaltingVehicleDurations.find(i->id);
278  if (v != myHaltingVehicleDurations.end()) {
279  myPastStandingDurations.push_back((*v).second);
280  myHaltingVehicleDurations.erase(v);
281  }
282  v = myIntervalHaltingVehicleDurations.find(i->id);
283  if (v != myIntervalHaltingVehicleDurations.end()) {
284  myPastIntervalStandingDurations.push_back((*v).second);
286  }
287  }
288 
289  // jam-building
290  if (isInJam) {
291  // the vehicle is in a jam;
292  // it may be a new one or already an existing one
293  if (currentJam == 0) {
294  // the vehicle is the first vehicle in a jam
295  currentJam = new JamInfo();
296  currentJam->firstStandingVehicle = i;
297  } else {
298  // ok, we have a jam already. But - maybe it is too far away
299  // ... honestly, I can hardly find a reason for doing this,
300  // but jams were defined this way in an earlier version...
301  if (i->position - currentJam->lastStandingVehicle->position > myJamDistanceThreshold) {
302  // yep, yep, yep - it's a new one...
303  // close the frist, build a new
304  jams.push_back(currentJam);
305  currentJam = new JamInfo();
306  currentJam->firstStandingVehicle = i;
307  }
308  }
309  currentJam->lastStandingVehicle = i;
310  } else {
311  // the vehicle is not part of a jam...
312  // maybe we have to close an already computed jam
313  if (currentJam != 0) {
314  jams.push_back(currentJam);
315  currentJam = 0;
316  }
317  }
318  }
319  if (currentJam != 0) {
320  jams.push_back(currentJam);
321  currentJam = 0;
322  }
323 
328  // process jam information
329  for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
330  // compute current jam's values
331  const SUMOReal jamLengthInMeters = (*i)->firstStandingVehicle->position
332  - (*i)->lastStandingVehicle->position
333  + (*i)->lastStandingVehicle->lengthOnDet;
334  const int jamLengthInVehicles = (int)distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
335  // apply them to the statistics
338  myJamLengthInMetersSum += jamLengthInMeters;
339  myJamLengthInVehiclesSum += jamLengthInVehicles;
340  myCurrentJamLengthInMeters += jamLengthInMeters;
341  myCurrentJamLengthInVehicles += jamLengthInVehicles;
342  }
343  myCurrentJamNo = (int) jams.size();
344 
345  myTimeSamples += 1;
346  // compute occupancy values
347  SUMOReal currentOccupancy = lengthSum / (myEndPos - myStartPos) * (SUMOReal) 100.;
348  myCurrentOccupancy = currentOccupancy;
349  myOccupancySum += currentOccupancy;
350  myMaxOccupancy = MAX2(myMaxOccupancy, currentOccupancy);
351  // compute jam values
356  // save information about halting vehicles
357  myHaltingVehicleDurations = haltingVehicles;
358  myIntervalHaltingVehicleDurations = intervalHaltingVehicles;
359  // compute information about vehicle numbers
360  myMeanVehicleNumber += numVehicles;
362  // norm current values
363  myCurrentMeanSpeed = numVehicles != 0 ? myCurrentMeanSpeed / (SUMOReal) numVehicles : -1;
364  myCurrentMeanLength = numVehicles != 0 ? myCurrentMeanLength / (SUMOReal) numVehicles : -1;
365 
366  // clean up
367  for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
368  delete *i;
369  }
370 
371 
372  // Accumulate the timelosses for the individual vehicles
373  // TODO: This could be speeded up by (1) not starting the search from the begin() but using the previous iv+1 as a start point and
374  // looking in a zigzag fashion for the next vehicle; (2) not using strings in the comparison but (maybe) pointers
375  // (include in VehicleInfo?); (3) including this code into the first loop above on the price of using a non-constant
376  // iterator there.
377  for (std::vector<VehicleInfo>::iterator i = myKnownVehicles.begin(); i != myKnownVehicles.end(); ++i) {
378  for (iv = myPreviousKnownVehicles.begin(); iv != myPreviousKnownVehicles.end(); ++iv) {
379  // if the vehicle was here before, account for the accumulated timeloss as well (i->timeLoss is only the last step's timeloss)
380  if (iv->id == i->id) {
381  i->accumulatedTimeLoss += iv->timeLoss;
382  break;
383  }
384  }
385  }
386 
387 
389  myKnownVehicles.clear();
390 }
391 
392 
393 
394 void
396  dev << " <interval begin=\"" << time2string(startTime) << "\" end=\"" << time2string(stopTime) << "\" " << "id=\"" << getID() << "\" ";
397 
398  const SUMOReal meanSpeed = myVehicleSamples != 0 ? mySpeedSum / myVehicleSamples : -1;
399  const SUMOReal meanOccupancy = myTimeSamples != 0 ? myOccupancySum / (SUMOReal) myTimeSamples : 0;
400  const SUMOReal meanJamLengthInMeters = myTimeSamples != 0 ? myMeanMaxJamInMeters / (SUMOReal) myTimeSamples : 0;
401  const SUMOReal meanJamLengthInVehicles = myTimeSamples != 0 ? myMeanMaxJamInVehicles / (SUMOReal) myTimeSamples : 0;
402  const SUMOReal meanVehicleNumber = myTimeSamples != 0 ? (SUMOReal) myMeanVehicleNumber / (SUMOReal) myTimeSamples : 0;
403  const SUMOReal meanTimeLoss = meanVehicleNumber != 0 ? myTimeLossSum / meanVehicleNumber : -1;
404 
405  SUMOTime haltingDurationSum = 0;
406  SUMOTime maxHaltingDuration = 0;
407  int haltingNo = 0;
408  for (std::vector<SUMOTime>::iterator i = myPastStandingDurations.begin(); i != myPastStandingDurations.end(); ++i) {
409  haltingDurationSum += (*i);
410  maxHaltingDuration = MAX2(maxHaltingDuration, (*i));
411  haltingNo++;
412  }
413  for (std::map<std::string, SUMOTime> ::iterator i = myHaltingVehicleDurations.begin(); i != myHaltingVehicleDurations.end(); ++i) {
414  haltingDurationSum += (*i).second;
415  maxHaltingDuration = MAX2(maxHaltingDuration, (*i).second);
416  haltingNo++;
417  }
418  const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
419 
420  SUMOTime intervalHaltingDurationSum = 0;
421  SUMOTime intervalMaxHaltingDuration = 0;
422  int intervalHaltingNo = 0;
423  for (std::vector<SUMOTime>::iterator i = myPastIntervalStandingDurations.begin(); i != myPastIntervalStandingDurations.end(); ++i) {
424  intervalHaltingDurationSum += (*i);
425  intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i));
426  intervalHaltingNo++;
427  }
428  for (std::map<std::string, SUMOTime> ::iterator i = myIntervalHaltingVehicleDurations.begin(); i != myIntervalHaltingVehicleDurations.end(); ++i) {
429  intervalHaltingDurationSum += (*i).second;
430  intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i).second);
431  intervalHaltingNo++;
432  }
433  const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
434 
435  dev << "sampledSeconds=\"" << myVehicleSamples << "\" "
436  << "nVehEntered=\"" << myPassedVeh << "\" "
437  << "meanSpeed=\"" << meanSpeed << "\" "
438  << "meanTimeLoss=\"" << meanTimeLoss << "\" "
439  << "meanOccupancy=\"" << meanOccupancy << "\" "
440  << "maxOccupancy=\"" << myMaxOccupancy << "\" "
441  << "meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles << "\" "
442  << "meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters << "\" "
443  << "maxJamLengthInVehicles=\"" << myMaxJamInVehicles << "\" "
444  << "maxJamLengthInMeters=\"" << myMaxJamInMeters << "\" "
445  << "jamLengthInVehiclesSum=\"" << myJamLengthInVehiclesSum << "\" "
446  << "jamLengthInMetersSum=\"" << myJamLengthInMetersSum << "\" "
447  << "meanHaltingDuration=\"" << STEPS2TIME(meanHaltingDuration) << "\" "
448  << "maxHaltingDuration=\"" << STEPS2TIME(maxHaltingDuration) << "\" "
449  << "haltingDurationSum=\"" << STEPS2TIME(haltingDurationSum) << "\" "
450  << "meanIntervalHaltingDuration=\"" << STEPS2TIME(intervalMeanHaltingDuration) << "\" "
451  << "maxIntervalHaltingDuration=\"" << STEPS2TIME(intervalMaxHaltingDuration) << "\" "
452  << "intervalHaltingDurationSum=\"" << STEPS2TIME(intervalHaltingDurationSum) << "\" "
453  << "startedHalts=\"" << myStartedHalts << "\" "
454  << "meanVehicleNumber=\"" << meanVehicleNumber << "\" "
455  << "maxVehicleNumber=\"" << myMaxVehicleNumber << "\" "
456  << "/>\n";
457  reset();
458 }
459 
460 
461 void
463  dev.writeXMLHeader("detector", "det_e2_file.xsd");
464 }
465 
466 
467 int
469  int result = 0;
470  for (std::vector<VehicleInfo>::const_iterator it = myPreviousKnownVehicles.begin();
471  it != myPreviousKnownVehicles.end(); it++) {
472  if (it->stillOnDet) {
473  result++;
474  }
475  }
476  return result;
477 }
478 
479 int
481 
483  SUMOReal thresholdSpeed = myLane->getSpeedLimit() / speedThreshold;
484 
485  int count = 0;
486  for (std::vector<VehicleInfo>::const_iterator it = myPreviousKnownVehicles.begin();
487  it != myKnownVehicles.end(); it++) {
488  if (it->stillOnDet) {
489  if (it->position < distance) {
490  distance = it->position;
491  }
492  const SUMOReal realDistance = myLane->getLength() - distance; // the closer vehicle get to the light the greater is the distance
493  if (it->speed <= thresholdSpeed || it->accel > 0) { //TODO speed less than half of the maximum speed for the lane NEED TUNING
494  count = (int)(realDistance / it->lengthWithGap) + 1;
495  }
496  }
497  }
498 
499  return count;
500 }
501 
502 SUMOReal
504 
505  if (myPreviousKnownVehicles.empty()) {
506  return -1;
507  }
508 
510  SUMOReal realDistance = 0;
511  bool flowing = true;
512  for (std::vector<VehicleInfo>::const_iterator it = myPreviousKnownVehicles.begin();
513  it != myPreviousKnownVehicles.end(); it++) {
514  if (it->stillOnDet) {
515  if (it->position < distance) {
516  distance = it->position;
517  }
518  // SUMOReal distanceTemp = myLane->getLength() - distance;
519  if (it->speed <= 0.5) {
520  realDistance = distance - it->lengthWithGap;
521  flowing = false;
522  }
523  DBG(
524  std::ostringstream str;
525  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
526  << " MSE2Collector::getEstimateQueueLength::"
527  << " lane " << myLane->getID()
528  << " vehicle " << it->id
529  << " positionOnLane " << it->position
530  << " vel " << it->speed
531  << " realDistance " << realDistance;
532  WRITE_MESSAGE(str.str());
533  )
534  }
535  }
536  if (flowing) {
537  return 0;
538  } else {
539  return myLane->getLength() - realDistance;
540  }
541 }
542 
543 
544 SUMOReal
546  return myCurrentOccupancy;
547 }
548 
549 
550 SUMOReal
552  return myCurrentMeanSpeed;
553 }
554 
555 
556 SUMOReal
558  return myCurrentMeanLength;
559 }
560 
561 
562 int
564  return myCurrentJamNo;
565 }
566 
567 
568 int
571 }
572 
573 
574 SUMOReal
577 }
578 
579 
580 int
583 }
584 
585 
586 SUMOReal
589 }
590 
591 
592 int
594  return myCurrentStartedHalts;
595 }
596 
597 
598 int
601 }
602 
603 
604 std::vector<std::string>
606  std::vector<std::string> ret;
607  for (std::vector<VehicleInfo>::const_iterator i = myPreviousKnownVehicles.begin(); i != myPreviousKnownVehicles.end(); ++i) {
608  ret.push_back(i->id);
609  }
610  std::sort(ret.begin(), ret.end());
611  return ret;
612 }
613 
614 
615 const std::vector<MSE2Collector::VehicleInfo>&
618 }
619 
620 /****************************************************************************/
621 
int myMaxVehicleNumber
The max number of vehicles [#veh].
virtual SUMOReal getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle&#39;s back position along the given lane.
int myMeanMaxJamInVehicles
The mean jam length [#veh].
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.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
long long int SUMOTime
Definition: SUMOTime.h:43
SUMOReal myTimeLossSum
The sum of timeLoss values [s].
SUMOReal myMaxJamInMeters
The max jam length [m].
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.
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:480
MSLane *const myLane
Lane on which the reminder works.
int getCurrentStartedHalts() const
Returns the length of all jams in meters.
int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
SUMOReal myStartedHalts
The number of started halts [#].
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:60
SUMOReal getLength() const
Get vehicle&#39;s length [m].
int getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
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:70
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
SUMOTime DELTA_T
Definition: SUMOTime.cpp:40
SUMOReal getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
int myMeanVehicleNumber
The mean number of vehicles [#veh].
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 [#].
int myTimeSamples
The current aggregation duration [#steps].
const std::string & getID() const
Returns the id.
Definition: Named.h:66
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Adds the vehicle to known vehicles if not beyond the dector.
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:88
std::vector< VehicleInfo > myKnownVehicles
List of known vehicles.
#define max(a, b)
Definition: polyfonts.c:65
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
Representation of a vehicle.
Definition: SUMOVehicle.h:67
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
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.
std::vector< VehicleInfo >::const_iterator firstStandingVehicle
The first standing vehicle.
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
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:64
SUMOReal getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:472
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
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
Something on a lane to be noticed about vehicle movement.
std::map< std::string, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
#define DBG(X)
Definition: SwarmDebug.h:30
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
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 getEstimateQueueLength() const
Returns an estimate of the lenght of the queue of vehicles currently stopped on the detector...
SUMOReal mySpeedSum
The sum of collected vehicle speeds [m/s].
SUMOReal myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
SUMOReal myCurrentJamLengthInMeters
The overall jam length in meters.
SUMOReal myStartPos
The position the detector starts at.
int getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
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.
int getCurrentJamNumber() const
Returns the current number of jams.
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.
SUMOReal getCurrentOccupancy() const
Returns the curent detector occupancy.
DetectorUsage myUsage
Information about how this detector is used.
SUMOReal myCurrentMeanSpeed
The current mean speed.
void reset()
Resets all values.
std::map< std::string, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
int myMaxJamInVehicles
The max jam length [#veh].
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.
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
virtual SUMOReal getAcceleration() const =0
Returns the vehicle&#39;s acceleration.
SUMOReal myJamLengthInMetersSum
The sum of jam lengths [m].
SUMOReal getCurrentMaxJamLengthInMeters() const
Returns the length in meters of the currently largest jam.
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:208
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.
const std::vector< VehicleInfo > & getCurrentVehicles() const
Returns the vehicles within the area.
#define NUMERICAL_EPS
Definition: config.h:158
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:458
virtual SUMOReal getPreviousSpeed() const =0
Returns the vehicle&#39;s previous speed.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
int myPassedVeh
The number of vehicles passed on the sensor.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
Base of value-generating classes (detectors)
SUMOReal myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.