 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
45 #define DEBUG_COND (false)
59 nVehDeparted(0), nVehArrived(0), nVehEntered(0), nVehLeft(0),
60 nVehVaporized(0), waitSeconds(0),
61 nVehLaneChangeFrom(0), nVehLaneChangeTo(0),
62 frontSampleSeconds(0), frontTravelledDistance(0),
63 vehLengthSum(0), occupationSum(0),
79 nVehLaneChangeFrom = 0;
82 travelledDistance = 0;
84 frontSampleSeconds = 0;
85 frontTravelledDistance = 0;
120 const double timeOnLane,
const double ,
121 const double meanSpeedVehicleOnLane,
122 const double travelledDistanceFrontOnLane,
123 const double travelledDistanceVehicleOnLane,
124 const double meanLengthOnLane) {
125 #ifdef DEBUG_OCCUPANCY
127 std::cout <<
SIMTIME <<
"\n MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal()\n"
128 <<
" veh '" << veh.
getID() <<
"' on lane '" << veh.getLane()->
getID() <<
"'"
129 <<
", timeOnLane=" << timeOnLane
130 <<
", meanSpeedVehicleOnLane=" << meanSpeedVehicleOnLane
131 <<
",\ntravelledDistanceFrontOnLane=" << travelledDistanceFrontOnLane
132 <<
", travelledDistanceVehicleOnLane=" << travelledDistanceVehicleOnLane
133 <<
", meanLengthOnLane=" << meanLengthOnLane
137 if (myParent !=
nullptr && !myParent->vehicleApplies(veh)) {
140 sampleSeconds += timeOnLane;
141 travelledDistance += travelledDistanceVehicleOnLane;
151 occupationSum += meanLengthOnLane *
TS;
153 if (myParent !=
nullptr && meanSpeedVehicleOnLane < myParent->
myHaltSpeed) {
154 waitSeconds += timeOnLane;
156 frontSampleSeconds += frontOnLane;
157 frontTravelledDistance += travelledDistanceFrontOnLane;
163 #ifdef DEBUG_OCCUPANCY2
165 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength << std::endl;
172 if ((myParent ==
nullptr || myParent->vehicleApplies(veh)) && (
173 getLane() ==
nullptr || !veh.
isVehicle() || getLane() ==
static_cast<MSVehicle&
>(veh).getLane())) {
178 removeFromVehicleUpdateValues(veh);
183 ++nVehLaneChangeFrom;
200 #ifdef DEBUG_NOTIFY_ENTER
201 std::cout <<
"\n" <<
SIMTIME <<
" MSMeanData_Net::MSLaneMeanDataValues: veh '" << veh.
getID() <<
"' enters lane '" << enteredLane->
getID() <<
"'" << std::endl;
205 if (myParent ==
nullptr || myParent->vehicleApplies(veh)) {
206 if (getLane() ==
nullptr || !veh.
isVehicle() || getLane() ==
static_cast<MSVehicle&
>(veh).getLane()) {
226 return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0
227 && nVehLeft == 0 && nVehVaporized == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
233 const double numLanes,
const double defaultTravelTime,
const int numVehicles)
const {
235 #ifdef DEBUG_OCCUPANCY2
237 double occupancy = occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (double) 100;
238 if (occupancy > 100) {
239 std::cout <<
SIMTIME <<
" Encountered bad occupancy: " << occupancy
240 <<
", myLaneLength=" << myLaneLength <<
", period=" <<
STEPS2TIME(period) <<
", occupationSum=" << occupationSum
244 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength
245 <<
"\ndensity=" <<
MIN2(sampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength, 1. /
MAX2(minimalVehicleLength,
NUMERICAL_EPS)) << std::endl;
248 if (myParent ==
nullptr) {
249 if (sampleSeconds > 0) {
251 .
writeAttr(
"occupancy", occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (
double) 100)
252 .
writeAttr(
"waitingTime", waitSeconds).
writeAttr(
"speed", travelledDistance / sampleSeconds);
255 if (nVehVaporized > 0) {
256 dev.
writeAttr(
"vaporized", nVehVaporized);
261 if (sampleSeconds > myParent->myMinSamples) {
262 double overlapTraveltime = myParent->myMaxTravelTime;
263 if (travelledDistance > 0.f) {
266 overlapTraveltime =
MIN2(overlapTraveltime, (myLaneLength + vehLengthSum / sampleSeconds) * sampleSeconds / travelledDistance);
268 if (numVehicles > 0) {
269 dev.
writeAttr(
"traveltime", sampleSeconds / numVehicles).
writeAttr(
"waitingTime", waitSeconds).
writeAttr(
"speed", travelledDistance / sampleSeconds);
271 double traveltime = myParent->myMaxTravelTime;
273 traveltime =
MIN2(traveltime, myLaneLength * frontSampleSeconds / frontTravelledDistance);
275 }
else if (defaultTravelTime >= 0.) {
276 dev.
writeAttr(
"traveltime", defaultTravelTime);
278 dev.
writeAttr(
"overlapTraveltime", overlapTraveltime)
280 .
writeAttr(
"occupancy", occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (
double) 100)
281 .
writeAttr(
"waitingTime", waitSeconds).
writeAttr(
"speed", travelledDistance / sampleSeconds);
283 }
else if (defaultTravelTime >= 0.) {
284 dev.
writeAttr(
"traveltime", defaultTravelTime).
writeAttr(
"speed", myLaneLength / defaultTravelTime);
287 .
writeAttr(
"laneChangedFrom", nVehLaneChangeFrom).
writeAttr(
"laneChangedTo", nVehLaneChangeTo);
288 if (nVehVaporized > 0) {
289 dev.
writeAttr(
"vaporized", nVehVaporized);
299 const SUMOTime dumpEnd,
const bool useLanes,
300 const bool withEmpty,
const bool printDefaults,
301 const bool withInternal,
302 const bool trackVehicles,
304 const double maxTravelTime,
305 const double minSamples,
306 const double haltSpeed,
307 const std::string& vTypes)
308 :
MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
309 withInternal, trackVehicles,
detectPersons, maxTravelTime, minSamples, vTypes),
virtual ~MSLaneMeanDataValues()
Destructor.
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
#define UNUSED_PARAMETER(x)
Representation of a vehicle or person.
Representation of a lane in the micro simulation.
double frontTravelledDistance
The travelled distance regarding the vehicle front.
Static storage of an output device and its base (abstract) implementation.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
virtual bool isVehicle() const =0
Get the vehicle's ID.
virtual const std::string & getID() const =0
Get the vehicle's ID.
Data structure for mean (aggregated) edge/lane values.
void write(OutputDevice &dev, const SUMOTime period, const double numLanes, const double defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
static int gNumSimThreads
how many threads to use for simulation
int nVehArrived
The number of vehicles that finished on the lane.
double waitSeconds
The number of vehicle probes with small speed.
int nVehLeft
The number of vehicles that left this lane within the sample interval.
void addTo(MSMeanData::MeanDataValues &val) const
Add the values of this to the given one and store them there.
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Called if the vehicle leaves the reminder's lane.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
@ NOTIFICATION_VAPORIZED
The vehicle got vaporized.
int nVehLaneChangeFrom
The number of vehicles that changed from this lane.
double occupationSum
The sum of the occupation of the lane.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Data collector for edges/lanes.
int nVehVaporized
The number of vehicles that left this lane within the sample interval.
bool isEmpty() const
Returns whether any data was collected.
double frontSampleSeconds
The number of vehicle probes regarding the vehicle front.
MSMeanData::MeanDataValues * createValues(MSLane *const lane, const double length, const bool doAdd) const
Create an instance of MeanDataValues.
A scoped lock which only triggers on condition.
double travelledDistance
The sum of the distances the vehicles travelled.
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.
double minimalVehicleLength
minimal vehicle length in the current interval (used to determine a maximal density,...
Network state mean data collector for edges/lanes.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
Data structure for mean (aggregated) edge/lane values.
bool detectPersons() const
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
double getLength() const
Get vehicle's length [m].
const double INVALID_DOUBLE
int nVehLaneChangeTo
The number of vehicles that changed to this lane.
const double myHaltSpeed
the minimum sample seconds
MSLaneMeanDataValues(MSLane *const lane, const double length, const bool doAdd, const MSMeanData_Net *parent)
Constructor.
int nVehEntered
The number of vehicles that entered this lane within the sample interval.
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)
Constructor.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes current values and adds them to their sums.
const std::string & getID() const
Returns the id.
Notification
Definition of a vehicle state.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
virtual ~MSMeanData_Net()
Destructor.
double vehLengthSum
The sum of the lengths the vehicles had.
Representation of a vehicle in the micro simulation.