Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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
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
73
74
75void
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
98void
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 if (mySubData != nullptr) {
123 mySubData->addTo(*val.getSubData());
124 }
125}
126
127
128void
130 const SUMOTrafficObject& veh, const double frontOnLane,
131 const double timeOnLane, const double /* meanSpeedFrontOnLane */,
132 const double meanSpeedVehicleOnLane,
133 const double travelledDistanceFrontOnLane,
134 const double travelledDistanceVehicleOnLane,
135 const double meanLengthOnLane) {
136#ifdef DEBUG_OCCUPANCY
137 if (DEBUG_COND2) {
138 std::cout << SIMTIME << "\n MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal()\n"
139 << " veh '" << veh.getID() << "' on edge '" << veh.getEdge()->getID() << "'"
140 << ", timeOnLane=" << timeOnLane
141 << ", meanSpeedVehicleOnLane=" << meanSpeedVehicleOnLane
142 << ",\ntravelledDistanceFrontOnLane=" << travelledDistanceFrontOnLane
143 << ", travelledDistanceVehicleOnLane=" << travelledDistanceVehicleOnLane
144 << ", meanLengthOnLane=" << meanLengthOnLane
145 << std::endl;
146 }
147#endif
148 if (myParent != nullptr && !myParent->vehicleApplies(veh)) {
149 return;
150 }
151 sampleSeconds += timeOnLane;
152 travelledDistance += travelledDistanceVehicleOnLane;
153 vehLengthSum += veh.getVehicleType().getLength() * timeOnLane;
155 // For the mesosim case no information on whether the vehicle was occupying
156 // the lane with its whole length is available. We assume the whole length
157 // Therefore this increment is taken out with more information on the vehicle movement.
158 occupationSum += veh.getVehicleType().getLength() * timeOnLane;
159 } else {
160 // for the microsim case more elaborate calculation of the average length on the lane,
161 // is taken out in notifyMove(), refs #153
162 occupationSum += meanLengthOnLane * TS;
163 }
164 if (!veh.isStopped()) {
165 if (myParent != nullptr && (meanSpeedVehicleOnLane < myParent->myHaltSpeed
166 || (myParent->myHaltSpeedRel > 0 && meanSpeedVehicleOnLane / veh.getCurrentEdge()->getSpeedLimit(veh.getVClass()) < myParent->myHaltSpeedRel))) {
167 waitSeconds += timeOnLane;
168 } else if (MSGlobals::gUseMesoSim) {
169 waitSeconds += STEPS2TIME(veh.getWaitingTime());
170 }
171 const double vmax = veh.getLane() == nullptr ? veh.getEdge()->getVehicleMaxSpeed(&veh) : veh.getLane()->getVehicleMaxSpeed(&veh);
172 if (vmax > 0) {
173 timeLoss += timeOnLane * MAX2(0.0, vmax - meanSpeedVehicleOnLane) / vmax;
174 }
175 }
176 frontSampleSeconds += frontOnLane;
177 frontTravelledDistance += travelledDistanceFrontOnLane;
178 if (minimalVehicleLength == INVALID_DOUBLE) {
179 minimalVehicleLength = veh.getVehicleType().getLengthWithGap();
180 } else {
181 minimalVehicleLength = MIN2(minimalVehicleLength, veh.getVehicleType().getLengthWithGap());
182 }
183#ifdef DEBUG_OCCUPANCY2
184 // refs #3265
185 std::cout << SIMTIME << "ID: " << getDescription() << " minVehicleLength=" << minimalVehicleLength << std::endl;
186#endif
187}
188
189
190bool
192 if ((myParent == nullptr || myParent->vehicleApplies(veh)) && (
193 getLane() == nullptr || !veh.isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane())) {
194#ifdef HAVE_FOX
195 ScopedLocker<> lock(myNotificationMutex, MSGlobals::gNumSimThreads > 1);
196#endif
198 removeFromVehicleUpdateValues(veh);
199 }
201 ++nVehArrived;
202 } else if (reason == MSMoveReminder::NOTIFICATION_LANE_CHANGE) {
203 ++nVehLaneChangeFrom;
204 } else if (myParent == nullptr || reason != MSMoveReminder::NOTIFICATION_SEGMENT) {
205 ++nVehLeft;
207 ++nVehTeleported;
209 ++nVehVaporized;
210 }
211 }
212 }
213 if (MSGlobals::gUseMesoSim || !veh.isVehicle()) {
214 // only microsim vehicles keep the reminder until their back has fully left the edge/lane
215 return false;
216 }
218}
219
220
221bool
223#ifdef DEBUG_NOTIFY_ENTER
224 std::cout << "\n" << SIMTIME << " MSMeanData_Net::MSLaneMeanDataValues: veh '" << veh.getID() << "' enters lane '" << enteredLane->getID() << "'" << std::endl;
225#else
226 UNUSED_PARAMETER(enteredLane);
227#endif
228 if (myParent == nullptr || myParent->vehicleApplies(veh)) {
229 if (getLane() == nullptr || !veh.isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane()) {
230#ifdef HAVE_FOX
231 ScopedLocker<> lock(myNotificationMutex, MSGlobals::gNumSimThreads > 1);
232#endif
234 ++nVehDeparted;
235 } else if (reason == MSMoveReminder::NOTIFICATION_LANE_CHANGE) {
236 ++nVehLaneChangeTo;
237 } else if (myParent == nullptr || reason != MSMoveReminder::NOTIFICATION_SEGMENT) {
238 ++nVehEntered;
239 }
240 }
241 return true;
242 }
243 return false;
244}
245
246
247bool
249 return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0
250 && nVehLeft == 0 && nVehVaporized == 0 && nVehTeleported == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
251}
252
253double
255 return occupationSum / STEPS2TIME(period) / myLaneLength / (double)numLanes * 100.;
256}
257
258void
260 const int numLanes, const double speedLimit, const double defaultTravelTime, const int numVehicles) const {
261
262 double density = frontSampleSeconds / STEPS2TIME(period) * 1000. / myLaneLength;
263 double overlapDensity = sampleSeconds / STEPS2TIME(period) * 1000. / myLaneLength;
265 // avoid exceeding upper bound
266 density = MIN2(density, 1000 * (double)numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
267 overlapDensity = MIN2(overlapDensity, 1000 * (double)numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
268 }
269 const double laneDensity = density / (double)numLanes;
270 const double occupancy = getOccupancy(period, numLanes);
271#ifdef DEBUG_OCCUPANCY2
272 // tests #3264
273 if (occupancy > 100) {
274 std::cout << SIMTIME << " Encountered bad occupancy: " << occupancy
275 << ", myLaneLength=" << myLaneLength << ", period=" << STEPS2TIME(period) << ", occupationSum=" << occupationSum
276 << std::endl;
277 }
278 // refs #3265
279 std::cout << SIMTIME << "ID: " << getDescription() << " minVehicleLength=" << minimalVehicleLength
280 << "\ndensity=" << density << "\n";
281#endif
282
283 if (myParent == nullptr) {
284 const double speed = sampleSeconds == 0 ? 0. : travelledDistance / sampleSeconds;
285 const double frontSpeed = frontSampleSeconds == 0 ? 0. : frontTravelledDistance / frontSampleSeconds;
286 dev.writeOptionalAttr(SUMO_ATTR_DENSITY, density, attributeMask, sampleSeconds == 0);
287 dev.writeOptionalAttr(SUMO_ATTR_LANEDENSITY, laneDensity, attributeMask, sampleSeconds == 0);
288 dev.writeOptionalAttr(SUMO_ATTR_OCCUPANCY, occupancy, attributeMask, sampleSeconds == 0);
289 dev.writeOptionalAttr(SUMO_ATTR_WAITINGTIME, waitSeconds, attributeMask, sampleSeconds == 0);
290 dev.writeOptionalAttr(SUMO_ATTR_TIMELOSS, timeLoss, attributeMask, sampleSeconds == 0);
291 dev.writeOptionalAttr(SUMO_ATTR_SPEED, speed, attributeMask, sampleSeconds == 0);
292 dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. || sampleSeconds == 0 ? 0. : travelledDistance / sampleSeconds / speedLimit,
293 attributeMask, sampleSeconds == 0);
294 dev.writeOptionalAttr(SUMO_ATTR_DEPARTED, nVehDeparted, attributeMask);
295 dev.writeOptionalAttr(SUMO_ATTR_ARRIVED, nVehArrived, attributeMask);
296 dev.writeOptionalAttr(SUMO_ATTR_ENTERED, nVehEntered, attributeMask);
297 dev.writeOptionalAttr(SUMO_ATTR_LEFT, nVehLeft, attributeMask);
298 dev.writeOptionalAttr(SUMO_ATTR_VAPORIZED, nVehVaporized, attributeMask, nVehVaporized == 0);
299 dev.writeOptionalAttr(SUMO_ATTR_TELEPORTED, nVehTeleported, attributeMask, nVehTeleported == 0);
300 dev.writeOptionalAttr(SUMO_ATTR_FLOW, density * frontSpeed * 3.6, attributeMask, frontSampleSeconds == 0);
301 dev.writeOptionalAttr(SUMO_ATTR_DISTANCE, frontTravelledDistance, attributeMask);
302 dev.closeTag();
303 return;
304 }
305 const bool haveSamples = sampleSeconds > myParent->myMinSamples;
306 const bool haveFrontSamples = frontSampleSeconds > myParent->myMinSamples;
307 const bool haveSamplesOrDefault = haveSamples || defaultTravelTime >= 0.;
308 bool haveTravelTime = haveSamplesOrDefault;
309 double traveltime = myParent->myMaxTravelTime;
310 if (haveSamples) {
311 if (numVehicles > 0) {
312 traveltime = sampleSeconds / numVehicles;
313 } else {
314 traveltime = myParent->myMaxTravelTime;
315 if (frontTravelledDistance > NUMERICAL_EPS) {
316 traveltime = MIN2(traveltime, myLaneLength * frontSampleSeconds / frontTravelledDistance);
317 } else if (defaultTravelTime >= 0.) {
318 traveltime = defaultTravelTime;
319 } else {
320 haveTravelTime = false;
321 }
322 }
323 } else if (defaultTravelTime >= 0.) {
324 traveltime = defaultTravelTime;
325 }
326 dev.writeOptionalAttr(SUMO_ATTR_TRAVELTIME, traveltime, attributeMask, !haveTravelTime);
327 double overlapTraveltime = myParent->myMaxTravelTime;
328 if (travelledDistance > 0.) {
329 // one vehicle has to drive lane length + vehicle length before it has left the lane
330 // thus we need to scale with an extended length, approximated by lane length + average vehicle length
331 overlapTraveltime = MIN2(overlapTraveltime, (myLaneLength + vehLengthSum / sampleSeconds) * sampleSeconds / travelledDistance);
332 }
333 dev.writeOptionalAttr(SUMO_ATTR_OVERLAPTRAVELTIME, overlapTraveltime, attributeMask, !haveSamples || numVehicles > 0);
334 dev.writeOptionalAttr(SUMO_ATTR_DENSITY, density, attributeMask, !haveSamples || numVehicles > 0);
335 dev.writeOptionalAttr(SUMO_ATTR_OVERLAPDENSITY, overlapDensity, attributeMask, sampleSeconds == 0);
336 dev.writeOptionalAttr(SUMO_ATTR_LANEDENSITY, laneDensity, attributeMask, !haveSamples || numVehicles > 0);
337 dev.writeOptionalAttr(SUMO_ATTR_OCCUPANCY, occupancy, attributeMask, !haveSamples || numVehicles > 0);
338 dev.writeOptionalAttr(SUMO_ATTR_WAITINGTIME, waitSeconds, attributeMask, !haveSamples);
339 dev.writeOptionalAttr(SUMO_ATTR_TIMELOSS, timeLoss, attributeMask, !haveSamples);
340 double speed = 0.;
341 double frontSpeed = 0.;
342 if (haveSamples) {
343 speed = travelledDistance / sampleSeconds;
344 } else if (defaultTravelTime > 0.) {
345 speed = myLaneLength / defaultTravelTime;
346 }
347 if (haveFrontSamples) {
348 frontSpeed = frontTravelledDistance / frontSampleSeconds;
349 } else if (defaultTravelTime > 0.) {
350 frontSpeed = myLaneLength / defaultTravelTime;
351 }
352 dev.writeOptionalAttr(SUMO_ATTR_SPEED, speed, attributeMask, !haveSamplesOrDefault);
353 dev.writeOptionalAttr(SUMO_ATTR_SPEEDREL, speedLimit == 0. ? 0. : speed / speedLimit, attributeMask, !haveSamplesOrDefault);
354 dev.writeOptionalAttr(SUMO_ATTR_DEPARTED, nVehDeparted, attributeMask);
355 dev.writeOptionalAttr(SUMO_ATTR_ARRIVED, nVehArrived, attributeMask);
356 dev.writeOptionalAttr(SUMO_ATTR_ENTERED, nVehEntered, attributeMask);
357 dev.writeOptionalAttr(SUMO_ATTR_LEFT, nVehLeft, attributeMask);
358 dev.writeOptionalAttr(SUMO_ATTR_LANECHANGEDFROM, nVehLaneChangeFrom, attributeMask);
359 dev.writeOptionalAttr(SUMO_ATTR_LANECHANGEDTO, nVehLaneChangeTo, attributeMask);
360 dev.writeOptionalAttr(SUMO_ATTR_VAPORIZED, nVehVaporized, attributeMask, nVehVaporized == 0);
361 dev.writeOptionalAttr(SUMO_ATTR_TELEPORTED, nVehTeleported, attributeMask, nVehTeleported == 0);
362 dev.writeOptionalAttr(SUMO_ATTR_FLOW, density * frontSpeed * 3.6, attributeMask, !haveSamples || numVehicles == 0);
363 dev.writeOptionalAttr(SUMO_ATTR_DISTANCE, frontTravelledDistance, attributeMask);
364}
365
366
367double
369 const SUMOTime period, const double numLanes, const double speedLimit) const {
371 switch (a) {
373 return MIN2(frontSampleSeconds / STEPS2TIME(period) * (double) 1000 / myLaneLength,
374 1000. * numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
376 const double density = MIN2(frontSampleSeconds / STEPS2TIME(period) * (double) 1000 / myLaneLength,
377 1000. * numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
378 return density / numLanes;
379 }
381 const double overlapDensity = MIN2(sampleSeconds / STEPS2TIME(period) * (double) 1000 / myLaneLength,
382 1000. * numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
383 return overlapDensity / numLanes;
384 }
386 return occupationSum / STEPS2TIME(period) / myLaneLength / numLanes * (double) 1000;
388 return waitSeconds;
390 return timeLoss;
391 case SUMO_ATTR_SPEED:
392 return travelledDistance / sampleSeconds;
394 return speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit;
396 return nVehDeparted;
398 return nVehArrived;
400 return nVehEntered;
401 case SUMO_ATTR_LEFT:
402 return nVehLeft;
404 return nVehVaporized;
406 return nVehTeleported;
407 case SUMO_ATTR_FLOW: {
408 const double density = MIN2(frontSampleSeconds / STEPS2TIME(period) * (double) 1000 / myLaneLength,
409 1000. * numLanes / MAX2(minimalVehicleLength, NUMERICAL_EPS));
410 const double speed = frontTravelledDistance / frontSampleSeconds;
411 return density * speed * 3.6;
412 }
414 return frontTravelledDistance;
415 default:
416 return 0;
417 }
418}
419
420
421// ---------------------------------------------------------------------------
422// MSMeanData_Net - methods
423// ---------------------------------------------------------------------------
424MSMeanData_Net::MSMeanData_Net(const std::string& id,
425 const SUMOTime dumpBegin,
426 const SUMOTime dumpEnd, const bool useLanes,
427 const std::string& excludeEmpty,
428 const bool withInternal,
429 const bool trackVehicles,
430 const int detectPersons,
431 const double maxTravelTime,
432 const double minSamples,
433 const double haltSpeed,
434 const double haltSpeedRel,
435 const std::string& vTypes,
436 const std::string& writeAttributes,
437 const std::vector<MSEdge*>& edges,
438 AggregateType aggregate) :
439 MSMeanData(id, dumpBegin, dumpEnd, useLanes, excludeEmpty,
440 withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate),
441 myHaltSpeed(haltSpeed),
442 myHaltSpeedRel(haltSpeedRel)
443{ }
444
445
447
448
450MSMeanData_Net::createValues(MSLane* const lane, const double length, const bool doAdd) const {
451 return new MSLaneMeanDataValues(lane, length, doAdd, this);
452}
453
454
455std::vector<std::string>
457 std::vector<std::string> result;
458 result.push_back(toString(SUMO_ATTR_DENSITY));
459 result.push_back(toString(SUMO_ATTR_LANEDENSITY));
460 result.push_back(toString(SUMO_ATTR_OVERLAPDENSITY));
461 result.push_back(toString(SUMO_ATTR_OCCUPANCY));
462 result.push_back(toString(SUMO_ATTR_WAITINGTIME));
463 result.push_back(toString(SUMO_ATTR_TIMELOSS));
464 result.push_back(toString(SUMO_ATTR_SPEED));
465 result.push_back(toString(SUMO_ATTR_SPEEDREL));
466 result.push_back(toString(SUMO_ATTR_DEPARTED));
467 result.push_back(toString(SUMO_ATTR_ARRIVED));
468 result.push_back(toString(SUMO_ATTR_ENTERED));
469 result.push_back(toString(SUMO_ATTR_LEFT));
470 result.push_back(toString(SUMO_ATTR_LANECHANGEDFROM));
471 result.push_back(toString(SUMO_ATTR_LANECHANGEDTO));
472 result.push_back(toString(SUMO_ATTR_VAPORIZED));
473 result.push_back(toString(SUMO_ATTR_TELEPORTED));
474 result.push_back(toString(SUMO_ATTR_FLOW));
475 result.push_back(toString(SUMO_ATTR_DISTANCE));
476 return result;
477}
478
479
480bool
482 return
483 attributeMask.test(SUMO_ATTR_DENSITY) ||
484 attributeMask.test(SUMO_ATTR_LANEDENSITY) ||
485 attributeMask.test(SUMO_ATTR_OVERLAPDENSITY) ||
486 attributeMask.test(SUMO_ATTR_OCCUPANCY) ||
487 attributeMask.test(SUMO_ATTR_WAITINGTIME) ||
488 attributeMask.test(SUMO_ATTR_TIMELOSS) ||
489 attributeMask.test(SUMO_ATTR_SPEED) ||
490 attributeMask.test(SUMO_ATTR_SPEEDREL) ||
491 attributeMask.test(SUMO_ATTR_DEPARTED) ||
492 attributeMask.test(SUMO_ATTR_ARRIVED) ||
493 attributeMask.test(SUMO_ATTR_ENTERED) ||
494 attributeMask.test(SUMO_ATTR_LEFT) ||
495 attributeMask.test(SUMO_ATTR_LANECHANGEDFROM) ||
496 attributeMask.test(SUMO_ATTR_LANECHANGEDTO) ||
497 attributeMask.test(SUMO_ATTR_VAPORIZED) ||
498 attributeMask.test(SUMO_ATTR_TELEPORTED) ||
499 attributeMask.test(SUMO_ATTR_FLOW) ||
500 attributeMask.test(SUMO_ATTR_DISTANCE);
501}
502
503
504/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define DEBUG_COND2(obj)
#define STEPS2TIME(x)
Definition SUMOTime.h:58
#define SIMSTEP
Definition SUMOTime.h:64
#define TS
Definition SUMOTime.h:45
#define SIMTIME
Definition SUMOTime.h:65
std::bitset< 96 > SumoXMLAttrMask
AggregateType
Numbers representing special SUMO-XML-attribute values Information on edgeData/laneData output should...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_FLOW
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_WAITINGTIME
@ SUMO_ATTR_OVERLAPDENSITY
@ 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_DISTANCE
@ 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:68
T MIN2(T a, T b)
Definition StdDefs.h:80
T MAX2(T a, T b)
Definition StdDefs.h:86
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
Definition MSEdge.cpp:1200
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition MSEdge.cpp:1219
static bool gUseMesoSim
Definition MSGlobals.h:106
static double gLateralResolution
Definition MSGlobals.h:100
static int gNumSimThreads
how many threads to use for simulation
Definition MSGlobals.h:149
Representation of a lane in the micro simulation.
Definition MSLane.h:84
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition MSLane.h:575
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:198
MeanDataValues * getSubData()
Definition MSMeanData.h:177
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.
void write(OutputDevice &dev, const SumoXMLAttrMask &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.
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,...
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.
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.
static bool supports(const SumoXMLAttrMask &attributeMask)
check whether any of the given attributes can be calculated by this meandata
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 myHaltSpeedRel
the minimum relative speed to consider a vehicle halting
MSMeanData_Net(const std::string &id, const SUMOTime dumpBegin, const SUMOTime dumpEnd, const bool useLanes, const std::string &excludeEmpty, const bool withInternal, const bool trackVehicles, const int detectPersons, const double maxTravelTime, const double minSamples, const double haltSpeed, const double haltSpeedRel, const std::string &vTypes, const std::string &writeAttributes, const std::vector< MSEdge * > &edges, AggregateType aggregate)
Constructor.
const double myHaltSpeed
the minimum speed to consider a vehicle halting
Data collector for edges/lanes.
Definition MSMeanData.h:57
MSMeanData * mySubData
more data collectors which write to the same output
Definition MSMeanData.h:555
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].
void addTo(const StoringVisitor &cont) const
Adds this object to the given container.
Definition Named.h:117
const std::string & getID() const
Returns the id.
Definition Named.h:73
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeOptionalAttr(const SumoXMLAttr attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute unless null
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 const MSEdge * getCurrentEdge() const =0
Returns the edge (normal or internal) the object is currently at.
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 SUMOTime getWaitingTime(const bool accumulated=false) const =0
virtual bool isStopped() const =0
Returns whether the object is at a stop.
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual const MSEdge * getEdge() const =0
Returns the (normal) route edge the object is currently at.
A scoped lock which only triggers on condition.
#define UNUSED_PARAMETER(x)