45 #define DEBUG_COND (false)
59 nVehDeparted(0), nVehArrived(0), nVehEntered(0), nVehLeft(0),
60 nVehVaporized(0), waitSeconds(0),
61 nVehLaneChangeFrom(0), nVehLaneChangeTo(0),
62 frontSampleSeconds(0), frontTravelledDistance(0),
63 vehLengthSum(0), occupationSum(0),
79 nVehLaneChangeFrom = 0;
82 travelledDistance = 0;
84 frontSampleSeconds = 0;
85 frontTravelledDistance = 0;
120 const double timeOnLane,
const double ,
121 const double meanSpeedVehicleOnLane,
122 const double travelledDistanceFrontOnLane,
123 const double travelledDistanceVehicleOnLane,
124 const double meanLengthOnLane) {
125 #ifdef DEBUG_OCCUPANCY
127 std::cout <<
SIMTIME <<
"\n MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal()\n"
128 <<
" veh '" << veh.
getID() <<
"' on lane '" << veh.getLane()->
getID() <<
"'"
129 <<
", timeOnLane=" << timeOnLane
130 <<
", meanSpeedVehicleOnLane=" << meanSpeedVehicleOnLane
131 <<
",\ntravelledDistanceFrontOnLane=" << travelledDistanceFrontOnLane
132 <<
", travelledDistanceVehicleOnLane=" << travelledDistanceVehicleOnLane
133 <<
", meanLengthOnLane=" << meanLengthOnLane
137 if (myParent !=
nullptr && !myParent->vehicleApplies(veh)) {
140 sampleSeconds += timeOnLane;
141 travelledDistance += travelledDistanceVehicleOnLane;
151 occupationSum += meanLengthOnLane *
TS;
153 if (myParent !=
nullptr && meanSpeedVehicleOnLane < myParent->
myHaltSpeed) {
154 waitSeconds += timeOnLane;
156 frontSampleSeconds += frontOnLane;
157 frontTravelledDistance += travelledDistanceFrontOnLane;
163 #ifdef DEBUG_OCCUPANCY2
165 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength << std::endl;
172 if ((myParent ==
nullptr || myParent->vehicleApplies(veh)) && (
173 getLane() ==
nullptr || !veh.
isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane())) {
178 removeFromVehicleUpdateValues(veh);
183 ++nVehLaneChangeFrom;
200 #ifdef DEBUG_NOTIFY_ENTER
201 std::cout <<
"\n" <<
SIMTIME <<
" MSMeanData_Net::MSLaneMeanDataValues: veh '" << veh.
getID() <<
"' enters lane '" << enteredLane->
getID() <<
"'" << std::endl;
205 if (myParent ==
nullptr || myParent->vehicleApplies(veh)) {
206 if (getLane() ==
nullptr || !veh.
isVehicle() || getLane() == static_cast<MSVehicle&>(veh).getLane()) {
226 return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0
227 && nVehLeft == 0 && nVehVaporized == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
233 const double numLanes,
const double defaultTravelTime,
const int numVehicles)
const {
235 #ifdef DEBUG_OCCUPANCY2
237 double occupancy = occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (double) 100;
238 if (occupancy > 100) {
239 std::cout <<
SIMTIME <<
" Encountered bad occupancy: " << occupancy
240 <<
", myLaneLength=" << myLaneLength <<
", period=" <<
STEPS2TIME(period) <<
", occupationSum=" << occupationSum
244 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength
245 <<
"\ndensity=" <<
MIN2(sampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength, 1. /
MAX2(minimalVehicleLength,
NUMERICAL_EPS)) << std::endl;
248 if (myParent ==
nullptr) {
249 if (sampleSeconds > 0) {
251 .
writeAttr(
"occupancy", occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (
double) 100)
252 .
writeAttr(
"waitingTime", waitSeconds).
writeAttr(
"speed", travelledDistance / sampleSeconds);
255 if (nVehVaporized > 0) {
256 dev.
writeAttr(
"vaporized", nVehVaporized);
261 if (sampleSeconds > myParent->myMinSamples) {
262 double overlapTraveltime = myParent->myMaxTravelTime;
263 if (travelledDistance > 0.f) {
266 overlapTraveltime =
MIN2(overlapTraveltime, (myLaneLength + vehLengthSum / sampleSeconds) * sampleSeconds / travelledDistance);
268 if (numVehicles > 0) {
269 dev.
writeAttr(
"traveltime", sampleSeconds / numVehicles).
writeAttr(
"waitingTime", waitSeconds).
writeAttr(
"speed", travelledDistance / sampleSeconds);
271 double traveltime = myParent->myMaxTravelTime;
273 traveltime =
MIN2(traveltime, myLaneLength * frontSampleSeconds / frontTravelledDistance);
275 }
else if (defaultTravelTime >= 0.) {
276 dev.
writeAttr(
"traveltime", defaultTravelTime);
278 dev.
writeAttr(
"overlapTraveltime", overlapTraveltime)
280 .
writeAttr(
"occupancy", occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (
double) 100)
281 .
writeAttr(
"waitingTime", waitSeconds).
writeAttr(
"speed", travelledDistance / sampleSeconds);
283 }
else if (defaultTravelTime >= 0.) {
284 dev.
writeAttr(
"traveltime", defaultTravelTime).
writeAttr(
"speed", myLaneLength / defaultTravelTime);
287 .
writeAttr(
"laneChangedFrom", nVehLaneChangeFrom).
writeAttr(
"laneChangedTo", nVehLaneChangeTo);
288 if (nVehVaporized > 0) {
289 dev.
writeAttr(
"vaporized", nVehVaporized);
299 const SUMOTime dumpEnd,
const bool useLanes,
300 const bool withEmpty,
const bool printDefaults,
301 const bool withInternal,
302 const bool trackVehicles,
304 const double maxTravelTime,
305 const double minSamples,
306 const double haltSpeed,
307 const std::string& vTypes)
308 :
MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
309 withInternal, trackVehicles,
detectPersons, maxTravelTime, minSamples, vTypes),