44 #define DEBUG_COND (false)
58 nVehDeparted(0), nVehArrived(0), nVehEntered(0), nVehLeft(0),
59 nVehVaporized(0), waitSeconds(0), timeLoss(0),
60 nVehLaneChangeFrom(0), nVehLaneChangeTo(0),
61 frontSampleSeconds(0), frontTravelledDistance(0),
62 vehLengthSum(0), occupationSum(0),
78 nVehLaneChangeFrom = 0;
81 travelledDistance = 0;
84 frontSampleSeconds = 0;
85 frontTravelledDistance = 0;
121 const double timeOnLane,
const double ,
122 const double meanSpeedVehicleOnLane,
123 const double travelledDistanceFrontOnLane,
124 const double travelledDistanceVehicleOnLane,
125 const double meanLengthOnLane) {
126 #ifdef DEBUG_OCCUPANCY
128 std::cout <<
SIMTIME <<
"\n MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal()\n"
130 <<
", timeOnLane=" << timeOnLane
131 <<
", meanSpeedVehicleOnLane=" << meanSpeedVehicleOnLane
132 <<
",\ntravelledDistanceFrontOnLane=" << travelledDistanceFrontOnLane
133 <<
", travelledDistanceVehicleOnLane=" << travelledDistanceVehicleOnLane
134 <<
", meanLengthOnLane=" << meanLengthOnLane
138 if (myParent !=
nullptr && !myParent->vehicleApplies(veh)) {
141 sampleSeconds += timeOnLane;
142 travelledDistance += travelledDistanceVehicleOnLane;
152 occupationSum += meanLengthOnLane *
TS;
155 if (myParent !=
nullptr && meanSpeedVehicleOnLane < myParent->
myHaltSpeed) {
156 waitSeconds += timeOnLane;
160 timeLoss += timeOnLane *
MAX2(0.0, vmax - meanSpeedVehicleOnLane) / vmax;
163 frontSampleSeconds += frontOnLane;
164 frontTravelledDistance += travelledDistanceFrontOnLane;
170 #ifdef DEBUG_OCCUPANCY2
172 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength << std::endl;
179 if ((myParent ==
nullptr || myParent->vehicleApplies(veh)) && (
180 getLane() ==
nullptr || !veh.
isVehicle() || getLane() ==
static_cast<MSVehicle&
>(veh).getLane())) {
185 removeFromVehicleUpdateValues(veh);
190 ++nVehLaneChangeFrom;
207 #ifdef DEBUG_NOTIFY_ENTER
208 std::cout <<
"\n" <<
SIMTIME <<
" MSMeanData_Net::MSLaneMeanDataValues: veh '" << veh.
getID() <<
"' enters lane '" << enteredLane->
getID() <<
"'" << std::endl;
212 if (myParent ==
nullptr || myParent->vehicleApplies(veh)) {
213 if (getLane() ==
nullptr || !veh.
isVehicle() || getLane() ==
static_cast<MSVehicle&
>(veh).getLane()) {
233 return sampleSeconds == 0 && nVehDeparted == 0 && nVehArrived == 0 && nVehEntered == 0
234 && nVehLeft == 0 && nVehVaporized == 0 && nVehLaneChangeFrom == 0 && nVehLaneChangeTo == 0;
240 const double numLanes,
const double defaultTravelTime,
const int numVehicles)
const {
242 const double density =
MIN2(sampleSeconds /
STEPS2TIME(period) * (
double) 1000 / myLaneLength,
243 1000. * numLanes /
MAX2(minimalVehicleLength, NUMERICAL_EPS));
244 const double laneDensity = density / numLanes;
245 #ifdef DEBUG_OCCUPANCY2
247 double occupancy = occupationSum /
STEPS2TIME(period) / myLaneLength / numLanes * (double) 100;
248 if (occupancy > 100) {
249 std::cout <<
SIMTIME <<
" Encountered bad occupancy: " << occupancy
250 <<
", myLaneLength=" << myLaneLength <<
", period=" <<
STEPS2TIME(period) <<
", occupationSum=" << occupationSum
254 std::cout <<
SIMTIME <<
"ID: " << getDescription() <<
" minVehicleLength=" << minimalVehicleLength
255 <<
"\ndensity=" << density <<
"\n";
258 if (myParent ==
nullptr) {
259 if (sampleSeconds > 0) {
265 checkWriteAttribute(dev, attributeMask,
SUMO_ATTR_SPEED, travelledDistance / sampleSeconds);
270 checkWriteAttribute(dev, attributeMask,
SUMO_ATTR_LEFT, nVehLeft);
271 if (nVehVaporized > 0) {
277 if (sampleSeconds > myParent->myMinSamples) {
278 double overlapTraveltime = myParent->myMaxTravelTime;
279 if (travelledDistance > 0.f) {
282 overlapTraveltime =
MIN2(overlapTraveltime, (myLaneLength + vehLengthSum / sampleSeconds) * sampleSeconds / travelledDistance);
284 if (numVehicles > 0) {
288 checkWriteAttribute(dev, attributeMask,
SUMO_ATTR_SPEED, travelledDistance / sampleSeconds);
290 double traveltime = myParent->myMaxTravelTime;
291 if (frontTravelledDistance > NUMERICAL_EPS) {
292 traveltime =
MIN2(traveltime, myLaneLength * frontSampleSeconds / frontTravelledDistance);
294 }
else if (defaultTravelTime >= 0.) {
303 checkWriteAttribute(dev, attributeMask,
SUMO_ATTR_SPEED, travelledDistance / sampleSeconds);
305 }
else if (defaultTravelTime >= 0.) {
307 checkWriteAttribute(dev, attributeMask,
SUMO_ATTR_SPEED, myLaneLength / defaultTravelTime);
312 checkWriteAttribute(dev, attributeMask,
SUMO_ATTR_LEFT, nVehLeft);
315 if (nVehVaporized > 0) {
326 const SUMOTime dumpEnd,
const bool useLanes,
327 const bool withEmpty,
const bool printDefaults,
328 const bool withInternal,
329 const bool trackVehicles,
331 const double maxTravelTime,
332 const double minSamples,
333 const double haltSpeed,
334 const std::string& vTypes,
335 const std::string& writeAttributes) :
336 MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
337 withInternal, trackVehicles,
detectPersons, maxTravelTime, minSamples, vTypes, writeAttributes),
@ SUMO_ATTR_OVERLAPTRAVELTIME
@ SUMO_ATTR_LANECHANGEDFROM
@ SUMO_ATTR_LANECHANGEDTO
const double INVALID_DOUBLE
#define UNUSED_PARAMETER(x)
A scoped lock which only triggers on condition.
bool detectPersons() const
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
static int gNumSimThreads
how many threads to use for simulation
Representation of a lane in the micro simulation.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Data structure for mean (aggregated) edge/lane values.
double travelledDistance
The sum of the distances the vehicles travelled.
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.
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.
int nVehVaporized
The number of vehicles that left this lane within the sample interval.
double minimalVehicleLength
minimal vehicle length in the current interval (used to determine a maximal density,...
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.
double timeLoss
The time loss accrued by vehicle probes.
double frontSampleSeconds
The number of vehicle probes regarding the vehicle front.
void write(OutputDevice &dev, long long int attributeMask, const SUMOTime period, const double numLanes, const double defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
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 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)
Constructor.
MSMeanData::MeanDataValues * createValues(MSLane *const lane, const double length, const bool doAdd) const
Create an instance of MeanDataValues.
const double myHaltSpeed
the minimum sample seconds
Data collector for edges/lanes.
Notification
Definition of a vehicle state.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
Representation of a vehicle in the micro simulation.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual bool isStopped() const =0
Returns whether the object is at a stop.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.