44 #ifdef CHECK_MEMORY_LEAKS 46 #endif // CHECK_MEMORY_LEAKS 59 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
60 myJamHaltingTimeThreshold(haltingTimeThreshold),
61 myJamDistanceThreshold(jamDistThreshold),
62 myStartPos(startPos), myEndPos(startPos + detLength),
64 myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
65 myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
66 myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
67 myCurrentHaltingsNumber(0)
71 assert(
myStartPos >= 0 && myStartPos < myLane->getLength());
164 std::map<const SUMOVehicle*, SUMOTime> haltingVehicles;
165 std::map<const SUMOVehicle*, SUMOTime> intervalHaltingVehicles;
166 std::vector<JamInfo*> jams;
204 bool isInJam =
false;
215 haltingVehicles[veh] =
DELTA_T;
216 intervalHaltingVehicles[veh] =
DELTA_T;
243 if (currentJam == 0) {
254 jams.push_back(currentJam);
263 if (currentJam != 0) {
264 jams.push_back(currentJam);
269 if (currentJam != 0) {
270 jams.push_back(currentJam);
279 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
282 (*(*i)->firstStandingVehicle)->getPositionOnLane()
283 - (*(*i)->lastStandingVehicle)->getPositionOnLane()
284 + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
286 if (occ && occ == *(*i)->firstStandingVehicle && occ != *(*i)->lastStandingVehicle) {
288 - (*(*i)->lastStandingVehicle)->getPositionOnLane()
289 + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
291 unsigned jamLengthInVehicles = (unsigned) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
326 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
336 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
346 unsigned haltingNo = 0;
348 haltingDurationSum += (*i);
349 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
353 haltingDurationSum += (*i).second;
354 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
357 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
359 SUMOTime intervalHaltingDurationSum = 0;
360 SUMOTime intervalMaxHaltingDuration = 0;
361 unsigned intervalHaltingNo = 0;
363 intervalHaltingDurationSum += (*i);
364 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
368 intervalHaltingDurationSum += (*i).second;
369 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
372 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
375 <<
"meanSpeed=\"" << meanSpeed <<
"\" " 376 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" " 378 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" " 379 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" " 384 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" " 385 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" " 386 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" " 387 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" " 388 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" " 389 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" " 391 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" " 400 dev.
writeXMLHeader(
"detector",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/det_e2_file.xsd\"");
482 std::vector<std::string>
484 std::vector<std::string> ret;
487 ret.push_back(veh->
getID());
489 std::sort(ret.begin(), ret.end());
std::map< const 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::list< SUMOVehicle * > myKnownVehicles
List of known vehicles.
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed 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.
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
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 [%].
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.
int myCurrentHaltingsNumber
The number of halted vehicles [#].
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.
std::map< const SUMOVehicle *, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
MSLane * getLane() const
Returns the lane the vehicle is on.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
Representation of a lane in the micro simulation.
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.