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 79 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id 80 <<
" with lane = " << lane->
getID()
81 <<
" startPos = " << startPos
82 <<
" endPos = " << endPos
83 <<
" length = " << length
84 <<
" haltingTimeThreshold = " << haltingTimeThreshold
85 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
86 <<
" 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 171 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id 173 <<
" endPos = " << endPos
175 <<
" startPos = " << startPos
176 <<
" haltingTimeThreshold = " << haltingTimeThreshold
177 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
178 <<
" jamDistThreshold = " << jamDistThreshold
189 myEndPos = lanes[lanes.size() - 1]->getLength();
203 std::stringstream ss;
204 ss <<
"Cannot build detector of length " << desiredLength
232 #ifdef DEBUG_E2_CONSTRUCTOR 233 std::stringstream ss;
236 std::cout <<
"myStartPos = " << myStartPos << std::endl;
237 std::cout <<
"myEndPos = " << myEndPos << std::endl;
251 if (fabs(value - snapPoint) < snapDist) {
261 std::vector<std::string>::const_iterator i;
262 std::vector<MSLane*> lanes;
266 lanes.push_back(lane);
270 std::vector<MSLane*>::const_iterator j;
273 for (j = lanes.begin(); j != lanes.end(); ++j) {
286 #ifdef DEBUG_E2_CONSTRUCTOR 287 std::cout <<
"Total detector length after recalculation = " <<
myDetectorLength << std::endl;
310 assert(dir ==
"fw" || dir ==
"bw");
311 bool fw = dir ==
"fw";
312 double linkLength = 0;
313 bool substractedLinkLength =
false;
315 #ifdef DEBUG_E2_CONSTRUCTOR 316 std::cout <<
"\n" <<
"selectLanes()" << (fw ?
"(forward)" :
"(backward)") << std::endl;
318 std::vector<MSLane*> lanes;
324 assert(
myStartPos != std::numeric_limits<double>::max());
327 assert(
myEndPos != std::numeric_limits<double>::max());
334 lanes.push_back(lane);
335 #ifdef DEBUG_E2_CONSTRUCTOR 336 std::cout <<
"Added lane " << lane->
getID()
337 <<
" (length: " << lane->
getLength() <<
")" << std::endl;
350 substractedLinkLength =
false;
360 length -= linkLength;
361 substractedLinkLength =
true;
365 #ifdef DEBUG_E2_CONSTRUCTOR 367 std::cout << (fw ?
"Successor lane: " :
"Predecessor lane: ") <<
"'" << lane->
getID() <<
"'";
369 std::cout << std::endl;
373 if (substractedLinkLength) {
377 length += linkLength;
391 myEndPos = lanes[lanes.size() - 1]->getLength();
392 }
else if (length < 0) {
393 myEndPos = lanes[lanes.size() - 1]->getLength() + length;
398 }
else if (length < 0) {
405 std::reverse(lanes.begin(), lanes.end());
413 #ifdef DEBUG_E2_CONSTRUCTOR 414 std::cout <<
"\n" <<
"Adding detector " <<
myID <<
" to lanes:" << std::endl;
416 for (std::vector<MSLane*>::iterator l = lanes.begin(); l != lanes.end(); ++l) {
417 (*l)->addMoveReminder(
this);
418 #ifdef DEBUG_E2_CONSTRUCTOR 419 std::cout << (*l)->getID() << std::endl;
430 #ifdef DEBUG_E2_CONSTRUCTOR 431 std::cout <<
"\n" <<
"Initializing auxiliaries:" 450 std::vector<MSLane*>::iterator il = lanes.begin();
457 #ifdef DEBUG_E2_CONSTRUCTOR 458 std::cout <<
"\n" <<
"Initializing offsets:" << std::endl;
462 #pragma warning(push) 463 #pragma warning(disable: 4127) // do not warn about constant conditional expression 470 while (
internal != 0) {
471 myLanes.push_back(internal->getID());
474 #ifdef DEBUG_E2_CONSTRUCTOR 475 std::cout <<
"Offset for lane " <<
internal->getID() <<
" = " <<
myDetectorLength 485 assert(internal->getLinkCont().size() == 1);
487 internal =
internal->getLinkCont()[0]->getViaLaneOrLane();
488 if (!internal->isInternal()) {
500 while (il != lanes.end() && (*il)->isInternal()) {
503 if (il == lanes.end()) {
511 #ifdef DEBUG_E2_CONSTRUCTOR 523 if (++il == lanes.end()) {
527 if ((*il)->isInternal()) {
536 throw InvalidArgument(
"Lanes '" + lane->
getID() +
"' and '" + (*il)->getID() +
"' are not consecutive in defintion of e2Detector '" +
getID() +
"'");
547 bool fw =
myEndPos == std::numeric_limits<double>::max();
554 #ifdef DEBUG_E2_CONSTRUCTOR 555 std::cout <<
"Total detector length after initAuxiliaries() = " <<
myDetectorLength << std::endl;
565 std::vector<MSLane*> res;
566 for (std::vector<std::string>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
575 double newPos,
double newSpeed) {
579 const std::string& vehID = veh.
getID();
588 #ifdef DEBUG_E2_NOTIFY_MOVE 590 <<
" MSE2Collector::notifyMove() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')" 591 <<
" called by vehicle '" << vehID <<
"'" 592 <<
" at relative position " << relPos
599 #ifdef DEBUG_E2_NOTIFY_MOVE 600 std::cout <<
"Vehicle has not yet reached the detector start position." << std::endl;
616 if (vehicleEnteredLaneAfterDetector) {
617 #ifdef DEBUG_E2_NOTIFY_MOVE 618 std::cout <<
"Vehicle entered lane behind detector." << std::endl;
625 if (vehPassedDetectorEnd) {
626 #ifdef DEBUG_E2_NOTIFY_MOVE 627 std::cout <<
"Vehicle has left the detector longitudinally." << std::endl;
640 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 641 std::cout <<
"\n" <<
SIMTIME <<
" notifyLeave() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')" 642 <<
"called by vehicle '" << veh.
getID() <<
"'" << std::endl;
648 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 649 std::cout <<
SIMTIME <<
" Left longitudinally (along junction) -> keep subscription [handle exit in notifyMove()]" << std::endl;
656 double exitOffset = vi->second->entryOffset -
myOffsets[vi->second->currentOffsetIndex] - vi->second->currentLane->getLength();
657 vi->second->exitOffset =
MAX2(vi->second->exitOffset, exitOffset);
658 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 659 std::cout <<
SIMTIME <<
" Vehicle '" << veh.
getID() <<
"' leaves the detector. Exit offset = " << vi->second->exitOffset << std::endl;
670 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 671 std::cout <<
SIMTIME <<
" Left non-longitudinally (lanechange, teleport, parking, etc) -> discard subscription" << std::endl;
680 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 681 std::cout <<
"\n" <<
SIMTIME <<
" notifyEnter() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')" 682 <<
"called by vehicle '" << veh.
getID()
683 <<
"' entering lane '" << (enteredLane != 0 ? enteredLane->
getID() :
"NULL") <<
"'" << std::endl;
689 assert(veh.
getLane() == enteredLane);
695 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 698 std::cout <<
"Vehicle is off road (teleporting over edge)..." << std::endl;
702 const std::string& vehID = veh.
getID();
706 vi->second->currentOffsetIndex++;
707 vi->second->currentLane = enteredLane;
709 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 711 <<
"' already known. No new VehicleInfo is created.\n" 712 <<
"enteredLane = " << enteredLane->
getID() <<
"\nmyLanes[vi->offset] = " <<
myLanes[vi->second->currentOffsetIndex]
715 assert(
myLanes[vi->second->currentOffsetIndex] == enteredLane->
getID());
723 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 724 std::cout <<
SIMTIME <<
" Adding VehicleInfo for vehicle '" << veh.
getID() <<
"'." << std::endl;
737 assert(j >= 0 && j < (
int)
myLanes.size());
742 #ifdef DEBUG_E2_MAKE_VEHINFO 743 std::cout <<
SIMTIME <<
" Making VehicleInfo for vehicle '" << veh.
getID() <<
"'." 744 <<
"\ndistToDetectorEnd = " << distToDetectorEnd
746 <<
"\nentry lane offset (lane begin from detector begin) = " << entryOffset
756 #ifdef DEBUG_E2_DETECTOR_UPDATE 757 std::cout <<
"\n" <<
SIMTIME <<
" detectorUpdate() for detector '" <<
myID <<
"'" 777 std::vector<JamInfo*> jams;
778 std::map<std::string, SUMOTime> haltingVehicles;
779 std::map<std::string, SUMOTime> intervalHaltingVehicles;
784 const std::string& vehID = (*i)->id;
795 bool isInJam =
checkJam(i, haltingVehicles, intervalHaltingVehicles);
796 buildJam(isInJam, i, currentJam, jams);
809 #ifdef DEBUG_E2_DETECTOR_UPDATE 810 std::cout <<
"\n" <<
SIMTIME <<
" Current lanes for vehicles still on the detector:" << std::endl;
813 VehicleInfoMap::iterator iv;
815 #ifdef DEBUG_E2_DETECTOR_UPDATE 816 std::cout <<
" Vehicle '" << iv->second->id <<
"'" <<
": '" 817 << iv->second->currentLane->getID() <<
"'" 822 #ifdef DEBUG_E2_DETECTOR_UPDATE 823 std::cout <<
SIMTIME <<
" Discarding vehicles that have left the detector:" << std::endl;
826 std::set<std::string>::const_iterator i;
832 #ifdef DEBUG_E2_DETECTOR_UPDATE 833 std::cout <<
"Erased vehicle '" << *i <<
"'" << std::endl;
873 #ifdef DEBUG_E2_DETECTOR_UPDATE 874 std::cout <<
SIMTIME <<
" integrateMoveNotification() for vehicle '" << mni->
id <<
"'" 878 <<
"\nspeed = " << mni->
speed 906 #ifdef DEBUG_E2_NOTIFY_MOVE 907 std::cout <<
SIMTIME <<
" makeMoveNotification() for vehicle '" << veh.
getID() <<
"'" 908 <<
" oldPos = " << oldPos <<
" newPos = " << newPos <<
" newSpeed = " << newSpeed
913 double timeOnDetector;
925 double distToExit = -vehInfo.
exitOffset - newPos;
927 lengthOnDetector =
MAX2(0., lengthOnDetector +
MIN2(0., distToExit));
930 bool stillOnDetector = -distToExit < vehInfo.
length;
932 #ifdef DEBUG_E2_NOTIFY_MOVE 933 std::cout <<
SIMTIME <<
" lengthOnDetector = " << lengthOnDetector
934 <<
"\nvehInfo.exitOffset = " << vehInfo.
exitOffset 935 <<
" vehInfo.entryOffset = " << vehInfo.
entryOffset 936 <<
" distToExit = " << distToExit
947 std::cout <<
SIMTIME <<
" buildJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
952 if (currentJam == 0) {
954 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of the first jam" << std::endl;
967 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of a new jam" << std::endl;
971 jams.push_back(currentJam);
980 if (currentJam != 0) {
982 std::cout <<
SIMTIME <<
" Closing current jam." << std::endl;
984 jams.push_back(currentJam);
992 MSE2Collector::checkJam(std::vector<MoveNotificationInfo*>::const_iterator mni, std::map<std::string, SUMOTime>& haltingVehicles, std::map<std::string, SUMOTime>& intervalHaltingVehicles) {
994 std::cout <<
SIMTIME <<
" CheckJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
997 bool isInJam =
false;
1008 #ifdef DEBUG_E2_JAMS 1009 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' starts halting." << std::endl;
1011 haltingVehicles[(*mni)->id] =
DELTA_T;
1012 intervalHaltingVehicles[(*mni)->id] =
DELTA_T;
1034 #ifdef DEBUG_E2_JAMS 1035 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"'" << (isInJam ?
"is jammed." :
"is not jammed.") << std::endl;
1044 if (currentJam != 0) {
1045 jams.push_back(currentJam);
1049 #ifdef DEBUG_E2_JAMS 1050 std::cout <<
"\n" <<
SIMTIME <<
" processJams()" 1051 <<
"\nNumber of jams: " << jams.size() << std::endl;
1059 for (std::vector<JamInfo*>::const_iterator i = jams.begin(); i != jams.end(); ++i) {
1066 const int jamLengthInVehicles = (int) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
1074 #ifdef DEBUG_E2_JAMS 1075 std::cout <<
SIMTIME <<
" processing jam nr." << ((int) distance((std::vector<JamInfo*>::const_iterator) jams.begin(), i) + 1)
1076 <<
"\njamLengthInMeters = " << jamLengthInMeters
1077 <<
" jamLengthInVehicles = " << jamLengthInVehicles
1084 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
1094 if (oldPos == newPos) {
1097 timeOnDetector =
TS;
1104 double entryTime = 0;
1106 if (oldPos < entryPos) {
1114 assert(entryPos < exitPos);
1118 if (exitPos == newPos) {
1133 timeOnDetector = exitTime - entryTime;
1134 timeLoss =
MAX2(0., timeOnDetector * (vmax - (entrySpeed + exitSpeed) / 2) / vmax);
1136 #ifdef DEBUG_E2_TIME_ON_DETECTOR 1137 std::cout <<
SIMTIME <<
" calculateTimeLoss() for vehicle '" << veh.
getID() <<
"'" 1138 <<
" oldPos = " << oldPos <<
" newPos = " << newPos
1139 <<
" entryPos = " << entryPos <<
" exitPos = " << exitPos
1140 <<
" timeOnDetector = " << timeOnDetector
1141 <<
" timeLoss = " << timeLoss
1154 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
1167 haltingDurationSum += (*i);
1168 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
1172 haltingDurationSum += (*i).second;
1173 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
1176 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
1178 SUMOTime intervalHaltingDurationSum = 0;
1179 SUMOTime intervalMaxHaltingDuration = 0;
1180 int intervalHaltingNo = 0;
1182 intervalHaltingDurationSum += (*i);
1183 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
1184 intervalHaltingNo++;
1187 intervalHaltingDurationSum += (*i).second;
1188 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
1189 intervalHaltingNo++;
1191 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
1193 #ifdef DEBUG_E2_XML_OUT 1194 std::stringstream ss;
1200 <<
"meanSpeed=\"" << meanSpeed <<
"\"";
1201 std::cout << ss.str() << std::endl;
1209 <<
"meanSpeed=\"" << meanSpeed <<
"\" " 1210 <<
"meanTimeLoss=\"" << meanTimeLoss <<
"\" " 1211 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" " 1213 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" " 1214 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" " 1219 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" " 1220 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" " 1221 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" " 1222 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" " 1223 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" " 1224 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" " 1226 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" " 1266 if (it->second->onDetector) {
1275 std::vector<std::string>
1277 std::vector<std::string> ret;
1279 if (i->second->onDetector) {
1280 ret.push_back(i->second->id);
1283 std::sort(ret.begin(), ret.end());
1288 std::vector<MSE2Collector::VehicleInfo*>
1290 std::vector<VehicleInfo*> res;
1291 VehicleInfoMap::const_iterator i;
1293 if (i->second->onDetector) {
1294 res.push_back(i->second);
1311 if (it->second->onDetector) {
1316 const double realDistance = it->second->distToDetectorEnd;
1317 if (it->second->lastSpeed <= thresholdSpeed || it->second->lastAccel > 0) {
1318 count = (int)(realDistance / (it->second->length + it->second->minGap)) + 1;
1333 double distance = std::numeric_limits<double>::max();
1334 double realDistance = 0;
1335 bool flowing =
true;
1338 if (it->second->onDetector) {
1339 distance =
MIN2(it->second->lastPos, distance);
1341 if (it->second->lastSpeed <= 0.5) {
1342 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...
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