MSMeanData_Net::MSLaneMeanDataValues Class Reference

#include <MSMeanData_Net.h>

Inheritance diagram for MSMeanData_Net::MSLaneMeanDataValues:

MSMeanData::MeanDataValues MSMoveReminder

Detailed Description

Data structure for mean (aggregated) edge/lane values.

Structure holding values that describe the flow and other physical properties aggregated over some seconds.

Definition at line 75 of file MSMeanData_Net.h.


Collected values

The number of vehicles that were emitted on the lane

unsigned nVehArrived
 The number of vehicles that finished on the lane.
unsigned nVehDeparted
unsigned nVehEntered
 The number of vehicles that entered this lane within the sample intervall.
unsigned nVehLeft
 The number of vehicles that left this lane within the sample intervall.
unsigned nVehLaneChangeFrom
 The number of vehicles that changed from this lane.
unsigned nVehLaneChangeTo
 The number of vehicles that changed to this lane.
SUMOReal vehLengthSum
 The sum of the lengths the vehicles had.
SUMOReal waitSeconds
 The number of vehicle probes with small speed.

Collected values

The number of sampled vehicle movements (in s)

SUMOReal travelledDistance
 The sum of the distances the vehicles travelled.
SUMOReal sampleSeconds

Public Member Functions

void addTo (MSMeanData::MeanDataValues &val) const throw ()
 Add the values of this to the given one and store them there.
const MSLane *const getLane () const throw ()
 Returns the lane the reminder works on.
virtual SUMOReal getSamples () const throw ()
bool isEmpty () const throw ()
 Returns whether any data was collected.
 MSLaneMeanDataValues (MSLane *const lane, const bool doAdd, const std::set< std::string > *const vTypes=0, const MSMeanData_Net *parent=0) throw ()
 Constructor.
void reset () throw ()
 Resets values so they may be used for the next interval.
virtual void update () throw ()
 Called if a per timestep update is needed. Default does nothing.
void write (OutputDevice &dev, const SUMOTime period, const SUMOReal numLanes, const SUMOReal length, const int numVehicles=-1) const throw (IOError)
 Writes output values into the given stream.
virtual ~MSLaneMeanDataValues () throw ()
 Destructor.
Methods inherited from MSMoveReminder
bool isStillActive (MSVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed) throw ()
 Computes current values and adds them to their sums.
bool notifyEnter (MSVehicle &veh, bool isEmit, bool isLaneChange) throw ()
 Computes current values and adds them to their sums.
void notifyLeave (MSVehicle &veh, bool isArrival, bool isLaneChange) throw ()
 Called if the vehicle leaves the reminder's lane.
Methods inherited from MSMoveReminder.
bool vehicleApplies (const SUMOVehicle &veh) const throw ()
 Tests whether the vehicles type is to be regarded.

Protected Attributes

MSLane *const myLane
 Lane on which the reminder works.

Private Attributes

const MSMeanData_NetmyParent
 The meandata parent.

Constructor & Destructor Documentation

MSMeanData_Net::MSLaneMeanDataValues::MSLaneMeanDataValues ( MSLane *const   lane,
const bool  doAdd,
const std::set< std::string > *const   vTypes = 0,
const MSMeanData_Net parent = 0 
) throw ()

Constructor.

Definition at line 57 of file MSMeanData_Net.cpp.

00060         : MSMeanData::MeanDataValues(lane, doAdd, vTypes), myParent(parent),
00061         nVehDeparted(0), nVehArrived(0), nVehEntered(0), nVehLeft(0),
00062         nVehLaneChangeFrom(0), nVehLaneChangeTo(0), waitSeconds(0), vehLengthSum(0) {}

MSMeanData_Net::MSLaneMeanDataValues::~MSLaneMeanDataValues (  )  throw () [virtual]

Destructor.

Definition at line 65 of file MSMeanData_Net.cpp.

00065                                                                   {
00066 }


Member Function Documentation

void MSMeanData_Net::MSLaneMeanDataValues::addTo ( MSMeanData::MeanDataValues val  )  const throw () [virtual]

Add the values of this to the given one and store them there.

Parameters:
[in] val The meandata to add to

Implements MSMeanData::MeanDataValues.

Definition at line 85 of file MSMeanData_Net.cpp.

References nVehArrived, nVehDeparted, nVehEntered, nVehLaneChangeFrom, nVehLaneChangeTo, nVehLeft, MSMeanData::MeanDataValues::sampleSeconds, MSMeanData::MeanDataValues::travelledDistance, vehLengthSum, and waitSeconds.

Referenced by MSMeanData_Net::writeEdge().

