SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSMeanData_Harmonoise.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // Redirector for mean data output (net->edgecontrol)
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <microsim/MSLane.h>
33 #include <microsim/MSVehicle.h>
35 #include <utils/common/SUMOTime.h>
36 #include <utils/common/ToString.h>
38 #include "MSMeanData_Harmonoise.h"
40 #include <limits>
41 
42 #ifdef CHECK_MEMORY_LEAKS
43 #include <foreign/nvwa/debug_new.h>
44 #endif // CHECK_MEMORY_LEAKS
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 // ---------------------------------------------------------------------------
51 // MSMeanData_Harmonoise::MSLaneMeanDataValues - methods
52 // ---------------------------------------------------------------------------
54  const std::set<std::string>* const vTypes, const MSMeanData_Harmonoise* parent)
55  : MSMeanData::MeanDataValues(lane, length, doAdd, vTypes),
56  currentTimeN(0), meanNTemp(0), myParent(parent) {}
57 
58 
60 }
61 
62 
63 void
65  sampleSeconds = 0;
66  currentTimeN = 0;
67  meanNTemp = 0;
68  travelledDistance = 0;
69 }
70 
71 
72 void
75  v.sampleSeconds += sampleSeconds;
76  v.meanNTemp += (SUMOReal) pow(10., HelpersHarmonoise::sum(meanNTemp) / 10.);
77  v.travelledDistance += travelledDistance;
78 }
79 
80 
81 void
83  meanNTemp += (SUMOReal) pow(10., HelpersHarmonoise::sum(currentTimeN) / 10.);
84  currentTimeN = 0;
85 }
86 
87 
88 void
91  (double) speed, veh.getPreDawdleAcceleration());
92  currentTimeN += (SUMOReal) pow(10., (sn / 10.));
93  sampleSeconds += timeOnLane;
94  travelledDistance += speed * timeOnLane;
95 }
96 
97 
98 bool
100  return vehicleApplies(veh);
101 }
102 
103 
104 void
106  const SUMOReal /*numLanes*/, const SUMOReal defaultTravelTime, const int /*numVehicles*/) const {
107  dev << "\" noise=\"" << (meanNTemp != 0 ? (SUMOReal)(10. * log10(meanNTemp * TS / STEPS2TIME(period))) : (SUMOReal) 0.);
108  if (sampleSeconds > myParent->myMinSamples) {
109  SUMOReal traveltime = myParent->myMaxTravelTime;
110  if (travelledDistance > 0.f) {
111  traveltime = MIN2(traveltime, myLaneLength * sampleSeconds / travelledDistance);
112  }
113  dev << "\" traveltime=\"" << traveltime;
114  } else if (defaultTravelTime >= 0.) {
115  // @todo default value for noise
116  dev << "\" traveltime=\"" << defaultTravelTime;
117  }
118  dev << "\"";
119  dev.closeTag(true);
120 }
121 
122 
123 
124 // ---------------------------------------------------------------------------
125 // MSMeanData_Harmonoise - methods
126 // ---------------------------------------------------------------------------
128  const SUMOTime dumpBegin, const SUMOTime dumpEnd,
129  const bool useLanes, const bool withEmpty,
130  const bool printDefaults, const bool withInternal,
131  const bool trackVehicles,
132  const SUMOReal maxTravelTime, const SUMOReal minSamples,
133  const std::set<std::string> vTypes)
134  : MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
135  withInternal, trackVehicles, maxTravelTime, minSamples, vTypes) {
136 }
137 
138 
140 
141 
143 MSMeanData_Harmonoise::createValues(MSLane* const lane, const SUMOReal length, const bool doAdd) const {
144  return new MSLaneMeanDataValues(lane, length, doAdd, &myVehicleTypes, this);
145 }
146 
147 
148 void
151  for (std::vector<std::vector<MeanDataValues*> >::const_iterator i = myMeasures.begin(); i != myMeasures.end(); ++i) {
152  const std::vector<MeanDataValues*> &lm = *i;
153  for (std::vector<MeanDataValues*>::const_iterator j = lm.begin(); j != lm.end(); ++j) {
154  (*j)->update();
155  }
156  }
157 }
158 
159 
160 /****************************************************************************/
161