Eclipse SUMO - Simulation of Urban MObility
MSDevice_Taxi.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2013-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 /****************************************************************************/
18 // A device which controls a taxi
19 /****************************************************************************/
20 #include <config.h>
21 
30 #include <microsim/MSGlobals.h>
31 #include <microsim/MSVehicle.h>
32 #include <microsim/MSEdge.h>
33 #include <microsim/MSStop.h>
34 
35 #include "MSDispatch.h"
36 #include "MSDispatch_Greedy.h"
39 #include "MSDispatch_TraCI.h"
40 
41 #include "MSIdling.h"
42 
43 #include "MSRoutingEngine.h"
44 #include "MSDevice_Taxi.h"
45 
46 //#define DEBUG_DISPATCH
47 
48 // ===========================================================================
49 // static member variables
50 // ===========================================================================
56 // @brief the list of available taxis
57 std::vector<MSDevice_Taxi*> MSDevice_Taxi::myFleet;
59 
60 #define TAXI_SERVICE "taxi"
61 
62 // ===========================================================================
63 // method definitions
64 // ===========================================================================
65 // ---------------------------------------------------------------------------
66 // static initialisation methods
67 // ---------------------------------------------------------------------------
68 void
70  oc.addOptionSubTopic("Taxi Device");
71  insertDefaultAssignmentOptions("taxi", "Taxi Device", oc);
72 
73  oc.doRegister("device.taxi.dispatch-algorithm", new Option_String("greedy"));
74  oc.addDescription("device.taxi.dispatch-algorithm", "Taxi Device", "The dispatch algorithm [greedy|greedyClosest|greedyShared|routeExtension|traci]");
75 
76  oc.doRegister("device.taxi.dispatch-algorithm.output", new Option_String(""));
77  oc.addDescription("device.taxi.dispatch-algorithm.output", "Taxi Device", "Write information from the dispatch algorithm to FILE");
78 
79  oc.doRegister("device.taxi.dispatch-algorithm.params", new Option_String(""));
80  oc.addDescription("device.taxi.dispatch-algorithm.params", "Taxi Device", "Load dispatch algorithm parameters in format KEY1:VALUE1[,KEY2:VALUE]");
81 
82  oc.doRegister("device.taxi.dispatch-period", new Option_String("60", "TIME"));
83  oc.addDescription("device.taxi.dispatch-period", "Taxi Device", "The period between successive calls to the dispatcher");
84 
85  oc.doRegister("device.taxi.idle-algorithm", new Option_String("stop"));
86  oc.addDescription("device.taxi.idle-algorithm", "Taxi Device", "The behavior of idle taxis [stop|randomCircling]");
87 
88  oc.doRegister("device.taxi.idle-algorithm.output", new Option_String(""));
89  oc.addDescription("device.taxi.idle-algorithm.output", "Taxi Device", "Write information from the idling algorithm to FILE");
90 }
91 
92 
93 void
94 MSDevice_Taxi::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
96  if (equippedByDefaultAssignmentOptions(oc, "taxi", v, false)) {
98  WRITE_WARNING("Mesoscopic simulation does not support the taxi device yet.");
99  return;
100  }
101  // build the device
102  MSDevice_Taxi* device = new MSDevice_Taxi(v, "taxi_" + v.getID());
103  into.push_back(device);
104  myFleet.push_back(device);
105  if (v.getParameter().line == "") {
106  // automatically set the line so that persons are willing to enter
107  // (see MSStageDriving::isWaitingFor)
108  const_cast<SUMOVehicleParameter&>(v.getParameter()).line = TAXI_SERVICE;
109  }
110  if (v.getVClass() != SVC_TAXI) {
111  WRITE_WARNING("Vehicle '" + v.getID() + "' with device.taxi should have vClass taxi instead of '" + toString(v.getVClass()) + "'.");
112  }
113  const int personCapacity = v.getVehicleType().getPersonCapacity();
114  myMaxCapacity = MAX2(myMaxCapacity, personCapacity);
115  if (personCapacity < 1) {
116  WRITE_WARNINGF("Vehicle '%' with personCapacity % is not usable as taxi.", v.getID(), toString(personCapacity));
117  }
118  }
119 }
120 
121 void
124  myDispatchPeriod = string2time(oc.getString("device.taxi.dispatch-period"));
125  // init dispatch algorithm
126  std::string algo = oc.getString("device.taxi.dispatch-algorithm");
127  Parameterised params;
128  params.setParametersStr(OptionsCont::getOptions().getString("device.taxi.dispatch-algorithm.params"), ":", ",");
129  if (algo == "greedy") {
131  } else if (algo == "greedyClosest") {
133  } else if (algo == "greedyShared") {
135  } else if (algo == "routeExtension") {
137  } else if (algo == "traci") {
139  } else {
140  throw ProcessError("Dispatch algorithm '" + algo + "' is not known");
141  }
143  // round to next multiple of myDispatchPeriod
145  const SUMOTime begin = string2time(oc.getString("begin"));
146  const SUMOTime delay = (myDispatchPeriod - ((now - begin) % myDispatchPeriod)) % myDispatchPeriod;
148 }
149 
150 void
152  const std::set<std::string>& lines,
153  SUMOTime reservationTime,
154  SUMOTime pickupTime,
155  const MSEdge* from, double fromPos,
156  const MSEdge* to, double toPos,
157  const std::string& group) {
158  if (lines.size() == 1 && *lines.begin() == TAXI_SERVICE) {
159  if (myDispatchCommand == nullptr) {
160  initDispatch();
161  }
162  myDispatcher->addReservation(person, reservationTime, pickupTime, from, fromPos, to, toPos, group, myMaxCapacity);
163  }
164 }
165 
166 
167 SUMOTime
169  std::vector<MSDevice_Taxi*> active;
170  for (MSDevice_Taxi* taxi : myFleet) {
171  if (taxi->getHolder().hasDeparted()) {
172  active.push_back(taxi);
173  }
174  }
175  myDispatcher->computeDispatch(currentTime, active);
176  return myDispatchPeriod;
177 }
178 
179 bool
181  return myDispatcher != nullptr && myDispatcher->hasServableReservations();
182 }
183 
184 void
186  if (myDispatcher != nullptr) {
187  delete myDispatcher;
188  myDispatcher = nullptr;
189  }
190  myDispatchCommand = nullptr;
191 }
192 
193 // ---------------------------------------------------------------------------
194 // MSDevice_Taxi-methods
195 // ---------------------------------------------------------------------------
196 MSDevice_Taxi::MSDevice_Taxi(SUMOVehicle& holder, const std::string& id) :
197  MSVehicleDevice(holder, id) {
198  std::string defaultServiceEnd = toString(1e15);
199  const std::string algo = getStringParam(holder, OptionsCont::getOptions(), "taxi.idle-algorithm", "", false);
200  if (algo == "stop") {
202  } else if (algo == "randomCircling") {
204  // make sure simulation terminates
205  defaultServiceEnd = toString(STEPS2TIME(
208  : MSNet::getInstance()->getCurrentTimeStep()) + (3600 * 8));
209  } else {
210  throw ProcessError("Idle algorithm '" + algo + "' is not known for vehicle '" + myHolder.getID() + "'");
211  }
212  myServiceEnd = string2time(getStringParam(holder, OptionsCont::getOptions(), "taxi.end", defaultServiceEnd, false));
213 }
214 
215 
217  myFleet.erase(std::find(myFleet.begin(), myFleet.end(), this));
218  // recompute myMaxCapacity
219  myMaxCapacity = 0;
220  for (MSDevice_Taxi* taxi : myFleet) {
221  myMaxCapacity = MAX2(myMaxCapacity, taxi->getHolder().getVehicleType().getPersonCapacity());
222  }
223 }
224 
225 
228  if (myFleet.size() > 0) {
229  return &myFleet[0]->getHolder();
230  } else {
231  return nullptr;
232  }
233 }
234 
235 
236 void
238  dispatchShared({&res, &res});
239 }
240 
241 
242 void
243 MSDevice_Taxi::dispatchShared(const std::vector<const Reservation*>& reservations) {
244 #ifdef DEBUG_DISPATCH
245  if (true) {
246  std::cout << SIMTIME << " taxi=" << myHolder.getID() << " dispatch:\n";
247  for (const Reservation* res : reservations) {
248  std::cout << " persons=" << toString(res->persons) << "\n";
249  }
250  }
251 #endif
252  if (isEmpty()) {
255  ConstMSEdgeVector tmpEdges({ myHolder.getEdge() });
256  std::vector<SUMOVehicleParameter::Stop> stops;
257  double lastPos = myHolder.getPositionOnLane();
258  for (const Reservation* res : reservations) {
259  bool isPickup = false;
260  for (MSTransportable* person : res->persons) {
261  if (myCustomers.count(person) == 0) {
262  myCustomers.insert(person);
263  isPickup = true;
264  }
265  }
266  if (isPickup) {
267  prepareStop(tmpEdges, stops, lastPos, res->from, res->fromPos, "pickup " + toString(res->persons));
268  for (MSTransportable* t : res->persons) {
269  if (t->isPerson()) {
270  stops.back().triggered = true;
271  } else {
272  stops.back().containerTriggered = true;
273  }
274  }
275  //stops.back().awaitedPersons.insert(res.person->getID());
276  } else {
277  prepareStop(tmpEdges, stops, lastPos, res->to, res->toPos, "dropOff " + toString(res->persons));
278  stops.back().duration = TIME2STEPS(60); // pay and collect bags
279  }
280  }
281  myHolder.replaceRouteEdges(tmpEdges, -1, 0, "taxi:prepare_dispatch", false, false, false);
282  for (SUMOVehicleParameter::Stop& stop : stops) {
283  std::string error;
284  myHolder.addStop(stop, error);
285  if (error != "") {
286  WRITE_WARNINGF("Could not add taxi stop for vehicle '%' to %. time=% error=%", myHolder.getID(), stop.actType, time2string(t), error)
287  }
288  }
290  // SUMOAbstractRouter<MSEdge, SUMOVehicle>& router = myHolder.getInfluencer().getRouterTT(veh->getRNGIndex())
291  myHolder.reroute(t, "taxi:dispatch", router, false);
292  } else {
293  throw ProcessError("Dispatch for busy taxis not yet implemented");
294  }
295  myState = PICKUP;
296 }
297 
298 
299 void
301  std::vector<SUMOVehicleParameter::Stop>& stops,
302  double& lastPos, const MSEdge* stopEdge, double stopPos,
303  const std::string& action) {
304  assert(!edges.empty());
305  if (stopEdge == edges.back() && !stops.empty()) {
306  if (stopPos >= lastPos && stopPos <= stops.back().endPos) {
307  // no new stop and no adaption needed
308  return;
309  }
310  if (stopPos >= lastPos && stopPos <= lastPos + myHolder.getVehicleType().getLength()) {
311  // stop length adaption needed
312  stops.back().endPos = MIN2(lastPos + myHolder.getVehicleType().getLength(), stopEdge->getLength());
313  return;
314  }
315  }
316  if (stopEdge != edges.back() || stopPos < lastPos) {
317  edges.push_back(stopEdge);
318  }
319  lastPos = stopPos;
321  stop.lane = getStopLane(stopEdge)->getID();
322  stop.startPos = stopPos;
323  stop.endPos = MAX2(stopPos, MIN2(myHolder.getVehicleType().getLength(), stopEdge->getLength()));
324  stop.parking = true;
325  stop.actType = action;
326  stop.index = STOP_INDEX_END;
327  stops.push_back(stop);
328 }
329 
330 
331 MSLane*
333  const std::vector<MSLane*>* allowedLanes = edge->allowedLanes(myHolder.getVClass());
334  if (allowedLanes == nullptr) {
335  throw ProcessError("Taxi '" + myHolder.getID() + "' cannot pick up person on edge '" + edge->getID() + "'");
336  }
337  return allowedLanes->front();
338 }
339 
340 bool
342  return myState == EMPTY;
343 }
344 
345 
346 bool
348  return myCustomers.count(t) != 0;
349 }
350 
351 
352 bool
353 MSDevice_Taxi::notifyMove(SUMOTrafficObject& /*tObject*/, double oldPos,
354  double newPos, double /*newSpeed*/) {
356  myOccupiedDistance += (newPos - oldPos);
358  }
360  myIdleAlgorithm->idle(this);
361  }
362  if (myHolder.isStopped()) {
363  if (!myIsStopped) {
364  // limit duration of stop
365  // @note: stops are not yet added to the vehicle so we can change the loaded parameters. Stops added from a route are not affected
366  MSVehicle& veh = static_cast<MSVehicle&>(myHolder);
368  }
369  }
371  return true; // keep the device
372 }
373 
374 
375 bool
376 MSDevice_Taxi::notifyEnter(SUMOTrafficObject& /*veh*/, MSMoveReminder::Notification /*reason*/, const MSLane* /* enteredLane */) {
377  if (isEmpty() && MSNet::getInstance()->getCurrentTimeStep() < myServiceEnd) {
378  myIdleAlgorithm->idle(this);
379  }
380  return true; // keep the device
381 }
382 
383 
384 bool
385 MSDevice_Taxi::notifyLeave(SUMOTrafficObject& /*veh*/, double /*lastPos*/, MSMoveReminder::Notification /*reason*/, const MSLane* /* enteredLane */) {
386  return true; // keep the device
387 }
388 
389 void
391  myState |= OCCUPIED;
392  if (!hasFuturePickup()) {
393  myState &= ~PICKUP;
394  }
395 }
396 
397 
398 void
401  myCustomers.erase(person);
402  if (myHolder.getPersonNumber() == 0 && myHolder.getContainerNumber() == 0) {
403  myState &= ~OCCUPIED;
404  MSVehicle* veh = static_cast<MSVehicle*>(&myHolder);
405  if (veh->getStops().size() > 1 && (myState & PICKUP) == 0) {
406  WRITE_WARNINGF("All customers left vehicle '%' at time % but there are % remaining stops",
407  veh->getID(), time2string(MSNet::getInstance()->getCurrentTimeStep()), veh->getStops().size() - 1);
408  while (veh->getStops().size() > 1) {
409  veh->abortNextStop(1);
410  }
411  }
412  }
413 }
414 
415 bool
417  MSVehicle* veh = static_cast<MSVehicle*>(&myHolder);
418  for (const auto& stop : veh->getStops()) {
419  if (stop.reached) {
420  continue;
421  }
422  if (StringUtils::startsWith(stop.pars.actType, "pickup")) {
423  return true;
424  }
425  }
426  return false;
427 }
428 
429 void
431  if (tripinfoOut != nullptr) {
432  tripinfoOut->openTag("taxi");
433  tripinfoOut->writeAttr("customers", toString(myCustomersServed));
434  tripinfoOut->writeAttr("occupiedDistance", toString(myOccupiedDistance));
435  tripinfoOut->writeAttr("occupiedTime", time2string(myOccupiedTime));
436  tripinfoOut->closeTag();
437  }
438 }
439 
440 std::string
441 MSDevice_Taxi::getParameter(const std::string& key) const {
442  if (key == "customers") {
443  return toString(myCustomersServed);
444  } else if (key == "occupiedDistance") {
446  } else if (key == "occupiedTime") {
448  } else if (key == "state") {
449  return toString(myState);
450  }
451  throw InvalidArgument("Parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
452 }
453 
454 
455 void
456 MSDevice_Taxi::setParameter(const std::string& key, const std::string& value) {
457  double doubleValue;
458  try {
459  doubleValue = StringUtils::toDouble(value);
460  } catch (NumberFormatException&) {
461  throw InvalidArgument("Setting parameter '" + key + "' requires a number for device of type '" + deviceName() + "'");
462  }
463  UNUSED_PARAMETER(doubleValue);
464  throw InvalidArgument("Setting parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
465 }
466 
467 
468 /****************************************************************************/
#define TAXI_SERVICE
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:277
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define SIMTIME
Definition: SUMOTime.h:60
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:31
@ SVC_TAXI
vehicle is a taxi
const int STOP_INDEX_END
@ DEPART_GIVEN
The time is given.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
T MIN2(T a, T b)
Definition: StdDefs.h:73
T MAX2(T a, T b)
Definition: StdDefs.h:79
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
Base (microsim) event class.
Definition: Command.h:49
const std::list< MSStop > & getStops() const
bool abortNextStop(int nextStopIndex=0)
deletes the next stop at the given index if it exists
A device which collects info on the vehicle trip (mainly on departure and arrival)
Definition: MSDevice_Taxi.h:48
static void initDispatch()
initialize the dispatch algorithm
static Command * myDispatchCommand
The repeated call to the dispatcher.
void customerArrived(const MSTransportable *person)
called by MSDevice_Transportable upon unloading a person
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
static SUMOTime triggerDispatch(SUMOTime currentTime)
period command to trigger the dispatch algorithm
MSLane * getStopLane(const MSEdge *edge)
determine stopping lane for taxi
void dispatch(const Reservation &res)
service the given reservation
void dispatchShared(const std::vector< const Reservation * > &reservations)
service the given reservations
std::set< const MSTransportable * > myCustomers
the customer of the current reservation
SUMOTime myServiceEnd
the time at which the taxi service ends (end the vehicle may leave the simulation)
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
static int myMaxCapacity
MSIdling * myIdleAlgorithm
algorithm for controlling idle behavior
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
bool hasFuturePickup()
whether the taxi has another pickup scheduled
bool allowsBoarding(MSTransportable *t) const
whether the given person is allowed to board this taxi
static MSDispatch * myDispatcher
the dispatch algorithm
int myCustomersServed
number of customers that were served
bool isEmpty()
whether the taxi is empty
const std::string deviceName() const
return the name for this type of device
static std::vector< MSDevice_Taxi * > myFleet
static SUMOTime myDispatchPeriod
the time between successive calls to the dispatcher
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
static void cleanup()
resets counters
double myOccupiedDistance
distance driven with customers
MSDevice_Taxi(SUMOVehicle &holder, const std::string &id)
Constructor.
static void addReservation(MSTransportable *person, const std::set< std::string > &lines, SUMOTime reservationTime, SUMOTime pickupTime, const MSEdge *from, double fromPos, const MSEdge *to, double toPos, const std::string &group)
add new reservation
static bool hasServableReservations()
check whether there are still (servable) reservations in the system
void prepareStop(ConstMSEdgeVector &edges, std::vector< SUMOVehicleParameter::Stop > &stops, double &lastPos, const MSEdge *stopEdge, double stopPos, const std::string &action)
prepare stop for the given action
static SUMOVehicle * getTaxi()
returns a taxi if any exist or nullptr
void customerEntered(const MSTransportable *t)
called by MSDevice_Transportable upon loading a person
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Taxi-options.
bool myIsStopped
whether the vehicle is currently stopped
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
SUMOTime myOccupiedTime
time spent driving with customers
~MSDevice_Taxi()
Destructor.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
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
static std::string getStringParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, std::string deflt, bool required)
Definition: MSDevice.cpp:161
A dispatch algorithm that services the reservations with the shortest traveltime-to-pickup first.
A dispatch algorithm that services customers in reservation order and always sends the closest availa...
A dispatch algorithm that services customers in reservation order and always sends the closest availa...
An algorithm that performs distpach for a taxi fleet.
Definition: MSDispatch.h:85
virtual Reservation * addReservation(MSTransportable *person, SUMOTime reservationTime, SUMOTime pickupTime, const MSEdge *from, double fromPos, const MSEdge *to, double toPos, const std::string &group, int maxCapacity)
add a new reservation
Definition: MSDispatch.cpp:63
bool hasServableReservations()
check whether there are still (servable) reservations in the system
Definition: MSDispatch.h:122
virtual void computeDispatch(SUMOTime now, const std::vector< MSDevice_Taxi * > &fleet)=0
computes dispatch and updates reservations
A road/street connecting two junctions.
Definition: MSEdge.h:77
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
Definition: MSEdge.cpp:366
double getLength() const
return the length of the edge
Definition: MSEdge.h:630
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static bool gUseMesoSim
Definition: MSGlobals.h:88
virtual void idle(MSDevice_Taxi *taxi)=0
computes Idling and updates reservations
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Notification
Definition of a vehicle state.
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
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition: MSNet.h:474
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
SUMOTime endBoarding
the maximum time at which persons may board this vehicle
Definition: MSStop.h:87
bool isPerson() const
Whether it is a person.
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
MSStop & getNextStop()
Definition: MSVehicle.cpp:6046
int getPersonCapacity() const
Get this vehicle type's person capacity.
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
Definition: Named.h:73
A storage for options typed value containers)
Definition: OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:75
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:239
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
Representation of a vehicle, person, or container.
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 SUMOVehicleClass getVClass() const =0
Returns the object's access class.
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 void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false)=0
Performs a rerouting using the given router.
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, ConstMSEdgeVector::const_iterator *searchStart=0)=0
Adds a stop.
virtual int getRNGIndex() const =0
virtual int getPersonNumber() const =0
Returns the number of persons.
virtual int getContainerNumber() const =0
Returns the number of containers.
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)=0
Replaces the current route by the given edges.
virtual bool abortNextStop(int nextStopIndex=0)=0
deletes the next stop at the given index if it exists
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
int index
at which position in the stops list
std::string actType
act Type (only used by Persons) (used by NETEDIT)
double endPos
The stopping position end.
bool parking
whether the vehicle is removed from the net while stopping
Structure representing possible vehicle parameter.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string line
The vehicle's line (mainly for public transport)
A wrapper for a Command function.
Definition: StaticCommand.h:37
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.