00085                                                                                      {
00086     MSLaneMeanDataValues& v = (MSLaneMeanDataValues&) val;
00087     v.nVehDeparted += nVehDeparted;
00088     v.nVehArrived += nVehArrived;
00089     v.nVehEntered += nVehEntered;
00090     v.nVehLeft += nVehLeft;
00091     v.nVehLaneChangeFrom += nVehLaneChangeFrom;
00092     v.nVehLaneChangeTo += nVehLaneChangeTo;
00093     v.sampleSeconds += sampleSeconds;
00094     v.travelledDistance += travelledDistance;
00095     v.waitSeconds += waitSeconds;
00096     v.vehLengthSum += vehLengthSum;
00097 }

const MSLane* const MSMoveReminder::getLane (  )  const throw () [inline, inherited]

SUMOReal MSMeanData::MeanDataValues::getSamples (  )  const throw () [virtual, inherited]

Reimplemented in MSMeanData::MeanDataValueTracker.

Definition at line 84 of file MSMeanData.cpp.

References MSMeanData::MeanDataValues::sampleSeconds.

00084                                                    {
00085     return sampleSeconds;
00086 }

bool MSMeanData_Net::MSLaneMeanDataValues::isEmpty (  )  const throw () [virtual]

Returns whether any data was collected.

Returns:
whether no data was collected

Reimplemented from MSMeanData::MeanDataValues.

Definition at line 162 of file MSMeanData_Net.cpp.

References nVehArrived, nVehDeparted, nVehEntered, nVehLaneChangeFrom, nVehLaneChangeTo, nVehLeft, and MSMeanData::MeanDataValues::sampleSeconds.

00162                                                           {
00163     return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0 && nVehLeft == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
00164 }

bool MSMeanData_Net::MSLaneMeanDataValues::isStillActive ( MSVehicle veh,
SUMOReal  oldPos,
SUMOReal  newPos,
SUMOReal  newSpeed 
) throw () [virtual]

Computes current values and adds them to their sums.

The fraction of time the vehicle is on the lane is computed and used as a weight for the vehicle's current values.

Additionally, if the vehicle has entered this lane, "nVehEnteredLane" is incremented, and if the vehicle has left the lane, "nVehLeftLane".

Parameters:
[in] veh The regarded vehicle
[in] oldPos Position before the move-micro-timestep.
[in] newPos Position after the move-micro-timestep.
[in] newSpeed The vehicle's current speed
Returns:
false, if the vehicle is beyond the lane, true otherwise
See also:
MSMoveReminder

MSMoveReminder::isStillActive

Reimplemented from MSMoveReminder.

Definition at line 101 of file MSMeanData_Net.cpp.

References DELTA_T, MsgHandler::getErrorInstance(), MSMoveReminder::getLane(), MSLane::getLength(), MsgHandler::inform(), MSMeanData_Net::myHaltSpeed, MSMeanData::MeanDataValues::sampleSeconds, SPEED2DIST, SUMOReal, MSMeanData::MeanDataValues::travelledDistance, MSMeanData::MeanDataValues::vehicleApplies(), vehLengthSum, and waitSeconds.

00101                                                                                                                              {
00102     if (!vehicleApplies(veh)) {
00103         return false;
00104     }
00105     bool ret = true;
00106     SUMOReal timeOnLane = (SUMOReal) DELTA_T / 1000.;
00107     if (oldPos<0&&newSpeed!=0) {
00108         timeOnLane = (oldPos+SPEED2DIST(newSpeed)) / newSpeed;
00109     }
00110     if (getLane() != 0 && oldPos+SPEED2DIST(newSpeed)>getLane()->getLength() && newSpeed != 0) {
00111         timeOnLane -= (oldPos+SPEED2DIST(newSpeed) - getLane()->getLength()) / newSpeed;
00112         ret = false;
00113     }
00114     if (timeOnLane<0) {
00115         MsgHandler::getErrorInstance()->inform("Negative vehicle step fraction on lane '" + getLane()->getID() + "'.");
00116         return false;
00117     }
00118     if (timeOnLane==0) {
00119         return false;
00120     }
00121     sampleSeconds += timeOnLane;
00122     travelledDistance += newSpeed * timeOnLane;
00123     vehLengthSum += veh.getVehicleType().getLength() * timeOnLane;
00124     if (newSpeed<myParent->myHaltSpeed) {
00125         waitSeconds += timeOnLane;
00126     }
00127     return ret;
00128 }

bool MSMeanData_Net::MSLaneMeanDataValues::notifyEnter ( MSVehicle veh,
bool  isEmit,
bool  isLaneChange 
) throw () [virtual]

Computes current values and adds them to their sums.

The fraction of time the vehicle is on the lane is computed and used as a weight for the vehicle's current values. The "emitted" field is incremented, additionally.

