 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
65 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
66 const std::string& vTypes) :
70 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
71 myJamHaltingTimeThreshold(haltingTimeThreshold),
72 myJamDistanceThreshold(jamDistThreshold),
73 myNumberOfEnteredVehicles(0),
74 myNumberOfSeenVehicles(0),
75 myNumberOfLeftVehicles(0) {
78 #ifdef DEBUG_E2_CONSTRUCTOR
80 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id
81 <<
" with lane = " << lane->
getID()
82 <<
" startPos = " << startPos
83 <<
" endPos = " << endPos
84 <<
" length = " << length
85 <<
" haltingTimeThreshold = " << haltingTimeThreshold
86 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
87 <<
" jamDistThreshold = " << jamDistThreshold
95 bool lengthInvalid = length == std::numeric_limits<double>::max() || length <= 0;
96 bool endPosInvalid = endPos == std::numeric_limits<double>::max();
97 bool posInvalid = startPos == std::numeric_limits<double>::max();
103 WRITE_WARNING(
"No valid detector length and start position given. Assuming startPos = 0 and length = end position");
107 WRITE_WARNING(
"No valid detector length and end position given. Assuming endPos = lane length and length = endPos-startPos");
110 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
111 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
112 bool valid = endPos <= lane->
getLength() && 0 <= startPos && startPos < endPos;
114 throw InvalidArgument(
"Error in specification for E2Detector '" +
id +
"'. Positional argument is malformed. 0 <= pos < endPos <= lane.getLength() is required.");
119 length = endPos - startPos;
120 }
else if (posInvalid) {
122 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
126 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
133 std::vector<MSLane*> lanes;
136 }
else if (endPosInvalid) {
140 lanes.push_back(lane);
150 DetectorUsage usage, std::vector<MSLane*> lanes,
double startPos,
double endPos,
151 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
152 const std::string& vTypes) :
156 myFirstLane(lanes[0]),
157 myLastLane(lanes[lanes.size() - 1]),
158 myStartPos(startPos),
160 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
161 myJamHaltingTimeThreshold(haltingTimeThreshold),
162 myJamDistanceThreshold(jamDistThreshold),
163 myNumberOfEnteredVehicles(0),
164 myNumberOfSeenVehicles(0),
165 myNumberOfLeftVehicles(0) {
168 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
172 #ifdef DEBUG_E2_CONSTRUCTOR
174 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id
176 <<
" endPos = " << endPos
178 <<
" startPos = " << startPos
179 <<
" haltingTimeThreshold = " << haltingTimeThreshold
180 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
181 <<
" jamDistThreshold = " << jamDistThreshold
193 myEndPos = lanes[lanes.size() - 1]->getLength();
207 std::stringstream ss;
208 ss <<
"Cannot build detector of length " << desiredLength
236 #ifdef DEBUG_E2_CONSTRUCTOR
238 std::stringstream ss;
241 std::cout <<
"myStartPos = " <<
myStartPos << std::endl;
242 std::cout <<
"myEndPos = " <<
myEndPos << std::endl;
256 if (fabs(value - snapPoint) < snapDist) {
266 std::vector<std::string>::const_iterator i;
267 std::vector<MSLane*> lanes;
271 lanes.push_back(lane);
275 std::vector<MSLane*>::const_iterator j;
276 MSLane* previous =
nullptr;
278 for (j = lanes.begin(); j != lanes.end(); ++j) {
291 #ifdef DEBUG_E2_CONSTRUCTOR
293 std::cout <<
"Total detector length after recalculation = " <<
myDetectorLength << std::endl;
317 assert(dir ==
"fw" || dir ==
"bw");
318 bool fw = dir ==
"fw";
319 double linkLength = 0;
320 bool substractedLinkLength =
false;
322 #ifdef DEBUG_E2_CONSTRUCTOR
324 std::cout <<
"\n" <<
"selectLanes()" << (fw ?
"(forward)" :
"(backward)") << std::endl;
327 std::vector<MSLane*> lanes;
333 assert(
myStartPos != std::numeric_limits<double>::max());
336 assert(
myEndPos != std::numeric_limits<double>::max());
343 lanes.push_back(lane);
344 #ifdef DEBUG_E2_CONSTRUCTOR
346 std::cout <<
"Added lane " << lane->
getID()
347 <<
" (length: " << lane->
getLength() <<
")" << std::endl;
361 substractedLinkLength =
false;
371 length -= linkLength;
372 substractedLinkLength =
true;
376 #ifdef DEBUG_E2_CONSTRUCTOR
379 std::cout << (fw ?
"Successor lane: " :
"Predecessor lane: ") <<
"'" << lane->
getID() <<
"'";
381 std::cout << std::endl;
386 if (substractedLinkLength) {
390 length += linkLength;
404 myEndPos = lanes[lanes.size() - 1]->getLength();
405 }
else if (length < 0) {
406 myEndPos = lanes[lanes.size() - 1]->getLength() + length;
411 }
else if (length < 0) {
418 std::reverse(lanes.begin(), lanes.end());
426 #ifdef DEBUG_E2_CONSTRUCTOR
428 std::cout <<
"\n" <<
"Adding detector " <<
myID <<
" to lanes:" << std::endl;
431 for (std::vector<MSLane*>::iterator l = lanes.begin(); l != lanes.end(); ++l) {
432 (*l)->addMoveReminder(
this);
433 #ifdef DEBUG_E2_CONSTRUCTOR
435 std::cout << (*l)->getID() << std::endl;
447 #ifdef DEBUG_E2_CONSTRUCTOR
449 std::cout <<
"\n" <<
"Initializing auxiliaries:"
469 std::vector<MSLane*>::iterator il = lanes.begin();
476 #ifdef DEBUG_E2_CONSTRUCTOR
478 std::cout <<
"\n" <<
"Initializing offsets:" << std::endl;
483 #pragma warning(push)
484 #pragma warning(disable: 4127) // do not warn about constant conditional expression
491 while (
internal !=
nullptr) {
492 myLanes.push_back(internal->getID());
495 #ifdef DEBUG_E2_CONSTRUCTOR
497 std::cout <<
"Offset for lane " <<
internal->getID() <<
" = " <<
myDetectorLength
508 assert(internal->getLinkCont().size() == 1);
510 internal =
internal->getLinkCont()[0]->getViaLaneOrLane();
511 if (!internal->isInternal()) {
523 while (il != lanes.end() && (*il)->isInternal()) {
526 if (il == lanes.end()) {
534 #ifdef DEBUG_E2_CONSTRUCTOR
548 if (++il == lanes.end()) {
552 if ((*il)->isInternal()) {
560 if (link ==
nullptr) {
561 throw InvalidArgument(
"Lanes '" + lane->
getID() +
"' and '" + (*il)->getID() +
"' are not consecutive in defintion of e2Detector '" +
getID() +
"'");
572 bool fw =
myEndPos == std::numeric_limits<double>::max();
579 #ifdef DEBUG_E2_CONSTRUCTOR
581 std::cout <<
"Total detector length after initAuxiliaries() = " <<
myDetectorLength << std::endl;
592 std::vector<MSLane*> res;
593 for (std::vector<std::string>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
602 double newPos,
double newSpeed) {
613 const std::string& vehID = veh.
getID();
622 #ifdef DEBUG_E2_NOTIFY_MOVE
625 <<
" MSE2Collector::notifyMove() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')"
626 <<
" called by vehicle '" << vehID <<
"'"
627 <<
" at relative position " << relPos
635 #ifdef DEBUG_E2_NOTIFY_MOVE
637 std::cout <<
"Vehicle has not yet reached the detector start position." << std::endl;
654 if (vehicleEnteredLaneAfterDetector) {
655 #ifdef DEBUG_E2_NOTIFY_MOVE
657 std::cout <<
"Vehicle entered lane behind detector." << std::endl;
665 if (vehPassedDetectorEnd) {
666 #ifdef DEBUG_E2_NOTIFY_MOVE
668 std::cout <<
"Vehicle has left the detector longitudinally." << std::endl;
686 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
688 std::cout <<
"\n" <<
SIMTIME <<
" notifyLeave() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')"
689 <<
"called by vehicle '" << veh.
getID() <<
"'" << std::endl;
699 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
701 std::cout <<
SIMTIME <<
" Left longitudinally (along junction) -> keep subscription [handle exit in notifyMove()]" << std::endl;
709 double exitOffset = vi->second->entryOffset -
myOffsets[vi->second->currentOffsetIndex] - vi->second->currentLane->getLength();
710 vi->second->exitOffset =
MAX2(vi->second->exitOffset, exitOffset);
711 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
713 std::cout <<
SIMTIME <<
" Vehicle '" << veh.
getID() <<
"' leaves the detector. Exit offset = " << vi->second->exitOffset << std::endl;
722 if (vi->second->hasEntered) {
727 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
729 std::cout <<
SIMTIME <<
" Left non-longitudinally (lanechange, teleport, parking, etc) -> discard subscription" << std::endl;
743 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
745 std::cout << std::endl <<
SIMTIME <<
" notifyEnter() (detID = " <<
myID <<
" on lane '" <<
myLane->
getID() <<
"')"
746 <<
" called by vehicle '" << veh.
getID()
747 <<
"' entering lane '" << (enteredLane != 0 ? enteredLane->
getID() :
"NULL") <<
"'" << std::endl;
752 assert(veh.
getLane() == enteredLane);
763 bool vehEnteredBehindDetectorEnd = (enteredLane ==
myLastLane) &&
myEndPos <= vehBackPos;
764 if (vehEnteredBehindDetectorEnd) {
767 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
769 std::cout <<
"Vehicle entered the lane behind the detector, ignoring it." << std::endl;
770 std::cout <<
"(myEndPos = " << this->
myEndPos <<
", veh.getBackPositionOnLane() = " << vehBackPos <<
")" << std::endl;
777 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
781 std::cout <<
"Vehicle is off road (teleporting over edge)..." << std::endl;
789 const std::string& vehID = veh.
getID();
793 if (vi->second->currentLane != enteredLane) {
794 vi->second->currentOffsetIndex++;
795 vi->second->currentLane = enteredLane;
798 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
801 <<
"' already known. No new VehicleInfo is created.\n"
802 <<
"enteredLane = " << enteredLane->
getID() <<
"\nmyLanes[vi->offset] = " <<
myLanes[vi->second->currentOffsetIndex]
806 assert(
myLanes[vi->second->currentOffsetIndex] == enteredLane->
getID());
814 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE
816 std::cout <<
SIMTIME <<
" Adding VehicleInfo for vehicle '" << veh.
getID() <<
"'." << std::endl;
831 assert(j >= 0 && j < (
int)
myLanes.size());
836 #ifdef DEBUG_E2_MAKE_VEHINFO
838 std::cout <<
SIMTIME <<
" Making VehicleInfo for vehicle '" << veh.
getID() <<
"'."
839 <<
"\ndistToDetectorEnd = " << distToDetectorEnd
841 <<
"\nentry lane offset (lane begin from detector begin) = " << entryOffset
852 #ifdef DEBUG_E2_DETECTOR_UPDATE
854 std::cout <<
"\n" <<
SIMTIME <<
" detectorUpdate() for detector '" <<
myID <<
"'"
875 std::vector<JamInfo*> jams;
876 std::map<std::string, SUMOTime> haltingVehicles;
877 std::map<std::string, SUMOTime> intervalHaltingVehicles;
882 const std::string& vehID = (*i)->id;
893 bool isInJam =
checkJam(i, haltingVehicles, intervalHaltingVehicles);
894 buildJam(isInJam, i, currentJam, jams);
907 #ifdef DEBUG_E2_DETECTOR_UPDATE
909 std::cout <<
"\n" <<
SIMTIME <<
" Current lanes for vehicles still on or approaching the detector:" << std::endl;
913 VehicleInfoMap::iterator iv;
915 #ifdef DEBUG_E2_DETECTOR_UPDATE
917 std::cout <<
" Vehicle '" << iv->second->id <<
"'" <<
": '"
918 << iv->second->currentLane->getID() <<
"'"
924 #ifdef DEBUG_E2_DETECTOR_UPDATE
926 std::cout <<
SIMTIME <<
" Discarding vehicles that have left the detector:" << std::endl;
930 std::set<std::string>::const_iterator i;
936 #ifdef DEBUG_E2_DETECTOR_UPDATE
938 std::cout <<
"Erased vehicle '" << *i <<
"'" << std::endl;
979 #ifdef DEBUG_E2_DETECTOR_UPDATE
981 std::cout <<
SIMTIME <<
" integrateMoveNotification() for vehicle '" << mni->
id <<
"'"
985 <<
"\nspeed = " << mni->
speed
1014 #ifdef DEBUG_E2_NOTIFY_MOVE
1016 std::cout <<
SIMTIME <<
" makeMoveNotification() for vehicle '" << veh.
getID() <<
"'"
1017 <<
" oldPos = " << oldPos <<
" newPos = " << newPos <<
" newSpeed = " << newSpeed
1023 double timeOnDetector;
1035 double distToExit = -vehInfo.
exitOffset - newPos;
1037 lengthOnDetector =
MAX2(0., lengthOnDetector +
MIN2(0., distToExit));
1040 bool stillOnDetector = -distToExit < vehInfo.
length;
1042 #ifdef DEBUG_E2_NOTIFY_MOVE
1044 std::cout <<
SIMTIME <<
" lengthOnDetector = " << lengthOnDetector
1045 <<
"\nvehInfo.exitOffset = " << vehInfo.
exitOffset
1046 <<
" vehInfo.entryOffset = " << vehInfo.
entryOffset
1047 <<
" distToExit = " << distToExit
1055 timeOnDetector, lengthOnDetector, timeLoss, stillOnDetector);
1060 #ifdef DEBUG_E2_JAMS
1062 std::cout <<
SIMTIME <<
" buildJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1068 if (currentJam ==
nullptr) {
1069 #ifdef DEBUG_E2_JAMS
1071 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of the first jam" << std::endl;
1084 #ifdef DEBUG_E2_JAMS
1086 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of a new jam" << std::endl;
1091 jams.push_back(currentJam);
1100 if (currentJam !=
nullptr) {
1101 #ifdef DEBUG_E2_JAMS
1103 std::cout <<
SIMTIME <<
" Closing current jam." << std::endl;
1106 jams.push_back(currentJam);
1107 currentJam =
nullptr;
1114 MSE2Collector::checkJam(std::vector<MoveNotificationInfo*>::const_iterator mni, std::map<std::string, SUMOTime>& haltingVehicles, std::map<std::string, SUMOTime>& intervalHaltingVehicles) {
1115 #ifdef DEBUG_E2_JAMS
1117 std::cout <<
SIMTIME <<
" CheckJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1121 bool isInJam =
false;
1132 #ifdef DEBUG_E2_JAMS
1134 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' starts halting." << std::endl;
1137 haltingVehicles[(*mni)->id] =
DELTA_T;
1138 intervalHaltingVehicles[(*mni)->id] =
DELTA_T;
1160 #ifdef DEBUG_E2_JAMS
1162 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"'" << (isInJam ?
"is jammed." :
"is not jammed.") << std::endl;
1172 if (currentJam !=
nullptr) {
1173 jams.push_back(currentJam);
1174 currentJam =
nullptr;
1177 #ifdef DEBUG_E2_JAMS
1179 std::cout <<
"\n" <<
SIMTIME <<
" processJams()"
1180 <<
"\nNumber of jams: " << jams.size() << std::endl;
1189 for (std::vector<JamInfo*>::const_iterator i = jams.begin(); i != jams.end(); ++i) {
1196 const int jamLengthInVehicles = (int) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
1204 #ifdef DEBUG_E2_JAMS
1206 std::cout <<
SIMTIME <<
" processing jam nr." << ((int) distance((std::vector<JamInfo*>::const_iterator) jams.begin(), i) + 1)
1207 <<
"\njamLengthInMeters = " << jamLengthInMeters
1208 <<
" jamLengthInVehicles = " << jamLengthInVehicles
1216 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
1226 if (oldPos == newPos) {
1229 timeOnDetector =
TS;
1236 double entryTime = 0;
1238 if (oldPos < entryPos) {
1246 assert(entryPos < exitPos);
1250 if (exitPos == newPos) {
1265 timeOnDetector = exitTime - entryTime;
1266 timeLoss =
MAX2(0., timeOnDetector * (vmax - (entrySpeed + exitSpeed) / 2) / vmax);
1268 #ifdef DEBUG_E2_TIME_ON_DETECTOR
1270 std::cout <<
SIMTIME <<
" calculateTimeLoss() for vehicle '" << veh.
getID() <<
"'"
1271 <<
" oldPos = " << oldPos <<
" newPos = " << newPos
1272 <<
" entryPos = " << entryPos <<
" exitPos = " << exitPos
1273 <<
" timeOnDetector = " << timeOnDetector
1274 <<
" timeLoss = " << timeLoss
1288 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
1301 haltingDurationSum += (*i);
1302 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
1306 haltingDurationSum += (*i).second;
1307 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
1310 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
1312 SUMOTime intervalHaltingDurationSum = 0;
1313 SUMOTime intervalMaxHaltingDuration = 0;
1314 int intervalHaltingNo = 0;
1316 intervalHaltingDurationSum += (*i);
1317 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
1318 intervalHaltingNo++;
1321 intervalHaltingDurationSum += (*i).second;
1322 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
1323 intervalHaltingNo++;
1325 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
1327 #ifdef DEBUG_E2_XML_OUT
1329 std::stringstream ss;
1335 <<
"meanSpeed=\"" << meanSpeed <<
"\"";
1336 std::cout << ss.str() << std::endl;
1345 <<
"meanSpeed=\"" << meanSpeed <<
"\" "
1346 <<
"meanTimeLoss=\"" << meanTimeLoss <<
"\" "
1347 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" "
1349 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" "
1350 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" "
1355 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" "
1356 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" "
1357 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" "
1358 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" "
1359 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" "
1360 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" "
1362 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" "
1402 if (it->second->onDetector) {
1411 std::vector<std::string>
1413 std::vector<std::string> ret;
1415 if (i->second->onDetector) {
1416 ret.push_back(i->second->id);
1419 std::sort(ret.begin(), ret.end());
1424 std::vector<MSE2Collector::VehicleInfo*>
1426 std::vector<VehicleInfo*> res;
1427 VehicleInfoMap::const_iterator i;
1429 if (i->second->onDetector) {
1430 res.push_back(i->second);
1447 if (it->second->onDetector) {
1452 const double realDistance = it->second->distToDetectorEnd;
1453 if (it->second->lastSpeed <= thresholdSpeed || it->second->lastAccel > 0) {
1454 count = (int)(realDistance / (it->second->length + it->second->minGap)) + 1;
1469 double distance = std::numeric_limits<double>::max();
1470 double realDistance = 0;
1471 bool flowing =
true;
1474 if (it->second->onDetector) {
1475 distance =
MIN2(it->second->lastPos, distance);
1477 if (it->second->lastSpeed <= 0.5) {
1478 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 length 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].
static int gNumSimThreads
how many threads to use for simulation
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,...
A scoped lock which only triggers on condition.
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.
@ NOTIFICATION_JUNCTION
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.