71 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
72 const std::string name,
const std::string& vTypes,
73 const std::string& nextEdges,
79 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
80 myJamHaltingTimeThreshold(haltingTimeThreshold),
81 myJamDistanceThreshold(jamDistThreshold) {
83#ifdef DEBUG_E2_CONSTRUCTOR
85 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id
86 <<
" with lane = " << lane->
getID()
87 <<
" startPos = " << startPos
88 <<
" endPos = " << endPos
89 <<
" length = " << length
90 <<
" haltingTimeThreshold = " << haltingTimeThreshold
91 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
92 <<
" jamDistThreshold = " << jamDistThreshold
100 bool lengthInvalid = length == std::numeric_limits<double>::max() || length <= 0;
101 bool endPosInvalid = endPos == std::numeric_limits<double>::max();
102 bool posInvalid = startPos == std::numeric_limits<double>::max();
108 WRITE_WARNING(
TL(
"No valid detector length and start position given. Assuming startPos = 0 and length = end position"));
112 WRITE_WARNING(
TL(
"No valid detector length and end position given. Assuming endPos = lane length and length = endPos-startPos"));
115 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
116 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
117 bool valid = endPos <= lane->
getLength() && 0 <= startPos && startPos < endPos;
119 throw InvalidArgument(
"Error in specification for E2Detector '" +
id +
"'. Positional argument is malformed. 0 <= pos < endPos <= lane.getLength() is required.");
123 startPos =
snap(startPos, 0., POSITION_EPS);
124 length = endPos - startPos;
125 }
else if (posInvalid) {
127 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
131 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
132 startPos =
snap(startPos, 0., POSITION_EPS);
138 std::vector<MSLane*> lanes;
141 }
else if (endPosInvalid) {
145 lanes.push_back(lane);
155 DetectorUsage usage, std::vector<MSLane*> lanes,
double startPos,
double endPos,
156 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
157 const std::string name,
const std::string& vTypes,
158 const std::string& nextEdges,
164 myFirstLane(lanes[0]),
165 myLastLane(lanes[lanes.size() - 1]),
166 myStartPos(startPos),
168 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
169 myJamHaltingTimeThreshold(haltingTimeThreshold),
170 myJamDistanceThreshold(jamDistThreshold) {
172 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
176#ifdef DEBUG_E2_CONSTRUCTOR
178 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id
180 <<
" endPos = " << endPos
182 <<
" startPos = " << startPos
183 <<
" haltingTimeThreshold = " << haltingTimeThreshold
184 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
185 <<
" jamDistThreshold = " << jamDistThreshold
196 if (
myEndPos > lanes[lanes.size() - 1]->getLength() - POSITION_EPS) {
197 myEndPos = lanes[lanes.size() - 1]->getLength();
210 if (desiredLength > 0 &&
myDetectorLength < desiredLength - NUMERICAL_EPS) {
211 std::stringstream ss;
212 ss <<
"Cannot build detector of length " << desiredLength
227 WRITE_WARNING(
"Adjusted detector positioning to meet requirement length >= " +
toString(POSITION_EPS)
240#ifdef DEBUG_E2_CONSTRUCTOR
242 std::stringstream ss;
245 std::cout <<
"myStartPos = " <<
myStartPos << std::endl;
246 std::cout <<
"myEndPos = " <<
myEndPos << std::endl;
260 if (fabs(value - snapPoint) < snapDist) {
270 std::vector<std::string>::const_iterator i;
271 std::vector<MSLane*> lanes;
275 lanes.push_back(lane);
279 std::vector<MSLane*>::const_iterator j;
280 MSLane* previous =
nullptr;
282 for (j = lanes.begin(); j != lanes.end(); ++j) {
295#ifdef DEBUG_E2_CONSTRUCTOR
297 std::cout <<
"Total detector length after recalculation = " <<
myDetectorLength << std::endl;
312 assert(dir ==
"fw" || dir ==
"bw");
313 bool fw = dir ==
"fw";
314 double linkLength = 0;
315 bool subtractedLinkLength =
false;
317#ifdef DEBUG_E2_CONSTRUCTOR
319 std::cout <<
"\n" <<
"selectLanes()" << (fw ?
"(forward)" :
"(backward)") << std::endl;
322 std::vector<MSLane*> lanes;
328 assert(
myStartPos != std::numeric_limits<double>::max());
331 assert(
myEndPos != std::numeric_limits<double>::max());
334 length =
MAX2(POSITION_EPS, length);
335 while (length >= POSITION_EPS && lane !=
nullptr) {
338 lanes.push_back(lane);
339#ifdef DEBUG_E2_CONSTRUCTOR
341 std::cout <<
"Added lane " << lane->
getID()
342 <<
" (length: " << lane->
getLength() <<
")" << std::endl;
356 subtractedLinkLength =
false;
366 length -= linkLength;
367 subtractedLinkLength =
true;
371#ifdef DEBUG_E2_CONSTRUCTOR
374 std::cout << (fw ?
"Successor lane: " :
"Predecessor lane: ") <<
"'" << lane->
getID() <<
"'";
376 std::cout << std::endl;
381 if (subtractedLinkLength) {
385 length += linkLength;
398 if (length > -POSITION_EPS) {
399 myEndPos = lanes[lanes.size() - 1]->getLength();
400 }
else if (length < 0) {
401 myEndPos = lanes[lanes.size() - 1]->getLength() + length;
404 if (length > -POSITION_EPS) {
406 }
else if (length < 0) {
413 std::reverse(lanes.begin(), lanes.end());
421#ifdef DEBUG_E2_CONSTRUCTOR
423 std::cout <<
"\n" <<
"Adding detector " <<
myID <<
" to lanes:" << std::endl;
426 for (std::vector<MSLane*>::iterator l = lanes.begin(); l != lanes.end(); ++l) {
427 (*l)->addMoveReminder(
this);
428#ifdef DEBUG_E2_CONSTRUCTOR
430 std::cout << (*l)->getID() << std::endl;
442#ifdef DEBUG_E2_CONSTRUCTOR
444 std::cout <<
"\n" <<
"Initializing auxiliaries:"
464 std::vector<MSLane*>::iterator il = lanes.begin();
471#ifdef DEBUG_E2_CONSTRUCTOR
473 std::cout <<
"\n" <<
"Initializing offsets:" << std::endl;
479 while (internal !=
nullptr) {
483#ifdef DEBUG_E2_CONSTRUCTOR
498 internal = internal->
getLinkCont()[0]->getViaLaneOrLane();
511 while (il != lanes.end() && (*il)->isInternal()) {
514 if (il == lanes.end()) {
522#ifdef DEBUG_E2_CONSTRUCTOR
536 if (++il == lanes.end()) {
540 if ((*il)->isInternal()) {
548 if (link ==
nullptr) {
549 throw InvalidArgument(
"Lanes '" + lane->
getID() +
"' and '" + (*il)->getID() +
"' are not consecutive in definition of e2Detector '" +
getID() +
"'");
560 bool fw =
myEndPos == std::numeric_limits<double>::max();
567#ifdef DEBUG_E2_CONSTRUCTOR
569 std::cout <<
"Total detector length after initAuxiliaries() = " <<
myDetectorLength << std::endl;
580 std::vector<MSLane*> res;
581 for (std::vector<std::string>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
590 double newPos,
double newSpeed) {
596 keep =
notifyMove(*p, oldPos, newPos, newSpeed);
605 const std::string objectType = veh.
isPerson() ?
"Person" :
"Vehicle";
614 const std::string& vehID = veh.
getID();
623#ifdef DEBUG_E2_NOTIFY_MOVE
626 <<
" MSE2Collector::notifyMove() (detID = " <<
myID <<
" on lane '" <<
myLane->
getID() <<
"')"
627 <<
" called by vehicle '" << vehID <<
"'"
628 <<
" at relative position " << relPos
636#ifdef DEBUG_E2_NOTIFY_MOVE
638 std::cout <<
"Vehicle has not yet reached the detector start position." << std::endl;
655 if (vehicleEnteredLaneAfterDetector) {
656#ifdef DEBUG_E2_NOTIFY_MOVE
658 std::cout <<
"Vehicle entered lane behind detector." << std::endl;
666 if (vehPassedDetectorEnd) {
667#ifdef DEBUG_E2_NOTIFY_MOVE
669 std::cout <<
"Vehicle has left the detector longitudinally." << std::endl;
683#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
685 std::cout <<
"\n" <<
SIMTIME <<
" notifyLeave() (detID = " <<
myID <<
" on lane '" <<
myLane->
getID() <<
"')"
686 <<
"called by vehicle '" << veh.
getID() <<
"'" << std::endl;
696#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
698 std::cout <<
SIMTIME <<
" Left longitudinally (along junction) -> keep subscription [handle exit in notifyMove()]" << std::endl;
706 double exitOffset = vi->second->entryOffset -
myOffsets[vi->second->currentOffsetIndex] - vi->second->currentLane->getLength();
707 vi->second->exitOffset =
MAX2(vi->second->exitOffset, exitOffset);
708#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
710 std::cout <<
SIMTIME <<
" Vehicle '" << veh.
getID() <<
"' leaves the detector. Exit offset = " << vi->second->exitOffset << std::endl;
720 if (vi->second->hasEntered) {
725#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
727 std::cout <<
SIMTIME <<
" Left non-longitudinally (lanechange, teleport, parking, etc) -> discard subscription" << std::endl;
740#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
742 std::cout << std::endl <<
SIMTIME <<
" notifyEnter() (detID = " <<
myID <<
" on lane '" <<
myLane->
getID() <<
"')"
743 <<
" called by vehicle '" << veh.
getID()
744 <<
"' entering lane '" << (enteredLane != 0 ? enteredLane->
getID() :
"NULL") <<
"'" << std::endl;
769 bool vehEnteredBehindDetectorEnd = (enteredLane ==
myLastLane) &&
myEndPos <= vehBackPos;
770 if (vehEnteredBehindDetectorEnd) {
773#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
775 std::cout <<
"Vehicle entered the lane behind the detector, ignoring it." << std::endl;
776 std::cout <<
"(myEndPos = " << this->
myEndPos <<
", veh.getBackPositionOnLane() = " << vehBackPos <<
")" << std::endl;
783#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
787 std::cout <<
"Vehicle is off road (teleporting over edge)..." << std::endl;
795 const std::string& vehID = veh.
getID();
799 if (vi->second->currentLane != enteredLane) {
800 vi->second->currentOffsetIndex++;
801 vi->second->currentLane = enteredLane;
804#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
807 <<
"' already known. No new VehicleInfo is created.\n"
808 <<
"enteredLane = " << enteredLane->
getID() <<
"\nmyLanes[vi->offset] = " <<
myLanes[vi->second->currentOffsetIndex]
812 assert(
myLanes[vi->second->currentOffsetIndex] == enteredLane->
getID());
820#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
822 std::cout <<
SIMTIME <<
" Adding VehicleInfo for vehicle '" << veh.
getID() <<
"'." << std::endl;
837 assert(j >= 0 && j < (
int)
myLanes.size());
842#ifdef DEBUG_E2_MAKE_VEHINFO
844 std::cout <<
SIMTIME <<
" Making VehicleInfo for vehicle '" << veh.
getID() <<
"'."
845 <<
"\ndistToDetectorEnd = " << distToDetectorEnd
847 <<
"\nentry lane offset (lane begin from detector begin) = " << entryOffset
859 const double newSpeed = p->
getSpeed();
864 const double oldPos = newPos -
SPEED2DIST(newSpeed);
879 throw ProcessError(
TL(
"Multi-lane e2Detector does not support detecting persons yet"));
882 if (lane->hasPedestrians()) {
892#ifdef DEBUG_E2_DETECTOR_UPDATE
894 std::cout <<
"\n" <<
SIMTIME <<
" detectorUpdate() for detector '" <<
myID <<
"'"
916 std::vector<JamInfo*> jams;
917 std::map<std::string, SUMOTime> haltingVehicles;
918 std::map<std::string, SUMOTime> intervalHaltingVehicles;
923 const std::string& vehID = (*i)->id;
934 bool isInJam =
checkJam(i, haltingVehicles, intervalHaltingVehicles);
935 buildJam(isInJam, i, currentJam, jams);
948#ifdef DEBUG_E2_DETECTOR_UPDATE
950 std::cout <<
"\n" <<
SIMTIME <<
" Current lanes for vehicles still on or approaching the detector:" << std::endl;
954 VehicleInfoMap::iterator iv;
956#ifdef DEBUG_E2_DETECTOR_UPDATE
958 std::cout <<
" Vehicle '" << iv->second->id <<
"'" <<
": '"
959 << iv->second->currentLane->getID() <<
"'"
965#ifdef DEBUG_E2_DETECTOR_UPDATE
967 std::cout <<
SIMTIME <<
" Discarding vehicles that have left the detector:" << std::endl;
971 std::set<std::string>::const_iterator i;
977#ifdef DEBUG_E2_DETECTOR_UPDATE
979 std::cout <<
"Erased vehicle '" << *i <<
"'" << std::endl;
1020#ifdef DEBUG_E2_DETECTOR_UPDATE
1022 std::cout <<
SIMTIME <<
" integrateMoveNotification() for vehicle '" << mni->
id <<
"'"
1025 <<
"\ntimeLoss = " << mni->
timeLoss
1026 <<
"\nspeed = " << mni->
speed
1039 if (vi !=
nullptr) {
1056#ifdef DEBUG_E2_NOTIFY_MOVE
1058 std::cout <<
SIMTIME <<
" makeMoveNotification() for vehicle '" << veh.
getID() <<
"'"
1059 <<
" oldPos = " << oldPos <<
" newPos = " << newPos <<
" newSpeed = " << newSpeed
1065 double timeOnDetector;
1077 double distToExit = -vehInfo.
exitOffset - newPos;
1079 lengthOnDetector =
MAX2(0., lengthOnDetector +
MIN2(0., distToExit));
1082 bool stillOnDetector = -distToExit < vehInfo.
length;
1084#ifdef DEBUG_E2_NOTIFY_MOVE
1086 std::cout <<
SIMTIME <<
" lengthOnDetector = " << lengthOnDetector
1087 <<
"\nvehInfo.exitOffset = " << vehInfo.
exitOffset
1088 <<
" vehInfo.entryOffset = " << vehInfo.
entryOffset
1089 <<
" distToExit = " << distToExit
1097 timeOnDetector, lengthOnDetector, timeLoss,
1105 std::cout <<
SIMTIME <<
" buildJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1111 if (currentJam ==
nullptr) {
1114 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of the first jam" << std::endl;
1129 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->
id <<
"' forms the start of a new jam" << std::endl;
1134 jams.push_back(currentJam);
1143 if (currentJam !=
nullptr) {
1146 std::cout <<
SIMTIME <<
" Closing current jam." << std::endl;
1149 jams.push_back(currentJam);
1150 currentJam =
nullptr;
1157MSE2Collector::checkJam(std::vector<MoveNotificationInfo*>::const_iterator mni, std::map<std::string, SUMOTime>& haltingVehicles, std::map<std::string, SUMOTime>& intervalHaltingVehicles) {
1160 std::cout <<
SIMTIME <<
" CheckJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1164 bool isInJam =
false;
1177 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' starts halting." << std::endl;
1180 haltingVehicles[(*mni)->id] =
DELTA_T;
1181 intervalHaltingVehicles[(*mni)->id] =
DELTA_T;
1205 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"'" << (isInJam ?
"is jammed." :
"is not jammed.") << std::endl;
1215 if (currentJam !=
nullptr) {
1216 jams.push_back(currentJam);
1217 currentJam =
nullptr;
1222 std::cout <<
"\n" <<
SIMTIME <<
" processJams()"
1223 <<
"\nNumber of jams: " << jams.size() << std::endl;
1233 for (std::vector<JamInfo*>::const_iterator i = jams.begin(); i != jams.end(); ++i) {
1240 const int jamLengthInVehicles = (int) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
1251 std::cout <<
SIMTIME <<
" processing jam nr." << ((int) distance((std::vector<JamInfo*>::const_iterator) jams.begin(), i) + 1)
1252 <<
"\njamLengthInMeters = " << jamLengthInMeters
1253 <<
" jamLengthInVehicles = " << jamLengthInVehicles
1261 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
1271 if (oldPos == newPos) {
1274 timeOnDetector =
TS;
1281 double entryTime = 0;
1283 if (oldPos < entryPos) {
1291 assert(entryPos < exitPos);
1295 if (exitPos == newPos) {
1310 timeOnDetector = exitTime - entryTime;
1311 timeLoss =
MAX2(0., timeOnDetector * (vmax - (entrySpeed + exitSpeed) / 2) / vmax);
1313#ifdef DEBUG_E2_TIME_ON_DETECTOR
1315 std::cout <<
SIMTIME <<
" calculateTimeLoss() for vehicle '" << veh.
getID() <<
"'"
1316 <<
" oldPos = " << oldPos <<
" newPos = " << newPos
1317 <<
" entryPos = " << entryPos <<
" exitPos = " << exitPos
1318 <<
" timeOnDetector = " << timeOnDetector
1319 <<
" timeLoss = " << timeLoss
1354 haltingDurationSum += (*i);
1355 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
1359 haltingDurationSum += (*i).second;
1360 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
1363 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
1365 SUMOTime intervalHaltingDurationSum = 0;
1366 SUMOTime intervalMaxHaltingDuration = 0;
1367 int intervalHaltingNo = 0;
1369 intervalHaltingDurationSum += (*i);
1370 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
1371 intervalHaltingNo++;
1374 intervalHaltingDurationSum += (*i).second;
1375 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
1376 intervalHaltingNo++;
1378 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
1380#ifdef DEBUG_E2_XML_OUT
1382 std::stringstream ss;
1388 <<
"meanSpeed=\"" << meanSpeed <<
"\"";
1389 std::cout << ss.str() << std::endl;
1400 .
writeAttr(
"meanTimeLoss", meanTimeLoss)
1401 .
writeAttr(
"meanOccupancy", meanOccupancy)
1403 .
writeAttr(
"meanMaxJamLengthInVehicles", meanJamLengthInVehicles)
1404 .
writeAttr(
"meanMaxJamLengthInMeters", meanJamLengthInMeters)
1416 .
writeAttr(
"meanVehicleNumber", meanVehicleNumber)
1459 if (it->second->onDetector) {
1474std::vector<std::string>
1476 std::vector<std::string> ret;
1478 if (i->second->onDetector) {
1479 ret.push_back(i->second->id);
1482 std::sort(ret.begin(), ret.end());
1487std::vector<MSE2Collector::VehicleInfo*>
1489 std::vector<VehicleInfo*> res;
1490 VehicleInfoMap::const_iterator i;
1492 if (i->second->onDetector) {
1493 res.push_back(i->second);
1510 if (it->second->onDetector) {
1515 const double realDistance = it->second->distToDetectorEnd;
1516 if (it->second->lastSpeed <= thresholdSpeed || it->second->lastAccel > 0) {
1517 count = (int)(realDistance / (it->second->length + it->second->minGap)) + 1;
1532 double distance = 0;
1533 double realDistance = 0;
1534 bool flowing =
true;
1537 if (it->second->onDetector && it->second->totalTimeOnDetector > 0) {
1540 distance =
MAX2(it->second->distToDetectorEnd, distance);
1541 realDistance = distance + it->second->length;
1560 return realDistance;
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The base class for microscopic and mesoscopic vehicles.
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
static double speedAfterTime(const double t, const double oldSpeed, const double dist)
Calculates the speed after a time t \in [0,TS] given the initial speed and the distance traveled in a...
static double passingTime(const double lastPos, const double passedPos, const double currentPos, const double lastSpeed, const double currentSpeed)
Calculates the time at which the position passedPosition has been passed In case of a ballistic updat...
Base of value-generating classes (detectors)
bool vehicleApplies(const SUMOTrafficObject &veh) const
Checks whether the detector measures vehicles of the given type.
std::vector< const MSEdge * > myNextEdges
The upcoming edges to filter by (empty means no filtering)
const int myDetectPersons
Whether pedestrians shall be detected instead of vehicles.
bool personApplies(const MSTransportable &p, int dir) const
void checkPositioning(bool posGiven=false, double desiredLength=0.)
Adjusts positioning if the detector length is less than POSITION_EPS and tests some assertions.
void notifyMovePerson(MSTransportable *p, int dir, double pos)
double myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
VehicleInfo * makeVehicleInfo(const SUMOTrafficObject &veh, const MSLane *enteredLane) const
Creates and returns a VehicleInfo (called at the vehicle's entry)
bool checkJam(std::vector< MoveNotificationInfo * >::const_iterator mni, std::map< std::string, SUMOTime > &haltingVehicles, std::map< std::string, SUMOTime > &intervalHaltingVehicles)
checks whether the vehicle stands in a jam
void buildJam(bool isInJam, std::vector< MoveNotificationInfo * >::const_iterator mni, JamInfo *¤tJam, std::vector< JamInfo * > &jams)
Either adds the vehicle to the end of an existing jam, or closes the last jam, and/or creates a new j...
std::map< std::string, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
int myMeanVehicleNumber
The mean number of vehicles [#veh].
int myCurrentStartedHalts
The number of started halts in the last step.
int myTimeSamples
The current aggregation duration [#steps].
static bool compareMoveNotification(MoveNotificationInfo *mni1, MoveNotificationInfo *mni2)
int myNumberOfSeenVehicles
The number of vehicles, present on the detector at the last reset.
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
std::vector< MSLane * > getLanes()
Returns a vector containing pointers to the lanes covered by the detector ordered from its first to i...
int myNumberOfLeftVehicles
The number of vehicles, which have left the detector since the last reset.
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
void processJams(std::vector< JamInfo * > &jams, JamInfo *currentJam)
Calculates aggregated values from the given jam structure, deletes all jam-pointers.
std::vector< double > myOffsets
The distances of the lane-beginnings from the detector start-point.
double myPreviousMeanSpeed
int myMaxJamInVehicles
The max jam length [#veh].
virtual void reset()
Resets all values.
virtual bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
std::vector< VehicleInfo * > getCurrentVehicles() const
Returns the VehicleInfos for the vehicles currently on the detector.
double myPreviousMaxJamLengthInMeters
double myJamHaltingSpeedThreshold
A vehicle must driver slower than this to be counted as a part of a jam.
virtual bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane)
Adds the vehicle to known vehicles if not beyond the dector.
VehicleInfoMap myVehicleInfos
int myNumberOfEnteredVehicles
static double snap(double value, double snapPoint, double snapDist)
Snaps value to snpPoint if they are closer than snapDist.
void initAuxiliaries(std::vector< MSLane * > &lanes)
Checks integrity of myLanes, adds internal-lane information, inits myLength, myFirstLane,...
MSLane * myFirstLane
The first lane of the detector's lane sequence.
std::vector< std::string > getCurrentVehicleIDs() const
Returns the IDs of the vehicles within the area.
double mySpeedSum
The sum of collected vehicle speeds [m/s].
std::set< std::string > myLeftVehicles
Keep track of vehicles that left the detector by a regular move along a junction (not lanechange,...
double getIntervalMeanSpeed() const
double myEndPos
The position the detector ends at on the last lane.
int myPreviousNumberOfSeenVehicles
double myDetectorLength
The total detector length.
virtual void clearState(SUMOTime step)
Remove all vehicles before quick-loading state.
std::vector< MSLane * > selectLanes(MSLane *endLane, double length, std::string dir)
This is called if no lane sequence is given to the constructor. Builds myLanes from the given informa...
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
double myCurrentMeanSpeed
The current mean speed.
double myStartPos
The position the detector starts at on the first lane.
std::vector< MoveNotificationInfo * > myMoveNotifications
Temporal storage for notifications from vehicles that did call the detector's notifyMove() in the las...
void addDetectorToLanes(std::vector< MSLane * > &lanes)
This adds the detector as a MoveReminder to the associated lanes.
SUMOTime myJamHaltingTimeThreshold
A vehicle must be that long beyond myJamHaltingSpeedThreshold to be counted as a part of a jam.
int myMaxVehicleNumber
The maximal number of vehicles located on the detector simultaneously since the last reset.
void recalculateDetectorLength()
Updates the detector length after myStartPos and myEndPos have been modified.
double myMaxOccupancy
The maximum occupancy [%].
double myPreviousMeanOccupancy
virtual void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
int myCurrentJamNo
The current jam number.
double myCurrentVehicleSamples
The current vehicle samples.
MSE2Collector(const std::string &id, DetectorUsage usage, MSLane *lane, double startPos, double endPos, double length, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string name, const std::string &vTypes, const std::string &nextEdges, int detectPersons)
Constructor with given end position and detector length.
virtual bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes a known vehicle due to its lane-change.
double myCurrentJamDuration
The overall jam duration in s.
double getEstimateQueueLength() const
Returns an estimate of the length of the queue of vehicles currently stopped on the detector.
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Write the generated output to the given device.
double myMeanMaxJamInMeters
The mean jam length [m].
int myOverrideVehNumber
stores the overriden (via Traci) number of vehicles on detector
double myCurrentJamLengthInMeters
The overall jam length in meters.
double myCurrentMeanLength
The current mean length.
double myMaxJamInMeters
The max jam length [m].
int myStartedHalts
The number of started halts [#].
std::vector< std::string > myLanes
The detector's lane sequence.
int myMeanMaxJamInVehicles
The mean jam length [#veh].
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
void calculateTimeLossAndTimeOnDetector(const SUMOTrafficObject &veh, double oldPos, double newPos, const VehicleInfo &vi, double &timeOnDetector, double &timeLoss) const
Calculates the time spent on the detector in the last step and the timeloss suffered in the last step...
double myJamLengthInMetersSum
The sum of jam lengths [m].
double myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
int getEstimatedCurrentVehicleNumber(double speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
double getLength() const
Returns the length of the detector.
std::vector< SUMOTime > myPastIntervalStandingDurations
Halting durations of ended halts for the current interval [s].
virtual ~MSE2Collector()
Destructor.
MSLane * myLastLane
The last lane of the detector's lane sequence.
void overrideVehicleNumber(int num)
Persistently overrides the number of vehicles on top of the detector Setting a negative value removes...
double myCurrentOccupancy
The current occupancy.
double getIntervalOccupancy() const
double myOccupancySum
The sum of occupancies [%].
double myPreviousMeanTimeLoss
int myCurrentHaltingsNumber
The number of halted vehicles [#].
virtual void writeXMLDetectorProlog(OutputDevice &dev) const
Open the XML-output.
double myTotalTimeLoss
The total amount of all time losses [time x vehicle] since the last reset.
void integrateMoveNotification(VehicleInfo *vi, const MoveNotificationInfo *mni)
This updates the detector values and the VehicleInfo of a vehicle on the detector with the given Move...
std::map< std::string, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
MoveNotificationInfo * makeMoveNotification(const SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed, const VehicleInfo &vehInfo) const
Creates and returns a MoveNotificationInfo containing detector specific information on the vehicle's ...
double getIntervalMeanTimeLoss() const
void aggregateOutputValues()
Aggregates and normalize some values for the detector output during detectorUpdate()
const std::set< MSTransportable *, ComparatorNumericalIdLess > & getPersons() const
Returns this edge's persons set.
static int gNumSimThreads
how many threads to use for simulation
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Representation of a lane in the micro simulation.
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
MSLane * getCanonicalPredecessorLane() const
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.
MSLane * getCanonicalSuccessorLane() const
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
MSEdge & getEdge() const
Returns the lane's edge.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
MSLane * getViaLane() const
Returns the following inner lane.
double getLength() const
Returns the length of this link.
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
MSLane * myLane
Lane on which the reminder works.
virtual double getSpeed() const override
the current speed of the transportable
const MSVehicleType & getVehicleType() const override
Returns the object's "vehicle" type.
const std::string & getID() const
Returns the name of the vehicle type.
double getMinGap() const
Get the free space in front of vehicles of this class.
double getLength() const
Get vehicle's length [m].
std::string myID
The name of the object.
const std::string & getID() const
Returns the id.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
virtual bool isNull()
returns the information whether the device will discard all output
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
OutputDevice & writeTime(const SumoXMLAttr attr, const SUMOTime val)
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual double getAcceleration() const =0
Returns the object's acceleration.
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 double getPreviousSpeed() const =0
Returns the object's previous speed.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual SUMOTime getWaitingTime(const bool accumulated=false) const =0
virtual bool isPerson() const
Whether it is a person.
virtual double getBackPositionOnLane(const MSLane *lane) const =0
Get the object's back position along the given lane.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
A scoped lock which only triggers on condition.
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
Internal representation of a jam.
std::vector< MoveNotificationInfo * >::const_iterator lastStandingVehicle
The last standing vehicle.
std::vector< MoveNotificationInfo * >::const_iterator firstStandingVehicle
The first standing vehicle.
Values collected in notifyMove and needed in detectorUpdate() to calculate the accumulated quantities...
double speed
Speed after the last integration step.
double waitingTime
the current (consecutive) waitingTime on the detector in s
double newPos
Position after the last integration step (relative to the vehicle's entry lane on the detector)
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
double accel
Acceleration in the last integration step.
double timeLoss
timeloss during the last integration step
double timeOnDetector
Time spent on the detector during the last integration step.
double lengthOnDetector
The length of the part of the vehicle on the detector at the end of the last time step.
bool onDetector
whether the vehicle is on the detector at the end of the current timestep
std::string id
Vehicle's id.
A VehicleInfo stores values that are tracked for the individual vehicles on the detector,...
double lastAccel
Last value of the acceleration.
double length
vehicle's length
double accumulatedTimeLoss
Accumulated time loss that this vehicle suffered since it entered the detector.
bool onDetector
whether the vehicle is on the detector at the end of the current timestep
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
double lastSpeed
Last value of the speed.
bool hasEntered
Whether the vehicle has already entered the detector (don't count twice!)
std::string id
vehicle's ID
double totalTimeOnDetector
Accumulated time that this vehicle has spent on the detector since its last entry.