Parameters:
[in] veh The vehicle that enters the lane
[in] isEmit whether the vehicle was just emitted into the net
[in] isLaneChange whether the vehicle changed to the lane
See also:
MSMoveReminder::notifyEnter
Returns:
Always true

Reimplemented from MSMoveReminder.

Definition at line 146 of file MSMeanData_Net.cpp.

References nVehDeparted, nVehEntered, nVehLaneChangeTo, and MSMeanData::MeanDataValues::vehicleApplies().

00146                                                                                                       {
00147     if (vehicleApplies(veh)) {
00148         if (isEmit) {
00149             ++nVehDeparted;
00150         } else if (isLaneChange) {
00151             ++nVehLaneChangeTo;
00152         } else {
00153             ++nVehEntered;
00154         }
00155         return true;
00156     }
00157     return false;
00158 }

void MSMeanData_Net::MSLaneMeanDataValues::notifyLeave ( MSVehicle veh,
bool  isArrival,
bool  isLaneChange 
) throw () [virtual]

Called if the vehicle leaves the reminder's lane.

Parameters:
veh The leaving vehicle.
See also:
MSMoveReminder

MSMoveReminder::notifyLeave

Reimplemented from MSMoveReminder.

Definition at line 132 of file MSMeanData_Net.cpp.

References nVehArrived, nVehLaneChangeFrom, nVehLeft, and MSMeanData::MeanDataValues::vehicleApplies().

00132                                                                                                          {
00133     if (vehicleApplies(veh)) {
00134         if (isArrival) {
00135             ++nVehArrived;
00136         } else if (isLaneChange) {
00137             ++nVehLaneChangeFrom;
00138         } else {
00139             ++nVehLeft;
00140         }
00141     }
00142 }

void MSMeanData_Net::MSLaneMeanDataValues::reset (  )  throw () [virtual]

Resets values so they may be used for the next interval.

Implements MSMeanData::MeanDataValues.

Definition at line 70 of file MSMeanData_Net.cpp.

References nVehArrived, nVehDeparted, nVehEntered, nVehLaneChangeFrom, nVehLaneChangeTo, nVehLeft, MSMeanData::MeanDataValues::sampleSeconds, MSMeanData::MeanDataValues::travelledDistance, vehLengthSum, and waitSeconds.

Referenced by MSMeanData_Net::writeEdge().

00070                                                   {
00071     nVehDeparted = 0;
00072     nVehArrived = 0;
00073     nVehEntered = 0;
00074     nVehLeft = 0;
00075     nVehLaneChangeFrom = 0;
00076     nVehLaneChangeTo = 0;
00077     sampleSeconds = 0.;
00078     travelledDistance = 0;
00079     waitSeconds = 0;
00080     vehLengthSum = 0;
00081 }

void MSMeanData::MeanDataValues::update (  )  throw () [virtual, inherited]

Called if a per timestep update is needed. Default does nothing.

Reimplemented in MSMeanData_Harmonoise::MSLaneMeanDataValues.

Definition at line 79 of file MSMeanData.cpp.

00079                                          {
00080 }

bool MSMeanData::MeanDataValues::vehicleApplies ( const SUMOVehicle veh  )  const throw () [inherited]

Tests whether the vehicles type is to be regarded.

Parameters:
[in] veh The regarded vehicle
Returns:
whether the type of the vehicle is in the set of regarded types

Definition at line 66 of file MSMeanData.cpp.

References MSMeanData::MeanDataValues::myVehicleTypes.

Referenced by isStillActive(), MSMeanData_HBEFA::MSLaneMeanDataValues::isStillActive(), MSMeanData_Harmonoise::MSLaneMeanDataValues::isStillActive(), MSMeanData::MeanDataValueTracker::isStillActive(), notifyEnter(), MSMeanData_Harmonoise::MSLaneMeanDataValues::notifyEnter(), MSMeanData::MeanDataValueTracker::notifyEnter(), notifyLeave(), and MSMeanData::MeanDataValueTracker::notifyLeave().

00066                                                                              {
00067     return myVehicleTypes == 0 || myVehicleTypes->empty() ||
00068            myVehicleTypes->find(veh.getVehicleType().getID()) != myVehicleTypes->end();
00069 }

void MSMeanData_Net::MSLaneMeanDataValues::write ( OutputDevice dev,
const SUMOTime  period,
const SUMOReal  numLanes,
const SUMOReal  length,
const int  numVehicles = -1 
) const throw (IOError) [virtual]

Writes output values into the given stream.

Parameters:
[in] dev The output device to write the data into
[in] period Length of the period the data were gathered
[in] numLanes The total number of lanes for which the data was collected
[in] length The length of the object for which the data was collected
Exceptions:
IOError If an error on writing occurs (!!! not yet implemented)

