46 #ifdef CHECK_MEMORY_LEAKS 48 #endif // CHECK_MEMORY_LEAKS 60 const std::string& vTypes) :
63 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
64 myJamHaltingTimeThreshold(haltingTimeThreshold),
65 myJamDistanceThreshold(jamDistThreshold),
66 myStartPos(startPos), myEndPos(startPos + detLength),
68 myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
69 myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
70 myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
71 myCurrentHaltingsNumber(0), myPassedVeh(0) {
73 assert(
myStartPos >= 0 && myStartPos < myLane->getLength());
84 const std::set<std::string>& vTypes) :
97 assert(
myStartPos >= 0 && myStartPos < myLane->getLength());
132 timeOnDet -= timeBeforeEnter;
144 const SUMOReal timeAfterLeave =
TS - timeBeforeLeave;
145 timeOnDet -= timeAfterLeave;
151 const SUMOReal averageSpeedOnDetector = (enterSpeed + leaveSpeed) / 2.;
153 timeOnDet, lengthOnDet, newPos,
158 const SUMOReal averageSpeedOnDetector = (enterSpeed + leaveSpeed) / 2.;
160 timeOnDet, lengthOnDet, newPos,
163 #ifdef DEBUG_NOTIFY_MOVE 164 std::ostringstream str;
166 <<
" MSE2Collector::notifyMove::" 171 std::cout << str.str() << std::endl;
231 std::map<std::string, SUMOTime> haltingVehicles;
232 std::map<std::string, SUMOTime> intervalHaltingVehicles;
233 std::vector<JamInfo*> jams;
243 std::vector<VehicleInfo>::const_iterator iv;
250 lengthSum += i->lengthOnDet;
254 bool isInJam =
false;
265 haltingVehicles[i->id] =
DELTA_T;
266 intervalHaltingVehicles[i->id] =
DELTA_T;
293 if (currentJam == 0) {
304 jams.push_back(currentJam);
313 if (currentJam != 0) {
314 jams.push_back(currentJam);
319 if (currentJam != 0) {
320 jams.push_back(currentJam);
329 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
331 const SUMOReal jamLengthInMeters = (*i)->firstStandingVehicle->position
332 - (*i)->lastStandingVehicle->position
333 + (*i)->lastStandingVehicle->lengthOnDet;
334 const int jamLengthInVehicles = (int)distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
367 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
380 if (iv->id == i->id) {
381 i->accumulatedTimeLoss += iv->timeLoss;
396 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
409 haltingDurationSum += (*i);
410 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
414 haltingDurationSum += (*i).second;
415 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
418 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
420 SUMOTime intervalHaltingDurationSum = 0;
421 SUMOTime intervalMaxHaltingDuration = 0;
422 int intervalHaltingNo = 0;
424 intervalHaltingDurationSum += (*i);
425 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
429 intervalHaltingDurationSum += (*i).second;
430 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
433 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
437 <<
"meanSpeed=\"" << meanSpeed <<
"\" " 438 <<
"meanTimeLoss=\"" << meanTimeLoss <<
"\" " 439 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" " 441 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" " 442 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" " 447 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" " 448 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" " 449 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" " 450 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" " 451 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" " 452 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" " 454 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" " 472 if (it->stillOnDet) {
488 if (it->stillOnDet) {
489 if (it->position < distance) {
490 distance = it->position;
493 if (it->speed <= thresholdSpeed || it->accel > 0) {
494 count = (int)(realDistance / it->lengthWithGap) + 1;
514 if (it->stillOnDet) {
515 if (it->position < distance) {
516 distance = it->position;
519 if (it->speed <= 0.5) {
520 realDistance = distance - it->lengthWithGap;
524 std::ostringstream str;
526 <<
" MSE2Collector::getEstimateQueueLength::" 528 <<
" vehicle " << it->id
529 <<
" positionOnLane " << it->position
530 <<
" vel " << it->speed
531 <<
" realDistance " << realDistance;
604 std::vector<std::string>
606 std::vector<std::string> ret;
608 ret.push_back(i->id);
610 std::sort(ret.begin(), ret.end());
615 const std::vector<MSE2Collector::VehicleInfo>&
int myMaxVehicleNumber
The max number of vehicles [#veh].
virtual SUMOReal getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
int myMeanMaxJamInVehicles
The mean jam length [#veh].
std::vector< SUMOTime > myPastIntervalStandingDurations
Halting durations of ended halts for the current interval [s].
std::vector< std::string > getCurrentVehicleIDs() const
Returns the IDs of the vehicles within the area.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
SUMOReal myTimeLossSum
The sum of timeLoss values [s].
SUMOReal myMaxJamInMeters
The max jam length [m].
virtual ~MSE2Collector()
Destructor.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
SUMOReal getCurrentMeanLength() const
Returns the mean vehicle length of vehicles currently on the detector.
The vehicle arrived at a junction.
Internal representation of a jam.
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
SUMOReal getLength() const
Returns the lane's length.
MSLane *const myLane
Lane on which the reminder works.
int getCurrentStartedHalts() const
Returns the length of all jams in meters.
int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
SUMOReal myStartedHalts
The number of started halts [#].
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
SUMOReal getLength() const
Get vehicle's length [m].
int getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
SUMOReal getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
int myMeanVehicleNumber
The mean number of vehicles [#veh].
int myCurrentStartedHalts
The number of started halts in the last step.
SUMOReal myCurrentMeanLength
The current mean length.
SUMOReal myVehicleSamples
The number of collected samples [#].
int myTimeSamples
The current aggregation duration [#steps].
const std::string & getID() const
Returns the id.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Adds the vehicle to known vehicles if not beyond the dector.
static SUMOReal speedAfterTime(const SUMOReal t, const SUMOReal oldSpeed, const SUMOReal dist)
Calculates the speed after a time t [0,TS] given the initial speed and the distance traveled in an i...
Internal representation of a vehicle.
std::vector< VehicleInfo > myKnownVehicles
List of known vehicles.
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
Representation of a vehicle.
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
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< VehicleInfo >::const_iterator firstStandingVehicle
The first standing vehicle.
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
std::vector< VehicleInfo >::const_iterator lastStandingVehicle
The last standing vehicle.
int myCurrentJamNo
The current jam number.
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
static SUMOReal passingTime(const SUMOReal lastPos, const SUMOReal passedPos, const SUMOReal currentPos, const SUMOReal lastSpeed, const SUMOReal currentSpeed)
Calculates the time at which the position passedPosition has been passed In case of a ballistic updat...
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
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)
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
SUMOReal myJamHaltingSpeedThreshold
A vehicle must driver slower than this to be counted as a part of a jam.
SUMOTime myJamHaltingTimeThreshold
A vehicle must be that long beyond myJamHaltingSpeedThreshold to be counted as a part of a jam...
SUMOReal getEstimateQueueLength() const
Returns an estimate of the lenght of the queue of vehicles currently stopped on the detector...
SUMOReal mySpeedSum
The sum of collected vehicle speeds [m/s].
SUMOReal myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
SUMOReal myCurrentJamLengthInMeters
The overall jam length in meters.
SUMOReal myStartPos
The position the detector starts at.
int getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
SUMOReal myEndPos
The position the detector ends at.
SUMOReal myCurrentOccupancy
The current occupancy.
SUMOReal myMaxOccupancy
The maximum occupancy [%].
std::vector< VehicleInfo > myPreviousKnownVehicles
List of previously known vehicles.
int getCurrentJamNumber() const
Returns the current number of jams.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
MSE2Collector(const std::string &id, DetectorUsage usage, MSLane *const lane, SUMOReal startPos, SUMOReal detLength, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, const std::string &vTypes)
Constructor.
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
SUMOReal getCurrentOccupancy() const
Returns the curent detector occupancy.
DetectorUsage myUsage
Information about how this detector is used.
SUMOReal myCurrentMeanSpeed
The current mean speed.
void reset()
Resets all values.
std::map< std::string, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
int myMaxJamInVehicles
The max jam length [#veh].
SUMOReal myMeanMaxJamInMeters
The mean jam length [m].
SUMOReal myOccupancySum
The sum of occupancies [%].
const std::string & getID() const
Returns the name of the vehicle type.
virtual const std::string & getID() const =0
Get the vehicle's ID.
virtual SUMOReal getAcceleration() const =0
Returns the vehicle's acceleration.
SUMOReal myJamLengthInMetersSum
The sum of jam lengths [m].
SUMOReal getCurrentMaxJamLengthInMeters() const
Returns the length in meters of the currently largest jam.
Static storage of an output device and its base (abstract) implementation.
int myCurrentHaltingsNumber
The number of halted vehicles [#].
static bool gSemiImplicitEulerUpdate
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes a known vehicle due to its lane-change.
const std::vector< VehicleInfo > & getCurrentVehicles() const
Returns the vehicles within the area.
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
virtual SUMOReal getPreviousSpeed() const =0
Returns the vehicle's previous speed.
#define WRITE_MESSAGE(msg)
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
int myPassedVeh
The number of vehicles passed on the sensor.
Representation of a lane in the micro simulation.
Base of value-generating classes (detectors)
SUMOReal myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.