Eclipse SUMO - Simulation of Urban MObility
MSDevice_Vehroutes.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2009-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // A device which collects info on the vehicle trip
22 /****************************************************************************/
23 #include <config.h>
24 
25 #include <microsim/MSGlobals.h>
26 #include <microsim/MSNet.h>
27 #include <microsim/MSLane.h>
28 #include <microsim/MSEdge.h>
29 #include <microsim/MSRoute.h>
30 #include <microsim/MSVehicle.h>
31 #include <microsim/MSVehicleType.h>
37 #include "MSDevice_Vehroutes.h"
38 
39 
40 // ===========================================================================
41 // static member variables
42 // ===========================================================================
47 bool MSDevice_Vehroutes::mySorted = false;
54 std::map<const SUMOTime, int> MSDevice_Vehroutes::myDepartureCounts;
55 std::map<const SUMOTime, std::map<const std::string, std::string> > MSDevice_Vehroutes::myRouteInfos;
56 
57 
58 // ===========================================================================
59 // method definitions
60 // ===========================================================================
61 // ---------------------------------------------------------------------------
62 // static initialisation methods
63 // ---------------------------------------------------------------------------
64 void
67  if (oc.isSet("vehroute-output")) {
68  OutputDevice::createDeviceByOption("vehroute-output", "routes", "routes_file.xsd");
69  mySaveExits = oc.getBool("vehroute-output.exit-times");
70  myLastRouteOnly = oc.getBool("vehroute-output.last-route");
71  myDUAStyle = oc.getBool("vehroute-output.dua");
72  myWriteCosts = oc.getBool("vehroute-output.cost");
73  mySorted = myDUAStyle || oc.getBool("vehroute-output.sorted");
74  myIntendedDepart = oc.getBool("vehroute-output.intended-depart");
75  myRouteLength = oc.getBool("vehroute-output.route-length");
76  mySkipPTLines = oc.getBool("vehroute-output.skip-ptlines");
77  myIncludeIncomplete = oc.getBool("vehroute-output.incomplete");
78  myWriteStopPriorEdges = oc.getBool("vehroute-output.stop-edges");
80  }
81 }
82 
83 void
85  oc.addOptionSubTopic("Vehroutes Device");
86  insertDefaultAssignmentOptions("vehroute", "Vehroutes Device", oc);
87 }
88 
89 
90 
92 MSDevice_Vehroutes::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, int maxRoutes) {
93  if (maxRoutes < std::numeric_limits<int>::max()) {
94  return new MSDevice_Vehroutes(v, "vehroute_" + v.getID(), maxRoutes);
95  }
96  if (mySkipPTLines && v.getParameter().line != "") {
97  return nullptr;
98  }
100  if (equippedByDefaultAssignmentOptions(oc, "vehroute", v, oc.isSet("vehroute-output"))) {
101  if (myLastRouteOnly) {
102  maxRoutes = 0;
103  }
104  myStateListener.myDevices[&v] = new MSDevice_Vehroutes(v, "vehroute_" + v.getID(), maxRoutes);
105  into.push_back(myStateListener.myDevices[&v]);
106  return myStateListener.myDevices[&v];
107  }
108  return nullptr;
109 }
110 
111 
112 // ---------------------------------------------------------------------------
113 // MSDevice_Vehroutes::StateListener-methods
114 // ---------------------------------------------------------------------------
115 void
117  if (to == MSNet::VEHICLE_STATE_NEWROUTE) {
118  const auto& deviceEntry = myDevices.find(vehicle);
119  if (deviceEntry != myDevices.end()) {
120  deviceEntry->second->addRoute(info);
121  }
122  }
123 }
124 
125 
126 // ---------------------------------------------------------------------------
127 // MSDevice_Vehroutes-methods
128 // ---------------------------------------------------------------------------
129 MSDevice_Vehroutes::MSDevice_Vehroutes(SUMOVehicle& holder, const std::string& id, int maxRoutes) :
130  MSVehicleDevice(holder, id),
131  myCurrentRoute(&holder.getRoute()),
132  myMaxRoutes(maxRoutes),
133  myLastSavedAt(nullptr),
134  myDepartLane(-1),
135  myDepartPos(-1),
136  myDepartSpeed(-1),
137  myDepartPosLat(0),
138  myStopOut(2) {
140 }
141 
142 
144  for (const RouteReplaceInfo& rri : myReplacedRoutes) {
145  rri.route->release();
146  }
149 }
150 
151 
152 bool
155  if (mySorted && myStateListener.myDevices[static_cast<SUMOVehicle*>(&veh)] == this) {
157  myDepartureCounts[departure]++;
158  }
159  if (!MSGlobals::gUseMesoSim) {
160  const MSVehicle& vehicle = static_cast<MSVehicle&>(veh);
161  myDepartLane = vehicle.getLane()->getIndex();
163  }
164  myDepartSpeed = veh.getSpeed();
166  }
167  if (myWriteStopPriorEdges) {
168  myPriorEdges.push_back(&enteredLane->getEdge());
169  }
171 }
172 
173 
174 bool
175 MSDevice_Vehroutes::notifyLeave(SUMOTrafficObject& veh, double /*lastPos*/, MSMoveReminder::Notification reason, const MSLane* /* enteredLane */) {
176  if (mySaveExits && reason != NOTIFICATION_LANE_CHANGE) {
177  if (reason != NOTIFICATION_TELEPORT && myLastSavedAt == veh.getEdge()) { // need to check this for internal lanes
179  } else if (myLastSavedAt != veh.getEdge()) {
180  myExits.push_back(MSNet::getInstance()->getCurrentTimeStep());
181  myLastSavedAt = veh.getEdge();
182  }
183  }
185 }
186 
187 
188 void
191  if (myWriteStopPriorEdges) {
192  myStopOut.writeAttr("priorEdges", myPriorEdges);
193  myPriorEdges.clear();
195  }
196 }
197 
198 
199 void
201  if (index == 0 && !myIncludeIncomplete && myReplacedRoutes[index].route->size() == 2 &&
202  myReplacedRoutes[index].route->getEdges().front()->isTazConnector() &&
203  myReplacedRoutes[index].route->getEdges().back()->isTazConnector()) {
204  return;
205  }
206  // check if a previous route shall be written
208  if (index >= 0) {
209  assert((int)myReplacedRoutes.size() > index);
210  if (myDUAStyle || myWriteCosts) {
211  os.writeAttr(SUMO_ATTR_COST, myReplacedRoutes[index].route->getCosts());
212  }
213  if (myWriteCosts) {
214  os.writeAttr(SUMO_ATTR_SAVINGS, myReplacedRoutes[index].route->getSavings());
215  }
216  // write edge on which the vehicle was when the route was valid
217  os.writeAttr("replacedOnEdge", (myReplacedRoutes[index].edge ?
218  myReplacedRoutes[index].edge->getID() : ""));
219  // write the reason for replacement
220  os.writeAttr("reason", myReplacedRoutes[index].info);
221 
222  // write the time at which the route was replaced
223  os.writeAttr("replacedAtTime", time2string(myReplacedRoutes[index].time));
224  os.writeAttr(SUMO_ATTR_PROB, "0");
225  os << " edges=\"";
226  // get the route
227  int i = index;
228  while (i > 0 && myReplacedRoutes[i - 1].edge != nullptr && !myIncludeIncomplete) {
229  i--;
230  }
231  const MSEdge* lastEdge = nullptr;
232  for (; i < index; ++i) {
233  myReplacedRoutes[i].route->writeEdgeIDs(os, lastEdge, myReplacedRoutes[i].edge);
234  lastEdge = myReplacedRoutes[i].edge;
235  }
236  myReplacedRoutes[index].route->writeEdgeIDs(os, lastEdge);
237  os << "\"";
238  } else {
239  if (myDUAStyle || myWriteCosts) {
241  }
242  if (myWriteCosts) {
244  }
245  os << " edges=\"";
246  const MSEdge* lastEdge = nullptr;
247  int numWritten = 0;
248  if (myHolder.getNumberReroutes() > 0) {
249  assert((int)myReplacedRoutes.size() <= myHolder.getNumberReroutes());
250  int i = (int)myReplacedRoutes.size();
251  while (i > 0 && myReplacedRoutes[i - 1].edge) {
252  i--;
253  }
254  for (; i < (int)myReplacedRoutes.size(); ++i) {
255  numWritten += myReplacedRoutes[i].route->writeEdgeIDs(os, lastEdge, myReplacedRoutes[i].edge);
256  lastEdge = myReplacedRoutes[i].edge;
257  }
258  }
259  numWritten += myCurrentRoute->writeEdgeIDs(os, lastEdge, nullptr);
260  os << "\"";
261 
262  if (mySaveExits) {
263  std::vector<std::string> exits;
264  for (SUMOTime t : myExits) {
265  exits.push_back(time2string(t));
266  }
267  assert(numWritten >= (int)myExits.size());
268  std::vector<std::string> missing(numWritten - (int)myExits.size(), "-1");
269  exits.insert(exits.end(), missing.begin(), missing.end());
270  os.writeAttr("exitTimes", exits);
271  }
272  }
273  os.closeTag();
274 }
275 
276 
277 void
279  writeOutput(true);
280 }
281 
282 
283 void
284 MSDevice_Vehroutes::writeOutput(const bool hasArrived) const {
285  OutputDevice& routeOut = OutputDevice::getDeviceByOption("vehroute-output");
286  OutputDevice_String od(1);
289  if (!MSGlobals::gUseMesoSim) {
290  if (tmp.wasSet(VEHPARS_DEPARTLANE_SET)) {
292  tmp.departLane = myDepartLane;
293  }
294  if (tmp.wasSet(VEHPARS_DEPARTPOSLAT_SET)) {
297  }
298  }
299  if (tmp.wasSet(VEHPARS_DEPARTPOS_SET)) {
301  tmp.departPos = myDepartPos;
302  }
303  if (tmp.wasSet(VEHPARS_DEPARTSPEED_SET)) {
306  }
307  const std::string typeID = myHolder.getVehicleType().getID() != DEFAULT_VTYPE_ID ? myHolder.getVehicleType().getID() : "";
308  tmp.write(od, OptionsCont::getOptions(), SUMO_TAG_VEHICLE, typeID);
309  if (hasArrived) {
310  od.writeAttr("arrival", time2string(MSNet::getInstance()->getCurrentTimeStep()));
311  if (myRouteLength) {
312  const bool includeInternalLengths = MSGlobals::gUsingInternalLanes && MSNet::getInstance()->hasInternalLinks();
314  myHolder.getRoute().begin(), myHolder.getCurrentRouteEdge(), includeInternalLengths);
315  od.writeAttr("routeLength", routeLength);
316  }
317  }
318  if (myDUAStyle) {
320  if (routeDist != nullptr) {
321  const std::vector<const MSRoute*>& routes = routeDist->getVals();
322  unsigned index = 0;
323  while (index < routes.size() && routes[index] != myCurrentRoute) {
324  ++index;
325  }
327  const std::vector<double>& probs = routeDist->getProbs();
328  for (int i = 0; i < (int)routes.size(); ++i) {
329  od.setPrecision();
331  od.writeAttr(SUMO_ATTR_COST, routes[i]->getCosts());
332  if (myWriteCosts) {
333  od.writeAttr(SUMO_ATTR_SAVINGS, routes[i]->getSavings());
334  }
335  od.setPrecision(8);
336  od.writeAttr(SUMO_ATTR_PROB, probs[i]);
337  od.setPrecision();
338  od << " edges=\"";
339  routes[i]->writeEdgeIDs(od, *routes[i]->begin());
340  (od << "\"").closeTag();
341  }
342  od.closeTag();
343  } else {
344  writeXMLRoute(od);
345  }
346  } else {
347  const int routesToSkip = myHolder.getParameter().wasSet(VEHPARS_FORCE_REROUTE) && !myIncludeIncomplete ? 1 : 0;
348  if ((int)myReplacedRoutes.size() > routesToSkip) {
350  for (int i = routesToSkip; i < (int)myReplacedRoutes.size(); ++i) {
351  writeXMLRoute(od, i);
352  }
353  writeXMLRoute(od);
354  od.closeTag();
355  } else {
356  writeXMLRoute(od);
357  }
358  }
359  od << myStopOut.getString();
361  od.closeTag();
362  od.lf();
363  if (mySorted) {
364  myRouteInfos[tmp.depart][myHolder.getID()] = od.getString();
365  myDepartureCounts[tmp.depart]--;
366  std::map<const SUMOTime, int>::iterator it = myDepartureCounts.begin();
367  while (it != myDepartureCounts.end() && it->second == 0) {
368  std::map<const std::string, std::string>& infos = myRouteInfos[it->first];
369  for (std::map<const std::string, std::string>::const_iterator it2 = infos.begin(); it2 != infos.end(); ++it2) {
370  routeOut << it2->second;
371  }
372  myRouteInfos.erase(it->first);
373  myDepartureCounts.erase(it);
374  it = myDepartureCounts.begin();
375  }
376  } else {
377  routeOut << od.getString();
378  }
379 }
380 
381 
382 const MSRoute*
384  if (index < (int)myReplacedRoutes.size()) {
385  return myReplacedRoutes[index].route;
386  } else {
387  return nullptr;
388  }
389 }
390 
391 
392 void
393 MSDevice_Vehroutes::addRoute(const std::string& info) {
394  if (myMaxRoutes > 0) {
395  if (myHolder.hasDeparted()) {
397  } else {
398  myReplacedRoutes.push_back(RouteReplaceInfo(nullptr, MSNet::getInstance()->getCurrentTimeStep(), myCurrentRoute, info));
399  }
400  if ((int)myReplacedRoutes.size() > myMaxRoutes) {
401  myReplacedRoutes.front().route->release();
402  myReplacedRoutes.erase(myReplacedRoutes.begin());
403  }
404  } else {
406  }
409 }
410 
411 
412 void
414  for (const auto& it : myStateListener.myDevices) {
415  if (it.first->hasDeparted()) {
416  it.second->writeOutput(false);
417  }
418  }
419  // unfinished persons
420  MSNet* net = MSNet::getInstance();
421  if (net->hasPersons()) {
423  while (pc.loadedBegin() != pc.loadedEnd()) {
424  pc.erase(pc.loadedBegin()->second);
425  }
426  }
427 }
428 
429 
430 void
433  out.writeAttr(SUMO_ATTR_ID, getID());
434  std::vector<std::string> internals;
435  if (!MSGlobals::gUseMesoSim) {
436  internals.push_back(toString(myDepartLane));
437  internals.push_back(toString(myDepartPosLat));
438  }
439  internals.push_back(toString(myDepartSpeed));
440  internals.push_back(toString(myDepartPos));
441  internals.push_back(toString(myReplacedRoutes.size()));
442  for (int i = 0; i < (int)myReplacedRoutes.size(); ++i) {
443  const std::string replacedOnEdge = myReplacedRoutes[i].edge == nullptr ? "!NULL" : myReplacedRoutes[i].edge->getID();
444  internals.push_back(replacedOnEdge);
445  internals.push_back(toString(myReplacedRoutes[i].time));
446  internals.push_back(myReplacedRoutes[i].route->getID());
447  internals.push_back(myReplacedRoutes[i].info);
448  }
449  out.writeAttr(SUMO_ATTR_STATE, toString(internals));
450  out.closeTag();
451 }
452 
453 
454 void
456  std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
457  if (!MSGlobals::gUseMesoSim) {
458  bis >> myDepartLane;
459  bis >> myDepartPosLat;
460  }
461  bis >> myDepartSpeed;
462  bis >> myDepartPos;
463  int size;
464  bis >> size;
465  for (int i = 0; i < size; ++i) {
466  std::string edgeID;
467  SUMOTime time;
468  std::string routeID;
469  std::string info;
470  bis >> edgeID;
471  bis >> time;
472  bis >> routeID;
473  bis >> info;
474  const MSRoute* route = MSRoute::dictionary(routeID);
475  route->addReference();
476  myReplacedRoutes.push_back(RouteReplaceInfo(MSEdge::dictionary(edgeID), time, route, info));
477  }
478 }
479 
480 
481 /****************************************************************************/
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
long long int SUMOTime
Definition: SUMOTime.h:31
const std::string DEFAULT_VTYPE_ID
@ GIVEN
The lane is given.
@ GIVEN
The position is given.
@ GIVEN
The position is given.
const int VEHPARS_DEPARTPOS_SET
@ GIVEN
The speed is given.
const int VEHPARS_DEPARTLANE_SET
const int VEHPARS_FORCE_REROUTE
const int VEHPARS_DEPARTSPEED_SET
const int VEHPARS_DEPARTPOSLAT_SET
@ SUMO_TAG_DEVICE
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_ATTR_LAST
@ SUMO_ATTR_COST
@ SUMO_ATTR_PROB
@ SUMO_ATTR_SAVINGS
@ SUMO_ATTR_ID
@ SUMO_ATTR_STATE
The state of a link.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
Information about a replaced route.
A class that is notified about reroutings.
std::map< const SUMOVehicle *, MSDevice_Vehroutes *, ComparatorNumericalIdLess > myDevices
A map for internal notification.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
A device which collects info on the vehicle trip (mainly on departure and arrival)
static bool myWriteCosts
A shortcut for the Option "vehroute-output.costs".
static void init()
Static intialization.
std::vector< SUMOTime > myExits
The times the vehicle exites an edge.
static bool mySorted
A shortcut for the Option "vehroute-output.sorted".
static bool myIntendedDepart
A shortcut for the Option "vehroute-output.intended-depart".
static std::map< const SUMOTime, std::map< const std::string, std::string > > myRouteInfos
void addRoute(const std::string &info)
Called on route change.
static bool myIncludeIncomplete
A shortcut for the Option "vehroute-output.incomplete".
void stopEnded(const SUMOVehicleParameter::Stop &stop)
MSDevice_Vehroutes(SUMOVehicle &holder, const std::string &id, int maxRoutes)
Constructor.
static bool myRouteLength
A shortcut for the Option "vehroute-output.route-length".
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_FCD-options.
void writeXMLRoute(OutputDevice &os, int index=-1) const
Called on route output.
static std::map< const SUMOTime, int > myDepartureCounts
Map needed to sort vehicles by departure time.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, int maxRoutes=std::numeric_limits< int >::max())
Build devices for the given vehicle, if needed.
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
std::vector< RouteReplaceInfo > myReplacedRoutes
Prior routes.
std::vector< const MSEdge * > myPriorEdges
the edges that were passed before the current stop
const int myMaxRoutes
The maximum number of routes to report.
static bool myWriteStopPriorEdges
A shortcut for the Option "vehroute-output.stop-edges".
double myDepartPosLat
The lateral depart position.
const MSEdge * myLastSavedAt
The last edge the exit time was saved for.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
OutputDevice_String myStopOut
double myDepartPos
The lane the vehicle departed at.
const MSRoute * getRoute(int index) const
Called on route retrieval.
static bool myLastRouteOnly
A shortcut for the Option "vehroute-output.last-route".
double myDepartSpeed
The speed on departure.
int myDepartLane
The lane the vehicle departed at.
void writeOutput(const bool hasArrived) const
Called on writing vehroutes output.
~MSDevice_Vehroutes()
Destructor.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Saves exit times if needed.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Does nothing, returns true only if exit times should be collected.
static bool mySkipPTLines
A shortcut for the Option "vehroute-output.skip-ptlines".
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing vehroutes output.
const MSRoute * myCurrentRoute
The currently used route.
static bool myDUAStyle
A shortcut for the Option "vehroute-output.dua".
static bool mySaveExits
A shortcut for the Option "vehroute-output.exit-times".
void saveState(OutputDevice &out) const
Saves the state of the device.
static StateListener myStateListener
A class that is notified about reroutings.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
Definition: MSDevice.cpp:134
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
Definition: MSDevice.h:204
A road/street connecting two junctions.
Definition: MSEdge.h:77
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition: MSEdge.cpp:814
static bool gUseMesoSim
Definition: MSGlobals.h:88
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:66
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:562
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:673
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
The simulated network and simulation perfomer.
Definition: MSNet.h:89
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:587
@ VEHICLE_STATE_NEWROUTE
The vehicle got a new route.
Definition: MSNet.h:599
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:313
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:1054
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:388
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:986
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:695
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:94
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:113
double getSavings() const
Returns the estimated savings due to using this route (compare to the route before rerouting)
Definition: MSRoute.h:172
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:100
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
Definition: MSRoute.cpp:165
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes....
Definition: MSRoute.cpp:299
int writeEdgeIDs(OutputDevice &os, const MSEdge *const from, const MSEdge *const upTo=0) const
Output the edge ids up to but not including the id of the given edge.
Definition: MSRoute.cpp:226
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:69
double getCosts() const
Returns the costs of the route.
Definition: MSRoute.h:164
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
virtual void erase(MSTransportable *transportable)
removes a single transportable
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition: MSVehicle.h:411
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:550
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:90
const std::string & getID() const
Returns the id.
Definition: Named.h:73
A storage for options typed value containers)
Definition: OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
An output device that encapsulates an ofstream.
std::string getString() const
Returns the current content as a string.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
void lf()
writes a line feed if applicable
Definition: OutputDevice.h:227
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:239
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precison or resets it to default.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
const std::vector< T > & getVals() const
Returns the members of the distribution.
Encapsulated SAX-Attributes.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
Representation of a vehicle, person, or container.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition: SUMOVehicle.h:58
virtual const MSRoute & getRoute() const =0
Returns the current route.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
Definition of vehicle stop (position and duration)
void write(OutputDevice &dev, bool close=true) const
Writes the stop as XML.
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
double departSpeed
(optional) The initial speed of the vehicle
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
bool wasSet(int what) const
Returns whether the given parameter was set.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)