Implements MSMeanData::MeanDataValues.

Definition at line 168 of file MSMeanData_Net.cpp.

References MIN2(), MSMeanData::myMaxTravelTime, MSMeanData::myMinSamples, myParent, nVehArrived, nVehDeparted, nVehEntered, nVehLaneChangeFrom, nVehLaneChangeTo, nVehLeft, MSMeanData::MeanDataValues::sampleSeconds, STEPS2TIME, SUMOReal, MSMeanData::MeanDataValues::travelledDistance, vehLengthSum, and waitSeconds.

Referenced by MSMeanData_Net::writeEdge().

00169                                                                                                     {
00170     if (myParent == 0) {
00171         if (sampleSeconds > 0) {
00172             dev << "\" density=\"" << sampleSeconds / STEPS2TIME(period) *(SUMOReal) 1000 / length <<
00173             "\" occupancy=\"" << vehLengthSum / STEPS2TIME(period) / length / numLanes *(SUMOReal) 100 <<
00174             "\" waitingTime=\"" << waitSeconds <<
00175             "\" speed=\"" << travelledDistance / sampleSeconds;
00176         }
00177         dev<<"\" departed=\""<<nVehDeparted<<
00178         "\" arrived=\""<<nVehArrived<<
00179         "\" entered=\""<<nVehEntered<<
00180         "\" left=\""<<nVehLeft<<
00181         "\"/>\n";
00182         return;
00183     }
00184     if (sampleSeconds > myParent->myMinSamples) {
00185         SUMOReal traveltime = myParent->myMaxTravelTime;
00186         if (travelledDistance > 0.f) {
00187             traveltime = MIN2(traveltime, length * sampleSeconds / travelledDistance);
00188         }
00189         if (numVehicles > 0) {
00190             dev << "\" traveltime=\"" << sampleSeconds / numVehicles <<
00191             "\" waitingTime=\"" << waitSeconds <<
00192             "\" speed=\"" << travelledDistance / sampleSeconds;
00193         } else {
00194             dev << "\" traveltime=\"" << traveltime <<
00195             "\" density=\"" << sampleSeconds / STEPS2TIME(period) *(SUMOReal) 1000 / length <<
00196             "\" occupancy=\"" << vehLengthSum / STEPS2TIME(period) / length / numLanes *(SUMOReal) 100 <<
00197             "\" waitingTime=\"" << waitSeconds <<
00198             "\" speed=\"" << travelledDistance / sampleSeconds;
00199         }
00200     }
00201     dev<<"\" departed=\""<<nVehDeparted<<
00202     "\" arrived=\""<<nVehArrived<<
00203     "\" entered=\""<<nVehEntered<<
00204     "\" left=\""<<nVehLeft<<
00205     "\" laneChangedFrom=\""<<nVehLaneChangeFrom<<
00206     "\" laneChangedTo=\""<<nVehLaneChangeTo<<
00207     "\"/>\n";
00208 }


Field Documentation

MSLane* const MSMoveReminder::myLane [protected, inherited]

The meandata parent.

Definition at line 190 of file MSMeanData_Net.h.

Referenced by write().

The number of vehicles that finished on the lane.

Definition at line 167 of file MSMeanData_Net.h.

Referenced by addTo(), isEmpty(), notifyLeave(), reset(), and write().

Definition at line 164 of file MSMeanData_Net.h.

Referenced by addTo(), isEmpty(), notifyEnter(), reset(), and write().

The number of vehicles that entered this lane within the sample intervall.

Definition at line 170 of file MSMeanData_Net.h.

Referenced by addTo(), isEmpty(), notifyEnter(), reset(), write(), and MSMeanData_Net::writeEdge().

The number of vehicles that changed from this lane.

Definition at line 177 of file MSMeanData_Net.h.

Referenced by addTo(), isEmpty(), notifyLeave(), reset(), and write().

The number of vehicles that changed to this lane.

Definition at line 180 of file MSMeanData_Net.h.

Referenced by addTo(), isEmpty(), notifyEnter(), reset(), and write().

The number of vehicles that left this lane within the sample intervall.

Definition at line 173 of file MSMeanData_Net.h.

Referenced by addTo(), isEmpty(), notifyLeave(), reset(), write(), and MSMeanData_Net::writeEdge().

SUMOReal MSMeanData::MeanDataValues::sampleSeconds [protected, inherited]

The sum of the lengths the vehicles had.

Definition at line 186 of file MSMeanData_Net.h.

Referenced by addTo(), isStillActive(), reset(), and write().

The number of vehicle probes with small speed.

Definition at line 183 of file MSMeanData_Net.h.

Referenced by addTo(), isStillActive(), reset(), and write().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:49 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6