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),
83 nVehLaneChangeFrom = 0;
86 travelledDistance = 0;
89 frontSampleSeconds = 0;
90 frontTravelledDistance = 0;
131 const double timeOnLane,
const double ,
132 const double meanSpeedVehicleOnLane,
133 const double travelledDistanceFrontOnLane,
134 const double travelledDistanceVehicleOnLane,
135 const double meanLengthOnLane) {
136#ifdef DEBUG_OCCUPANCY
138 std::cout <<
SIMTIME <<
"\n MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal()\n"
140 <<
", timeOnLane=" << timeOnLane
141 <<
", meanSpeedVehicleOnLane=" << meanSpeedVehicleOnLane
142 <<
",\ntravelledDistanceFrontOnLane=" << travelledDistanceFrontOnLane
143 <<
", travelledDistanceVehicleOnLane=" << travelledDistanceVehicleOnLane
144 <<
", meanLengthOnLane=" << meanLengthOnLane
148 if (myParent !=
nullptr && !myParent->vehicleApplies(veh)) {
151 sampleSeconds += timeOnLane;
152 travelledDistance += travelledDistanceVehicleOnLane;
162 occupationSum += meanLengthOnLane *
TS;
165 if (myParent !=
nullptr && (meanSpeedVehicleOnLane < myParent->
myHaltSpeed
167 waitSeconds += timeOnLane;
173 timeLoss += timeOnLane *
MAX2(0.0, vmax - meanSpeedVehicleOnLane) / vmax;
176 frontSampleSeconds += frontOnLane;
177 frontTravelledDistance += travelledDistanceFrontOnLane;
183#ifdef DEBUG_OCCUPANCY2
185 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength << std::endl;
192 if ((myParent ==
nullptr || myParent->vehicleApplies(veh)) && (
193 getLane() ==
nullptr || !veh.
isVehicle() || getLane() ==
static_cast<MSVehicle&
>(veh).getLane())) {
198 removeFromVehicleUpdateValues(veh);
203 ++nVehLaneChangeFrom;
226#ifdef DEBUG_NOTIFY_ENTER
227 std::cout <<
"\n" <<
SIMTIME <<
" MSMeanData_Net::MSLaneMeanDataValues: veh '" << veh.
getID() <<
"' enters lane '" << enteredLane->
getID() <<
"'" << std::endl;
231 if (myParent ==
nullptr || myParent->vehicleApplies(veh)) {
232 if (getLane() ==
nullptr || !veh.
isVehicle() || getLane() ==
static_cast<MSVehicle&
>(veh).getLane()) {
253 return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0
254 && nVehLeft == 0 && nVehVaporized == 0 && nVehTeleported == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
259 return occupationSum /
STEPS2TIME(period) / myLaneLength / (double)numLanes * 100.;
264 const int numLanes,
const double speedLimit,
const double defaultTravelTime,
const int numVehicles)
const {
266 double density = frontSampleSeconds /
STEPS2TIME(period) * 1000. / myLaneLength;
267 double overlapDensity = sampleSeconds /
STEPS2TIME(period) * 1000. / myLaneLength;
270 density =
MIN2(density, 1000 * (
double)numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
271 overlapDensity =
MIN2(overlapDensity, 1000 * (
double)numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
273 const double laneDensity = density / (double)numLanes;
274 const double occupancy = getOccupancy(period, numLanes);
275#ifdef DEBUG_OCCUPANCY2
277 if (occupancy > 100) {
278 std::cout <<
SIMTIME <<
" Encountered bad occupancy: " << occupancy
279 <<
", myLaneLength=" << myLaneLength <<
", period=" <<
STEPS2TIME(period) <<
", occupationSum=" << occupationSum
283 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength
284 <<
"\ndensity=" << density <<
"\n";
287 if (myParent ==
nullptr) {
288 const double speed = sampleSeconds == 0 ? 0. : travelledDistance / sampleSeconds;
289 const double frontSpeed = frontSampleSeconds == 0 ? 0. : frontTravelledDistance / frontSampleSeconds;
297 attributeMask, sampleSeconds == 0);
309 const bool haveSamples = sampleSeconds > myParent->myMinSamples;
310 const bool haveFrontSamples = frontSampleSeconds > myParent->myMinSamples;
311 const bool haveSamplesOrDefault = haveSamples || defaultTravelTime >= 0.;
312 bool haveTravelTime = haveSamplesOrDefault;
313 double traveltime = myParent->myMaxTravelTime;
315 if (numVehicles > 0) {
316 traveltime = sampleSeconds / numVehicles;
318 traveltime = myParent->myMaxTravelTime;
319 if (frontTravelledDistance > NUMERICAL_EPS) {
320 traveltime =
MIN2(traveltime, myLaneLength * frontSampleSeconds / frontTravelledDistance);
321 }
else if (defaultTravelTime >= 0.) {
322 traveltime = defaultTravelTime;
324 haveTravelTime =
false;
327 }
else if (defaultTravelTime >= 0.) {
328 traveltime = defaultTravelTime;
331 double overlapTraveltime = myParent->myMaxTravelTime;
332 if (travelledDistance > 0.) {
335 overlapTraveltime =
MIN2(overlapTraveltime, (myLaneLength + vehLengthSum / sampleSeconds) * sampleSeconds / travelledDistance);
345 double frontSpeed = 0.;
347 speed = travelledDistance / sampleSeconds;
348 }
else if (defaultTravelTime > 0.) {
349 speed = myLaneLength / defaultTravelTime;
351 if (haveFrontSamples) {
352 frontSpeed = frontTravelledDistance / frontSampleSeconds;
353 }
else if (defaultTravelTime > 0.) {
354 frontSpeed = myLaneLength / defaultTravelTime;
373 const SUMOTime period,
const double numLanes,
const double speedLimit)
const {
377 return MIN2(frontSampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength,
378 1000. * numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
380 const double density =
MIN2(frontSampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength,
381 1000. * numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
382 return density / numLanes;
385 const double overlapDensity =
MIN2(sampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength,
386 1000. * numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
387 return overlapDensity / numLanes;
390 return occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (double) 1000;
396 return travelledDistance / sampleSeconds;
398 return speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit;
408 return nVehVaporized;
410 return nVehTeleported;
412 const double density =
MIN2(frontSampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength,
413 1000. * numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
414 const double speed = frontTravelledDistance / frontSampleSeconds;
415 return density * speed * 3.6;
418 return frontTravelledDistance;
430 const SUMOTime dumpEnd,
const bool useLanes,
431 const std::string& excludeEmpty,
432 const bool withInternal,
433 const bool trackVehicles,
434 const int detectPersons,
435 const double maxTravelTime,
436 const double minSamples,
437 const double haltSpeed,
438 const double haltSpeedRel,
439 const std::string& vTypes,
440 const std::string& writeAttributes,
441 const std::vector<MSEdge*>& edges,
443 MSMeanData(id, dumpBegin, dumpEnd, useLanes, excludeEmpty,
444 withInternal, trackVehicles, detectPersons, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate),
459std::vector<std::string>
461 std::vector<std::string> result;
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_OVERLAPDENSITY
@ SUMO_ATTR_OVERLAPTRAVELTIME
@ SUMO_ATTR_LANECHANGEDFROM
@ SUMO_ATTR_LANECHANGEDTO
const double INVALID_DOUBLE
invalid double
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is returned; should pr...
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
static double gLateralResolution
static int gNumSimThreads
how many threads to use for simulation
Representation of a lane in the micro simulation.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Data structure for mean (aggregated) edge/lane values.
double travelledDistance
The sum of the distances the vehicles travelled.
MeanDataValues * getSubData()
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.
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.
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.
MSMeanData * mySubData
more data collectors which write to the same output
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_CONTINUATION_ARRIVED
The vehicle entered this edge during teleport and was teleported out of the net.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
@ NOTIFICATION_TELEPORT_CONTINUATION
The vehicle continues being teleported past an edge.
Representation of a vehicle in the micro simulation.
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.
const std::string & getID() const
Returns the id.
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)