43 #ifdef CHECK_MEMORY_LEAKS
45 #endif // CHECK_MEMORY_LEAKS
58 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
59 myJamHaltingTimeThreshold(haltingTimeThreshold),
60 myJamDistanceThreshold(jamDistThreshold),
61 myStartPos(startPos), myEndPos(startPos + detLength),
63 myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
64 myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
65 myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
66 myCurrentHaltingsNumber(0)
70 assert(
myStartPos >= 0 && myStartPos < myLane->getLength());
161 std::map<SUMOVehicle*, SUMOTime> haltingVehicles;
162 std::map<SUMOVehicle*, SUMOTime> intervalHaltingVehicles;
163 std::vector<JamInfo*> jams;
201 bool isInJam =
false;
212 haltingVehicles[veh] =
DELTA_T;
213 intervalHaltingVehicles[veh] =
DELTA_T;
240 if (currentJam == 0) {
251 jams.push_back(currentJam);
260 if (currentJam != 0) {
261 jams.push_back(currentJam);
266 if (currentJam != 0) {
267 jams.push_back(currentJam);
276 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
279 (*(*i)->firstStandingVehicle)->getPositionOnLane()
280 - (*(*i)->lastStandingVehicle)->getPositionOnLane()
281 + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
283 if (occ && occ == *(*i)->firstStandingVehicle && occ != *(*i)->lastStandingVehicle) {
285 - (*(*i)->lastStandingVehicle)->getPositionOnLane()
286 + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
288 unsigned jamLengthInVehicles = (unsigned) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
323 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
333 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
343 unsigned haltingNo = 0;
345 haltingDurationSum += (*i);
346 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
350 haltingDurationSum += (*i).second;
351 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
354 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
356 SUMOTime intervalHaltingDurationSum = 0;
357 SUMOTime intervalMaxHaltingDuration = 0;
358 unsigned intervalHaltingNo = 0;
360 intervalHaltingDurationSum += (*i);
361 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
365 intervalHaltingDurationSum += (*i).second;
366 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
369 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
372 <<
"meanSpeed=\"" << meanSpeed <<
"\" "
373 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" "
375 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" "
376 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" "
381 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" "
382 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" "
383 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" "
384 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" "
385 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" "
386 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" "
388 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" "
397 dev.
writeXMLHeader(
"detector",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/det_e2_file.xsd\"");
479 std::vector<std::string>
481 std::vector<std::string> ret;
484 ret.push_back(veh->
getID());
486 std::sort(ret.begin(), ret.end());
std::map< SUMOVehicle *, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
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.
Representation of a vehicle in the micro simulation.
unsigned myCurrentJamNo
The current jam number.
unsigned getCurrentJamNumber() const
Returns the current number of jams.
SUMOReal myMaxJamInMeters
The max jam length [m].
unsigned getCurrentStartedHalts() const
Returns the length of all jams in meters.
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.
MSLane *const myLane
Lane on which the reminder works.
unsigned getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle's position along the lane.
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].
A class used to sort known vehicles by their position.
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
unsigned myMaxVehicleNumber
The max number of vehicles [#veh].
SUMOReal getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
SUMOReal myCurrentMeanLength
The current mean length.
unsigned myCurrentStartedHalts
The number of started halts in the last step.
const MSLane * getLane() const
Returns the lane the reminder works on.
SUMOReal getPartialOccupatorEnd() const
Returns the position of the in-lapping vehicle's end.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
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.
unsigned myVehicleSamples
The number of collected samples [#].
Representation of a vehicle.
std::map< SUMOVehicle *, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
std::list< SUMOVehicle * > myKnownVehicles
List of known vehicles.
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
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.
unsigned myCurrentJamLengthInVehicles
The overall jam length in vehicles.
SUMOTime myJamHaltingTimeThreshold
A vehicle must be that long beyond myJamHaltingSpeedThreshold to be counted as a part of a jam...
SUMOReal mySpeedSum
The sum of collected vehicle speeds [m/s].
unsigned myMeanVehicleNumber
The mean number of vehicles [#veh].
SUMOReal myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
SUMOReal getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
unsigned myMeanMaxJamInVehicles
The mean jam length [#veh].
SUMOReal myCurrentJamLengthInMeters
The overall jam length in meters.
std::list< SUMOVehicle * >::const_iterator firstStandingVehicle
The first standing vehicle.
SUMOReal myStartPos
The position the detector starts at.
unsigned myMaxJamInVehicles
The max jam length [#veh].
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 [%].
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
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.
unsigned myTimeSamples
The current aggregation duration [#steps].
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
unsigned getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
SUMOReal myMeanMaxJamInMeters
The mean jam length [m].
SUMOReal myOccupancySum
The sum of occupancies [%].
const MSLane *const myLane
The lane the detector is placed at.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
MSE2Collector(const std::string &id, DetectorUsage usage, MSLane *const lane, SUMOReal startPos, SUMOReal detLength, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold)
Constructor.
std::list< SUMOVehicle * >::const_iterator lastStandingVehicle
The last standing vehicle.
unsigned myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
SUMOReal myJamLengthInMetersSum
The sum of jam lengths [m].
SUMOReal getCurrentMaxJamLengthInMeters() const
Returns the length in meters of the currently largest jam.
MSVehicle * getPartialOccupator() const
Returns the vehicle which laps into this lane.
Static storage of an output device and its base (abstract) implementation.
unsigned getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes a known vehicle due to its lane-change.
MSLane * getLane() const
Returns the lane the vehicle is on.
Representation of a lane in the micro simulation.
SUMOReal myCurrentHaltingsNumber
The number of halted vehicles [#].
int operator()(const SUMOVehicle *v1, const SUMOVehicle *v2)
Comparison funtcion.
Base of value-generating classes (detectors)
const std::string & getID() const
Returns the name of the vehicle.
SUMOReal myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
unsigned myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
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.