47#define DEBUG_COND (false)
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),
82 nVehLaneChangeFrom = 0;
85 travelledDistance = 0;
88 frontSampleSeconds = 0;
89 frontTravelledDistance = 0;
126 const double timeOnLane,
const double ,
127 const double meanSpeedVehicleOnLane,
128 const double travelledDistanceFrontOnLane,
129 const double travelledDistanceVehicleOnLane,
130 const double meanLengthOnLane) {
131#ifdef DEBUG_OCCUPANCY
133 std::cout <<
SIMTIME <<
"\n MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal()\n"
135 <<
", timeOnLane=" << timeOnLane
136 <<
", meanSpeedVehicleOnLane=" << meanSpeedVehicleOnLane
137 <<
",\ntravelledDistanceFrontOnLane=" << travelledDistanceFrontOnLane
138 <<
", travelledDistanceVehicleOnLane=" << travelledDistanceVehicleOnLane
139 <<
", meanLengthOnLane=" << meanLengthOnLane
143 if (myParent !=
nullptr && !myParent->vehicleApplies(veh)) {
146 sampleSeconds += timeOnLane;
147 travelledDistance += travelledDistanceVehicleOnLane;
157 occupationSum += meanLengthOnLane *
TS;
160 if (myParent !=
nullptr && meanSpeedVehicleOnLane < myParent->
myHaltSpeed) {
161 waitSeconds += timeOnLane;
165 timeLoss += timeOnLane *
MAX2(0.0, vmax - meanSpeedVehicleOnLane) / vmax;
168 frontSampleSeconds += frontOnLane;
169 frontTravelledDistance += travelledDistanceFrontOnLane;
175#ifdef DEBUG_OCCUPANCY2
177 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength << std::endl;
184 if ((myParent ==
nullptr || myParent->vehicleApplies(veh)) && (
185 getLane() ==
nullptr || !veh.
isVehicle() || getLane() ==
static_cast<MSVehicle&
>(veh).getLane())) {
190 removeFromVehicleUpdateValues(veh);
195 ++nVehLaneChangeFrom;
214#ifdef DEBUG_NOTIFY_ENTER
215 std::cout <<
"\n" <<
SIMTIME <<
" MSMeanData_Net::MSLaneMeanDataValues: veh '" << veh.
getID() <<
"' enters lane '" << enteredLane->
getID() <<
"'" << std::endl;
219 if (myParent ==
nullptr || myParent->vehicleApplies(veh)) {
220 if (getLane() ==
nullptr || !veh.
isVehicle() || getLane() ==
static_cast<MSVehicle&
>(veh).getLane()) {
240 return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0
241 && nVehLeft == 0 && nVehVaporized == 0 && nVehTeleported == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
247 const double numLanes,
const double speedLimit,
const double defaultTravelTime,
const int numVehicles)
const {
249 const double density =
MIN2(sampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength,
250 1000. * numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
251 const double laneDensity = density / numLanes;
252#ifdef DEBUG_OCCUPANCY2
254 double occupancy = occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (double) 100;
255 if (occupancy > 100) {
256 std::cout <<
SIMTIME <<
" Encountered bad occupancy: " << occupancy
257 <<
", myLaneLength=" << myLaneLength <<
", period=" <<
STEPS2TIME(period) <<
", occupationSum=" << occupationSum
261 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength
262 <<
"\ndensity=" << density <<
"\n";
265 if (myParent ==
nullptr) {
266 if (sampleSeconds > 0) {
279 if (nVehVaporized > 0) {
282 if (nVehTeleported > 0) {
288 if (sampleSeconds > myParent->myMinSamples) {
289 double overlapTraveltime = myParent->myMaxTravelTime;
290 if (travelledDistance > 0.f) {
293 overlapTraveltime =
MIN2(overlapTraveltime, (myLaneLength + vehLengthSum / sampleSeconds) * sampleSeconds / travelledDistance);
295 if (numVehicles > 0) {
302 double traveltime = myParent->myMaxTravelTime;
303 if (frontTravelledDistance > NUMERICAL_EPS) {
304 traveltime =
MIN2(traveltime, myLaneLength * frontSampleSeconds / frontTravelledDistance);
306 }
else if (defaultTravelTime >= 0.) {
318 }
else if (defaultTravelTime >= 0.) {
329 if (nVehVaporized > 0) {
332 if (nVehTeleported > 0) {
341 const SUMOTime period,
const double numLanes,
const double speedLimit)
const {
345 return MIN2(sampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength,
346 1000. * numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
348 const double density =
MIN2(sampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength,
349 1000. * numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
350 return density / numLanes;
353 return occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (double) 1000;
359 return travelledDistance / sampleSeconds;
361 return speedLimit == 0. ? 0. : travelledDistance / sampleSeconds / speedLimit;
371 return nVehVaporized;
373 return nVehTeleported;
384 const SUMOTime dumpEnd,
const bool useLanes,
385 const bool withEmpty,
const bool printDefaults,
386 const bool withInternal,
387 const bool trackVehicles,
389 const double maxTravelTime,
390 const double minSamples,
391 const double haltSpeed,
392 const std::string& vTypes,
393 const std::string& writeAttributes,
394 const std::vector<MSEdge*>& edges,
396 MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
397 withInternal, trackVehicles,
detectPersons, maxTravelTime, minSamples, vTypes, writeAttributes, edges, aggregate),
411std::vector<std::string>
413 std::vector<std::string> result;
433 double result = defaultValue;
435 if (edgeValues ==
nullptr) {
440 values = (*edgeValues)[lane->
getIndex()];
444 meanData->addTo(*sumData);
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_OVERLAPTRAVELTIME
@ SUMO_ATTR_LANECHANGEDFROM
@ SUMO_ATTR_LANECHANGEDTO
const double INVALID_DOUBLE
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool detectPersons() const
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
static int gNumSimThreads
how many threads to use for simulation
Representation of a lane in the micro simulation.
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
double getLength() const
Returns the lane's length.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
int getIndex() const
Returns the lane's index.
MSEdge & getEdge() const
Returns the lane's edge.
Data structure for mean (aggregated) edge/lane values.
double travelledDistance
The sum of the distances the vehicles travelled.
virtual double getAttributeValue(SumoXMLAttr a, const SUMOTime period, const double numLanes, const double speedLimit) const
return attribute value
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,...
bool isEmpty() const
Returns whether any data was collected.
void write(OutputDevice &dev, long long int attributeMask, const SUMOTime period, const double numLanes, const double speedLimit, const double defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
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.
const bool myAmEdgeBased
Information whether the output shall be edge-based (not lane-based)
const std::vector< MeanDataValues * > * getEdgeValues(const MSEdge *edge) const
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.
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.
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
OutputDevice & writeOptionalAttr(const SumoXMLAttr attr, const T &val, long long int attributeMask)
writes a named attribute unless filtered
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
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 bool isStopped() const =0
Returns whether the object is at a stop.
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
A scoped lock which only triggers on condition.