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() == "")
47 //#define DEBUG_COND (false)
48 //#define DEBUG_COND2 (veh.getEdge()->getID() == "")
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 // ---------------------------------------------------------------------------
55 // MSMeanData_Net::MSLaneMeanDataValues - methods
56 // ---------------------------------------------------------------------------
58  const double length,
59  const bool doAdd,
60  const MSMeanData_Net* parent)
61  : MSMeanData::MeanDataValues(lane, length, doAdd, parent),
62  nVehDeparted(0), nVehArrived(0), nVehEntered(0), nVehLeft(0),
63  nVehVaporized(0), nVehTeleported(0), waitSeconds(0), timeLoss(0),
64  nVehLaneChangeFrom(0), nVehLaneChangeTo(0),
65  frontSampleSeconds(0), frontTravelledDistance(0),
66  vehLengthSum(0), occupationSum(0),
67  minimalVehicleLength(INVALID_DOUBLE),
68  myParent(parent) {}
69 
70 
72 }
73 
74 
75 void
77  nVehDeparted = 0;
78  nVehArrived = 0;
79  nVehEntered = 0;
80  nVehLeft = 0;
81  nVehVaporized = 0;
82  nVehTeleported = 0;
83  nVehLaneChangeFrom = 0;
84  nVehLaneChangeTo = 0;
85  sampleSeconds = 0.;
86  travelledDistance = 0;
87  waitSeconds = 0;
88  timeLoss = 0;
89  frontSampleSeconds = 0;
90  frontTravelledDistance = 0;
91  vehLengthSum = 0;
92  occupationSum = 0;
93  minimalVehicleLength = INVALID_DOUBLE;
94  resetTime = SIMSTEP;
95 }
96 
97 
98 void
101  v.nVehDeparted += nVehDeparted;
102  v.nVehArrived += nVehArrived;
103  v.nVehEntered += nVehEntered;
104  v.nVehLeft += nVehLeft;
105  v.nVehVaporized += nVehVaporized;
106  v.nVehTeleported += nVehTeleported;
107  v.nVehLaneChangeFrom += nVehLaneChangeFrom;
108  v.nVehLaneChangeTo += nVehLaneChangeTo;
109  v.sampleSeconds += sampleSeconds;
110  v.travelledDistance += travelledDistance;
111  v.waitSeconds += waitSeconds;
112  v.timeLoss += timeLoss;
113  v.frontSampleSeconds += frontSampleSeconds;
114  v.frontTravelledDistance += frontTravelledDistance;
115  v.vehLengthSum += vehLengthSum;
116  v.occupationSum += occupationSum;
118  v.minimalVehicleLength = minimalVehicleLength;
119  } else {
120  v.minimalVehicleLength = MIN2(minimalVehicleLength, v.minimalVehicleLength);
121  }
122 }
123 
124 
125 void
127  const SUMOTrafficObject& veh, const double frontOnLane,
128  const double timeOnLane, const double /* meanSpeedFrontOnLane */,
129  const double meanSpeedVehicleOnLane,
130  const double travelledDistanceFrontOnLane,
131  const double travelledDistanceVehicleOnLane,
132  const double meanLengthOnLane) {
133 #ifdef DEBUG_OCCUPANCY
134  if (DEBUG_COND2) {
135  std::cout << SIMTIME << "\n MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal()\n"
136  << " veh '" << veh.getID() << "' on edge '" << veh.getEdge()->getID() << "'"
137  << ", timeOnLane=" << timeOnLane
138  << ", meanSpeedVehicleOnLane=" << meanSpeedVehicleOnLane
139  << ",\ntravelledDistanceFrontOnLane=" << travelledDistanceFrontOnLane
140  << ", travelledDistanceVehicleOnLane=" << travelledDistanceVehicleOnLane
141  << ", meanLengthOnLane=" << meanLengthOnLane
142  << std::endl;
143  }
144 #endif
145  if (myParent != nullptr && !myParent->vehicleApplies(veh)) {
146  return;
147  }
148  sampleSeconds += timeOnLane;
149  travelledDistance += travelledDistanceVehicleOnLane;
150  vehLengthSum += veh.getVehicleType().getLength() * timeOnLane;
152  // For the mesosim case no information on whether the vehicle was occupying
153  // the lane with its whole length is available. We assume the whole length
154  // Therefore this increment is taken out with more information on the vehicle movement.
155  occupationSum += veh.getVehicleType().getLength() * timeOnLane;
156  } else {
157  // for the microsim case more elaborate calculation of the average length on the lane,
158  // is taken out in notifyMove(), refs #153
159  occupationSum += meanLengthOnLane * TS;
160  }
161  if (!veh.isStopped()) {
162  if (myParent != nullptr && meanSpeedVehicleOnLane < myParent->myHaltSpeed) {
163  waitSeconds += timeOnLane;
164  }
165  const double vmax = veh.getLane() == nullptr ? veh.getEdge()->getVehicleMaxSpeed(&veh) : veh.getLane()->getVehicleMaxSpeed(&veh);
166  if (vmax > 0) {
167  timeLoss += timeOnLane * MAX2(0.0, vmax - meanSpeedVehicleOnLane) / vmax;
168  }
169  }
170  frontSampleSeconds += frontOnLane;
171  frontTravelledDistance += travelledDistanceFrontOnLane;
172  if (minimalVehicleLength == INVALID_DOUBLE) {
173  minimalVehicleLength = veh.getVehicleType().getLengthWithGap();
174  } else {
175  minimalVehicleLength = MIN2(minimalVehicleLength, veh.getVehicleType().getLengthWithGap());
176  }
177 #ifdef DEBUG_OCCUPANCY2
178  // refs #3265
179  std::cout << SIMTIME << "ID: " << getDescription() << " minVehicleLength=" << minimalVehicleLength << std::endl;
180 #endif
181 }
182 
183 
184 bool
186  if ((myParent == nullptr || myParent->vehicleApplies(veh)) && (
187  getLane() == nullptr || !veh.isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane())) {
188 #ifdef HAVE_FOX
189  ScopedLocker<> lock(myNotificationMutex, MSGlobals::gNumSimThreads > 1);
190 #endif
192  removeFromVehicleUpdateValues(veh);
193  }
194  if (reason == MSMoveReminder::NOTIFICATION_ARRIVED) {
195  ++nVehArrived;
196  } else if (reason == MSMoveReminder::NOTIFICATION_LANE_CHANGE) {
197  ++nVehLaneChangeFrom;
198  } else if (myParent == nullptr || reason != MSMoveReminder::NOTIFICATION_SEGMENT) {
199  ++nVehLeft;
201  ++nVehTeleported;
203  ++nVehVaporized;
204  }
205  }
206  }
208  return false;
209  }
210  return reason == MSMoveReminder::NOTIFICATION_JUNCTION;
211 }
212 
213 
214 bool
216 #ifdef DEBUG_NOTIFY_ENTER
217  std::cout << "\n" << SIMTIME << " MSMeanData_Net::MSLaneMeanDataValues: veh '" << veh.getID() << "' enters lane '" << enteredLane->getID() << "'" << std::endl;
218 #else
219  UNUSED_PARAMETER(enteredLane);
220 #endif
221  if (myParent == nullptr || myParent->vehicleApplies(veh)) {
222  if (getLane() == nullptr || !veh.isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane()) {
223 #ifdef HAVE_FOX
224  ScopedLocker<> lock(myNotificationMutex, MSGlobals::gNumSimThreads > 1);
225 #endif
227  ++nVehDeparted;
228  } else if (reason == MSMoveReminder::NOTIFICATION_LANE_CHANGE) {
229  ++nVehLaneChangeTo;
230  } else if (myParent == nullptr || reason != MSMoveReminder::NOTIFICATION_SEGMENT) {
231  ++nVehEntered;
232  }
233  }
234  return true;
235  }
236  return false;
237 }
238 
239 
240 bool
242  return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0
243  && nVehLeft == 0 && nVehVaporized == 0 && nVehTeleported == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
244 }
245 
246 double
248  return occupationSum / STEPS2TIME(period) / myLaneLength / (double)numLanes * 100.;
249 }
250 
251 void
252 MSMeanData_Net::MSLaneMeanDataValues::write(OutputDevice& dev, long long int attributeMask, const SUMOTime period,
253  const int numLanes, const double speedLimit, const double defaultTravelTime, const int numVehicles) const {
254 
255  double density = sampleSeconds / STEPS2TIME(period) * 1000. / myLaneLength;
257  // avoid exceeding upper bound
258  density = MIN2(density, 1000 * (double)numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
259  }
260  const double laneDensity = density / (double)numLanes;
261  const double occupancy = getOccupancy(period, numLanes);
262 #ifdef DEBUG_OCCUPANCY2
263  // tests #3264
264  if (occupancy > 100) {
265  std::cout << SIMTIME << " Encountered bad occupancy: " << occupancy
266  << ", myLaneLength=" << myLaneLength << ", period=" << STEPS2TIME(period) << ", occupationSum=" << occupationSum
267  << std::endl;
268  }
269  // refs #3265
270  std::cout << SIMTIME << "ID: " << getDescription() << " minVehicleLength=" << minimalVehicleLength
271  << "\ndensity=" << density << "\n";
272 #endif
273 
274  if (myParent == nullptr) {
275  if (sampleSeconds > 0) {
276  dev.writeOptionalAttr(SUMO_ATTR_DENSITY, density, attributeMask);
277  dev.writeOptionalAttr(SUMO_ATTR_LANEDENSITY, laneDensity, attributeMask);
278  dev.writeOptionalAttr(SUMO_ATTR_OCCUPANCY, occupancy, attributeMask);
279  dev.writeOptionalAttr(SUMO_ATTR_WAITINGTIME, waitSeconds, attributeMask);
280  dev.writeOptionalAttr(SUMO_ATTR_TIMELOSS, timeLoss, attributeMask);
281  dev.writeOptionalAttr(SUMO_ATTR_SPEED, travelledDistance / sampleSeconds, attributeMask);
282  dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit, attributeMask);
283  }
284  dev.writeOptionalAttr(SUMO_ATTR_DEPARTED, nVehDeparted, attributeMask);
285  dev.writeOptionalAttr(SUMO_ATTR_ARRIVED, nVehArrived, attributeMask);
286  dev.writeOptionalAttr(SUMO_ATTR_ENTERED, nVehEntered, attributeMask);
287  dev.writeOptionalAttr(SUMO_ATTR_LEFT, nVehLeft, attributeMask);
288  if (nVehVaporized > 0) {
289  dev.writeOptionalAttr(SUMO_ATTR_VAPORIZED, nVehVaporized, attributeMask);
290  }
291  if (nVehTeleported > 0) {
292  dev.writeOptionalAttr(SUMO_ATTR_TELEPORTED, nVehTeleported, attributeMask);
293  }
294  dev.closeTag();
295  return;
296  }
297  if (sampleSeconds > myParent->myMinSamples) {
298  double overlapTraveltime = myParent->myMaxTravelTime;
299  if (travelledDistance > 0.f) {
300  // one vehicle has to drive lane length + vehicle length before it has left the lane
301  // thus we need to scale with an extended length, approximated by lane length + average vehicle length
302  overlapTraveltime = MIN2(overlapTraveltime, (myLaneLength + vehLengthSum / sampleSeconds) * sampleSeconds / travelledDistance);
303  }
304  if (numVehicles > 0) {
305  dev.writeOptionalAttr(SUMO_ATTR_TRAVELTIME, sampleSeconds / numVehicles, attributeMask);
306  dev.writeOptionalAttr(SUMO_ATTR_WAITINGTIME, waitSeconds, attributeMask);
307  dev.writeOptionalAttr(SUMO_ATTR_TIMELOSS, timeLoss, attributeMask);
308  dev.writeOptionalAttr(SUMO_ATTR_SPEED, travelledDistance / sampleSeconds, attributeMask);
309  dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit, attributeMask);
310  } else {
311  double traveltime = myParent->myMaxTravelTime;
312  if (frontTravelledDistance > NUMERICAL_EPS) {
313  traveltime = MIN2(traveltime, myLaneLength * frontSampleSeconds / frontTravelledDistance);
314  dev.writeOptionalAttr(SUMO_ATTR_TRAVELTIME, traveltime, attributeMask);
315  } else if (defaultTravelTime >= 0.) {
316  dev.writeOptionalAttr(SUMO_ATTR_TRAVELTIME, defaultTravelTime, attributeMask);
317  }
318  dev.writeOptionalAttr(SUMO_ATTR_OVERLAPTRAVELTIME, overlapTraveltime, attributeMask);
319  dev.writeOptionalAttr(SUMO_ATTR_DENSITY, density, attributeMask);
320  dev.writeOptionalAttr(SUMO_ATTR_LANEDENSITY, laneDensity, attributeMask);
321  dev.writeOptionalAttr(SUMO_ATTR_OCCUPANCY, occupancy, attributeMask);
322  dev.writeOptionalAttr(SUMO_ATTR_WAITINGTIME, waitSeconds, attributeMask);
323  dev.writeOptionalAttr(SUMO_ATTR_TIMELOSS, timeLoss, attributeMask);
324  dev.writeOptionalAttr(SUMO_ATTR_SPEED, travelledDistance / sampleSeconds, attributeMask);
325  dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit, attributeMask);
326  }
327  } else if (defaultTravelTime >= 0.) {
328  dev.writeOptionalAttr(SUMO_ATTR_TRAVELTIME, defaultTravelTime, attributeMask);
329  dev.writeOptionalAttr(SUMO_ATTR_SPEED, myLaneLength / defaultTravelTime, attributeMask);
330  dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. ? 0. : myLaneLength / defaultTravelTime / speedLimit, attributeMask);
331  }
332  dev.writeOptionalAttr(SUMO_ATTR_DEPARTED, nVehDeparted, attributeMask);
333  dev.writeOptionalAttr(SUMO_ATTR_ARRIVED, nVehArrived, attributeMask);
334  dev.writeOptionalAttr(SUMO_ATTR_ENTERED, nVehEntered, attributeMask);
335  dev.writeOptionalAttr(SUMO_ATTR_LEFT, nVehLeft, attributeMask);
336  dev.writeOptionalAttr(SUMO_ATTR_LANECHANGEDFROM, nVehLaneChangeFrom, attributeMask);
337  dev.writeOptionalAttr(SUMO_ATTR_LANECHANGEDTO, nVehLaneChangeTo, attributeMask);
338  if (nVehVaporized > 0) {
339  dev.writeOptionalAttr(SUMO_ATTR_VAPORIZED, nVehVaporized, attributeMask);
340  }
341  if (nVehTeleported > 0) {
342  dev.writeOptionalAttr(SUMO_ATTR_TELEPORTED, nVehTeleported, attributeMask);
343  }
344  dev.closeTag();
345 }
346 
347 
348 double
350  const SUMOTime period, const double numLanes, const double speedLimit) const {
352  switch (a) {
353  case SUMO_ATTR_DENSITY:
354  return MIN2(sampleSeconds / STEPS2TIME(period) * (double) 1000 / myLaneLength,
355  1000. * numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
356  case SUMO_ATTR_LANEDENSITY: {
357  const double density = MIN2(sampleSeconds / STEPS2TIME(period) * (double) 1000 / myLaneLength,
358  1000. * numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
359  return density / numLanes;
360  }
361  case SUMO_ATTR_OCCUPANCY:
362  return occupationSum / STEPS2TIME(period) / myLaneLength / numLanes * (double) 1000;
364  return waitSeconds;
365  case SUMO_ATTR_TIMELOSS:
366  return timeLoss;
367  case SUMO_ATTR_SPEED:
368  return travelledDistance / sampleSeconds;
369  case SUMO_ATTR_SPEEDREL:
370  return speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit;
371  case SUMO_ATTR_DEPARTED:
372  return nVehDeparted;
373  case SUMO_ATTR_ARRIVED:
374  return nVehArrived;
375  case SUMO_ATTR_ENTERED:
376  return nVehEntered;
377  case SUMO_ATTR_LEFT:
378  return nVehLeft;
379  case SUMO_ATTR_VAPORIZED:
380  return nVehVaporized;
382  return nVehTeleported;
383  default:
384  return 0;
385  }
386 }
387 
388 // ---------------------------------------------------------------------------
389 // MSMeanData_Net - methods
390 // ---------------------------------------------------------------------------
391 MSMeanData_Net::MSMeanData_Net(const std::string& id,
392  const SUMOTime dumpBegin,
393  const SUMOTime dumpEnd, const bool useLanes,
394  const bool withEmpty, const bool printDefaults,
395  const bool withInternal,
396  const bool trackVehicles,
397  const int detectPersons,
398  const double maxTravelTime,
399  const double minSamples,
400  const double haltSpeed,
401  const std::string& vTypes,
402  const std::string& writeAttributes,
403  const std::vector<MSEdge*>& edges,
404  bool aggregate) :
405  MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
406  withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate),
407  myHaltSpeed(haltSpeed)
408 { }
409 
410 
412 
413 
415 MSMeanData_Net::createValues(MSLane* const lane, const double length, const bool doAdd) const {
416  return new MSLaneMeanDataValues(lane, length, doAdd, this);
417 }
418 
419 
420 std::vector<std::string>
422  std::vector<std::string> result;
423  result.push_back(toString(SUMO_ATTR_DENSITY));
424  result.push_back(toString(SUMO_ATTR_LANEDENSITY));
425  result.push_back(toString(SUMO_ATTR_OCCUPANCY));
426  result.push_back(toString(SUMO_ATTR_WAITINGTIME));
427  result.push_back(toString(SUMO_ATTR_TIMELOSS));
428  result.push_back(toString(SUMO_ATTR_SPEED));
429  result.push_back(toString(SUMO_ATTR_SPEEDREL));
430  result.push_back(toString(SUMO_ATTR_DEPARTED));
431  result.push_back(toString(SUMO_ATTR_ARRIVED));
432  result.push_back(toString(SUMO_ATTR_ENTERED));
433  result.push_back(toString(SUMO_ATTR_LEFT));
434  result.push_back(toString(SUMO_ATTR_VAPORIZED));
435  result.push_back(toString(SUMO_ATTR_TELEPORTED));
436  return result;
437 }
438 
439 
440 double
441 MSMeanData_Net::getAttributeValue(const MSLane* lane, SumoXMLAttr a, double defaultValue) const {
442  double result = defaultValue;
443  const std::vector<MeanDataValues*>* edgeValues = getEdgeValues(&lane->getEdge());
444  if (edgeValues == nullptr) {
445  return result;
446  }
447  MeanDataValues* values = nullptr;
448  if (!myAmEdgeBased) {
449  values = (*edgeValues)[lane->getIndex()];
450  } else {
451  MeanDataValues* sumData = createValues(nullptr, lane->getLength(), false);
452  for (MeanDataValues* meanData : (*edgeValues)) {
453  meanData->addTo(*sumData);
454  }
455  values = sumData;
456  }
457  const SUMOTime myLastResetTime = 0; // XXX store last reset time
458  const SUMOTime period = SIMSTEP - myLastResetTime;
459  result = values->getAttributeValue(a, period, lane->getEdge().getNumLanes(), lane->getSpeedLimit());
460  if (myAmEdgeBased) {
461  delete values;
462  }
463  return result;
464 }
465 
466 
467 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
#define DEBUG_COND2(obj)
Definition: MESegment.cpp:52
#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:1118
static bool gUseMesoSim
Definition: MSGlobals.h:103
static double gLateralResolution
Definition: MSGlobals.h:97
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