66 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
67 const std::string& vTypes) :
71 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
72 myJamHaltingTimeThreshold(haltingTimeThreshold),
73 myJamDistanceThreshold(jamDistThreshold) {
76 #ifdef DEBUG_E2_CONSTRUCTOR 77 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id 78 <<
" with lane = " << lane->
getID()
79 <<
" startPos = " << startPos
80 <<
" endPos = " << endPos
81 <<
" length = " << length
82 <<
" haltingTimeThreshold = " << haltingTimeThreshold
83 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
84 <<
" jamDistThreshold = " << jamDistThreshold
99 WRITE_WARNING(
"No valid detector length and start position given. Assuming startPos = 0 and length = end position");
103 WRITE_WARNING(
"No valid detector length and end position given. Assuming endPos = lane length and length = endPos-startPos");
106 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
107 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
108 bool valid = endPos <= lane->
getLength() && 0 <= startPos && startPos < endPos;
110 throw InvalidArgument(
"Error in specification for E2Detector '" +
id +
"'. Positional argument is malformed. 0 <= pos < endPos <= lane.getLength() is required.");
115 length = endPos - startPos;
116 }
else if (posInvalid) {
118 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
122 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
129 std::vector<MSLane*> lanes;
132 }
else if (endPosInvalid) {
136 lanes.push_back(lane);
146 DetectorUsage usage, std::vector<MSLane*> lanes,
double startPos,
double endPos,
147 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
148 const std::string& vTypes) :
161 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
165 #ifdef DEBUG_E2_CONSTRUCTOR 166 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id 168 <<
" endPos = " << endPos
170 <<
" startPos = " << startPos
171 <<
" haltingTimeThreshold = " << haltingTimeThreshold
172 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
173 <<
" jamDistThreshold = " << jamDistThreshold
184 myEndPos = lanes[lanes.size() - 1]->getLength();
198 std::stringstream ss;
199 ss <<
"Cannot build detector of length " << desiredLength
227 #ifdef DEBUG_E2_CONSTRUCTOR 228 std::stringstream ss;
231 std::cout <<
"myStartPos = " << myStartPos << std::endl;
232 std::cout <<
"myEndPos = " << myEndPos << std::endl;
246 if (fabs(value - snapPoint) < snapDist) {
256 std::vector<std::string>::const_iterator i;
257 std::vector<MSLane*> lanes;
261 lanes.push_back(lane);
265 std::vector<MSLane*>::const_iterator j;
268 for (j = lanes.begin(); j != lanes.end(); ++j) {
281 #ifdef DEBUG_E2_CONSTRUCTOR 282 std::cout <<
"Total detector length after recalculation = " <<
myDetectorLength << std::endl;
305 assert(dir ==
"fw" || dir ==
"bw");
306 bool fw = dir ==
"fw";
307 double linkLength = 0;
308 bool substractedLinkLength =
false;
310 #ifdef DEBUG_E2_CONSTRUCTOR 311 std::cout <<
"\n" <<
"selectLanes()" << (fw ?
"(forward)" :
"(backward)") << std::endl;
313 std::vector<MSLane*> lanes;
329 lanes.push_back(lane);
330 #ifdef DEBUG_E2_CONSTRUCTOR 331 std::cout <<
"Added lane " << lane->
getID()
332 <<
" (length: " << lane->
getLength() <<
")" << std::endl;
345 substractedLinkLength =
false;
355 length -= linkLength;
356 substractedLinkLength =
true;
360 #ifdef DEBUG_E2_CONSTRUCTOR 362 std::cout << (fw ?
"Successor lane: " :
"Predecessor lane: ") <<
"'" << lane->
getID() <<
"'";
364 std::cout << std::endl;
368 if (substractedLinkLength) {
372 length += linkLength;
386 myEndPos = lanes[lanes.size() - 1]->getLength();
387 }
else if (length < 0) {
388 myEndPos = lanes[lanes.size() - 1]->getLength() + length;
393 }
else if (length < 0) {
400 std::reverse(lanes.begin(), lanes.end());
408 #ifdef DEBUG_E2_CONSTRUCTOR 409 std::cout <<
"\n" <<
"Adding detector " <<
myID <<
" to lanes:" << std::endl;
411 for (std::vector<MSLane*>::iterator l = lanes.begin(); l != lanes.end(); ++l) {
412 (*l)->addMoveReminder(
this);
413 #ifdef DEBUG_E2_CONSTRUCTOR 414 std::cout << (*l)->getID() << std::endl;
425 #ifdef DEBUG_E2_CONSTRUCTOR 426 std::cout <<
"\n" <<
"Initializing auxiliaries:" 445 std::vector<MSLane*>::iterator il = lanes.begin();
452 #ifdef DEBUG_E2_CONSTRUCTOR 453 std::cout <<
"\n" <<
"Initializing offsets:" << std::endl;
457 #pragma warning(push) 458 #pragma warning(disable: 4127) // do not warn about constant conditional expression 465 while (
internal != 0) {
466 myLanes.push_back(internal->getID());
469 #ifdef DEBUG_E2_CONSTRUCTOR 470 std::cout <<
"Offset for lane " <<
internal->getID() <<
" = " <<
myDetectorLength 480 assert(internal->getLinkCont().size() == 1);
482 internal =
internal->getLinkCont()[0]->getViaLaneOrLane();
483 if (!internal->isInternal()) {
495 while (il != lanes.end() && (*il)->isInternal()) {
498 if (il == lanes.end()) {
506 #ifdef DEBUG_E2_CONSTRUCTOR 518 if (++il == lanes.end()) {
522 if ((*il)->isInternal()) {
547 #ifdef DEBUG_E2_CONSTRUCTOR 548 std::cout <<
"Total detector length after initAuxiliaries() = " <<
myDetectorLength << std::endl;
558 std::vector<MSLane*> res;
559 for (std::vector<std::string>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
568 double newPos,
double newSpeed) {
572 const std::string& vehID = veh.
getID();
581 #ifdef DEBUG_E2_NOTIFY_MOVE 583 <<
" MSE2Collector::notifyMove()" 584 <<
" called by vehicle '" << vehID <<
"'" 585 <<
" at relative position " << relPos
592 #ifdef DEBUG_E2_NOTIFY_MOVE 593 std::cout <<
"Vehicle has not yet reached the detector start position." << std::endl;
606 if (vehPassedDetectorEnd) {
607 #ifdef DEBUG_E2_NOTIFY_MOVE 608 std::cout <<
"Vehicle has left the detector along a junction." << std::endl;
621 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 622 std::cout <<
"\n" <<
SIMTIME <<
" notifyLeave() called by vehicle '" << veh.
getID() <<
"'" << std::endl;
628 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 629 std::cout <<
SIMTIME <<
" Left longitudinally (along junction) -> keep subscription [handle exit in notifyMove()]" << std::endl;
636 double exitOffset =
myOffsets[vi->second->currentOffsetIndex] + vi->second->currentLane->getLength();
637 vi->second->exitOffset =
MIN2(vi->second->exitOffset, exitOffset);
638 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 639 std::cout <<
SIMTIME <<
" Vehicle '" << veh.
getID() <<
"' leaves the detector. Exit offset = " << exitOffset << std::endl;
650 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 651 std::cout <<
SIMTIME <<
" Left non-longitudinally (lanechange, teleport, parking, etc) -> discard subscription" << std::endl;
660 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 661 std::cout <<
"\n" <<
SIMTIME <<
" notifyEnter() called by vehicle '" << veh.
getID()
662 <<
"' entering lane '" << (enteredLane != 0 ? enteredLane->
getID() :
"NULL") <<
"'" << std::endl;
668 assert(veh.
getLane() == enteredLane);
674 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 677 std::cout <<
"Vehicle is off road (teleporting over edge)..." << std::endl;
681 const std::string& vehID = veh.
getID();
685 vi->second->currentOffsetIndex++;
686 vi->second->currentLane = enteredLane;
688 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 690 <<
"' already known. No new VehicleInfo is created.\n" 691 <<
"enteredLane = " << enteredLane->
getID() <<
"\nmyLanes[vi->offset] = " <<
myLanes[vi->second->currentOffsetIndex]
694 assert(
myLanes[vi->second->currentOffsetIndex] == enteredLane->
getID());
700 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 701 std::cout <<
SIMTIME <<
" Adding VehicleInfo for vehicle '" << veh.
getID() <<
"'." << std::endl;
714 assert(j >= 0 && j <
myLanes.size());
719 #ifdef DEBUG_E2_MAKE_VEHINFO 720 std::cout <<
SIMTIME <<
" Making VehicleInfo for vehicle '" << veh.
getID() <<
"'." 721 <<
"\ndistToDetectorEnd = " << distToDetectorEnd
723 <<
"\nentry lane offset (lane begin from detector begin) = " << entryOffset
732 #ifdef DEBUG_E2_DETECTOR_UPDATE 733 std::cout <<
"\n" <<
SIMTIME <<
" detectorUpdate() for detector '" <<
myID <<
"'" 751 std::vector<JamInfo*> jams;
752 std::map<std::string, SUMOTime> haltingVehicles;
753 std::map<std::string, SUMOTime> intervalHaltingVehicles;
758 const std::string& vehID = (*i)->id;
769 bool isInJam =
checkJam(i, haltingVehicles, intervalHaltingVehicles);
770 buildJam(isInJam, i, currentJam, jams);
783 #ifdef DEBUG_E2_DETECTOR_UPDATE 784 std::cout <<
"\n" <<
SIMTIME <<
" Current lanes for vehicles still on the detector:" << std::endl;
787 VehicleInfoMap::iterator iv;
789 #ifdef DEBUG_E2_DETECTOR_UPDATE 790 std::cout <<
" Vehicle '" << iv->second->id <<
"'" <<
": '" 791 << iv->second->currentLane->getID() <<
"'" 796 #ifdef DEBUG_E2_DETECTOR_UPDATE 797 std::cout <<
SIMTIME <<
" Discarding vehicles that have left the detector:" << std::endl;
800 std::set<std::string>::const_iterator i;
806 #ifdef DEBUG_E2_DETECTOR_UPDATE 807 std::cout <<
"Erased vehicle '" << *i <<
"'" << std::endl;
847 #ifdef DEBUG_E2_DETECTOR_UPDATE 848 std::cout <<
SIMTIME <<
" integrateMoveNotification() for vehicle '" << mni->
id <<
"'" 852 <<
"\nspeed = " << mni->
speed 880 #ifdef DEBUG_E2_NOTIFY_MOVE 881 std::cout <<
SIMTIME <<
" makeMoveNotification() for vehicle '" << veh.
getID() <<
"'" 882 <<
" oldPos = " << oldPos <<
" newPos = " << newPos <<
" newSpeed = " << newSpeed
887 double timeOnDetector;
901 lengthOnDetector =
MAX2(0., lengthOnDetector +
MIN2(0., distToExit));
904 bool stillOnDetector = -distToExit < vehInfo.
length;
906 #ifdef DEBUG_E2_NOTIFY_MOVE 907 std::cout <<
SIMTIME <<
" lengthOnDetector = " << lengthOnDetector
908 <<
"\nvehInfo.exitOffset = " << vehInfo.
exitOffset 909 <<
" vehInfo.entryOffset = " << vehInfo.
entryOffset 910 <<
" distToExit = " << distToExit
921 std::cout <<
SIMTIME <<
" buildJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
926 if (currentJam == 0) {
928 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of the first jam" << std::endl;
941 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of a new jam" << std::endl;
945 jams.push_back(currentJam);
954 if (currentJam != 0) {
956 std::cout <<
SIMTIME <<
" Closing current jam." << std::endl;
958 jams.push_back(currentJam);
966 MSE2Collector::checkJam(std::vector<MoveNotificationInfo*>::const_iterator mni, std::map<std::string, SUMOTime>& haltingVehicles, std::map<std::string, SUMOTime>& intervalHaltingVehicles) {
968 std::cout <<
SIMTIME <<
" CheckJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
971 bool isInJam =
false;
983 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' starts halting." << std::endl;
985 haltingVehicles[(*mni)->id] =
DELTA_T;
986 intervalHaltingVehicles[(*mni)->id] =
DELTA_T;
1008 #ifdef DEBUG_E2_JAMS 1009 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"'" << (isInJam ?
"is jammed." :
"is not jammed.") << std::endl;
1018 if (currentJam != 0) {
1019 jams.push_back(currentJam);
1023 #ifdef DEBUG_E2_JAMS 1024 std::cout <<
"\n" <<
SIMTIME <<
" processJams()" 1025 <<
"\nNumber of jams: " << jams.size() << std::endl;
1033 for (std::vector<JamInfo*>::const_iterator i = jams.begin(); i != jams.end(); ++i) {
1040 const int jamLengthInVehicles = (int) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
1048 #ifdef DEBUG_E2_JAMS 1049 std::cout <<
SIMTIME <<
" processing jam nr." << ((int) distance((std::vector<JamInfo*>::const_iterator) jams.begin(), i) + 1)
1050 <<
"\njamLengthInMeters = " << jamLengthInMeters
1051 <<
" jamLengthInVehicles = " << jamLengthInVehicles
1058 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
1068 if (oldPos == newPos) {
1071 timeOnDetector =
TS;
1078 double entryTime = 0;
1080 if (oldPos < entryPos) {
1088 assert(entryPos < exitPos);
1092 if (exitPos == newPos) {
1107 timeOnDetector = exitTime - entryTime;
1108 timeLoss =
MAX2(0., timeOnDetector * (vmax - (entrySpeed + exitSpeed) / 2) / vmax);
1110 #ifdef DEBUG_E2_TIME_ON_DETECTOR 1111 std::cout <<
SIMTIME <<
" calculateTimeLoss() for vehicle '" << veh.
getID() <<
"'" 1112 <<
" oldPos = " << oldPos <<
" newPos = " << newPos
1113 <<
" entryPos = " << entryPos <<
" exitPos = " << exitPos
1114 <<
" timeOnDetector = " << timeOnDetector
1115 <<
" timeLoss = " << timeLoss
1128 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
1135 const double meanTimeLoss = meanVehicleNumber != 0 ?
myTotalTimeLoss / meanVehicleNumber : -1;
1141 haltingDurationSum += (*i);
1142 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
1146 haltingDurationSum += (*i).second;
1147 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
1150 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
1152 SUMOTime intervalHaltingDurationSum = 0;
1153 SUMOTime intervalMaxHaltingDuration = 0;
1154 int intervalHaltingNo = 0;
1156 intervalHaltingDurationSum += (*i);
1157 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
1158 intervalHaltingNo++;
1161 intervalHaltingDurationSum += (*i).second;
1162 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
1163 intervalHaltingNo++;
1165 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
1167 #ifdef DEBUG_E2_XML_OUT 1168 std::stringstream ss;
1174 <<
"meanSpeed=\"" << meanSpeed <<
"\"";
1175 std::cout << ss.str() << std::endl;
1182 <<
"meanSpeed=\"" << meanSpeed <<
"\" " 1183 <<
"meanTimeLoss=\"" << meanTimeLoss <<
"\" " 1184 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" " 1186 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" " 1187 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" " 1192 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" " 1193 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" " 1194 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" " 1195 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" " 1196 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" " 1197 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" " 1199 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" " 1238 if (it->second->onDetector) {
1247 std::vector<std::string>
1249 std::vector<std::string> ret;
1251 if (i->second->onDetector) {
1252 ret.push_back(i->second->id);
1255 std::sort(ret.begin(), ret.end());
1260 std::vector<MSE2Collector::VehicleInfo*>
1262 std::vector<VehicleInfo*> res;
1263 VehicleInfoMap::const_iterator i;
1265 if (i->second->onDetector) {
1266 res.push_back(i->second);
1283 if (it->second->onDetector) {
1288 const double realDistance = it->second->distToDetectorEnd;
1289 if (it->second->lastSpeed <= thresholdSpeed || it->second->lastAccel > 0) {
1290 count = (int)(realDistance / (it->second->length + it->second->minGap)) + 1;
1306 double realDistance = 0;
1307 bool flowing =
true;
1310 if (it->second->onDetector) {
1311 distance =
MIN2(it->second->lastPos, distance);
1313 if (it->second->lastSpeed <= 0.5) {
1314 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 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...
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
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
The number of vehicles, which have entered the detector since the last reset.
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