SUMO - Simulation of Urban MObility
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-2017 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 //#define MSCalibrator_DEBUG
54 
55 // ===========================================================================
56 // static members
57 // ===========================================================================
58 std::vector<MSMoveReminder*> MSCalibrator::LeftoverReminders;
59 std::vector<SUMOVehicleParameter*> MSCalibrator::LeftoverVehicleParameters;
60 
61 // ===========================================================================
62 // method definitions
63 // ===========================================================================
64 MSCalibrator::MSCalibrator(const std::string& id,
65  const MSEdge* const edge, const double pos,
66  const std::string& aXMLFilename,
67  const std::string& outputFilename,
68  const SUMOTime freq, const double length,
69  const MSRouteProbe* probe,
70  const bool addLaneMeanData) :
71  MSTrigger(id),
72  MSRouteHandler(aXMLFilename, false),
73  myEdge(edge), myPos(pos), myProbe(probe),
74  myEdgeMeanData(0, length, false, 0),
75  myOutput(0), myFrequency(freq), myRemoved(0),
76  myInserted(0), myClearedInJam(0),
77  mySpeedIsDefault(true), myDidSpeedAdaption(false), myDidInit(false),
78  myDefaultSpeed(myEdge->getSpeedLimit()),
79  myHaveWarnedAboutClearingJam(false),
80  myAmActive(false) {
81  if (outputFilename != "") {
82  myOutput = &OutputDevice::getDevice(outputFilename);
83  myOutput->writeXMLHeader("calibratorstats", "calibratorstats_file.xsd");
84  }
85  if (aXMLFilename != "") {
86  XMLSubSys::runParser(*this, aXMLFilename);
87  if (!myDidInit) {
88  init();
89  }
90  }
91  if (addLaneMeanData) {
92  for (int i = 0; i < (int)myEdge->getLanes().size(); ++i) {
93  MSLane* lane = myEdge->getLanes()[i];
95  laneData->setDescription("meandata_calibrator_" + lane->getID());
96  LeftoverReminders.push_back(laneData);
97  myLaneMeanData.push_back(laneData);
98  VehicleRemover* remover = new VehicleRemover(lane, (int)i, this);
99  LeftoverReminders.push_back(remover);
100  myVehicleRemovers.push_back(remover);
101  }
102  }
103 }
104 
105 
106 void
108  if (myIntervals.size() > 0) {
109  if (myIntervals.back().end == -1) {
110  myIntervals.back().end = SUMOTime_MAX;
111  }
113  // calibration should happen after regular insertions have taken place
115  } else {
116  WRITE_WARNING("No flow intervals in calibrator '" + myID + "'.");
117  }
118  myDidInit = true;
119 }
120 
121 
123  if (myIntervals.size() > 0 && myCurrentStateInterval != myIntervals.end()) {
124  writeXMLOutput();
125  }
126  for (std::vector<VehicleRemover*>::iterator it = myVehicleRemovers.begin(); it != myVehicleRemovers.end(); ++it) {
127  (*it)->disable();
128  }
129 }
130 
131 
132 void
134  const SUMOSAXAttributes& attrs) {
135  if (element == SUMO_TAG_FLOW) {
136  AspiredState state;
137  SUMOTime lastEnd = -1;
138  if (myIntervals.size() > 0) {
139  lastEnd = myIntervals.back().end;
140  if (lastEnd == -1) {
141  lastEnd = myIntervals.back().begin;
142  }
143  }
144  try {
145  bool ok = true;
146  state.q = attrs.getOpt<double>(SUMO_ATTR_VEHSPERHOUR, 0, ok, -1.);
147  state.v = attrs.getOpt<double>(SUMO_ATTR_SPEED, 0, ok, -1.);
148  state.begin = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, myID.c_str(), ok);
149  if (state.begin < lastEnd) {
150  WRITE_ERROR("Overlapping or unsorted intervals in calibrator '" + myID + "'.");
151  }
152  state.end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, myID.c_str(), ok, -1);
155  // vehicles should be inserted with max speed unless stated otherwise
158  }
159  // vehicles should be inserted on any lane unless stated otherwise
162  }
163  if (state.vehicleParameter->vtypeid != DEFAULT_VTYPE_ID &&
165  WRITE_ERROR("Unknown vehicle type '" + state.vehicleParameter->vtypeid + "' in calibrator '" + myID + "'.");
166  }
167  } catch (EmptyData) {
168  WRITE_ERROR("Mandatory attribute missing in definition of calibrator '" + myID + "'.");
169  } catch (NumberFormatException) {
170  WRITE_ERROR("Non-numeric value for numeric attribute in definition of calibrator '" + myID + "'.");
171  }
172  if (state.q < 0 && state.v < 0) {
173  WRITE_ERROR("Either 'vehsPerHour' or 'speed' has to be given in flow definition of calibrator '" + myID + "'.");
174  }
175  if (myIntervals.size() > 0 && myIntervals.back().end == -1) {
176  myIntervals.back().end = state.begin;
177  }
178  myIntervals.push_back(state);
179  } else {
180  MSRouteHandler::myStartElement(element, attrs);
181  }
182 }
183 
184 
185 void
187  if (element == SUMO_TAG_CALIBRATOR) {
188  if (!myDidInit) {
189  init();
190  }
191  } else if (element != SUMO_TAG_FLOW) {
193  }
194 }
195 
196 
197 void
199  if (myOutput != 0) {
200  updateMeanData();
201  const int p = passed();
202  // meandata will be off if vehicles are removed on the next edge instead of this one
204  assert(discrepancy >= 0);
205  const std::string ds = (discrepancy > 0 ? "\" vaporizedOnNextEdge=\"" + toString(discrepancy) : "");
206  const double durationSeconds = STEPS2TIME(myCurrentStateInterval->end - myCurrentStateInterval->begin);
207  (*myOutput) << " <interval begin=\"" << time2string(myCurrentStateInterval->begin) <<
208  "\" end=\"" << time2string(myCurrentStateInterval->end) <<
209  "\" id=\"" << myID <<
210  "\" nVehContrib=\"" << p <<
211  "\" removed=\"" << myRemoved <<
212  "\" inserted=\"" << myInserted <<
213  "\" cleared=\"" << myClearedInJam <<
214  "\" flow=\"" << p * 3600.0 / durationSeconds <<
215  "\" aspiredFlow=\"" << myCurrentStateInterval->q <<
217  "\" aspiredSpeed=\"" << myCurrentStateInterval->v <<
218  ds << //optional
219  "\"/>\n";
220  }
221  myDidSpeedAdaption = false;
222  myInserted = 0;
223  myRemoved = 0;
224  myClearedInJam = 0;
226  reset();
227 }
228 
229 
230 bool
232  while (myCurrentStateInterval != myIntervals.end() && myCurrentStateInterval->end <= time) {
233  // XXX what about skipped intervals?
235  }
236  return myCurrentStateInterval != myIntervals.end() &&
237  myCurrentStateInterval->begin <= time && myCurrentStateInterval->end > time;
238 }
239 
240 int
242  if (myCurrentStateInterval != myIntervals.end()) {
243  const double totalHourFraction = STEPS2TIME(myCurrentStateInterval->end - myCurrentStateInterval->begin) / (double) 3600.;
244  return (int)std::floor(myCurrentStateInterval->q * totalHourFraction + 0.5); // round to closest int
245  } else {
246  return -1;
247  }
248 }
249 
250 
251 bool
253  if (myToRemove.size() > 0) {
255  // it is not save to remove the vehicles inside
256  // VehicleRemover::notifyEnter so we do it here
257  for (std::set<std::string>::iterator it = myToRemove.begin(); it != myToRemove.end(); ++it) {
258  MSVehicle* vehicle = dynamic_cast<MSVehicle*>(vc.getVehicle(*it));
259  if (vehicle != 0) {
262  vc.scheduleVehicleRemoval(vehicle);
263  } else {
264  WRITE_WARNING("Calibrator '" + getID() + "' could not remove vehicle '" + *it + "'.");
265  }
266  }
267  myToRemove.clear();
268  return true;
269  }
270  return false;
271 }
272 
273 
274 SUMOTime
276  // get current simulation values (valid for the last simulation second)
277  // XXX could we miss vehicle movements if this is called less often than every DELTA_T (default) ?
278  updateMeanData();
279  const bool hadRemovals = removePending();
280  // check whether an adaptation value exists
281  if (isCurrentStateActive(currentTime)) {
282  myAmActive = true;
283  // all happens in isCurrentStateActive()
284  } else {
285  myAmActive = false;
286  reset();
287  if (!mySpeedIsDefault) {
288  // reset speed to default
290  mySpeedIsDefault = true;
291  }
292  if (myCurrentStateInterval == myIntervals.end()) {
293  // keep calibrator alive for gui but do not call again
294  return TIME2STEPS(86400);
295  }
296  return myFrequency;
297  }
298  // we are active
299  if (!myDidSpeedAdaption && myCurrentStateInterval->v >= 0) {
301  mySpeedIsDefault = false;
302  myDidSpeedAdaption = true;
303  }
304 
305  const bool calibrateFlow = myCurrentStateInterval->q >= 0;
306  const int totalWishedNum = totalWished();
307  int adaptedNum = passed() + myClearedInJam;
308 #ifdef MSCalibrator_DEBUG
309  std::cout << time2string(currentTime) << " " << myID
310  << " q=" << myCurrentStateInterval->q
311  << " totalWished=" << totalWishedNum
312  << " adapted=" << adaptedNum
313  << " jam=" << invalidJam(-1)
314  << " entered=" << myEdgeMeanData.nVehEntered
315  << " departed=" << myEdgeMeanData.nVehDeparted
316  << " arrived=" << myEdgeMeanData.nVehArrived
317  << " left=" << myEdgeMeanData.nVehLeft
318  << " waitSecs=" << myEdgeMeanData.waitSeconds
319  << " vaporized=" << myEdgeMeanData.nVehVaporized
320  << "\n";
321 #endif
322  if (calibrateFlow && adaptedNum < totalWishedNum && !hadRemovals) {
323  // we need to insert some vehicles
324  const double hourFraction = STEPS2TIME(currentTime - myCurrentStateInterval->begin + DELTA_T) / (double) 3600.;
325  const int wishedNum = (int)std::floor(myCurrentStateInterval->q * hourFraction + 0.5); // round to closest int
326  // only the difference between inflow and aspiredFlow should be added, thus
327  // we should not count vehicles vaporized from a jam here
328  // if we have enough time left we can add missing vehicles later
329  const int relaxedInsertion = (int)std::floor(STEPS2TIME(myCurrentStateInterval->end - currentTime) / 3);
330  const int insertionSlack = MAX2(0, adaptedNum + relaxedInsertion - totalWishedNum);
331  // increase number of vehicles
332 #ifdef MSCalibrator_DEBUG
333  std::cout
334  << " wished:" << wishedNum
335  << " slack:" << insertionSlack
336  << " before:" << adaptedNum
337  << "\n";
338 #endif
339  while (wishedNum > adaptedNum + insertionSlack) {
340  SUMOVehicleParameter* pars = myCurrentStateInterval->vehicleParameter;
341  const MSRoute* route = myProbe != 0 ? myProbe->getRoute() : 0;
342  if (route == 0) {
343  route = MSRoute::dictionary(pars->routeid);
344  }
345  if (route == 0) {
346  WRITE_WARNING("No valid routes in calibrator '" + myID + "'.");
347  break;
348  }
349  if (!route->contains(myEdge)) {
350  WRITE_WARNING("Route '" + route->getID() + "' in calibrator '" + myID + "' does not contain edge '" + myEdge->getID() + "'.");
351  break;
352  }
353  const int routeIndex = (int)std::distance(route->begin(),
354  std::find(route->begin(), route->end(), myEdge));
356  assert(route != 0 && vtype != 0);
357  // build the vehicle
358  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
359  newPars->id = myID + "." + toString((int)STEPS2TIME(myCurrentStateInterval->begin)) + "." + toString(myInserted);
360  newPars->depart = currentTime;
361  newPars->routeid = route->getID();
363  newPars, route, vtype, true, false));
364 #ifdef MSCalibrator_DEBUG
365  std::cout << " resetting route pos: " << routeIndex << "\n";
366 #endif
367  vehicle->resetRoutePosition(routeIndex);
368  if (myEdge->insertVehicle(*vehicle, currentTime)) {
369  if (!MSNet::getInstance()->getVehicleControl().addVehicle(vehicle->getID(), vehicle)) {
370  throw ProcessError("Emission of vehicle '" + vehicle->getID() + "' in calibrator '" + getID() + "'failed!");
371  }
372  myInserted++;
373  adaptedNum++;
374 #ifdef MSCalibrator_DEBUG
375  std::cout << "I ";
376 #endif
377  } else {
378  // could not insert vehicle
379 #ifdef MSCalibrator_DEBUG
380  std::cout << "F ";
381 #endif
383  break;
384  }
385  }
386  }
387  if (myCurrentStateInterval->end <= currentTime + myFrequency) {
388  writeXMLOutput();
389  }
390  return myFrequency;
391 }
392 
393 void
396  for (std::vector<MSMeanData_Net::MSLaneMeanDataValues*>::iterator it = myLaneMeanData.begin(); it != myLaneMeanData.end(); ++it) {
397  (*it)->reset();
398  }
399 }
400 
401 
402 bool
403 MSCalibrator::invalidJam(int laneIndex) const {
404  if (laneIndex < 0) {
405  const int numLanes = (int)myEdge->getLanes().size();
406  for (int i = 0; i < numLanes; ++i) {
407  if (invalidJam(i)) {
408  return true;
409  }
410  }
411  return false;
412  }
413  assert(laneIndex < (int)myEdge->getLanes().size());
414  const MSLane* const lane = myEdge->getLanes()[laneIndex];
415  if (lane->getVehicleNumber() < 4) {
416  // cannot reliably detect invalid jams
417  return false;
418  }
419  // maxSpeed reflects the calibration target
420  const bool toSlow = lane->getMeanSpeed() < 0.5 * myEdge->getSpeedLimit();
421  return toSlow && remainingVehicleCapacity(laneIndex) < 1;
422 }
423 
424 
425 int
427  if (laneIndex < 0) {
428  const int numLanes = (int)myEdge->getLanes().size();
429  int result = 0;
430  for (int i = 0; i < numLanes; ++i) {
431  result = MAX2(result, remainingVehicleCapacity(i));
432  }
433  return result;
434  }
435  assert(laneIndex < (int)myEdge->getLanes().size());
436  MSLane* lane = myEdge->getLanes()[laneIndex];
437  MSVehicle* last = lane->getLastFullVehicle();
438  const SUMOVehicleParameter* pars = myCurrentStateInterval->vehicleParameter;
440  const double spacePerVehicle = vtype->getLengthWithGap() + myEdge->getSpeedLimit() * vtype->getCarFollowModel().getHeadwayTime();
441  if (last == 0) {
442  // ensure vehicles can be inserted on short edges
443  return MAX2(1, (int)(myEdge->getLength() / spacePerVehicle));
444  } else {
445  return (int)(last->getPositionOnLane() / spacePerVehicle);
446  }
447 }
448 
449 
450 void
452  for (std::vector<MSMoveReminder*>::iterator it = LeftoverReminders.begin(); it != LeftoverReminders.end(); ++it) {
453  delete *it;
454  }
455  LeftoverReminders.clear();
456  for (std::vector<SUMOVehicleParameter*>::iterator it = LeftoverVehicleParameters.begin();
457  it != LeftoverVehicleParameters.end(); ++it) {
458  delete *it;
459  }
461 }
462 
463 
464 void
467  for (std::vector<MSMeanData_Net::MSLaneMeanDataValues*>::iterator it = myLaneMeanData.begin();
468  it != myLaneMeanData.end(); ++it) {
469  (*it)->addTo(myEdgeMeanData);
470  }
471 }
472 
473 bool MSCalibrator::VehicleRemover::notifyEnter(SUMOVehicle& veh, Notification /* reason */, const MSLane* /* enteredLane */) {
474  if (myParent == 0) {
475  return false;
476  }
477  if (myParent->isActive()) {
478  myParent->updateMeanData();
479  const bool calibrateFlow = myParent->myCurrentStateInterval->q >= 0;
480  const int totalWishedNum = myParent->totalWished();
481  int adaptedNum = myParent->passed() + myParent->myClearedInJam;
482  MSVehicle* vehicle = dynamic_cast<MSVehicle*>(&veh);
483  if (calibrateFlow && adaptedNum > totalWishedNum) {
484 #ifdef MSCalibrator_DEBUG
485  std::cout << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << myParent->getID()
486  << " vaporizing " << vehicle->getID() << " to reduce flow\n";
487 #endif
488  if (myParent->scheduleRemoval(vehicle)) {
489  myParent->myRemoved++;
490  }
491  } else if (myParent->invalidJam(myLaneIndex)) {
492 #ifdef MSCalibrator_DEBUG
493  std::cout << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << myParent->getID()
494  << " vaporizing " << vehicle->getID() << " to clear jam\n";
495 #endif
496  if (!myParent->myHaveWarnedAboutClearingJam) {
497  WRITE_WARNING("Clearing jam at calibrator '" + myParent->myID + "' at time "
498  + time2string(MSNet::getInstance()->getCurrentTimeStep()));
499  myParent->myHaveWarnedAboutClearingJam = true;
500  }
501  if (myParent->scheduleRemoval(vehicle)) {
502  myParent->myClearedInJam++;
503  }
504  }
505  }
506  return true;
507 }
508 
509 
510 
511 /****************************************************************************/
512 
virtual bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Checks whether the reminder is activated by a vehicle entering the lane.
double getLength() const
return the length of the edge
Definition: MSEdge.h:586
int nVehEntered
The number of vehicles that entered this lane within the sample interval.
MSCalibrator(const std::string &id, const MSEdge *const edge, const double pos, const std::string &aXMLFilename, const std::string &outputFilename, const SUMOTime freq, const double length, const MSRouteProbe *probe, const bool addLaneMeanData=true)
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
std::string vtypeid
The vehicle&#39;s type id.
int nVehVaporized
The number of vehicles that left this lane within the sample interval.
a flow definition (used by router)
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:192
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
double getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
Definition: MSEdge.cpp:824
static SUMOVehicleParameter * parseVehicleAttributes(const SUMOSAXAttributes &attrs, const bool optionalID=false, const bool skipDepart=false, const bool isPerson=false)
Parses a vehicle&#39;s attributes.
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:60
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:1667
weights: time range begin
virtual double getHeadwayTime() const
Get the driver&#39;s reaction time [s].
Definition: MSCFModel.h:220
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:158
T MAX2(T a, T b)
Definition: StdDefs.h:70
SUMOTime DELTA_T
Definition: SUMOTime.cpp:40
The vehicle got vaporized.
double getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:375
double getTravelledDistance() const
Returns the total travelled distance.
Definition: MSMeanData.h:166
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
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&#39;s ok.
Definition: XMLSubSys.cpp:110
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&#39;s car following model definition (const version)
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.
double getLengthWithGap() const
Get vehicle&#39;s length including the minimum gap [m].
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
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
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&#39;s route id.
void writeXMLOutput()
Representation of a vehicle.
Definition: SUMOVehicle.h:67
The least occupied lane from lanes which allow the continuation.
Encapsulated SAX-Attributes.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
#define SUMOTime_MAX
Definition: TraCIDefs.h:53
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:310
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&#39;s departure time.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
void resetRoutePosition(int index)
Definition: MSVehicle.cpp:684
The maximum speed is used.
double myDefaultSpeed
The default (maximum) speed on the segment.
Definition: MSCalibrator.h:251
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:598
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false, const bool forceCheck=false) const
Tries to insert the given vehicle into the network.
Definition: MSEdge.cpp:527
std::vector< AspiredState > myIntervals
List of adaptation intervals.
Definition: MSCalibrator.h:221
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
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
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:413
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
double waitSeconds
The number of vehicle probes with small speed.
int nVehLeft
The number of vehicles that left this lane within the sample interval.
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:80
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
weights: time range end
virtual double getSamples() const
Returns the number of collected sample seconds.
Definition: MSMeanData.cpp:182
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
void setMaxSpeed(double val) const
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
Definition: MSEdge.cpp:843
virtual int passed() const
Definition: MSCalibrator.h:159
virtual ~MSCalibrator()
virtual SUMOTime execute(SUMOTime currentTime)
long long int SUMOTime
Definition: TraCIDefs.h:52
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:488
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.
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:74
std::string id
The vehicle&#39;s id.
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:118