Eclipse SUMO - Simulation of Urban MObility
MSMeanData_Net.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2004-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Network state mean data collector for edges/lanes
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <vector>
27 #include <set>
28 #include <limits>
29 #include "MSMeanData.h"
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class OutputDevice;
36 class MSEdgeControl;
37 class MSEdge;
38 class MSLane;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
55 class MSMeanData_Net : public MSMeanData {
56 public:
65  public:
69  MSLaneMeanDataValues(MSLane* const lane, const double length, const bool doAdd,
70  const MSMeanData_Net* parent);
71 
73  virtual ~MSLaneMeanDataValues();
74 
77  void reset(bool afterWrite = false);
78 
83  void addTo(MSMeanData::MeanDataValues& val) const;
84 
87 
97  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
98 
99 
113  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
115 
116  bool isEmpty() const;
117 
125  void write(OutputDevice& dev, long long int attributeMask, const SUMOTime period,
126  const int numLanes, const double speedLimit, const double defaultTravelTime,
127  const int numVehicles = -1) const;
128 
130  double getAttributeValue(SumoXMLAttr a, const SUMOTime period, const double numLanes, const double speedLimit) const;
131 
132  double getOccupancy(SUMOTime period, int numLanes) const;
133 
134  protected:
138  void notifyMoveInternal(const SUMOTrafficObject& veh,
139  const double frontOnLane, const double timeOnLane, const double,
140  const double meanSpeedVehicleOnLane,
141  const double travelledDistanceFrontOnLane,
142  const double travelledDistanceVehicleOnLane,
143  const double meanLengthOnLane);
144 
145  private:
146 // /// @brief Calculate the vehicle front's distance to myLane's end for a vehicle that called notifyMoveInternal()
147 // /// maxDist gives the maximal distance to search back from the vehicle's current lane to myLane
148 // /// returns INVALID_DOUBLE if myLane wasn't found in that range
149 // double getVehicleDistToMyLane(const SUMOVehicle& veh, double maxDist);
150 
151  public:
156 
159 
162 
164  int nVehLeft;
165 
168 
171 
173  double waitSeconds;
174 
176  double timeLoss;
177 
178  private:
181 
184 
187 
190 
192  double vehLengthSum;
193 
196 
199 
201 
204 
205  };
206 
207 
208 public:
225  MSMeanData_Net(const std::string& id,
226  const SUMOTime dumpBegin, const SUMOTime dumpEnd,
227  const bool useLanes, const bool withEmpty, const bool printDefaults,
228  const bool withInternal, const bool trackVehicles, const int detectPersons,
229  const double maxTravelTime, const double minSamples,
230  const double haltSpeed, const std::string& vTypes,
231  const std::string& writeAttributes,
232  const std::vector<MSEdge*>& edges,
233  bool aggregate);
234 
235 
237  virtual ~MSMeanData_Net();
238 
240  std::vector<std::string> getAttributeNames() const;
241 
243  double getAttributeValue(const MSLane* lane, SumoXMLAttr a, double defaultValue) const;
244 
245 protected:
251  MSMeanData::MeanDataValues* createValues(MSLane* const lane, const double length, const bool doAdd) const;
252 
258  void resetOnly(SUMOTime stopTime);
259 
260 private:
262  const double myHaltSpeed;
263 
266 
269 
270 };
long long int SUMOTime
Definition: GUI.h:35
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:78
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
Data structure for mean (aggregated) edge/lane values.
Definition: MSMeanData.h:66
Data structure for mean (aggregated) edge/lane values.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called if the vehicle leaves the reminder's lane.
const MSMeanData_Net * myParent
The meandata parent.
double frontTravelledDistance
The travelled distance regarding the vehicle front.
void addTo(MSMeanData::MeanDataValues &val) const
Add the values of this to the given one and store them there.
int nVehLaneChangeTo
The number of vehicles that changed to this lane.
double getAttributeValue(SumoXMLAttr a, const SUMOTime period, const double numLanes, const double speedLimit) const
return attribute value
int nVehVaporized
The number of vehicles that left this lane via vaporization within the sample interval.
double minimalVehicleLength
minimal vehicle length in the current interval (used to determine a maximal density,...
void write(OutputDevice &dev, long long int attributeMask, const SUMOTime period, const int numLanes, const double speedLimit, const double defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
double getOccupancy(SUMOTime period, int numLanes) const
bool isEmpty() const
Returns whether any data was collected.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes current values and adds them to their sums.
MSLaneMeanDataValues(MSLane *const lane, const double length, const bool doAdd, const MSMeanData_Net *parent)
Constructor.
void notifyMoveInternal(const SUMOTrafficObject &veh, const double frontOnLane, const double timeOnLane, const double, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double meanLengthOnLane)
Internal notification about the vehicle moves.
int nVehLeft
The number of vehicles that left this lane within the sample interval.
int nVehLaneChangeFrom
The number of vehicles that changed from this lane.
int nVehTeleported
The number of vehicles that left this lane via teleporting within the sample interval.
double timeLoss
The time loss accrued by vehicle probes.
double frontSampleSeconds
The number of vehicle probes regarding the vehicle front.
int nVehArrived
The number of vehicles that finished on the lane.
double waitSeconds
The number of vehicle probes with small speed.
virtual ~MSLaneMeanDataValues()
Destructor.
double occupationSum
The sum of the occupation of the lane.
int nVehEntered
The number of vehicles that entered this lane within the sample interval.
double vehLengthSum
The sum of the lengths the vehicles had.
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
Network state mean data collector for edges/lanes.
virtual ~MSMeanData_Net()
Destructor.
MSMeanData_Net(const MSMeanData_Net &)
Invalidated copy constructor.
MSMeanData_Net & operator=(const MSMeanData_Net &)
Invalidated assignment operator.
double getAttributeValue(const MSLane *lane, SumoXMLAttr a, double defaultValue) const
return attribute value for the given lane
MSMeanData_Net(const std::string &id, const SUMOTime dumpBegin, const SUMOTime dumpEnd, const bool useLanes, const bool withEmpty, const bool printDefaults, const bool withInternal, const bool trackVehicles, const int detectPersons, const double maxTravelTime, const double minSamples, const double haltSpeed, const std::string &vTypes, const std::string &writeAttributes, const std::vector< MSEdge * > &edges, bool aggregate)
Constructor.
std::vector< std::string > getAttributeNames() const
return all attributes that are (potentially) written by this output
MSMeanData::MeanDataValues * createValues(MSLane *const lane, const double length, const bool doAdd) const
Create an instance of MeanDataValues.
void resetOnly(SUMOTime stopTime)
Resets network value in order to allow processing of the next interval.
const double myHaltSpeed
the minimum sample seconds
Data collector for edges/lanes.
Definition: MSMeanData.h:57
Notification
Definition of a vehicle state.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
Representation of a vehicle, person, or container.