SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSCalibrator.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Calibrates the flow on an edge by removing an inserting vehicles
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2005-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <algorithm>
35 #include <cmath>
36 #include <microsim/MSNet.h>
37 #include <microsim/MSEdge.h>
38 #include <microsim/MSLane.h>
42 #include <utils/common/ToString.h>
45 #include <utils/xml/XMLSubSys.h>
51 #include "MSCalibrator.h"
52 
53 #ifdef CHECK_MEMORY_LEAKS
54 #include <foreign/nvwa/debug_new.h>
55 #endif // CHECK_MEMORY_LEAKS
56 
57 //#define MSCalibrator_DEBUG
58 
59 // ===========================================================================
60 // static members
61 // ===========================================================================
62 std::vector<MSMoveReminder*> MSCalibrator::LeftoverReminders;
63 std::vector<SUMOVehicleParameter*> MSCalibrator::LeftoverVehicleParameters;
64 
65 // ===========================================================================
66 // method definitions
67 // ===========================================================================
68 MSCalibrator::MSCalibrator(const std::string& id,
69  const MSEdge* const edge, const SUMOReal pos,
70  const std::string& aXMLFilename,
71  const std::string& outputFilename,
72  const SUMOTime freq, const SUMOReal length,
73  const MSRouteProbe* probe,
74  const bool addLaneMeanData) :
75  MSTrigger(id),
76  MSRouteHandler(aXMLFilename, false),
77  myEdge(edge), myPos(pos), myProbe(probe),
78  myEdgeMeanData(0, length, false, 0),
79  myOutput(0), myFrequency(freq), myRemoved(0),
80  myInserted(0), myClearedInJam(0),
81  mySpeedIsDefault(true), myDidSpeedAdaption(false), myDidInit(false),
82  myDefaultSpeed(myEdge->getSpeedLimit()),
83  myHaveWarnedAboutClearingJam(false),
84  myAmActive(false) {
85  if (outputFilename != "") {
86  myOutput = &OutputDevice::getDevice(outputFilename);
87  myOutput->writeXMLHeader("calibratorstats");
88  }
89  if (aXMLFilename != "") {
90  XMLSubSys::runParser(*this, aXMLFilename);
91  if (!myDidInit) {
92  init();
93  }
94  }
95  if (addLaneMeanData) {
96  for (int i = 0; i < (int)myEdge->getLanes().size(); ++i) {
97  MSLane* lane = myEdge->getLanes()[i];
99  laneData->setDescription("meandata_calibrator_" + lane->getID());
100  LeftoverReminders.push_back(laneData);
101  myLaneMeanData.push_back(laneData);
102  VehicleRemover* remover = new VehicleRemover(lane, (int)i, this);
103  LeftoverReminders.push_back(remover);
104  myVehicleRemovers.push_back(remover);
105  }
106  }
107 }
108 
109 
110 void
112  if (myIntervals.size() > 0) {
113  if (myIntervals.back().end == -1) {
114  myIntervals.back().end = SUMOTime_MAX;
115  }
117  // calibration should happen after regular insertions have taken place
119  MSNet::getInstance()->getCurrentTimeStep(),
121  } else {
122  WRITE_WARNING("No flow intervals in calibrator '" + myID + "'.");
123  }
124  myDidInit = true;
125 }
126 
127 
129  if (myIntervals.size() > 0 && myCurrentStateInterval != myIntervals.end()) {
130  writeXMLOutput();
131  }
132  for (std::vector<VehicleRemover*>::iterator it = myVehicleRemovers.begin(); it != myVehicleRemovers.end(); ++it) {
133  (*it)->disable();
134  }
135 }
136 
137 
138 void
140  const SUMOSAXAttributes& attrs) {
141  if (element == SUMO_TAG_FLOW) {
142  AspiredState state;
143  SUMOTime lastEnd = -1;
144  if (myIntervals.size() > 0) {
145  lastEnd = myIntervals.back().end;
146  if (lastEnd == -1) {
147  lastEnd = myIntervals.back().begin;
148  }
149  }
150  try {
151  bool ok = true;
152  state.q = attrs.getOpt<SUMOReal>(SUMO_ATTR_VEHSPERHOUR, 0, ok, -1.);
153  state.v = attrs.getOpt<SUMOReal>(SUMO_ATTR_SPEED, 0, ok, -1.);
154  state.begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, myID.c_str(), ok);
155  if (state.begin < lastEnd) {
156  WRITE_ERROR("Overlapping or unsorted intervals in calibrator '" + myID + "'.");
157  }
158  state.end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, myID.c_str(), ok, -1);
161  // vehicles should be inserted with max speed unless stated otherwise
164  }
165  // vehicles should be inserted on any lane unless stated otherwise
168  }
169  if (state.vehicleParameter->vtypeid != DEFAULT_VTYPE_ID &&
171  WRITE_ERROR("Unknown vehicle type '" + state.vehicleParameter->vtypeid + "' in calibrator '" + myID + "'.");
172  }
173  } catch (EmptyData) {
174  WRITE_ERROR("Mandatory attribute missing in definition of calibrator '" + myID + "'.");
175  } catch (NumberFormatException) {
176  WRITE_ERROR("Non-numeric value for numeric attribute in definition of calibrator '" + myID + "'.");
177  }
178  if (state.q < 0 && state.v < 0) {
179  WRITE_ERROR("Either 'vehsPerHour' or 'speed' has to be given in flow definition of calibrator '" + myID + "'.");
180  }
181  if (myIntervals.size() > 0 && myIntervals.back().end == -1) {
182  myIntervals.back().end = state.begin;
183  }
184  myIntervals.push_back(state);
185  } else {
186  MSRouteHandler::myStartElement(element, attrs);
187  }
188 }
189 
190 
191 void
193  if (element == SUMO_TAG_CALIBRATOR) {
194  if (!myDidInit) {
195  init();
196  }
197  } else if (element != SUMO_TAG_FLOW) {
199  }
200 }
201 
202 
203 void
205  if (myOutput != 0) {
206  updateMeanData();
207  const int p = passed();
208  // meandata will be off if vehicles are removed on the next edge instead of this one
210  assert(discrepancy >= 0);
211  const std::string ds = (discrepancy > 0 ? "\" vaporizedOnNextEdge=\"" + toString(discrepancy) : "");
212  const SUMOReal durationSeconds = STEPS2TIME(myCurrentStateInterval->end - myCurrentStateInterval->begin);
213  (*myOutput) << " <interval begin=\"" << time2string(myCurrentStateInterval->begin) <<
214  "\" end=\"" << time2string(myCurrentStateInterval->end) <<
215  "\" id=\"" << myID <<
216  "\" nVehContrib=\"" << p <<
217  "\" removed=\"" << myRemoved <<
218  "\" inserted=\"" << myInserted <<
219  "\" cleared=\"" << myClearedInJam <<
220  "\" flow=\"" << p * 3600.0 / durationSeconds <<
221  "\" aspiredFlow=\"" << myCurrentStateInterval->q <<
223  "\" aspiredSpeed=\"" << myCurrentStateInterval->v <<
224  ds << //optional
225  "\"/>\n";
226  }
227  myDidSpeedAdaption = false;
228  myInserted = 0;
229  myRemoved = 0;
230  myClearedInJam = 0;
232  reset();
233 }
234 
235 
236 bool
238  while (myCurrentStateInterval != myIntervals.end() && myCurrentStateInterval->end <= time) {
239  // XXX what about skipped intervals?
241  }
242  return myCurrentStateInterval != myIntervals.end() &&
243  myCurrentStateInterval->begin <= time && myCurrentStateInterval->end > time;
244 }
245 
246 int
248  if (myCurrentStateInterval != myIntervals.end()) {
249  const SUMOReal totalHourFraction = STEPS2TIME(myCurrentStateInterval->end - myCurrentStateInterval->begin) / (SUMOReal) 3600.;
250  return (int)std::floor(myCurrentStateInterval->q * totalHourFraction + 0.5); // round to closest int
251  } else {
252  return -1;
253  }
254 }
255 
256 
257 bool
259  if (myToRemove.size() > 0) {
261  // it is not save to remove the vehicles inside
262  // VehicleRemover::notifyEnter so we do it here
263  for (std::set<std::string>::iterator it = myToRemove.begin(); it != myToRemove.end(); ++it) {
264  MSVehicle* vehicle = dynamic_cast<MSVehicle*>(vc.getVehicle(*it));
265  if (vehicle != 0) {
268  vc.scheduleVehicleRemoval(vehicle);
269  } else {
270  WRITE_WARNING("Calibrator '" + getID() + "' could not remove vehicle '" + *it + "'.");
271  }
272  }
273  myToRemove.clear();
274  return true;
275  }
276  return false;
277 }
278 
279 
280 SUMOTime
282  // get current simulation values (valid for the last simulation second)
283  // XXX could we miss vehicle movements if this is called less often than every DELTA_T (default) ?
284  updateMeanData();
285  const bool hadRemovals = removePending();
286  // check whether an adaptation value exists
287  if (isCurrentStateActive(currentTime)) {
288  myAmActive = true;
289  // all happens in isCurrentStateActive()
290  } else {
291  myAmActive = false;
292  reset();
293  if (!mySpeedIsDefault) {
294  // reset speed to default
296  mySpeedIsDefault = true;
297  }
298  if (myCurrentStateInterval == myIntervals.end()) {
299  // keep calibrator alive for gui but do not call again
300  return TIME2STEPS(86400);
301  }
302  return myFrequency;
303  }
304  // we are active
305  if (!myDidSpeedAdaption && myCurrentStateInterval->v >= 0) {
307  mySpeedIsDefault = false;
308  myDidSpeedAdaption = true;
309  }
310 
311  const bool calibrateFlow = myCurrentStateInterval->q >= 0;
312  const int totalWishedNum = totalWished();
313  int adaptedNum = passed() + myClearedInJam;
314 #ifdef MSCalibrator_DEBUG
315  std::cout << time2string(currentTime) << " " << myID
316  << " q=" << myCurrentStateInterval->q
317  << " totalWished=" << totalWishedNum
318  << " adapted=" << adaptedNum
319  << " jam=" << invalidJam(-1)
320  << " entered=" << myEdgeMeanData.nVehEntered
321  << " departed=" << myEdgeMeanData.nVehDeparted
322  << " arrived=" << myEdgeMeanData.nVehArrived
323  << " left=" << myEdgeMeanData.nVehLeft
324  << " waitSecs=" << myEdgeMeanData.waitSeconds
325  << " vaporized=" << myEdgeMeanData.nVehVaporized
326  << "\n";
327 #endif
328  if (calibrateFlow && adaptedNum < totalWishedNum && !hadRemovals) {
329  // we need to insert some vehicles
330  const SUMOReal hourFraction = STEPS2TIME(currentTime - myCurrentStateInterval->begin + DELTA_T) / (SUMOReal) 3600.;
331  const int wishedNum = (int)std::floor(myCurrentStateInterval->q * hourFraction + 0.5); // round to closest int
332  // only the difference between inflow and aspiredFlow should be added, thus
333  // we should not count vehicles vaporized from a jam here
334  // if we have enough time left we can add missing vehicles later
335  const int relaxedInsertion = (int)std::floor(STEPS2TIME(myCurrentStateInterval->end - currentTime) / 3);
336  const int insertionSlack = MAX2(0, adaptedNum + relaxedInsertion - totalWishedNum);
337  // increase number of vehicles
338 #ifdef MSCalibrator_DEBUG
339  std::cout
340  << " wished:" << wishedNum
341  << " slack:" << insertionSlack
342  << " before:" << adaptedNum
343  << "\n";
344 #endif
345  while (wishedNum > adaptedNum + insertionSlack) {
346  SUMOVehicleParameter* pars = myCurrentStateInterval->vehicleParameter;
347  const MSRoute* route = myProbe != 0 ? myProbe->getRoute() : 0;
348  if (route == 0) {
349  route = MSRoute::dictionary(pars->routeid);
350  }
351  if (route == 0) {
352  WRITE_WARNING("No valid routes in calibrator '" + myID + "'.");
353  break;
354  }
355  if (!route->contains(myEdge)) {
356  WRITE_WARNING("Route '" + route->getID() + "' in calibrator '" + myID + "' does not contain edge '" + myEdge->getID() + "'.");
357  break;
358  }
359  const int routeIndex = (int)std::distance(route->begin(),
360  std::find(route->begin(), route->end(), myEdge));
362  assert(route != 0 && vtype != 0);
363  // build the vehicle
364  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
365  newPars->id = myID + "." + toString((int)STEPS2TIME(myCurrentStateInterval->begin)) + "." + toString(myInserted);
366  newPars->depart = currentTime;
367  newPars->routeid = route->getID();
369  newPars, route, vtype, true, false));
370 #ifdef MSCalibrator_DEBUG
371  std::cout << " resetting route pos: " << routeIndex << "\n";
372 #endif
373  vehicle->resetRoutePosition(routeIndex);
374  if (myEdge->insertVehicle(*vehicle, currentTime)) {
375  if (!MSNet::getInstance()->getVehicleControl().addVehicle(vehicle->getID(), vehicle)) {
376  throw ProcessError("Emission of vehicle '" + vehicle->getID() + "' in calibrator '" + getID() + "'failed!");
377  }
378  myInserted++;
379  adaptedNum++;
380 #ifdef MSCalibrator_DEBUG
381  std::cout << "I ";
382 #endif
383  } else {
384  // could not insert vehicle
385 #ifdef MSCalibrator_DEBUG
386  std::cout << "F ";
387 #endif
389  break;
390  }
391  }
392  }
393  if (myCurrentStateInterval->end <= currentTime + myFrequency) {
394  writeXMLOutput();
395  }
396  return myFrequency;
397 }
398 
399 void
402  for (std::vector<MSMeanData_Net::MSLaneMeanDataValues*>::iterator it = myLaneMeanData.begin(); it != myLaneMeanData.end(); ++it) {
403  (*it)->reset();
404  }
405 }
406 
407 
408 bool
409 MSCalibrator::invalidJam(int laneIndex) const {
410  if (laneIndex < 0) {
411  const int numLanes = (int)myEdge->getLanes().size();
412  for (int i = 0; i < numLanes; ++i) {
413  if (invalidJam(i)) {
414  return true;
415  }
416  }
417  return false;
418  }
419  assert(laneIndex < (int)myEdge->getLanes().size());
420  const MSLane* const lane = myEdge->getLanes()[laneIndex];
421  if (lane->getVehicleNumber() < 4) {
422  // cannot reliably detect invalid jams
423  return false;
424  }
425  // maxSpeed reflects the calibration target
426  const bool toSlow = lane->getMeanSpeed() < 0.5 * myEdge->getSpeedLimit();
427  return toSlow && remainingVehicleCapacity(laneIndex) < 1;
428 }
429 
430 
431 int
433  if (laneIndex < 0) {
434  const int numLanes = (int)myEdge->getLanes().size();
435  int result = 0;
436  for (int i = 0; i < numLanes; ++i) {
437  result = MAX2(result, remainingVehicleCapacity(i));
438  }
439  return result;
440  }
441  assert(laneIndex < (int)myEdge->getLanes().size());
442  MSLane* lane = myEdge->getLanes()[laneIndex];
443  MSVehicle* last = lane->getLastFullVehicle();
444  const SUMOVehicleParameter* pars = myCurrentStateInterval->vehicleParameter;
446  const SUMOReal spacePerVehicle = vtype->getLengthWithGap() + myEdge->getSpeedLimit() * vtype->getCarFollowModel().getHeadwayTime();
447  if (last == 0) {
448  // ensure vehicles can be inserted on short edges
449  return MAX2(1, (int)(myEdge->getLength() / spacePerVehicle));
450  } else {
451  return (int)(last->getPositionOnLane() / spacePerVehicle);
452  }
453 }
454 
455 
456 void
458  for (std::vector<MSMoveReminder*>::iterator it = LeftoverReminders.begin(); it != LeftoverReminders.end(); ++it) {
459  delete *it;
460  }
461  LeftoverReminders.clear();
462  for (std::vector<SUMOVehicleParameter*>::iterator it = LeftoverVehicleParameters.begin();
463  it != LeftoverVehicleParameters.end(); ++it) {
464  delete *it;
465  }
467 }
468 
469 
470 void
473  for (std::vector<MSMeanData_Net::MSLaneMeanDataValues*>::iterator it = myLaneMeanData.begin();
474  it != myLaneMeanData.end(); ++it) {
475  (*it)->addTo(myEdgeMeanData);
476  }
477 }
478 
480  if (myParent == 0) {
481  return false;
482  }
483  if (myParent->isActive()) {
485  const bool calibrateFlow = myParent->myCurrentStateInterval->q >= 0;
486  const int totalWishedNum = myParent->totalWished();
487  int adaptedNum = myParent->passed() + myParent->myClearedInJam;
488  MSVehicle* vehicle = dynamic_cast<MSVehicle*>(&veh);
489  if (calibrateFlow && adaptedNum > totalWishedNum) {
490 #ifdef MSCalibrator_DEBUG
491  std::cout << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << myParent->getID()
492  << " vaporizing " << vehicle->getID() << " to reduce flow\n";
493 #endif
494  if (myParent->scheduleRemoval(vehicle)) {
495  myParent->myRemoved++;
496  }
497  } else if (myParent->invalidJam(myLaneIndex)) {
498 #ifdef MSCalibrator_DEBUG
499  std::cout << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << myParent->getID()
500  << " vaporizing " << vehicle->getID() << " to clear jam\n";
501 #endif
503  WRITE_WARNING("Clearing jam at calibrator '" + myParent->myID + "' at time "
504  + time2string(MSNet::getInstance()->getCurrentTimeStep()));
506  }
507  if (myParent->scheduleRemoval(vehicle)) {
509  }
510  }
511  }
512  return true;
513 }
514 
515 
516 
517 /****************************************************************************/
518 
MSCalibrator(const std::string &id, const MSEdge *const edge, const SUMOReal pos, const std::string &aXMLFilename, const std::string &outputFilename, const SUMOTime freq, const SUMOReal length, const MSRouteProbe *probe, const bool addLaneMeanData=true)
int nVehEntered
The number of vehicles that entered this lane within the sample interval.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:82
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
long long int SUMOTime
Definition: SUMOTime.h:43
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false) const
Tries to insert the given vehicle into the network.
Definition: MSEdge.cpp:472
std::string vtypeid
The vehicle's type id.
int nVehVaporized
The number of vehicles that left this lane within the sample interval.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:192
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
static std::vector< SUMOVehicleParameter * > LeftoverVehicleParameters
Definition: MSCalibrator.h:261
virtual void myEndElement(int element)
Called on the closing of a tag;.
Writes routes of vehicles passing a certain edge.
Definition: MSRouteProbe.h:68
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
bool myDidSpeedAdaption
The information whether speed was adapted in the current interval.
Definition: MSCalibrator.h:247
static SUMOVehicleParameter * parseVehicleAttributes(const SUMOSAXAttributes &attrs, const bool optionalID=false, const bool skipDepart=false, const bool isPerson=false)
Parses a vehicle's attributes.
virtual bool notifyEnter(SUMOVehicle &veh, Notification reason)
Checks whether the reminder is activated by a vehicle entering the lane.
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
bool myAmActive
whether the calibrator was active when last checking
Definition: MSCalibrator.h:256
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1543
bool myDidInit
The information whether init was called.
Definition: MSCalibrator.h:249
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
T MAX2(T a, T b)
Definition: StdDefs.h:75
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
The vehicle got vaporized.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
Definition: MSVehicle.h:374
SUMOTime myFrequency
The frequeny with which to check for calibration.
Definition: MSCalibrator.h:237
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
int myRemoved
The number of vehicles that were removed in the current interval.
Definition: MSCalibrator.h:239
friend class VehicleRemover
Definition: MSCalibrator.h:133
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:114
const std::string DEFAULT_VTYPE_ID
int myClearedInJam
The number of vehicles that were removed when clearin a jam.
Definition: MSCalibrator.h:243
const MSEdge *const myEdge
the edge on which this calibrator lies
Definition: MSCalibrator.h:211
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Data structure for mean (aggregated) edge/lane values.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The car-following model and parameter.
Definition: MSVehicleType.h:74
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
SUMOReal waitSeconds
The number of vehicle probes with small speed.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
int remainingVehicleCapacity(int laneIndex) const
const std::string & getID() const
Returns the id.
Definition: Named.h:66
A road/street connecting two junctions.
Definition: MSEdge.h:80
SUMOReal getLength() const
return the length of the edge
Definition: MSEdge.h:591
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
std::vector< AspiredState >::const_iterator myCurrentStateInterval
Iterator pointing to the current interval.
Definition: MSCalibrator.h:223
An abstract device that changes the state of the micro simulation.
Definition: MSTrigger.h:48
std::string routeid
The vehicle's route id.
void writeXMLOutput()
Representation of a vehicle.
Definition: SUMOVehicle.h:66
The least occupied lane from lanes which allow the continuation.
Encapsulated SAX-Attributes.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:307
bool invalidJam(int laneIndex) const
bool contains(const MSEdge *const edge) const
Definition: MSRoute.h:110
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
SUMOTime depart
The vehicle's departure time.
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
void resetRoutePosition(int index)
Definition: MSVehicle.cpp:685
The maximum speed is used.
No information given; use default.
bool mySpeedIsDefault
The information whether the speed adaption has been reset.
Definition: MSCalibrator.h:245
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
Definition: MSVehicle.cpp:601
bool scheduleRemoval(MSVehicle *veh)
try to schedule the givne vehicle for removal. return true if it isn't already scheduled ...
Definition: MSCalibrator.h:200
std::vector< AspiredState > myIntervals
List of adaptation intervals.
Definition: MSCalibrator.h:221
SUMOReal getTravelledDistance() const
Returns the total travelled distance.
Definition: MSMeanData.h:166
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
virtual void reset()
reset collected vehicle data
SUMOReal getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
Definition: MSEdge.cpp:769
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
virtual SUMOReal getHeadwayTime() const
Get the driver's reaction time [s].
Definition: MSCFModel.h:220
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
bool myHaveWarnedAboutClearingJam
The default (maximum) speed on the segment.
Definition: MSCalibrator.h:253
void setDescription(const std::string &description)
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition: MSNet.h:410
int nVehLeft
The number of vehicles that left this lane within the sample interval.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
int nVehArrived
The number of vehicles that finished on the lane.
No information given; use default.
virtual void myEndElement(int element)
Called when a closing tag occurs.
std::vector< MSMeanData_Net::MSLaneMeanDataValues * > myLaneMeanData
data collector for the calibrator
Definition: MSCalibrator.h:217
const MSRoute * getRoute() const
static std::vector< MSMoveReminder * > LeftoverReminders
Definition: MSCalibrator.h:260
std::string myID
The name of the object.
Definition: Named.h:136
void scheduleVehicleRemoval(SUMOVehicle *veh)
Removes a vehicle after it has ended.
Structure representing possible vehicle parameter.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:84
#define SUMOTime_MAX
Definition: SUMOTime.h:44
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
SUMOVehicleParameter * vehicleParameter
Definition: MSCalibrator.h:148
const MSRouteProbe *const myProbe
the route probe to retrieve routes from
Definition: MSCalibrator.h:215
static void cleanup()
cleanup remaining data structures
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
OutputDevice * myOutput
The device for xml statistics.
Definition: MSCalibrator.h:234
virtual void updateMeanData()
aggregate lane values
virtual int passed() const
Definition: MSCalibrator.h:159
virtual ~MSCalibrator()
virtual SUMOTime execute(SUMOTime currentTime)
Patch the time in a way that it is at least as high as the simulation begin time. ...
#define SUMOReal
Definition: config.h:214
virtual SUMOReal getSamples() const
Returns the number of collected sample seconds.
Definition: MSMeanData.cpp:186
bool removePending()
remove any vehicles which are scheduled for removal. return true if removals took place ...
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
int totalWished() const
number of vehicles expected to pass this interval
MSMeanData_Net::MSLaneMeanDataValues myEdgeMeanData
accumlated data for the whole edge
Definition: MSCalibrator.h:219
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
The class responsible for building and deletion of vehicles.
bool isCurrentStateActive(SUMOTime time)
std::vector< VehicleRemover * > myVehicleRemovers
Definition: MSCalibrator.h:225
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:487
bool isActive() const
Definition: MSCalibrator.h:136
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, MTRand *rng=0)
Returns the named vehicle type or a sample from the named distribution.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
std::set< std::string > myToRemove
set of vehicle ids to remove
Definition: MSCalibrator.h:231
Parser and container for routes during their loading.
SUMOReal myDefaultSpeed
The default (maximum) speed on the segment.
Definition: MSCalibrator.h:251
int myInserted
The number of vehicles that were inserted in the current interval.
Definition: MSCalibrator.h:241
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:78
std::string id
The vehicle's id.
void setMaxSpeed(SUMOReal val) const
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
Definition: MSEdge.cpp:783
const std::string & getID() const
Returns the name of the vehicle.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:122