72 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
73 const std::string name,
const std::string& vTypes,
74 const std::string& nextEdges,
80 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
81 myJamHaltingTimeThreshold(haltingTimeThreshold),
82 myJamDistanceThreshold(jamDistThreshold) {
84#ifdef DEBUG_E2_CONSTRUCTOR
86 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id
87 <<
" with lane = " << lane->
getID()
88 <<
" startPos = " << startPos
89 <<
" endPos = " << endPos
90 <<
" length = " << length
91 <<
" haltingTimeThreshold = " << haltingTimeThreshold
92 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
93 <<
" jamDistThreshold = " << jamDistThreshold
101 bool lengthInvalid = length == std::numeric_limits<double>::max() || length <= 0;
102 bool endPosInvalid = endPos == std::numeric_limits<double>::max();
103 bool posInvalid = startPos == std::numeric_limits<double>::max();
109 WRITE_WARNING(
TL(
"No valid detector length and start position given. Assuming startPos = 0 and length = end position"));
113 WRITE_WARNING(
TL(
"No valid detector length and end position given. Assuming endPos = lane length and length = endPos-startPos"));
116 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
117 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
118 bool valid = endPos <= lane->
getLength() && 0 <= startPos && startPos < endPos;
120 throw InvalidArgument(
"Error in specification for E2Detector '" +
id +
"'. Positional argument is malformed. 0 <= pos < endPos <= lane.getLength() is required.");
124 startPos =
snap(startPos, 0., POSITION_EPS);
125 length = endPos - startPos;
126 }
else if (posInvalid) {
128 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
132 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
133 startPos =
snap(startPos, 0., POSITION_EPS);
139 std::vector<MSLane*> lanes;
142 }
else if (endPosInvalid) {
146 lanes.push_back(lane);
156 DetectorUsage usage, std::vector<MSLane*> lanes,
double startPos,
double endPos,
157 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
158 const std::string name,
const std::string& vTypes,
159 const std::string& nextEdges,
165 myFirstLane(lanes[0]),
166 myLastLane(lanes[lanes.size() - 1]),
167 myStartPos(startPos),
169 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
170 myJamHaltingTimeThreshold(haltingTimeThreshold),
171 myJamDistanceThreshold(jamDistThreshold) {
173 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
177#ifdef DEBUG_E2_CONSTRUCTOR
179 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id
181 <<
" endPos = " << endPos
183 <<
" startPos = " << startPos
184 <<
" haltingTimeThreshold = " << haltingTimeThreshold
185 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
186 <<
" jamDistThreshold = " << jamDistThreshold
197 if (
myEndPos > lanes[lanes.size() - 1]->getLength() - POSITION_EPS) {
198 myEndPos = lanes[lanes.size() - 1]->getLength();
211 if (desiredLength > 0 &&
myDetectorLength < desiredLength - NUMERICAL_EPS) {
212 std::stringstream ss;
213 ss <<
"Cannot build detector of length " << desiredLength
228 WRITE_WARNING(
"Adjusted detector positioning to meet requirement length >= " +
toString(POSITION_EPS)
241#ifdef DEBUG_E2_CONSTRUCTOR
243 std::stringstream ss;
246 std::cout <<
"myStartPos = " <<
myStartPos << std::endl;
247 std::cout <<
"myEndPos = " <<
myEndPos << std::endl;
261 if (fabs(value - snapPoint) < snapDist) {
271 std::vector<std::string>::const_iterator i;
272 std::vector<MSLane*> lanes;
276 lanes.push_back(lane);
280 std::vector<MSLane*>::const_iterator j;
281 MSLane* previous =
nullptr;
283 for (j = lanes.begin(); j != lanes.end(); ++j) {
296#ifdef DEBUG_E2_CONSTRUCTOR
298 std::cout <<
"Total detector length after recalculation = " <<
myDetectorLength << std::endl;
313 assert(dir ==
"fw" || dir ==
"bw");
314 bool fw = dir ==
"fw";
315 double linkLength = 0;
316 bool subtractedLinkLength =
false;
318#ifdef DEBUG_E2_CONSTRUCTOR
320 std::cout <<
"\n" <<
"selectLanes()" << (fw ?
"(forward)" :
"(backward)") << std::endl;
323 std::vector<MSLane*> lanes;
329 assert(
myStartPos != std::numeric_limits<double>::max());
332 assert(
myEndPos != std::numeric_limits<double>::max());
335 length =
MAX2(POSITION_EPS, length);
336 while (length >= POSITION_EPS && lane !=
nullptr) {
339 lanes.push_back(lane);
340#ifdef DEBUG_E2_CONSTRUCTOR
342 std::cout <<
"Added lane " << lane->
getID()
343 <<
" (length: " << lane->
getLength() <<
")" << std::endl;
357 subtractedLinkLength =
false;
367 length -= linkLength;
368 subtractedLinkLength =
true;
372#ifdef DEBUG_E2_CONSTRUCTOR
375 std::cout << (fw ?
"Successor lane: " :
"Predecessor lane: ") <<
"'" << lane->
getID() <<
"'";
377 std::cout << std::endl;
382 if (subtractedLinkLength) {
386 length += linkLength;
399 if (length > -POSITION_EPS) {
400 myEndPos = lanes[lanes.size() - 1]->getLength();
401 }
else if (length < 0) {
402 myEndPos = lanes[lanes.size() - 1]->getLength() + length;
405 if (length > -POSITION_EPS) {
407 }
else if (length < 0) {
414 std::reverse(lanes.begin(), lanes.end());
422#ifdef DEBUG_E2_CONSTRUCTOR
424 std::cout <<
"\n" <<
"Adding detector " <<
myID <<
" to lanes:" << std::endl;
427 for (std::vector<MSLane*>::iterator l = lanes.begin(); l != lanes.end(); ++l) {
428 (*l)->addMoveReminder(
this);
429#ifdef DEBUG_E2_CONSTRUCTOR
431 std::cout << (*l)->getID() << std::endl;
443#ifdef DEBUG_E2_CONSTRUCTOR
445 std::cout <<
"\n" <<
"Initializing auxiliaries:"
465 std::vector<MSLane*>::iterator il = lanes.begin();
472#ifdef DEBUG_E2_CONSTRUCTOR
474 std::cout <<
"\n" <<
"Initializing offsets:" << std::endl;
480 while (internal !=
nullptr) {
484#ifdef DEBUG_E2_CONSTRUCTOR
499 internal = internal->
getLinkCont()[0]->getViaLaneOrLane();
512 while (il != lanes.end() && (*il)->isInternal()) {
515 if (il == lanes.end()) {
523#ifdef DEBUG_E2_CONSTRUCTOR
537 if (++il == lanes.end()) {
541 if ((*il)->isInternal()) {
549 if (link ==
nullptr) {
550 throw InvalidArgument(
"Lanes '" + lane->
getID() +
"' and '" + (*il)->getID() +
"' are not consecutive in definition of e2Detector '" +
getID() +
"'");
561 bool fw =
myEndPos == std::numeric_limits<double>::max();
568#ifdef DEBUG_E2_CONSTRUCTOR
570 std::cout <<
"Total detector length after initAuxiliaries() = " <<
myDetectorLength << std::endl;
581 std::vector<MSLane*> res;
582 for (std::vector<std::string>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
591 double newPos,
double newSpeed) {
597 keep =
notifyMove(*p, oldPos, newPos, newSpeed);
606 const std::string objectType = veh.
isPerson() ?
"Person" :
"Vehicle";
615 const std::string& vehID = veh.
getID();
624#ifdef DEBUG_E2_NOTIFY_MOVE
627 <<
" MSE2Collector::notifyMove() (detID = " <<
myID <<
" on lane '" <<
myLane->
getID() <<
"')"
628 <<
" called by vehicle '" << vehID <<
"'"
629 <<
" at relative position " << relPos
637#ifdef DEBUG_E2_NOTIFY_MOVE
639 std::cout <<
"Vehicle has not yet reached the detector start position." << std::endl;
656 if (vehicleEnteredLaneAfterDetector) {
657#ifdef DEBUG_E2_NOTIFY_MOVE
659 std::cout <<
"Vehicle entered lane behind detector." << std::endl;
667 if (vehPassedDetectorEnd) {
668#ifdef DEBUG_E2_NOTIFY_MOVE
670 std::cout <<
"Vehicle has left the detector longitudinally." << std::endl;
684#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
686 std::cout <<
"\n" <<
SIMTIME <<
" notifyLeave() (detID = " <<
myID <<
" on lane '" <<
myLane->
getID() <<
"')"
687 <<
"called by vehicle '" << veh.
getID() <<
"'" << std::endl;
697#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
699 std::cout <<
SIMTIME <<
" Left longitudinally (along junction) -> keep subscription [handle exit in notifyMove()]" << std::endl;
707 double exitOffset = vi->second->entryOffset -
myOffsets[vi->second->currentOffsetIndex] - vi->second->currentLane->getLength();
708 vi->second->exitOffset =
MAX2(vi->second->exitOffset, exitOffset);
709#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
711 std::cout <<
SIMTIME <<
" Vehicle '" << veh.
getID() <<
"' leaves the detector. Exit offset = " << vi->second->exitOffset << std::endl;
721 if (vi->second->hasEntered) {
726#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
728 std::cout <<
SIMTIME <<
" Left non-longitudinally (lanechange, teleport, parking, etc) -> discard subscription" << std::endl;
741#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
743 std::cout << std::endl <<
SIMTIME <<
" notifyEnter() (detID = " <<
myID <<
" on lane '" <<
myLane->
getID() <<
"')"
744 <<
" called by vehicle '" << veh.
getID()
745 <<
"' entering lane '" << (enteredLane != 0 ? enteredLane->
getID() :
"NULL") <<
"'" << std::endl;
770 bool vehEnteredBehindDetectorEnd = (enteredLane ==
myLastLane) &&
myEndPos <= vehBackPos;
771 if (vehEnteredBehindDetectorEnd) {
774#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
776 std::cout <<
"Vehicle entered the lane behind the detector, ignoring it." << std::endl;
777 std::cout <<
"(myEndPos = " << this->
myEndPos <<
", veh.getBackPositionOnLane() = " << vehBackPos <<
")" << std::endl;
784#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
788 std::cout <<
"Vehicle is off road (teleporting over edge)..." << std::endl;
796 const std::string& vehID = veh.
getID();
800 if (vi->second->currentLane != enteredLane) {
801 vi->second->currentOffsetIndex++;
802 vi->second->currentLane = enteredLane;
805#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
808 <<
"' already known. No new VehicleInfo is created.\n"
809 <<
"enteredLane = " << enteredLane->
getID() <<
"\nmyLanes[vi->offset] = " <<
myLanes[vi->second->currentOffsetIndex]
813 assert(
myLanes[vi->second->currentOffsetIndex] == enteredLane->
getID());
821#ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
823 std::cout <<
SIMTIME <<
" Adding VehicleInfo for vehicle '" << veh.
getID() <<
"'." << std::endl;
838 assert(j >= 0 && j < (
int)
myLanes.size());
843#ifdef DEBUG_E2_MAKE_VEHINFO
845 std::cout <<
SIMTIME <<
" Making VehicleInfo for vehicle '" << veh.
getID() <<
"'."
846 <<
"\ndistToDetectorEnd = " << distToDetectorEnd
848 <<
"\nentry lane offset (lane begin from detector begin) = " << entryOffset
860 const double newSpeed = p->
getSpeed();
865 const double oldPos = newPos -
SPEED2DIST(newSpeed);
880 throw ProcessError(
TL(
"Multi-lane e2Detector does not support detecting persons yet"));
883 if (lane->hasPedestrians()) {
893#ifdef DEBUG_E2_DETECTOR_UPDATE
895 std::cout <<
"\n" <<
SIMTIME <<
" detectorUpdate() for detector '" <<
myID <<
"'"
917 std::vector<JamInfo*> jams;
918 std::map<std::string, SUMOTime> haltingVehicles;
919 std::map<std::string, SUMOTime> intervalHaltingVehicles;
924 const std::string& vehID = (*i)->id;
935 bool isInJam =
checkJam(i, haltingVehicles, intervalHaltingVehicles);
936 buildJam(isInJam, i, currentJam, jams);
949#ifdef DEBUG_E2_DETECTOR_UPDATE
951 std::cout <<
"\n" <<
SIMTIME <<
" Current lanes for vehicles still on or approaching the detector:" << std::endl;
955 VehicleInfoMap::iterator iv;
957#ifdef DEBUG_E2_DETECTOR_UPDATE
959 std::cout <<
" Vehicle '" << iv->second->id <<
"'" <<
": '"
960 << iv->second->currentLane->getID() <<
"'"
966#ifdef DEBUG_E2_DETECTOR_UPDATE
968 std::cout <<
SIMTIME <<
" Discarding vehicles that have left the detector:" << std::endl;
972 std::set<std::string>::const_iterator i;
978#ifdef DEBUG_E2_DETECTOR_UPDATE
980 std::cout <<
"Erased vehicle '" << *i <<
"'" << std::endl;
1021#ifdef DEBUG_E2_DETECTOR_UPDATE
1023 std::cout <<
SIMTIME <<
" integrateMoveNotification() for vehicle '" << mni->
id <<
"'"
1026 <<
"\ntimeLoss = " << mni->
timeLoss
1027 <<
"\nspeed = " << mni->
speed
1040 if (vi !=
nullptr) {
1057#ifdef DEBUG_E2_NOTIFY_MOVE
1059 std::cout <<
SIMTIME <<
" makeMoveNotification() for vehicle '" << veh.
getID() <<
"'"
1060 <<
" oldPos = " << oldPos <<
" newPos = " << newPos <<
" newSpeed = " << newSpeed
1066 double timeOnDetector;
1078 double distToExit = -vehInfo.
exitOffset - newPos;
1080 lengthOnDetector =
MAX2(0., lengthOnDetector +
MIN2(0., distToExit));
1083 bool stillOnDetector = -distToExit < vehInfo.
length;
1085#ifdef DEBUG_E2_NOTIFY_MOVE
1087 std::cout <<
SIMTIME <<
" lengthOnDetector = " << lengthOnDetector
1088 <<
"\nvehInfo.exitOffset = " << vehInfo.
exitOffset
1089 <<
" vehInfo.entryOffset = " << vehInfo.
entryOffset
1090 <<
" distToExit = " << distToExit
1098 timeOnDetector, lengthOnDetector, timeLoss,
1106 std::cout <<
SIMTIME <<
" buildJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1112 if (currentJam ==
nullptr) {
1115 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of the first jam" << std::endl;
1130 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->
id <<
"' forms the start of a new jam" << std::endl;
1135 jams.push_back(currentJam);
1144 if (currentJam !=
nullptr) {
1147 std::cout <<
SIMTIME <<
" Closing current jam." << std::endl;
1150 jams.push_back(currentJam);
1151 currentJam =
nullptr;
1158MSE2Collector::checkJam(std::vector<MoveNotificationInfo*>::const_iterator mni, std::map<std::string, SUMOTime>& haltingVehicles, std::map<std::string, SUMOTime>& intervalHaltingVehicles) {
1161 std::cout <<
SIMTIME <<
" CheckJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1165 bool isInJam =
false;
1178 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' starts halting." << std::endl;
1181 haltingVehicles[(*mni)->id] =
DELTA_T;
1182 intervalHaltingVehicles[(*mni)->id] =
DELTA_T;
1206 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"'" << (isInJam ?
"is jammed." :
"is not jammed.") << std::endl;
1216 if (currentJam !=
nullptr) {
1217 jams.push_back(currentJam);
1218 currentJam =
nullptr;
1223 std::cout <<
"\n" <<
SIMTIME <<
" processJams()"
1224 <<
"\nNumber of jams: " << jams.size() << std::endl;
1234 for (std::vector<JamInfo*>::const_iterator i = jams.begin(); i != jams.end(); ++i) {
1241 const int jamLengthInVehicles = (int) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
1252 std::cout <<
SIMTIME <<
" processing jam nr." << ((int) distance((std::vector<JamInfo*>::const_iterator) jams.begin(), i) + 1)
1253 <<
"\njamLengthInMeters = " << jamLengthInMeters
1254 <<
" jamLengthInVehicles = " << jamLengthInVehicles
1262 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
1272 if (oldPos == newPos) {
1275 timeOnDetector =
TS;
1282 double entryTime = 0;
1284 if (oldPos < entryPos) {
1292 assert(entryPos < exitPos);
1296 if (exitPos == newPos) {
1311 timeOnDetector = exitTime - entryTime;
1312 timeLoss =
MAX2(0., timeOnDetector * (vmax - (entrySpeed + exitSpeed) / 2) / vmax);
1314#ifdef DEBUG_E2_TIME_ON_DETECTOR
1316 std::cout <<
SIMTIME <<
" calculateTimeLoss() for vehicle '" << veh.
getID() <<
"'"
1317 <<
" oldPos = " << oldPos <<
" newPos = " << newPos
1318 <<
" entryPos = " << entryPos <<
" exitPos = " << exitPos
1319 <<
" timeOnDetector = " << timeOnDetector
1320 <<
" timeLoss = " << timeLoss
1355 haltingDurationSum += (*i);
1356 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
1360 haltingDurationSum += (*i).second;
1361 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
1364 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
1366 SUMOTime intervalHaltingDurationSum = 0;
1367 SUMOTime intervalMaxHaltingDuration = 0;
1368 int intervalHaltingNo = 0;
1370 intervalHaltingDurationSum += (*i);
1371 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
1372 intervalHaltingNo++;
1375 intervalHaltingDurationSum += (*i).second;
1376 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
1377 intervalHaltingNo++;
1379 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
1381#ifdef DEBUG_E2_XML_OUT
1383 std::stringstream ss;
1389 <<
"meanSpeed=\"" << meanSpeed <<
"\"";
1390 std::cout << ss.str() << std::endl;
1401 .
writeAttr(
"meanTimeLoss", meanTimeLoss)
1402 .
writeAttr(
"meanOccupancy", meanOccupancy)
1404 .
writeAttr(
"meanMaxJamLengthInVehicles", meanJamLengthInVehicles)
1405 .
writeAttr(
"meanMaxJamLengthInMeters", meanJamLengthInMeters)
1417 .
writeAttr(
"meanVehicleNumber", meanVehicleNumber)
1460 if (it->second->onDetector) {
1475std::vector<std::string>
1477 std::vector<std::string> ret;
1479 if (i->second->onDetector) {
1480 ret.push_back(i->second->id);
1483 std::sort(ret.begin(), ret.end());
1488std::vector<MSE2Collector::VehicleInfo*>
1490 std::vector<VehicleInfo*> res;
1491 VehicleInfoMap::const_iterator i;
1493 if (i->second->onDetector) {
1494 res.push_back(i->second);
1511 if (it->second->onDetector) {
1516 const double realDistance = it->second->distToDetectorEnd;
1517 if (it->second->lastSpeed <= thresholdSpeed || it->second->lastAccel > 0) {
1518 count = (int)(realDistance / (it->second->length + it->second->minGap)) + 1;
1533 double distance = 0;
1534 double realDistance = 0;
1535 bool flowing =
true;
1538 if (it->second->onDetector && it->second->totalTimeOnDetector > 0) {
1541 distance =
MAX2(it->second->distToDetectorEnd, distance);
1542 realDistance = distance + it->second->length;
1561 return realDistance;
1574 if (item.second->onDetector) {
1580 result =
MAX2(result, ad);
#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
const double INVALID_DOUBLE
invalid double
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
virtual double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
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 getArrivalDelay() const
Returns the maximum stop arrival delay of public transport vehicles that are on the detector or passe...
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.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual double getSpeed() const override
the current speed of the transportable
const MSVehicleType & getVehicleType() const override
Returns the object's "vehicle" type.
The class responsible for building and deletion of vehicles.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
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.