46 #define DEBUG_COND (false)
60 nVehDeparted(0), nVehArrived(0), nVehEntered(0), nVehLeft(0),
61 nVehVaporized(0), waitSeconds(0),
62 nVehLaneChangeFrom(0), nVehLaneChangeTo(0),
63 frontSampleSeconds(0), frontTravelledDistance(0),
64 vehLengthSum(0), occupationSum(0),
80 nVehLaneChangeFrom = 0;
83 travelledDistance = 0;
85 frontSampleSeconds = 0;
86 frontTravelledDistance = 0;
121 const double timeOnLane,
const double ,
122 const double meanSpeedVehicleOnLane,
123 const double travelledDistanceFrontOnLane,
124 const double travelledDistanceVehicleOnLane,
125 const double meanLengthOnLane) {
126 #ifdef DEBUG_OCCUPANCY
128 std::cout <<
SIMTIME <<
"\n MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal()\n"
129 <<
" veh '" << veh.
getID() <<
"' on lane '" << veh.getLane()->
getID() <<
"'"
130 <<
", timeOnLane=" << timeOnLane
131 <<
", meanSpeedVehicleOnLane=" << meanSpeedVehicleOnLane
132 <<
",\ntravelledDistanceFrontOnLane=" << travelledDistanceFrontOnLane
133 <<
", travelledDistanceVehicleOnLane=" << travelledDistanceVehicleOnLane
134 <<
", meanLengthOnLane=" << meanLengthOnLane
138 if (myParent !=
nullptr && !myParent->vehicleApplies(veh)) {
141 sampleSeconds += timeOnLane;
142 travelledDistance += travelledDistanceVehicleOnLane;
152 occupationSum += meanLengthOnLane *
TS;
154 if (myParent !=
nullptr && meanSpeedVehicleOnLane < myParent->
myHaltSpeed) {
155 waitSeconds += timeOnLane;
157 frontSampleSeconds += frontOnLane;
158 frontTravelledDistance += travelledDistanceFrontOnLane;
164 #ifdef DEBUG_OCCUPANCY2
166 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength << std::endl;
173 if ((myParent ==
nullptr || myParent->vehicleApplies(veh)) && (
174 getLane() ==
nullptr || !veh.
isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane())) {
176 removeFromVehicleUpdateValues(veh);
181 ++nVehLaneChangeFrom;
198 #ifdef DEBUG_NOTIFY_ENTER
199 std::cout <<
"\n" <<
SIMTIME <<
" MSMeanData_Net::MSLaneMeanDataValues: veh '" << veh.
getID() <<
"' enters lane '" << enteredLane->
getID() <<
"'" << std::endl;
203 if (myParent ==
nullptr || myParent->vehicleApplies(veh)) {
204 if (getLane() ==
nullptr || !veh.
isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane()) {
221 return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0
222 && nVehLeft == 0 && nVehVaporized == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
228 const double numLanes,
const double defaultTravelTime,
const int numVehicles)
const {
230 #ifdef DEBUG_OCCUPANCY2
232 double occupancy = occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (double) 100;
233 if (occupancy > 100) {
234 std::cout <<
SIMTIME <<
" Encountered bad occupancy: " << occupancy
235 <<
", myLaneLength=" << myLaneLength <<
", period=" <<
STEPS2TIME(period) <<
", occupationSum=" << occupationSum
239 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength
240 <<
"\ndensity=" <<
MIN2(sampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength, 1. /
MAX2(minimalVehicleLength,
NUMERICAL_EPS)) << std::endl;
243 if (myParent ==
nullptr) {
244 if (sampleSeconds > 0) {
246 .
writeAttr(
"occupancy", occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (
double) 100)
247 .
writeAttr(
"waitingTime", waitSeconds).
writeAttr(
"speed", travelledDistance / sampleSeconds);
250 if (nVehVaporized > 0) {
251 dev.
writeAttr(
"vaporized", nVehVaporized);
256 if (sampleSeconds > myParent->myMinSamples) {
257 double overlapTraveltime = myParent->myMaxTravelTime;
258 if (travelledDistance > 0.f) {
261 overlapTraveltime =
MIN2(overlapTraveltime, (myLaneLength + vehLengthSum / sampleSeconds) * sampleSeconds / travelledDistance);
263 if (numVehicles > 0) {
264 dev.
writeAttr(
"traveltime", sampleSeconds / numVehicles).
writeAttr(
"waitingTime", waitSeconds).
writeAttr(
"speed", travelledDistance / sampleSeconds);
266 double traveltime = myParent->myMaxTravelTime;
268 traveltime =
MIN2(traveltime, myLaneLength * frontSampleSeconds / frontTravelledDistance);
270 }
else if (defaultTravelTime >= 0.) {
271 dev.
writeAttr(
"traveltime", defaultTravelTime);
273 dev.
writeAttr(
"overlapTraveltime", overlapTraveltime)
275 .
writeAttr(
"occupancy", occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (
double) 100)
276 .
writeAttr(
"waitingTime", waitSeconds).
writeAttr(
"speed", travelledDistance / sampleSeconds);
278 }
else if (defaultTravelTime >= 0.) {
279 dev.
writeAttr(
"traveltime", defaultTravelTime).
writeAttr(
"speed", myLaneLength / defaultTravelTime);
282 .
writeAttr(
"laneChangedFrom", nVehLaneChangeFrom).
writeAttr(
"laneChangedTo", nVehLaneChangeTo);
283 if (nVehVaporized > 0) {
284 dev.
writeAttr(
"vaporized", nVehVaporized);
294 const SUMOTime dumpEnd,
const bool useLanes,
295 const bool withEmpty,
const bool printDefaults,
296 const bool withInternal,
297 const bool trackVehicles,
299 const double maxTravelTime,
300 const double minSamples,
301 const double haltSpeed,
302 const std::string& vTypes)
303 :
MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
304 withInternal, trackVehicles,
detectPersons, maxTravelTime, minSamples, vTypes),