 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
63 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
64 const std::string& vTypes) :
68 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
69 myJamHaltingTimeThreshold(haltingTimeThreshold),
70 myJamDistanceThreshold(jamDistThreshold),
71 myNumberOfEnteredVehicles(0),
72 myNumberOfSeenVehicles(0),
73 myNumberOfLeftVehicles(0) {
76 #ifdef DEBUG_E2_CONSTRUCTOR
78 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id
79 <<
" with lane = " << lane->
getID()
80 <<
" startPos = " << startPos
81 <<
" endPos = " << endPos
82 <<
" length = " << length
83 <<
" haltingTimeThreshold = " << haltingTimeThreshold
84 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
85 <<
" jamDistThreshold = " << jamDistThreshold
93 bool lengthInvalid = length == std::numeric_limits<double>::max() || length <= 0;
94 bool endPosInvalid = endPos == std::numeric_limits<double>::max();
95 bool posInvalid = startPos == std::numeric_limits<double>::max();
101 WRITE_WARNING(
"No valid detector length and start position given. Assuming startPos = 0 and length = end position");
105 WRITE_WARNING(
"No valid detector length and end position given. Assuming endPos = lane length and length = endPos-startPos");
108 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
109 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
110 bool valid = endPos <= lane->
getLength() && 0 <= startPos && startPos < endPos;
112 throw InvalidArgument(
"Error in specification for E2Detector '" +
id +
"'. Positional argument is malformed. 0 <= pos < endPos <= lane.getLength() is required.");
117 length = endPos - startPos;
118 }
else if (posInvalid) {
120 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
124 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
131 std::vector<MSLane*> lanes;
134 }
else if (endPosInvalid) {
138 lanes.push_back(lane);
148 DetectorUsage usage, std::vector<MSLane*> lanes,
double startPos,
double endPos,
149 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
150 const std::string& vTypes) :
154 myFirstLane(lanes[0]),
155 myLastLane(lanes[lanes.size() - 1]),
156 myStartPos(startPos),
158 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
159 myJamHaltingTimeThreshold(haltingTimeThreshold),
160 myJamDistanceThreshold(jamDistThreshold),
161 myNumberOfEnteredVehicles(0),
162 myNumberOfSeenVehicles(0),
163 myNumberOfLeftVehicles(0) {
166 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
170 #ifdef DEBUG_E2_CONSTRUCTOR
172 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id
174 <<
" endPos = " << endPos
176 <<
" startPos = " << startPos
177 <<
" haltingTimeThreshold = " << haltingTimeThreshold
178 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
179 <<
" jamDistThreshold = " << jamDistThreshold
191 myEndPos = lanes[lanes.size() - 1]->getLength();
205 std::stringstream ss;
206 ss <<
"Cannot build detector of length " << desiredLength
234 #ifdef DEBUG_E2_CONSTRUCTOR
236 std::stringstream ss;
239 std::cout <<
"myStartPos = " <<
myStartPos << std::endl;
240 std::cout <<
"myEndPos = " <<
myEndPos << std::endl;
254 if (fabs(value - snapPoint) < snapDist) {
264 std::vector<std::string>::const_iterator i;
265 std::vector<MSLane*> lanes;
269 lanes.push_back(lane);
273 std::vector<MSLane*>::const_iterator j;
274 MSLane* previous =
nullptr;
276 for (j = lanes.begin(); j != lanes.end(); ++j) {
289 #ifdef DEBUG_E2_CONSTRUCTOR
291 std::cout <<
"Total detector length after recalculation = " <<
myDetectorLength << std::endl;
315 assert(dir ==
"fw" || dir ==
"bw");
316 bool fw = dir ==
"fw";
317 double linkLength = 0;
318 bool substractedLinkLength =
false;
320 #ifdef DEBUG_E2_CONSTRUCTOR
322 std::cout <<
"\n" <<
"selectLanes()" << (fw ?
"(forward)" :
"(backward)") << std::endl;
325 std::vector<MSLane*> lanes;
331 assert(
myStartPos != std::numeric_limits<double>::max());
334 assert(
myEndPos != std::numeric_limits<double>::max());
341 lanes.push_back(lane);
342 #ifdef DEBUG_E2_CONSTRUCTOR
344 std::cout <<
"Added lane " << lane->
getID()
345 <<
" (length: " << lane->
getLength() <<
")" << std::endl;
359 substractedLinkLength =
false;
369 length -= linkLength;
370 substractedLinkLength =
true;
374 #ifdef DEBUG_E2_CONSTRUCTOR
377 std::cout << (fw ?
"Successor lane: " :
"Predecessor lane: ") <<
"'" << lane->
getID() <<
"'";
379 std::cout << std::endl;
384 if (substractedLinkLength) {
388 length += linkLength;
402 myEndPos = lanes[lanes.size() - 1]->getLength();
403 }
else if (length < 0) {
404 myEndPos = lanes[lanes.size() - 1]->getLength() + length;
409 }
else if (length < 0) {
416 std::reverse(lanes.begin(), lanes.end());
424 #ifdef DEBUG_E2_CONSTRUCTOR
426 std::cout <<
"\n" <<
"Adding detector " <<
myID <<
" to lanes:" << std::endl;
429 for (std::vector<MSLane*>::iterator l = lanes.begin(); l != lanes.end(); ++l) {
430 (*l)->addMoveReminder(
this);
431 #ifdef DEBUG_E2_CONSTRUCTOR
433 std::cout << (*l)->getID() << std::endl;
445 #ifdef DEBUG_E2_CONSTRUCTOR
447 std::cout <<
"\n" <<
"Initializing auxiliaries:"
467 std::vector<MSLane*>::iterator il = lanes.begin();
474 #ifdef DEBUG_E2_CONSTRUCTOR
476 std::cout <<
"\n" <<
"Initializing offsets:" << std::endl;
481 #pragma warning(push)
482 #pragma warning(disable: 4127) // do not warn about constant conditional expression
489 while (
internal !=
nullptr) {
490 myLanes.push_back(internal->getID());
493 #ifdef DEBUG_E2_CONSTRUCTOR
495 std::cout <<
"Offset for lane " <<
internal->getID() <<
" = " <<
myDetectorLength
506 assert(internal->getLinkCont().size() == 1);
508 internal =
internal->getLinkCont()[0]->getViaLaneOrLane();
509 if (!internal->isInternal()) {
521 while (il != lanes.end() && (*il)->isInternal()) {
524 if (il == lanes.end()) {
532 #ifdef DEBUG_E2_CONSTRUCTOR
546 if (++il == lanes.end()) {
550 if ((*il)->isInternal()) {
558 if (link ==
nullptr) {
559 throw InvalidArgument(
"Lanes '" + lane->
getID() +
"' and '" + (*il)->getID() +
"' are not consecutive in defintion of e2Detector '" +
getID() +
"'");
570 bool fw =
myEndPos == std::numeric_limits<double>::max();
577 #ifdef DEBUG_E2_CONSTRUCTOR
579 std::cout <<
"Total detector length after initAuxiliaries() = " <<
myDetectorLength << std::endl;
590 std::vector<MSLane*> res;
591 for (std::vector<std::string>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
600 double newPos,
double newSpeed) {
604 SUMOVehicle& veh = static_cast<SUMOVehicle&>(tObject);
608 const std::string& vehID = veh.
getID();
617 #ifdef DEBUG_E2_NOTIFY_MOVE
620 <<
" MSE2Collector::notifyMove() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')"
621 <<
" called by vehicle '" << vehID <<
"'"
622 <<
" at relative position " << relPos
630 #ifdef DEBUG_E2_NOTIFY_MOVE
632 std::cout <<
"Vehicle has not yet reached the detector start position." << std::endl;
649 if (vehicleEnteredLaneAfterDetector) {
650 #ifdef DEBUG_E2_NOTIFY_MOVE
652 std::cout <<
"Vehicle entered lane behind detector." << std::endl;
660 if (vehPassedDetectorEnd) {
661 #ifdef DEBUG_E2_NOTIFY_MOVE
663 std::cout <<
"Vehicle has left the detector longitudinally." << std::endl;
680 SUMOVehicle& veh = static_cast<SUMOVehicle&>(tObject);
681 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
683 std::cout <<
"\n" <<
SIMTIME <<
" notifyLeave() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')"
684 <<
"called by vehicle '" << veh.
getID() <<
"'" << std::endl;
691 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
693 std::cout <<
SIMTIME <<
" Left longitudinally (along junction) -> keep subscription [handle exit in notifyMove()]" << std::endl;
701 double exitOffset = vi->second->entryOffset -
myOffsets[vi->second->currentOffsetIndex] - vi->second->currentLane->getLength();
702 vi->second->exitOffset =
MAX2(vi->second->exitOffset, exitOffset);
703 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
705 std::cout <<
SIMTIME <<
" Vehicle '" << veh.
getID() <<
"' leaves the detector. Exit offset = " << vi->second->exitOffset << std::endl;
714 if (vi->second->hasEntered) {
719 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
721 std::cout <<
SIMTIME <<
" Left non-longitudinally (lanechange, teleport, parking, etc) -> discard subscription" << std::endl;
734 SUMOVehicle& veh = static_cast<SUMOVehicle&>(tObject);
735 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
737 std::cout << std::endl <<
SIMTIME <<
" notifyEnter() (detID = " <<
myID <<
" on lane '" <<
myLane->
getID() <<
"')"
738 <<
" called by vehicle '" << veh.
getID()
739 <<
"' entering lane '" << (enteredLane != 0 ? enteredLane->
getID() :
"NULL") <<
"'" << std::endl;
744 assert(veh.
getLane() == enteredLane);
755 bool vehEnteredBehindDetectorEnd = (enteredLane ==
myLastLane) &&
myEndPos <= vehBackPos;
756 if (vehEnteredBehindDetectorEnd) {
759 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
761 std::cout <<
"Vehicle entered the lane behind the detector, ignoring it." << std::endl;
762 std::cout <<
"(myEndPos = " << this->
myEndPos <<
", veh.getBackPositionOnLane() = " << vehBackPos <<
")" << std::endl;
769 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
773 std::cout <<
"Vehicle is off road (teleporting over edge)..." << std::endl;
778 const std::string& vehID = veh.
getID();
782 if (vi->second->currentLane != enteredLane) {
783 vi->second->currentOffsetIndex++;
784 vi->second->currentLane = enteredLane;
787 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
790 <<
"' already known. No new VehicleInfo is created.\n"
791 <<
"enteredLane = " << enteredLane->
getID() <<
"\nmyLanes[vi->offset] = " <<
myLanes[vi->second->currentOffsetIndex]
795 assert(
myLanes[vi->second->currentOffsetIndex] == enteredLane->
getID());
803 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
805 std::cout <<
SIMTIME <<
" Adding VehicleInfo for vehicle '" << veh.
getID() <<
"'." << std::endl;
819 assert(j >= 0 && j < (
int)
myLanes.size());
824 #ifdef DEBUG_E2_MAKE_VEHINFO
826 std::cout <<
SIMTIME <<
" Making VehicleInfo for vehicle '" << veh.
getID() <<
"'."
827 <<
"\ndistToDetectorEnd = " << distToDetectorEnd
829 <<
"\nentry lane offset (lane begin from detector begin) = " << entryOffset
840 #ifdef DEBUG_E2_DETECTOR_UPDATE
842 std::cout <<
"\n" <<
SIMTIME <<
" detectorUpdate() for detector '" <<
myID <<
"'"
863 std::vector<JamInfo*> jams;
864 std::map<std::string, SUMOTime> haltingVehicles;
865 std::map<std::string, SUMOTime> intervalHaltingVehicles;
870 const std::string& vehID = (*i)->id;
881 bool isInJam =
checkJam(i, haltingVehicles, intervalHaltingVehicles);
882 buildJam(isInJam, i, currentJam, jams);
895 #ifdef DEBUG_E2_DETECTOR_UPDATE
897 std::cout <<
"\n" <<
SIMTIME <<
" Current lanes for vehicles still on or approaching the detector:" << std::endl;
901 VehicleInfoMap::iterator iv;
903 #ifdef DEBUG_E2_DETECTOR_UPDATE
905 std::cout <<
" Vehicle '" << iv->second->id <<
"'" <<
": '"
906 << iv->second->currentLane->getID() <<
"'"
912 #ifdef DEBUG_E2_DETECTOR_UPDATE
914 std::cout <<
SIMTIME <<
" Discarding vehicles that have left the detector:" << std::endl;
918 std::set<std::string>::const_iterator i;
924 #ifdef DEBUG_E2_DETECTOR_UPDATE
926 std::cout <<
"Erased vehicle '" << *i <<
"'" << std::endl;
967 #ifdef DEBUG_E2_DETECTOR_UPDATE
969 std::cout <<
SIMTIME <<
" integrateMoveNotification() for vehicle '" << mni->
id <<
"'"
973 <<
"\nspeed = " << mni->
speed
1002 #ifdef DEBUG_E2_NOTIFY_MOVE
1004 std::cout <<
SIMTIME <<
" makeMoveNotification() for vehicle '" << veh.
getID() <<
"'"
1005 <<
" oldPos = " << oldPos <<
" newPos = " << newPos <<
" newSpeed = " << newSpeed
1011 double timeOnDetector;
1023 double distToExit = -vehInfo.
exitOffset - newPos;
1025 lengthOnDetector =
MAX2(0., lengthOnDetector +
MIN2(0., distToExit));
1028 bool stillOnDetector = -distToExit < vehInfo.
length;
1030 #ifdef DEBUG_E2_NOTIFY_MOVE
1032 std::cout <<
SIMTIME <<
" lengthOnDetector = " << lengthOnDetector
1033 <<
"\nvehInfo.exitOffset = " << vehInfo.
exitOffset
1034 <<
" vehInfo.entryOffset = " << vehInfo.
entryOffset
1035 <<
" distToExit = " << distToExit
1043 timeOnDetector, lengthOnDetector, timeLoss, stillOnDetector);
1048 #ifdef DEBUG_E2_JAMS
1050 std::cout <<
SIMTIME <<
" buildJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1056 if (currentJam ==
nullptr) {
1057 #ifdef DEBUG_E2_JAMS
1059 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of the first jam" << std::endl;
1072 #ifdef DEBUG_E2_JAMS
1074 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of a new jam" << std::endl;
1079 jams.push_back(currentJam);
1088 if (currentJam !=
nullptr) {
1089 #ifdef DEBUG_E2_JAMS
1091 std::cout <<
SIMTIME <<
" Closing current jam." << std::endl;
1094 jams.push_back(currentJam);
1095 currentJam =
nullptr;
1102 MSE2Collector::checkJam(std::vector<MoveNotificationInfo*>::const_iterator mni, std::map<std::string, SUMOTime>& haltingVehicles, std::map<std::string, SUMOTime>& intervalHaltingVehicles) {
1103 #ifdef DEBUG_E2_JAMS
1105 std::cout <<
SIMTIME <<
" CheckJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1109 bool isInJam =
false;
1120 #ifdef DEBUG_E2_JAMS
1122 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' starts halting." << std::endl;
1125 haltingVehicles[(*mni)->id] =
DELTA_T;
1126 intervalHaltingVehicles[(*mni)->id] =
DELTA_T;
1148 #ifdef DEBUG_E2_JAMS
1150 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"'" << (isInJam ?
"is jammed." :
"is not jammed.") << std::endl;
1160 if (currentJam !=
nullptr) {
1161 jams.push_back(currentJam);
1162 currentJam =
nullptr;
1165 #ifdef DEBUG_E2_JAMS
1167 std::cout <<
"\n" <<
SIMTIME <<
" processJams()"
1168 <<
"\nNumber of jams: " << jams.size() << std::endl;
1177 for (std::vector<JamInfo*>::const_iterator i = jams.begin(); i != jams.end(); ++i) {
1184 const int jamLengthInVehicles = (int) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
1192 #ifdef DEBUG_E2_JAMS
1194 std::cout <<
SIMTIME <<
" processing jam nr." << ((int) distance((std::vector<JamInfo*>::const_iterator) jams.begin(), i) + 1)
1195 <<
"\njamLengthInMeters = " << jamLengthInMeters
1196 <<
" jamLengthInVehicles = " << jamLengthInVehicles
1204 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
1214 if (oldPos == newPos) {
1217 timeOnDetector =
TS;
1224 double entryTime = 0;
1226 if (oldPos < entryPos) {
1234 assert(entryPos < exitPos);
1238 if (exitPos == newPos) {
1253 timeOnDetector = exitTime - entryTime;
1254 timeLoss =
MAX2(0., timeOnDetector * (vmax - (entrySpeed + exitSpeed) / 2) / vmax);
1256 #ifdef DEBUG_E2_TIME_ON_DETECTOR
1258 std::cout <<
SIMTIME <<
" calculateTimeLoss() for vehicle '" << veh.
getID() <<
"'"
1259 <<
" oldPos = " << oldPos <<
" newPos = " << newPos
1260 <<
" entryPos = " << entryPos <<
" exitPos = " << exitPos
1261 <<
" timeOnDetector = " << timeOnDetector
1262 <<
" timeLoss = " << timeLoss
1276 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
1289 haltingDurationSum += (*i);
1290 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
1294 haltingDurationSum += (*i).second;
1295 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
1298 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
1300 SUMOTime intervalHaltingDurationSum = 0;
1301 SUMOTime intervalMaxHaltingDuration = 0;
1302 int intervalHaltingNo = 0;
1304 intervalHaltingDurationSum += (*i);
1305 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
1306 intervalHaltingNo++;
1309 intervalHaltingDurationSum += (*i).second;
1310 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
1311 intervalHaltingNo++;
1313 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
1315 #ifdef DEBUG_E2_XML_OUT
1317 std::stringstream ss;
1323 <<
"meanSpeed=\"" << meanSpeed <<
"\"";
1324 std::cout << ss.str() << std::endl;
1333 <<
"meanSpeed=\"" << meanSpeed <<
"\" "
1334 <<
"meanTimeLoss=\"" << meanTimeLoss <<
"\" "
1335 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" "
1337 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" "
1338 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" "
1343 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" "
1344 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" "
1345 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" "
1346 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" "
1347 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" "
1348 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" "
1350 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" "
1390 if (it->second->onDetector) {
1399 std::vector<std::string>
1401 std::vector<std::string> ret;
1403 if (i->second->onDetector) {
1404 ret.push_back(i->second->id);
1407 std::sort(ret.begin(), ret.end());
1412 std::vector<MSE2Collector::VehicleInfo*>
1414 std::vector<VehicleInfo*> res;
1415 VehicleInfoMap::const_iterator i;
1417 if (i->second->onDetector) {
1418 res.push_back(i->second);
1435 if (it->second->onDetector) {
1440 const double realDistance = it->second->distToDetectorEnd;
1441 if (it->second->lastSpeed <= thresholdSpeed || it->second->lastAccel > 0) {
1442 count = (int)(realDistance / (it->second->length + it->second->minGap)) + 1;
1457 double distance = std::numeric_limits<double>::max();
1458 double realDistance = 0;
1459 bool flowing =
true;
1462 if (it->second->onDetector) {
1463 distance =
MIN2(it->second->lastPos, distance);
1465 if (it->second->lastSpeed <= 0.5) {
1466 realDistance = distance - it->second->length + it->second->minGap;
MSE2Collector(const std::string &id, DetectorUsage usage, MSLane *lane, double startPos, double endPos, double length, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string &vTypes)
Constructor with given end position and detector length.
Representation of a vehicle or person.
double getEstimateQueueLength() const
Returns an estimate of the lenght of the queue of vehicles currently stopped on the detector.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
const std::string & getID() const
Returns the name of the vehicle type.
double newPos
Position after the last integration step (relative to the vehicle's entry lane on the detector)
double myMaxOccupancy
The maximum occupancy [%].
double myTotalTimeLoss
The total amount of all time losses [time x vehicle] since the last reset.
#define WRITE_WARNING(msg)
Internal representation of a jam.
Base of value-generating classes (detectors)
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
Representation of a lane in the micro simulation.
bool onDetector
whether the vehicle is on the detector at the end of the current timestep
virtual double getAcceleration() const =0
Returns the vehicle's acceleration.
Static storage of an output device and its base (abstract) implementation.
double lastAccel
Last value of the acceleration.
int myNumberOfEnteredVehicles
int myMeanVehicleNumber
The mean number of vehicles [#veh].
MSLane * getCanonicalSuccessorLane() const
std::vector< MoveNotificationInfo * >::const_iterator lastStandingVehicle
The last standing vehicle.
int myCurrentStartedHalts
The number of started halts in the last step.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
virtual bool isVehicle() const =0
Get the vehicle's ID.
std::vector< MoveNotificationInfo * > myMoveNotifications
Temporal storage for notifications from vehicles that did call the detector's notifyMove() in the las...
virtual const std::string & getID() const =0
Get the vehicle's ID.
virtual bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes a known vehicle due to its lane-change.
Values collected in notifyMove and needed in detectorUpdate() to calculate the accumulated quantities...
int myMeanMaxJamInVehicles
The mean jam length [#veh].
Representation of a vehicle.
std::string id
Vehicle's id.
double totalTimeOnDetector
Accumulated time that this vehicle has spent on the detector since its last entry.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
void checkPositioning(bool posGiven=false, double desiredLength=0.)
Adjusts positioning if the detector length is less than POSITION_EPS and tests some assertions.
double lastSpeed
Last value of the speed.
void recalculateDetectorLength()
Updates the detector length after myStartPos and myEndPos have been modified.
int myTimeSamples
The current aggregation duration [#steps].
static bool compareMoveNotification(MoveNotificationInfo *mni1, MoveNotificationInfo *mni2)
std::vector< VehicleInfo * > getCurrentVehicles() const
Returns the VehicleInfos for the vehicles currently on the detector.
virtual ~MSE2Collector()
Destructor.
double myCurrentMeanLength
The current mean length.
std::vector< MoveNotificationInfo * >::const_iterator firstStandingVehicle
The first standing vehicle.
double getLength() const
Returns the length of the detector.
static double snap(double value, double snapPoint, double snapDist)
Snaps value to snpPoint if they are closer than snapDist.
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
double myJamHaltingSpeedThreshold
A vehicle must driver slower than this to be counted as a part of a jam.
virtual void writeXMLDetectorProlog(OutputDevice &dev) const
Open the XML-output.
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
VehicleInfo * makeVehicleInfo(const SUMOVehicle &veh, const MSLane *enteredLane) const
Creates and returns a VehicleInfo (called at the vehicle's entry)
std::vector< std::string > myLanes
double mySpeedSum
The sum of collected vehicle speeds [m/s].
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
virtual double getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
Something on a lane to be noticed about vehicle movement.
double lengthOnDetector
The length of the part of the vehicle on the detector at the end of the last time step.
double timeOnDetector
Time spent on the detector during the last integration step.
std::string id
vehicle's ID
double myCurrentMeanSpeed
The current mean speed.
void processJams(std::vector< JamInfo * > &jams, JamInfo *currentJam)
Calculates aggregated values from the given jam structure, deletes all jam-pointers.
void aggregateOutputValues()
Aggregates and normalize some values for the detector output during detectorUpdate()
int myNumberOfSeenVehicles
The number of vehicles, present on the detector at the last reset.
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
double myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
double myMaxJamInMeters
The max jam length [m].
double myDetectorLength
The total detector length.
A VehicleInfo stores values that are tracked for the individual vehicles on the detector,...
void initAuxiliaries(std::vector< MSLane * > &lanes)
Checks integrity of myLanes, adds internal-lane information, inits myLength, myFirstLane,...
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
double getLength() const
Returns the lane's length.
double myStartedHalts
The number of started halts [#].
double myStartPos
The position the detector starts at on the first lane.
std::string time2string(SUMOTime t)
virtual bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
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...
double getMinGap() const
Get the free space in front of vehicles of this class.
double myJamLengthInMetersSum
The sum of jam lengths [m].
bool hasEntered
Whether the vehicle has already entered the detector (don't count twice!)
double timeLoss
timeloss during the last integration step
double accumulatedTimeLoss
Accumulated time loss that this vehicle suffered since it entered the detector.
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
MSLane * getCanonicalPredecessorLane() const
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...
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...
int myCurrentJamNo
The current jam number.
virtual void reset()
Resets all values.
void calculateTimeLossAndTimeOnDetector(const SUMOVehicle &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...
std::map< std::string, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
VehicleInfoMap myVehicleInfos
int myNumberOfLeftVehicles
The number of vehicles, which have left the detector since the last reset.
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
double myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
MSLane * myFirstLane
The first lane of the detector's lane sequence.
double myEndPos
The position the detector ends at on the last lane.
MSLane * myLastLane
The last lane of the detector's lane sequence.
std::vector< MSLane * > getLanes()
Returns a vector containing pointers to the lanes covered by the detector ordered from its first to i...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double speed
Speed after the last integration step.
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...
int myCurrentHaltingsNumber
The number of halted vehicles [#].
void addDetectorToLanes(std::vector< MSLane * > &lanes)
This adds the detector as a MoveReminder to the associated lanes.
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Write the generated output to the given device.
double getLength() const
Returns the length of this link.
virtual double getPreviousSpeed() const =0
Returns the vehicle's previous speed.
double getLength() const
Get vehicle's length [m].
std::map< std::string, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
SUMOTime myJamHaltingTimeThreshold
A vehicle must be that long beyond myJamHaltingSpeedThreshold to be counted as a part of a jam.
bool vehicleApplies(const SUMOTrafficObject &veh) const
Checks whether the detector measures vehicles of the given type.
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...
double accel
Acceleration in the last integration step.
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
virtual void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
std::vector< double > myOffsets
The distances of the lane-beginnings from the detector start-point.
MoveNotificationInfo * makeMoveNotification(const SUMOVehicle &veh, double oldPos, double newPos, double newSpeed, const VehicleInfo &vehInfo) const
Creates and returns a MoveNotificationInfo containing detector specific information on the vehicle's ...
int getEstimatedCurrentVehicleNumber(double speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
double length
vehicle's length
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
std::vector< SUMOTime > myPastIntervalStandingDurations
Halting durations of ended halts for the current interval [s].
virtual double getPositionOnLane() const =0
Get the vehicle's position along the lane.
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
double myMeanMaxJamInMeters
The mean jam length [m].
std::string myID
The name of the object.
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
const std::string & getID() const
Returns the id.
Notification
Definition of a vehicle state.
The vehicle arrived at a junction.
std::vector< std::string > getCurrentVehicleIDs() const
Returns the IDs of the vehicles within the area.
int myMaxJamInVehicles
The max jam length [#veh].
MSLane * getViaLane() const
Returns the following inner lane.
double myCurrentOccupancy
The current occupancy.
int myMaxVehicleNumber
The maximal number of vehicles located on the detector simultaneously since the last reset.
MSLane *const myLane
Lane on which the reminder works.
bool onDetector
whether the vehicle is on the detector at the end of the current timestep
virtual bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane)
Adds the vehicle to known vehicles if not beyond the dector.
virtual double getSpeed() const =0
Returns the vehicle's current speed.
std::set< std::string > myLeftVehicles
Keep track of vehicles that left the detector by a regular move along a junction (not lanechange,...
double myOccupancySum
The sum of occupancies [%].
double myCurrentJamLengthInMeters
The overall jam length in meters.