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) :
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;
255 if (fabs(value - snapPoint) < snapDist) {
265 std::vector<std::string>::const_iterator i;
266 std::vector<MSLane*> lanes;
270 lanes.push_back(lane);
274 std::vector<MSLane*>::const_iterator j;
275 MSLane* previous =
nullptr;
277 for (j = lanes.begin(); j != lanes.end(); ++j) {
290 #ifdef DEBUG_E2_CONSTRUCTOR 292 std::cout <<
"Total detector length after recalculation = " <<
myDetectorLength << std::endl;
316 assert(dir ==
"fw" || dir ==
"bw");
317 bool fw = dir ==
"fw";
318 double linkLength = 0;
319 bool substractedLinkLength =
false;
321 #ifdef DEBUG_E2_CONSTRUCTOR 323 std::cout <<
"\n" <<
"selectLanes()" << (fw ?
"(forward)" :
"(backward)") << std::endl;
326 std::vector<MSLane*> lanes;
332 assert(
myStartPos != std::numeric_limits<double>::max());
335 assert(
myEndPos != std::numeric_limits<double>::max());
342 lanes.push_back(lane);
343 #ifdef DEBUG_E2_CONSTRUCTOR 345 std::cout <<
"Added lane " << lane->
getID()
346 <<
" (length: " << lane->
getLength() <<
")" << std::endl;
360 substractedLinkLength =
false;
370 length -= linkLength;
371 substractedLinkLength =
true;
375 #ifdef DEBUG_E2_CONSTRUCTOR 378 std::cout << (fw ?
"Successor lane: " :
"Predecessor lane: ") <<
"'" << lane->
getID() <<
"'";
380 std::cout << std::endl;
385 if (substractedLinkLength) {
389 length += linkLength;
403 myEndPos = lanes[lanes.size() - 1]->getLength();
404 }
else if (length < 0) {
405 myEndPos = lanes[lanes.size() - 1]->getLength() + length;
410 }
else if (length < 0) {
417 std::reverse(lanes.begin(), lanes.end());
425 #ifdef DEBUG_E2_CONSTRUCTOR 427 std::cout <<
"\n" <<
"Adding detector " <<
myID <<
" to lanes:" << std::endl;
430 for (std::vector<MSLane*>::iterator l = lanes.begin(); l != lanes.end(); ++l) {
431 (*l)->addMoveReminder(
this);
432 #ifdef DEBUG_E2_CONSTRUCTOR 434 std::cout << (*l)->getID() << std::endl;
446 #ifdef DEBUG_E2_CONSTRUCTOR 448 std::cout <<
"\n" <<
"Initializing auxiliaries:" 468 std::vector<MSLane*>::iterator il = lanes.begin();
475 #ifdef DEBUG_E2_CONSTRUCTOR 477 std::cout <<
"\n" <<
"Initializing offsets:" << std::endl;
482 #pragma warning(push) 483 #pragma warning(disable: 4127) // do not warn about constant conditional expression 490 while (
internal !=
nullptr) {
491 myLanes.push_back(internal->getID());
494 #ifdef DEBUG_E2_CONSTRUCTOR 496 std::cout <<
"Offset for lane " <<
internal->getID() <<
" = " <<
myDetectorLength 507 assert(internal->getLinkCont().size() == 1);
509 internal =
internal->getLinkCont()[0]->getViaLaneOrLane();
510 if (!internal->isInternal()) {
522 while (il != lanes.end() && (*il)->isInternal()) {
525 if (il == lanes.end()) {
533 #ifdef DEBUG_E2_CONSTRUCTOR 547 if (++il == lanes.end()) {
551 if ((*il)->isInternal()) {
559 if (link ==
nullptr) {
560 throw InvalidArgument(
"Lanes '" + lane->
getID() +
"' and '" + (*il)->getID() +
"' are not consecutive in defintion of e2Detector '" +
getID() +
"'");
571 bool fw =
myEndPos == std::numeric_limits<double>::max();
578 #ifdef DEBUG_E2_CONSTRUCTOR 580 std::cout <<
"Total detector length after initAuxiliaries() = " <<
myDetectorLength << std::endl;
591 std::vector<MSLane*> res;
592 for (std::vector<std::string>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
601 double newPos,
double newSpeed) {
605 const std::string& vehID = veh.
getID();
614 #ifdef DEBUG_E2_NOTIFY_MOVE 617 <<
" MSE2Collector::notifyMove() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')" 618 <<
" called by vehicle '" << vehID <<
"'" 619 <<
" at relative position " << relPos
627 #ifdef DEBUG_E2_NOTIFY_MOVE 629 std::cout <<
"Vehicle has not yet reached the detector start position." << std::endl;
646 if (vehicleEnteredLaneAfterDetector) {
647 #ifdef DEBUG_E2_NOTIFY_MOVE 649 std::cout <<
"Vehicle entered lane behind detector." << std::endl;
657 if (vehPassedDetectorEnd) {
658 #ifdef DEBUG_E2_NOTIFY_MOVE 660 std::cout <<
"Vehicle has left the detector longitudinally." << std::endl;
674 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 676 std::cout <<
"\n" <<
SIMTIME <<
" notifyLeave() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')" 677 <<
"called by vehicle '" << veh.
getID() <<
"'" << std::endl;
684 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 686 std::cout <<
SIMTIME <<
" Left longitudinally (along junction) -> keep subscription [handle exit in notifyMove()]" << std::endl;
694 double exitOffset = vi->second->entryOffset -
myOffsets[vi->second->currentOffsetIndex] - vi->second->currentLane->getLength();
695 vi->second->exitOffset =
MAX2(vi->second->exitOffset, exitOffset);
696 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 698 std::cout <<
SIMTIME <<
" Vehicle '" << veh.
getID() <<
"' leaves the detector. Exit offset = " << vi->second->exitOffset << std::endl;
707 if (vi->second->hasEntered) {
712 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 714 std::cout <<
SIMTIME <<
" Left non-longitudinally (lanechange, teleport, parking, etc) -> discard subscription" << std::endl;
724 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 726 std::cout << std::endl <<
SIMTIME <<
" notifyEnter() (detID = " <<
myID <<
" on lane '" <<
myLane->
getID() <<
"')" 727 <<
" called by vehicle '" << veh.
getID()
728 <<
"' entering lane '" << (enteredLane != 0 ? enteredLane->
getID() :
"NULL") <<
"'" << std::endl;
735 assert(veh.
getLane() == enteredLane);
746 bool vehEnteredBehindDetectorEnd =
myEndPos <= vehBackPos;
747 if (vehEnteredBehindDetectorEnd) {
750 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 752 std::cout <<
"Vehicle entered the lane behind the detector, ignoring it." << std::endl;
753 std::cout <<
"(myEndPos = " << this->
myEndPos <<
", veh.getBackPositionOnLane() = " << vehBackPos <<
")" << std::endl;
760 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 764 std::cout <<
"Vehicle is off road (teleporting over edge)..." << std::endl;
769 const std::string& vehID = veh.
getID();
773 vi->second->currentOffsetIndex++;
774 vi->second->currentLane = enteredLane;
776 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 779 <<
"' already known. No new VehicleInfo is created.\n" 780 <<
"enteredLane = " << enteredLane->
getID() <<
"\nmyLanes[vi->offset] = " <<
myLanes[vi->second->currentOffsetIndex]
784 assert(
myLanes[vi->second->currentOffsetIndex] == enteredLane->
getID());
792 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 794 std::cout <<
SIMTIME <<
" Adding VehicleInfo for vehicle '" << veh.
getID() <<
"'." << std::endl;
808 assert(j >= 0 && j < (
int)
myLanes.size());
813 #ifdef DEBUG_E2_MAKE_VEHINFO 815 std::cout <<
SIMTIME <<
" Making VehicleInfo for vehicle '" << veh.
getID() <<
"'." 816 <<
"\ndistToDetectorEnd = " << distToDetectorEnd
818 <<
"\nentry lane offset (lane begin from detector begin) = " << entryOffset
829 #ifdef DEBUG_E2_DETECTOR_UPDATE 831 std::cout <<
"\n" <<
SIMTIME <<
" detectorUpdate() for detector '" <<
myID <<
"'" 852 std::vector<JamInfo*> jams;
853 std::map<std::string, SUMOTime> haltingVehicles;
854 std::map<std::string, SUMOTime> intervalHaltingVehicles;
859 const std::string& vehID = (*i)->id;
870 bool isInJam =
checkJam(i, haltingVehicles, intervalHaltingVehicles);
871 buildJam(isInJam, i, currentJam, jams);
884 #ifdef DEBUG_E2_DETECTOR_UPDATE 886 std::cout <<
"\n" <<
SIMTIME <<
" Current lanes for vehicles still on or approaching the detector:" << std::endl;
890 VehicleInfoMap::iterator iv;
892 #ifdef DEBUG_E2_DETECTOR_UPDATE 894 std::cout <<
" Vehicle '" << iv->second->id <<
"'" <<
": '" 895 << iv->second->currentLane->getID() <<
"'" 901 #ifdef DEBUG_E2_DETECTOR_UPDATE 903 std::cout <<
SIMTIME <<
" Discarding vehicles that have left the detector:" << std::endl;
907 std::set<std::string>::const_iterator i;
913 #ifdef DEBUG_E2_DETECTOR_UPDATE 915 std::cout <<
"Erased vehicle '" << *i <<
"'" << std::endl;
956 #ifdef DEBUG_E2_DETECTOR_UPDATE 958 std::cout <<
SIMTIME <<
" integrateMoveNotification() for vehicle '" << mni->
id <<
"'" 962 <<
"\nspeed = " << mni->
speed 991 #ifdef DEBUG_E2_NOTIFY_MOVE 993 std::cout <<
SIMTIME <<
" makeMoveNotification() for vehicle '" << veh.
getID() <<
"'" 994 <<
" oldPos = " << oldPos <<
" newPos = " << newPos <<
" newSpeed = " << newSpeed
1000 double timeOnDetector;
1012 double distToExit = -vehInfo.
exitOffset - newPos;
1014 lengthOnDetector =
MAX2(0., lengthOnDetector +
MIN2(0., distToExit));
1017 bool stillOnDetector = -distToExit < vehInfo.
length;
1019 #ifdef DEBUG_E2_NOTIFY_MOVE 1021 std::cout <<
SIMTIME <<
" lengthOnDetector = " << lengthOnDetector
1022 <<
"\nvehInfo.exitOffset = " << vehInfo.
exitOffset 1023 <<
" vehInfo.entryOffset = " << vehInfo.
entryOffset 1024 <<
" distToExit = " << distToExit
1035 #ifdef DEBUG_E2_JAMS 1037 std::cout <<
SIMTIME <<
" buildJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1043 if (currentJam ==
nullptr) {
1044 #ifdef DEBUG_E2_JAMS 1046 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of the first jam" << std::endl;
1059 #ifdef DEBUG_E2_JAMS 1061 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of a new jam" << std::endl;
1066 jams.push_back(currentJam);
1075 if (currentJam !=
nullptr) {
1076 #ifdef DEBUG_E2_JAMS 1078 std::cout <<
SIMTIME <<
" Closing current jam." << std::endl;
1081 jams.push_back(currentJam);
1082 currentJam =
nullptr;
1089 MSE2Collector::checkJam(std::vector<MoveNotificationInfo*>::const_iterator mni, std::map<std::string, SUMOTime>& haltingVehicles, std::map<std::string, SUMOTime>& intervalHaltingVehicles) {
1090 #ifdef DEBUG_E2_JAMS 1092 std::cout <<
SIMTIME <<
" CheckJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
1096 bool isInJam =
false;
1107 #ifdef DEBUG_E2_JAMS 1109 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' starts halting." << std::endl;
1112 haltingVehicles[(*mni)->id] =
DELTA_T;
1113 intervalHaltingVehicles[(*mni)->id] =
DELTA_T;
1135 #ifdef DEBUG_E2_JAMS 1137 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"'" << (isInJam ?
"is jammed." :
"is not jammed.") << std::endl;
1147 if (currentJam !=
nullptr) {
1148 jams.push_back(currentJam);
1149 currentJam =
nullptr;
1152 #ifdef DEBUG_E2_JAMS 1154 std::cout <<
"\n" <<
SIMTIME <<
" processJams()" 1155 <<
"\nNumber of jams: " << jams.size() << std::endl;
1164 for (std::vector<JamInfo*>::const_iterator i = jams.begin(); i != jams.end(); ++i) {
1171 const int jamLengthInVehicles = (int) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
1179 #ifdef DEBUG_E2_JAMS 1181 std::cout <<
SIMTIME <<
" processing jam nr." << ((int) distance((std::vector<JamInfo*>::const_iterator) jams.begin(), i) + 1)
1182 <<
"\njamLengthInMeters = " << jamLengthInMeters
1183 <<
" jamLengthInVehicles = " << jamLengthInVehicles
1191 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
1201 if (oldPos == newPos) {
1204 timeOnDetector =
TS;
1211 double entryTime = 0;
1213 if (oldPos < entryPos) {
1221 assert(entryPos < exitPos);
1225 if (exitPos == newPos) {
1240 timeOnDetector = exitTime - entryTime;
1241 timeLoss =
MAX2(0., timeOnDetector * (vmax - (entrySpeed + exitSpeed) / 2) / vmax);
1243 #ifdef DEBUG_E2_TIME_ON_DETECTOR 1245 std::cout <<
SIMTIME <<
" calculateTimeLoss() for vehicle '" << veh.
getID() <<
"'" 1246 <<
" oldPos = " << oldPos <<
" newPos = " << newPos
1247 <<
" entryPos = " << entryPos <<
" exitPos = " << exitPos
1248 <<
" timeOnDetector = " << timeOnDetector
1249 <<
" timeLoss = " << timeLoss
1263 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
1276 haltingDurationSum += (*i);
1277 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
1281 haltingDurationSum += (*i).second;
1282 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
1285 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
1287 SUMOTime intervalHaltingDurationSum = 0;
1288 SUMOTime intervalMaxHaltingDuration = 0;
1289 int intervalHaltingNo = 0;
1291 intervalHaltingDurationSum += (*i);
1292 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
1293 intervalHaltingNo++;
1296 intervalHaltingDurationSum += (*i).second;
1297 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
1298 intervalHaltingNo++;
1300 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
1302 #ifdef DEBUG_E2_XML_OUT 1304 std::stringstream ss;
1310 <<
"meanSpeed=\"" << meanSpeed <<
"\"";
1311 std::cout << ss.str() << std::endl;
1320 <<
"meanSpeed=\"" << meanSpeed <<
"\" " 1321 <<
"meanTimeLoss=\"" << meanTimeLoss <<
"\" " 1322 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" " 1324 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" " 1325 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" " 1330 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" " 1331 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" " 1332 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" " 1333 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" " 1334 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" " 1335 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" " 1337 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" " 1377 if (it->second->onDetector) {
1386 std::vector<std::string>
1388 std::vector<std::string> ret;
1390 if (i->second->onDetector) {
1391 ret.push_back(i->second->id);
1394 std::sort(ret.begin(), ret.end());
1399 std::vector<MSE2Collector::VehicleInfo*>
1401 std::vector<VehicleInfo*> res;
1402 VehicleInfoMap::const_iterator i;
1404 if (i->second->onDetector) {
1405 res.push_back(i->second);
1422 if (it->second->onDetector) {
1427 const double realDistance = it->second->distToDetectorEnd;
1428 if (it->second->lastSpeed <= thresholdSpeed || it->second->lastAccel > 0) {
1429 count = (int)(realDistance / (it->second->length + it->second->minGap)) + 1;
1444 double distance = std::numeric_limits<double>::max();
1445 double realDistance = 0;
1446 bool flowing =
true;
1449 if (it->second->onDetector) {
1450 distance =
MIN2(it->second->lastPos, distance);
1452 if (it->second->lastSpeed <= 0.5) {
1453 realDistance = distance - it->second->length + it->second->minGap;
std::vector< double > myOffsets
The distances of the lane-beginnings from the detector start-point.
int myMaxVehicleNumber
The maximal number of vehicles located on the detector simultaneously since the last reset...
static double speedAfterTime(const double t, const double oldSpeed, const double dist)
Calculates the speed after a time t [0,TS] given the initial speed and the distance traveled in an i...
int myMeanMaxJamInVehicles
The mean jam length [#veh].
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double lastAccel
Last value of the acceleration.
std::vector< SUMOTime > myPastIntervalStandingDurations
Halting durations of ended halts for the current interval [s].
std::vector< MoveNotificationInfo * >::const_iterator firstStandingVehicle
The first standing vehicle.
double myMeanMaxJamInMeters
The mean jam length [m].
void addDetectorToLanes(std::vector< MSLane *> &lanes)
This adds the detector as a MoveReminder to the associated lanes.
std::vector< std::string > getCurrentVehicleIDs() const
Returns the IDs of the vehicles within the area.
bool onDetector
whether the vehicle is on the detector at the end of the current timestep
static bool compareMoveNotification(MoveNotificationInfo *mni1, MoveNotificationInfo *mni2)
double myMaxOccupancy
The maximum occupancy [%].
double lastSpeed
Last value of the speed.
virtual ~MSE2Collector()
Destructor.
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
The vehicle arrived at a junction.
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.
Internal representation of a jam.
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
bool onDetector
whether the vehicle is on the detector at the end of the current timestep
MSLane *const myLane
Lane on which the reminder works.
Values collected in notifyMove and needed in detectorUpdate() to calculate the accumulated quantities...
double lengthOnDetector
The length of the part of the vehicle on the detector at the end of the last time step...
double myTotalTimeLoss
The total amount of all time losses [time x vehicle] since the last reset.
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
double timeOnDetector
Time spent on the detector during the last integration step.
double newPos
Position after the last integration step (relative to the vehicle's entry lane on the detector) ...
double getLength() const
Returns the length of the detector.
std::string id
Vehicle's id.
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
double accel
Acceleration in the last integration step.
double getLength() const
Returns the lane's length.
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
MSLane * getCanonicalPredecessorLane() const
int myMeanVehicleNumber
The mean number of vehicles [#veh].
virtual bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane)
Adds the vehicle to known vehicles if not beyond the dector.
const std::string & getID() const
Returns the id.
double totalTimeOnDetector
Accumulated time that this vehicle has spent on the detector since its last entry.
int myCurrentStartedHalts
The number of started halts in the last step.
std::vector< VehicleInfo * > getCurrentVehicles() const
Returns the VehicleInfos for the vehicles currently on the detector.
std::vector< MoveNotificationInfo * > myMoveNotifications
Temporal storage for notifications from vehicles that did call the detector's notifyMove() in the las...
void initAuxiliaries(std::vector< MSLane *> &lanes)
Checks integrity of myLanes, adds internal-lane information, inits myLength, myFirstLane, myLastLane, myOffsets Called once at construction. myLanes should form a continuous sequence.
#define WRITE_WARNING(msg)
MSLane * getCanonicalSuccessorLane() const
void aggregateOutputValues()
Aggregates and normalize some values for the detector output during detectorUpdate() ...
double myJamHaltingSpeedThreshold
A vehicle must driver slower than this to be counted as a part of a jam.
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].
std::vector< MoveNotificationInfo * >::const_iterator lastStandingVehicle
The last standing vehicle.
void checkPositioning(bool posGiven=false, double desiredLength=0.)
Adjusts positioning if the detector length is less than POSITION_EPS and tests some assertions...
void recalculateDetectorLength()
Updates the detector length after myStartPos and myEndPos have been modified.
double myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
int myTimeSamples
The current aggregation duration [#steps].
A VehicleInfo stores values that are tracked for the individual vehicles on the detector, e.g., accumulated timeloss. These infos are stored in myVehicles. If a vehicle leaves the detector (may it be temporarily), the entry in myVehicles is discarded, i.e. all information on the vehicle is reset.
double myCurrentMeanLength
The current mean length.
static double snap(double value, double snapPoint, double snapDist)
Snaps value to snpPoint if they are closer than snapDist.
MSLane * getViaLane() const
Returns the following inner lane.
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual void writeXMLDetectorProlog(OutputDevice &dev) const
Open the XML-output.
Representation of a vehicle.
int myNumberOfSeenVehicles
The number of vehicles, present on the detector at the last reset.
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
double myStartedHalts
The number of started halts [#].
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
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.
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 myJamLengthInMetersSum
The sum of jam lengths [m].
double myMaxJamInMeters
The max jam length [m].
MSLane * myFirstLane
The first lane of the detector's lane sequence.
std::string id
vehicle's ID
double myDetectorLength
The total detector length.
std::vector< MSLane * > getLanes()
Returns a vector containing pointers to the lanes covered by the detector ordered from its first to i...
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
virtual bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes a known vehicle due to its lane-change.
double myCurrentMeanSpeed
The current mean speed.
int myCurrentJamNo
The current jam number.
void processJams(std::vector< JamInfo *> &jams, JamInfo *currentJam)
Calculates aggregated values from the given jam structure, deletes all jam-pointers.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
double getMinGap() const
Get the free space in front of vehicles of this class.
Something on a lane to be noticed about vehicle movement.
std::map< std::string, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
double myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
double myEndPos
The position the detector ends at on the last lane.
MSLane * myLastLane
The last lane of the detector's lane sequence.
SUMOTime myJamHaltingTimeThreshold
A vehicle must be that long beyond myJamHaltingSpeedThreshold to be counted as a part of a jam...
double getLength() const
Returns the length of this link.
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
VehicleInfoMap myVehicleInfos
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...
virtual double getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
double accumulatedTimeLoss
Accumulated time loss that this vehicle suffered since it entered the detector.
bool hasEntered
Whether the vehicle has already entered the detector (don't count twice!)
double myStartPos
The position the detector starts at on the first lane.
virtual void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
std::string myID
The name of the object.
int getEstimatedCurrentVehicleNumber(double speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
virtual double getPositionOnLane() const =0
Get the vehicle's position along the lane.
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Write the generated output to the given device.
DetectorUsage myUsage
Information about how this detector is used.
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)
const std::string & getID() const
Returns the name of the vehicle type.
int myMaxJamInVehicles
The max jam length [#veh].
int myNumberOfLeftVehicles
The number of vehicles, which have left the detector since the last reset.
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
double getLength() const
Get vehicle's length [m].
double myOccupancySum
The sum of occupancies [%].
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...
Static storage of an output device and its base (abstract) implementation.
double myCurrentJamLengthInMeters
The overall jam length in meters.
int myCurrentHaltingsNumber
The number of halted vehicles [#].
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...
double timeLoss
timeloss during the last integration step
virtual bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
double myCurrentOccupancy
The current occupancy.
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 ...
double speed
Speed after the last integration step.
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...
Representation of a lane in the micro simulation.
virtual double getPreviousSpeed() const =0
Returns the vehicle's previous speed.
virtual const std::string & getID() const =0
Get the vehicle's ID.
int myNumberOfEnteredVehicles
Base of value-generating classes (detectors)
double getEstimateQueueLength() const
Returns an estimate of the lenght of the queue of vehicles currently stopped on the detector...
virtual double getAcceleration() const =0
Returns the vehicle's acceleration.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
double length
vehicle's length