45 #ifdef CHECK_MEMORY_LEAKS
47 #endif // CHECK_MEMORY_LEAKS
58 const std::string& vTypes) :
61 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
62 myJamHaltingTimeThreshold(haltingTimeThreshold),
63 myJamDistanceThreshold(jamDistThreshold),
64 myStartPos(startPos), myEndPos(startPos + detLength),
66 myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
67 myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
68 myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
69 myCurrentHaltingsNumber(0), myPassedVeh(0) {
71 assert(
myStartPos >= 0 && myStartPos < myLane->getLength());
82 const std::set<std::string>& vTypes) :
85 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
86 myJamHaltingTimeThreshold(haltingTimeThreshold),
87 myJamDistanceThreshold(jamDistThreshold),
88 myStartPos(startPos), myEndPos(startPos + detLength),
90 myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
91 myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
92 myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
93 myCurrentHaltingsNumber(0), myPassedVeh(0) {
95 assert(
myStartPos >= 0 && myStartPos < myLane->getLength());
130 timeOnDet -= timeBeforeEnter;
141 const SUMOReal timeAfterLeave =
TS - timeBeforeLeave;
142 timeOnDet -= timeAfterLeave;
148 const SUMOReal averageSpeedOnDetector = (enterSpeed + leaveSpeed) / 2.;
150 timeOnDet, lengthOnDet, newPos,
155 const SUMOReal averageSpeedOnDetector = (enterSpeed + leaveSpeed) / 2.;
157 timeOnDet, lengthOnDet, newPos,
160 std::ostringstream str;
162 <<
" MSE2Collector::notifyMove::"
223 std::map<const std::string, SUMOTime> haltingVehicles;
224 std::map<const std::string, SUMOTime> intervalHaltingVehicles;
225 std::vector<JamInfo*> jams;
240 lengthSum += i->lengthOnDet;
244 bool isInJam =
false;
255 haltingVehicles[i->id] =
DELTA_T;
256 intervalHaltingVehicles[i->id] =
DELTA_T;
283 if (currentJam == 0) {
294 jams.push_back(currentJam);
303 if (currentJam != 0) {
304 jams.push_back(currentJam);
309 if (currentJam != 0) {
310 jams.push_back(currentJam);
319 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
321 const SUMOReal jamLengthInMeters = (*i)->firstStandingVehicle->position
322 - (*i)->lastStandingVehicle->position
323 + (*i)->lastStandingVehicle->lengthOnDet;
324 const int jamLengthInVehicles = (int)distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
357 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
368 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
380 haltingDurationSum += (*i);
381 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
385 haltingDurationSum += (*i).second;
386 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
389 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
391 SUMOTime intervalHaltingDurationSum = 0;
392 SUMOTime intervalMaxHaltingDuration = 0;
393 int intervalHaltingNo = 0;
395 intervalHaltingDurationSum += (*i);
396 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
400 intervalHaltingDurationSum += (*i).second;
401 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
404 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
408 <<
"meanSpeed=\"" << meanSpeed <<
"\" "
409 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" "
411 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" "
412 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" "
417 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" "
418 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" "
419 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" "
420 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" "
421 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" "
422 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" "
424 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" "
433 dev.
writeXMLHeader(
"detector",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/det_e2_file.xsd\"");
442 if (it->stillOnDet) {
458 if (it->stillOnDet) {
459 if (it->position < distance) {
460 distance = it->position;
463 if (it->speed <= thresholdSpeed || it->accel > 0) {
464 count = (int)(realDistance / it->lengthWithGap) + 1;
484 if (it->stillOnDet) {
485 if (it->position < distance) {
486 distance = it->position;
489 if (it->speed <= 0.5) {
490 realDistance = distance - it->lengthWithGap;
494 std::ostringstream str;
496 <<
" MSE2Collector::getEstimateQueueLength::"
498 <<
" vehicle " << it->id
499 <<
" positionOnLane " << it->position
500 <<
" vel " << it->speed
501 <<
" realDistance " << realDistance;
574 std::vector<std::string>
576 std::vector<std::string> ret;
578 ret.push_back(i->id);
580 std::sort(ret.begin(), ret.end());
585 const std::vector<MSE2Collector::VehicleInfo>&
int myMaxVehicleNumber
The max number of vehicles [#veh].
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.
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.
std::map< const std::string, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
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].
virtual SUMOReal getPreviousSpeed() const =0
Returns the vehicle's previous speed.
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.
std::map< const std::string, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
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 [#].
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
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].
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.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
Something on a lane to be noticed about vehicle movement.
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.
SUMOReal myCurrentMeanSpeed
The current mean speed.
void reset()
Resets all values.
virtual SUMOReal getAcceleration() const =0
Returns the vehicle's acceleration.
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 SUMOReal getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
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.
#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.
virtual const std::string & getID() const =0
Get the vehicle's ID.
Base of value-generating classes (detectors)
SUMOReal myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.