Eclipse SUMO - Simulation of Urban MObility
MSMeanData_Net.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2004-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // Network state mean data collector for edges/lanes
21 /****************************************************************************/
22 #include <config.h>
23 
24 #ifdef HAVE_FOX
26 #endif
27 #include <utils/common/SUMOTime.h>
28 #include <utils/common/ToString.h>
30 #include <microsim/MSEdgeControl.h>
31 #include <microsim/MSEdge.h>
32 #include <microsim/MSLane.h>
33 #include <microsim/MSVehicle.h>
34 #include <microsim/MSGlobals.h>
35 #include <mesosim/MELoop.h>
36 #include <mesosim/MESegment.h>
37 #include "MSMeanData_Net.h"
38 
39 
40 // ===========================================================================
41 // debug constants
42 // ===========================================================================
43 //#define DEBUG_OCCUPANCY
44 //#define DEBUG_OCCUPANCY2
45 //#define DEBUG_NOTIFY_ENTER
46 //#define DEBUG_COND (veh.getLane()->getID() == "31to211_0")
47 #define DEBUG_COND (false)
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 // ---------------------------------------------------------------------------
54 // MSMeanData_Net::MSLaneMeanDataValues - methods
55 // ---------------------------------------------------------------------------
57  const double length,
58  const bool doAdd,
59  const MSMeanData_Net* parent)
60  : MSMeanData::MeanDataValues(lane, length, doAdd, parent),
61  nVehDeparted(0), nVehArrived(0), nVehEntered(0), nVehLeft(0),
62  nVehVaporized(0), nVehTeleported(0), waitSeconds(0), timeLoss(0),
63  nVehLaneChangeFrom(0), nVehLaneChangeTo(0),
64  frontSampleSeconds(0), frontTravelledDistance(0),
65  vehLengthSum(0), occupationSum(0),
66  minimalVehicleLength(INVALID_DOUBLE),
67  myParent(parent) {}
68 
69 
71 }
72 
73 
74 void
76  nVehDeparted = 0;
77  nVehArrived = 0;
78  nVehEntered = 0;
79  nVehLeft = 0;
80  nVehVaporized = 0;
81  nVehTeleported = 0;
82  nVehLaneChangeFrom = 0;
83  nVehLaneChangeTo = 0;
84  sampleSeconds = 0.;
85  travelledDistance = 0;
86  waitSeconds = 0;
87  timeLoss = 0;
88  frontSampleSeconds = 0;
89  frontTravelledDistance = 0;
90  vehLengthSum = 0;
91  occupationSum = 0;
92  minimalVehicleLength = INVALID_DOUBLE;
93  resetTime = SIMSTEP;
94 }
95 
96 
97 void
100  v.nVehDeparted += nVehDeparted;
101  v.nVehArrived += nVehArrived;
102  v.nVehEntered += nVehEntered;
103  v.nVehLeft += nVehLeft;
104  v.nVehVaporized += nVehVaporized;
105  v.nVehTeleported += nVehTeleported;
106  v.nVehLaneChangeFrom += nVehLaneChangeFrom;
107  v.nVehLaneChangeTo += nVehLaneChangeTo;
108  v.sampleSeconds += sampleSeconds;
109  v.travelledDistance += travelledDistance;
110  v.waitSeconds += waitSeconds;
111  v.timeLoss += timeLoss;
112  v.frontSampleSeconds += frontSampleSeconds;
113  v.frontTravelledDistance += frontTravelledDistance;
114  v.vehLengthSum += vehLengthSum;
115  v.occupationSum += occupationSum;
117  v.minimalVehicleLength = minimalVehicleLength;
118  } else {
119  v.minimalVehicleLength = MIN2(minimalVehicleLength, v.minimalVehicleLength);
120  }
121 }
122 
123 
124 void
126  const SUMOTrafficObject& veh, const double frontOnLane,
127  const double timeOnLane, const double /* meanSpeedFrontOnLane */,
128  const double meanSpeedVehicleOnLane,
129  const double travelledDistanceFrontOnLane,
130  const double travelledDistanceVehicleOnLane,
131  const double meanLengthOnLane) {
132 #ifdef DEBUG_OCCUPANCY
133  if (DEBUG_COND) {
134  std::cout << SIMTIME << "\n MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal()\n"
135  << " veh '" << veh.getID() << "' on lane '" << veh.getLane()->getID() << "'"
136  << ", timeOnLane=" << timeOnLane
137  << ", meanSpeedVehicleOnLane=" << meanSpeedVehicleOnLane
138  << ",\ntravelledDistanceFrontOnLane=" << travelledDistanceFrontOnLane
139  << ", travelledDistanceVehicleOnLane=" << travelledDistanceVehicleOnLane
140  << ", meanLengthOnLane=" << meanLengthOnLane
141  << std::endl;
142  }
143 #endif
144  if (myParent != nullptr && !myParent->vehicleApplies(veh)) {
145  return;
146  }
147  sampleSeconds += timeOnLane;
148  travelledDistance += travelledDistanceVehicleOnLane;
149  vehLengthSum += veh.getVehicleType().getLength() * timeOnLane;
151  // For the mesosim case no information on whether the vehicle was occupying
152  // the lane with its whole length is available. We assume the whole length
153  // Therefore this increment is taken out with more information on the vehicle movement.
154  occupationSum += veh.getVehicleType().getLength() * timeOnLane;
155  } else {
156  // for the microsim case more elaborate calculation of the average length on the lane,
157  // is taken out in notifyMove(), refs #153
158  occupationSum += meanLengthOnLane * TS;
159  }
160  if (!veh.isStopped()) {
161  if (myParent != nullptr && meanSpeedVehicleOnLane < myParent->myHaltSpeed) {
162  waitSeconds += timeOnLane;
163  }
164  const double vmax = veh.getLane() == nullptr ? veh.getEdge()->getVehicleMaxSpeed(&veh) : veh.getLane()->getVehicleMaxSpeed(&veh);
165  if (vmax > 0) {
166  timeLoss += timeOnLane * MAX2(0.0, vmax - meanSpeedVehicleOnLane) / vmax;
167  }
168  }
169  frontSampleSeconds += frontOnLane;
170  frontTravelledDistance += travelledDistanceFrontOnLane;
171  if (minimalVehicleLength == INVALID_DOUBLE) {
172  minimalVehicleLength = veh.getVehicleType().getLengthWithGap();
173  } else {
174  minimalVehicleLength = MIN2(minimalVehicleLength, veh.getVehicleType().getLengthWithGap());
175  }
176 #ifdef DEBUG_OCCUPANCY2
177  // refs #3265
178  std::cout << SIMTIME << "ID: " << getDescription() << " minVehicleLength=" << minimalVehicleLength << std::endl;
179 #endif
180 }
181 
182 
183 bool
185  if ((myParent == nullptr || myParent->vehicleApplies(veh)) && (
186  getLane() == nullptr || !veh.isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane())) {
187 #ifdef HAVE_FOX
188  ScopedLocker<> lock(myNotificationMutex, MSGlobals::gNumSimThreads > 1);
189 #endif
191  removeFromVehicleUpdateValues(veh);
192  }
193  if (reason == MSMoveReminder::NOTIFICATION_ARRIVED) {
194  ++nVehArrived;
195  } else if (reason == MSMoveReminder::NOTIFICATION_LANE_CHANGE) {
196  ++nVehLaneChangeFrom;
197  } else if (myParent == nullptr || reason != MSMoveReminder::NOTIFICATION_SEGMENT) {
198  ++nVehLeft;
200  ++nVehTeleported;
202  ++nVehVaporized;
203  }
204  }
205  }
207  return false;
208  }
209  return reason == MSMoveReminder::NOTIFICATION_JUNCTION;
210 }
211 
212 
213 bool
215 #ifdef DEBUG_NOTIFY_ENTER
216  std::cout << "\n" << SIMTIME << " MSMeanData_Net::MSLaneMeanDataValues: veh '" << veh.getID() << "' enters lane '" << enteredLane->getID() << "'" << std::endl;
217 #else
218  UNUSED_PARAMETER(enteredLane);
219 #endif
220  if (myParent == nullptr || myParent->vehicleApplies(veh)) {
221  if (getLane() == nullptr || !veh.isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane()) {
222 #ifdef HAVE_FOX
223  ScopedLocker<> lock(myNotificationMutex, MSGlobals::gNumSimThreads > 1);
224 #endif
226  ++nVehDeparted;
227  } else if (reason == MSMoveReminder::NOTIFICATION_LANE_CHANGE) {
228  ++nVehLaneChangeTo;
229  } else if (myParent == nullptr || reason != MSMoveReminder::NOTIFICATION_SEGMENT) {
230  ++nVehEntered;
231  }
232  }
233  return true;
234  }
235  return false;
236 }
237 
238 
239 bool
241  return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0
242  && nVehLeft == 0 && nVehVaporized == 0 && nVehTeleported == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
243 }
244 
245 double
247  return occupationSum / STEPS2TIME(period) / myLaneLength / (double)numLanes * 100.;
248 }
249 
250 void
251 MSMeanData_Net::MSLaneMeanDataValues::write(OutputDevice& dev, long long int attributeMask, const SUMOTime period,
252  const int numLanes, const double speedLimit, const double defaultTravelTime, const int numVehicles) const {
253 
254  const double density = MIN2(sampleSeconds / STEPS2TIME(period) * 1000. / myLaneLength,
255  1000. * (double)numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
256  const double laneDensity = density / (double)numLanes;
257  const double occupancy = getOccupancy(period, numLanes);
258 #ifdef DEBUG_OCCUPANCY2
259  // tests #3264
260  if (occupancy > 100) {
261  std::cout << SIMTIME << " Encountered bad occupancy: " << occupancy
262  << ", myLaneLength=" << myLaneLength << ", period=" << STEPS2TIME(period) << ", occupationSum=" << occupationSum
263  << std::endl;
264  }
265  // refs #3265
266  std::cout << SIMTIME << "ID: " << getDescription() << " minVehicleLength=" << minimalVehicleLength
267  << "\ndensity=" << density << "\n";
268 #endif
269 
270  if (myParent == nullptr) {
271  if (sampleSeconds > 0) {
272  dev.writeOptionalAttr(SUMO_ATTR_DENSITY, density, attributeMask);
273  dev.writeOptionalAttr(SUMO_ATTR_LANEDENSITY, laneDensity, attributeMask);
274  dev.writeOptionalAttr(SUMO_ATTR_OCCUPANCY, occupancy, attributeMask);
275  dev.writeOptionalAttr(SUMO_ATTR_WAITINGTIME, waitSeconds, attributeMask);
276  dev.writeOptionalAttr(SUMO_ATTR_TIMELOSS, timeLoss, attributeMask);
277  dev.writeOptionalAttr(SUMO_ATTR_SPEED, travelledDistance / sampleSeconds, attributeMask);
278  dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit, attributeMask);
279  }
280  dev.writeOptionalAttr(SUMO_ATTR_DEPARTED, nVehDeparted, attributeMask);
281  dev.writeOptionalAttr(SUMO_ATTR_ARRIVED, nVehArrived, attributeMask);
282  dev.writeOptionalAttr(SUMO_ATTR_ENTERED, nVehEntered, attributeMask);
283  dev.writeOptionalAttr(SUMO_ATTR_LEFT, nVehLeft, attributeMask);
284  if (nVehVaporized > 0) {
285  dev.writeOptionalAttr(SUMO_ATTR_VAPORIZED, nVehVaporized, attributeMask);
286  }
287  if (nVehTeleported > 0) {
288  dev.writeOptionalAttr(SUMO_ATTR_TELEPORTED, nVehTeleported, attributeMask);
289  }
290  dev.closeTag();
291  return;
292  }
293  if (sampleSeconds > myParent->myMinSamples) {
294  double overlapTraveltime = myParent->myMaxTravelTime;
295  if (travelledDistance > 0.f) {
296  // one vehicle has to drive lane length + vehicle length before it has left the lane
297  // thus we need to scale with an extended length, approximated by lane length + average vehicle length
298  overlapTraveltime = MIN2(overlapTraveltime, (myLaneLength + vehLengthSum / sampleSeconds) * sampleSeconds / travelledDistance);
299  }
300  if (numVehicles > 0) {
301  dev.writeOptionalAttr(SUMO_ATTR_TRAVELTIME, sampleSeconds / numVehicles, attributeMask);
302  dev.writeOptionalAttr(SUMO_ATTR_WAITINGTIME, waitSeconds, attributeMask);
303  dev.writeOptionalAttr(SUMO_ATTR_TIMELOSS, timeLoss, attributeMask);
304  dev.writeOptionalAttr(SUMO_ATTR_SPEED, travelledDistance / sampleSeconds, attributeMask);
305  dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit, attributeMask);
306  } else {
307  double traveltime = myParent->myMaxTravelTime;
308  if (frontTravelledDistance > NUMERICAL_EPS) {
309  traveltime = MIN2(traveltime, myLaneLength * frontSampleSeconds / frontTravelledDistance);
310  dev.writeOptionalAttr(SUMO_ATTR_TRAVELTIME, traveltime, attributeMask);
311  } else if (defaultTravelTime >= 0.) {
312  dev.writeOptionalAttr(SUMO_ATTR_TRAVELTIME, defaultTravelTime, attributeMask);
313  }
314  dev.writeOptionalAttr(SUMO_ATTR_OVERLAPTRAVELTIME, overlapTraveltime, attributeMask);
315  dev.writeOptionalAttr(SUMO_ATTR_DENSITY, density, attributeMask);
316  dev.writeOptionalAttr(SUMO_ATTR_LANEDENSITY, laneDensity, attributeMask);
317  dev.writeOptionalAttr(SUMO_ATTR_OCCUPANCY, occupancy, attributeMask);
318  dev.writeOptionalAttr(SUMO_ATTR_WAITINGTIME, waitSeconds, attributeMask);
319  dev.writeOptionalAttr(SUMO_ATTR_TIMELOSS, timeLoss, attributeMask);
320  dev.writeOptionalAttr(SUMO_ATTR_SPEED, travelledDistance / sampleSeconds, attributeMask);
321  dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit, attributeMask);
322  }
323  } else if (defaultTravelTime >= 0.) {
324  dev.writeOptionalAttr(SUMO_ATTR_TRAVELTIME, defaultTravelTime, attributeMask);
325  dev.writeOptionalAttr(SUMO_ATTR_SPEED, myLaneLength / defaultTravelTime, attributeMask);
326  dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. ? 0. : myLaneLength / defaultTravelTime / speedLimit, attributeMask);
327  }
328  dev.writeOptionalAttr(SUMO_ATTR_DEPARTED, nVehDeparted, attributeMask);
329  dev.writeOptionalAttr(SUMO_ATTR_ARRIVED, nVehArrived, attributeMask);
330  dev.writeOptionalAttr(SUMO_ATTR_ENTERED, nVehEntered, attributeMask);
331  dev.writeOptionalAttr(SUMO_ATTR_LEFT, nVehLeft, attributeMask);
332  dev.writeOptionalAttr(SUMO_ATTR_LANECHANGEDFROM, nVehLaneChangeFrom, attributeMask);
333  dev.writeOptionalAttr(SUMO_ATTR_LANECHANGEDTO, nVehLaneChangeTo, attributeMask);
334  if (nVehVaporized > 0) {
335  dev.writeOptionalAttr(SUMO_ATTR_VAPORIZED, nVehVaporized, attributeMask);
336  }
337  if (nVehTeleported > 0) {
338  dev.writeOptionalAttr(SUMO_ATTR_TELEPORTED, nVehTeleported, attributeMask);
339  }
340  dev.closeTag();
341 }
342 
343 
344 double
346  const SUMOTime period, const double numLanes, const double speedLimit) const {
348  switch (a) {
349  case SUMO_ATTR_DENSITY:
350  return MIN2(sampleSeconds / STEPS2TIME(period) * (double) 1000 / myLaneLength,
351  1000. * numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
352  case SUMO_ATTR_LANEDENSITY: {
353  const double density = MIN2(sampleSeconds / STEPS2TIME(period) * (double) 1000 / myLaneLength,
354  1000. * numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
355  return density / numLanes;
356  }
357  case SUMO_ATTR_OCCUPANCY:
358  return occupationSum / STEPS2TIME(period) / myLaneLength / numLanes * (double) 1000;
360  return waitSeconds;
361  case SUMO_ATTR_TIMELOSS:
362  return timeLoss;
363  case SUMO_ATTR_SPEED:
364  return travelledDistance / sampleSeconds;
365  case SUMO_ATTR_SPEEDREL:
366  return speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit;
367  case SUMO_ATTR_DEPARTED:
368  return nVehDeparted;
369  case SUMO_ATTR_ARRIVED:
370  return nVehArrived;
371  case SUMO_ATTR_ENTERED:
372  return nVehEntered;
373  case SUMO_ATTR_LEFT:
374  return nVehLeft;
375  case SUMO_ATTR_VAPORIZED:
376  return nVehVaporized;
378  return nVehTeleported;
379  default:
380  return 0;
381  }
382 }
383 
384 // ---------------------------------------------------------------------------
385 // MSMeanData_Net - methods
386 // ---------------------------------------------------------------------------
387 MSMeanData_Net::MSMeanData_Net(const std::string& id,
388  const SUMOTime dumpBegin,
389  const SUMOTime dumpEnd, const bool useLanes,
390  const bool withEmpty, const bool printDefaults,
391  const bool withInternal,
392  const bool trackVehicles,
393  const int detectPersons,
394  const double maxTravelTime,
395  const double minSamples,
396  const double haltSpeed,
397  const std::string& vTypes,
398  const std::string& writeAttributes,
399  const std::vector<MSEdge*>& edges,
400  bool aggregate) :
401  MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
402  withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate),
403  myHaltSpeed(haltSpeed)
404 { }
405 
406 
408 
409 
411 MSMeanData_Net::createValues(MSLane* const lane, const double length, const bool doAdd) const {
412  return new MSLaneMeanDataValues(lane, length, doAdd, this);
413 }
414 
415 
416 std::vector<std::string>
418  std::vector<std::string> result;
419  result.push_back(toString(SUMO_ATTR_DENSITY));
420  result.push_back(toString(SUMO_ATTR_LANEDENSITY));
421  result.push_back(toString(SUMO_ATTR_OCCUPANCY));
422  result.push_back(toString(SUMO_ATTR_WAITINGTIME));
423  result.push_back(toString(SUMO_ATTR_TIMELOSS));
424  result.push_back(toString(SUMO_ATTR_SPEED));
425  result.push_back(toString(SUMO_ATTR_SPEEDREL));
426  result.push_back(toString(SUMO_ATTR_DEPARTED));
427  result.push_back(toString(SUMO_ATTR_ARRIVED));
428  result.push_back(toString(SUMO_ATTR_ENTERED));
429  result.push_back(toString(SUMO_ATTR_LEFT));
430  result.push_back(toString(SUMO_ATTR_VAPORIZED));
431  result.push_back(toString(SUMO_ATTR_TELEPORTED));
432  return result;
433 }
434 
435 
436 double
437 MSMeanData_Net::getAttributeValue(const MSLane* lane, SumoXMLAttr a, double defaultValue) const {
438  double result = defaultValue;
439  const std::vector<MeanDataValues*>* edgeValues = getEdgeValues(&lane->getEdge());
440  if (edgeValues == nullptr) {
441  return result;
442  }
443  MeanDataValues* values = nullptr;
444  if (!myAmEdgeBased) {
445  values = (*edgeValues)[lane->getIndex()];
446  } else {
447  MeanDataValues* sumData = createValues(nullptr, lane->getLength(), false);
448  for (MeanDataValues* meanData : (*edgeValues)) {
449  meanData->addTo(*sumData);
450  }
451  values = sumData;
452  }
453  const SUMOTime myLastResetTime = 0; // XXX store last reset time
454  const SUMOTime period = SIMSTEP - myLastResetTime;
455  result = values->getAttributeValue(a, period, lane->getEdge().getNumLanes(), lane->getSpeedLimit());
456  if (myAmEdgeBased) {
457  delete values;
458  }
459  return result;
460 }
461 
462 
463 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
#define DEBUG_COND
#define STEPS2TIME(x)
Definition: SUMOTime.h:55
#define SIMSTEP
Definition: SUMOTime.h:61
#define TS
Definition: SUMOTime.h:42
#define SIMTIME
Definition: SUMOTime.h:62
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_WAITINGTIME
@ SUMO_ATTR_OVERLAPTRAVELTIME
@ SUMO_ATTR_LANECHANGEDFROM
@ SUMO_ATTR_TRAVELTIME
@ SUMO_ATTR_SPEEDREL
@ SUMO_ATTR_ARRIVED
@ SUMO_ATTR_TELEPORTED
@ SUMO_ATTR_LANECHANGEDTO
@ SUMO_ATTR_TIMELOSS
@ SUMO_ATTR_VAPORIZED
@ SUMO_ATTR_OCCUPANCY
@ SUMO_ATTR_ENTERED
@ SUMO_ATTR_DEPARTED
@ SUMO_ATTR_LANEDENSITY
@ SUMO_ATTR_DENSITY
@ SUMO_ATTR_LEFT
const double INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
T MIN2(T a, T b)
Definition: StdDefs.h:76
T MAX2(T a, T b)
Definition: StdDefs.h:82
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
int getNumLanes() const
Definition: MSEdge.h:172
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:1106
static bool gUseMesoSim
Definition: MSGlobals.h:103
static int gNumSimThreads
how many threads to use for simulation
Definition: MSGlobals.h:143
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:584
double getLength() const
Returns the lane's length.
Definition: MSLane.h:598
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:566
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:634
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:756
Data structure for mean (aggregated) edge/lane values.
Definition: MSMeanData.h:66
double travelledDistance
The sum of the distances the vehicles travelled.
Definition: MSMeanData.h:190
virtual double getAttributeValue(SumoXMLAttr a, const SUMOTime period, const double numLanes, const double speedLimit) const
return attribute value
Definition: MSMeanData.h:169
Data structure for mean (aggregated) edge/lane values.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called if the vehicle leaves the reminder's lane.
double frontTravelledDistance
The travelled distance regarding the vehicle front.
void addTo(MSMeanData::MeanDataValues &val) const
Add the values of this to the given one and store them there.
int nVehLaneChangeTo
The number of vehicles that changed to this lane.
double getAttributeValue(SumoXMLAttr a, const SUMOTime period, const double numLanes, const double speedLimit) const
return attribute value
int nVehVaporized
The number of vehicles that left this lane via vaporization within the sample interval.
double minimalVehicleLength
minimal vehicle length in the current interval (used to determine a maximal density,...
void write(OutputDevice &dev, long long int attributeMask, const SUMOTime period, const int numLanes, const double speedLimit, const double defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
double getOccupancy(SUMOTime period, int numLanes) const
bool isEmpty() const
Returns whether any data was collected.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes current values and adds them to their sums.
MSLaneMeanDataValues(MSLane *const lane, const double length, const bool doAdd, const MSMeanData_Net *parent)
Constructor.
void notifyMoveInternal(const SUMOTrafficObject &veh, const double frontOnLane, const double timeOnLane, const double, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double meanLengthOnLane)
Internal notification about the vehicle moves.
int nVehLeft
The number of vehicles that left this lane within the sample interval.
int nVehLaneChangeFrom
The number of vehicles that changed from this lane.
int nVehTeleported
The number of vehicles that left this lane via teleporting within the sample interval.
double timeLoss
The time loss accrued by vehicle probes.
double frontSampleSeconds
The number of vehicle probes regarding the vehicle front.
int nVehArrived
The number of vehicles that finished on the lane.
double waitSeconds
The number of vehicle probes with small speed.
virtual ~MSLaneMeanDataValues()
Destructor.
double occupationSum
The sum of the occupation of the lane.
int nVehEntered
The number of vehicles that entered this lane within the sample interval.
double vehLengthSum
The sum of the lengths the vehicles had.
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
Network state mean data collector for edges/lanes.
virtual ~MSMeanData_Net()
Destructor.
double getAttributeValue(const MSLane *lane, SumoXMLAttr a, double defaultValue) const
return attribute value for the given lane
MSMeanData_Net(const std::string &id, const SUMOTime dumpBegin, const SUMOTime dumpEnd, const bool useLanes, const bool withEmpty, const bool printDefaults, const bool withInternal, const bool trackVehicles, const int detectPersons, const double maxTravelTime, const double minSamples, const double haltSpeed, const std::string &vTypes, const std::string &writeAttributes, const std::vector< MSEdge * > &edges, bool aggregate)
Constructor.
std::vector< std::string > getAttributeNames() const
return all attributes that are (potentially) written by this output
MSMeanData::MeanDataValues * createValues(MSLane *const lane, const double length, const bool doAdd) const
Create an instance of MeanDataValues.
const double myHaltSpeed
the minimum sample seconds
Data collector for edges/lanes.
Definition: MSMeanData.h:57
const bool myAmEdgeBased
Information whether the output shall be edge-based (not lane-based)
Definition: MSMeanData.h:488
const std::vector< MeanDataValues * > * getEdgeValues(const MSEdge *edge) const
Definition: MSMeanData.cpp:777
Notification
Definition of a vehicle state.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
@ NOTIFICATION_VAPORIZED_CALIBRATOR
The vehicle got removed by a calibrator.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
Definition: Named.h:74
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & writeOptionalAttr(const SumoXMLAttr attr, const T &val, long long int attributeMask)
writes a named attribute unless filtered
Definition: OutputDevice.h:271
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual bool isStopped() const =0
Returns whether the object is at a stop.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
A scoped lock which only triggers on condition.
Definition: ScopedLocker.h:40