Eclipse SUMO - Simulation of Urban MObility
MSStage.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 /****************************************************************************/
20 // The common superclass for modelling transportable objects like persons and containers
21 /****************************************************************************/
22 #include <config.h>
23 
25 #include <utils/geom/GeomHelper.h>
29 #include <microsim/MSEdge.h>
30 #include <microsim/MSLane.h>
31 #include <microsim/MSNet.h>
43 
44 
45 /* -------------------------------------------------------------------------
46 * static member definitions
47 * ----------------------------------------------------------------------- */
48 const double MSStage::ROADSIDE_OFFSET(3);
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 /* -------------------------------------------------------------------------
55  * MSStage - methods
56  * ----------------------------------------------------------------------- */
57 MSStage::MSStage(const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos, MSStageType type, const std::string& group) :
58  myDestination(destination),
59  myDestinationStop(toStop),
60  myArrivalPos(arrivalPos),
61  myDeparted(-1),
62  myArrived(-1),
63  myType(type),
64  myGroup(group)
65 {}
66 
68 
69 const MSEdge*
71  return myDestination;
72 }
73 
74 
75 const MSEdge*
77  return myDestination;
78 }
79 
80 
81 const MSEdge*
83  return myDestination;
84 }
85 
86 
87 double
88 MSStage::getEdgePos(SUMOTime /* now */) const {
89  return myArrivalPos;
90 }
91 
92 int
95 }
96 
97 
100  return 0;
101 }
102 
103 
104 double
106  return 0.;
107 }
108 
109 
112  ConstMSEdgeVector result;
113  result.push_back(getDestination());
114  return result;
115 }
116 
117 
118 void
120  if (myDeparted < 0) {
121  myDeparted = now;
122  }
123 }
124 
125 SUMOTime
127  return myDeparted;
128 }
129 
130 SUMOTime
132  return myArrived;
133 }
134 
135 const std::string
136 MSStage::setArrived(MSNet* /* net */, MSTransportable* /* transportable */, SUMOTime now, const bool /* vehicleArrived */) {
137  myArrived = now;
138  return "";
139 }
140 
141 bool
142 MSStage::isWaitingFor(const SUMOVehicle* /*vehicle*/) const {
143  return false;
144 }
145 
146 Position
147 MSStage::getEdgePosition(const MSEdge* e, double at, double offset) const {
148  return getLanePosition(e->getLanes()[0], at, offset);
149 }
150 
151 Position
152 MSStage::getLanePosition(const MSLane* lane, double at, double offset) const {
153  return lane->getShape().positionAtOffset(lane->interpolateLanePosToGeometryPos(at), offset);
154 }
155 
156 
157 double
158 MSStage::getEdgeAngle(const MSEdge* e, double at) const {
159  return e->getLanes()[0]->getShape().rotationAtOffset(at);
160 }
161 
162 
163 void
164 MSStage::setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop) {
165  myDestination = newDestination;
166  myDestinationStop = newDestStop;
167  if (newDestStop != nullptr) {
168  myArrivalPos = (newDestStop->getBeginLanePosition() + newDestStop->getEndLanePosition()) / 2;
169  }
170 }
171 
172 
173 
174 /* -------------------------------------------------------------------------
175 * MSStageTrip - methods
176 * ----------------------------------------------------------------------- */
178  const MSEdge* destination, MSStoppingPlace* toStop,
179  const SUMOTime duration, const SVCPermissions modeSet,
180  const std::string& vTypes, const double speed, const double walkFactor,
181  const std::string& group,
182  const double departPosLat, const bool hasArrivalPos, const double arrivalPos):
183  MSStage(destination, toStop, arrivalPos, MSStageType::TRIP),
184  myOrigin(origin),
185  myOriginStop(fromStop),
186  myDuration(duration),
187  myModeSet(modeSet),
188  myVTypes(vTypes),
189  mySpeed(speed),
190  myWalkFactor(walkFactor),
191  myGroup(group),
192  myDepartPosLat(departPosLat),
193  myHaveArrivalPos(hasArrivalPos) {
194 }
195 
196 
198 
199 MSStage*
201  return new MSStageTrip(myOrigin, const_cast<MSStoppingPlace*>(myOriginStop),
204 }
205 
206 
207 Position
209  // may be called concurrently while the trip is still being routed
211 }
212 
213 
214 double
215 MSStageTrip::getAngle(SUMOTime /* now */) const {
216  // may be called concurrently while the trip is still being routed
217  return getEdgeAngle(myOrigin, myDepartPos) + M_PI / 2 * (MSGlobals::gLefthand ? -1 : 1);
218 }
219 
220 
221 const MSEdge*
223  return myOrigin;
224 }
225 
226 
227 double
229  return myDepartPos;
230 }
231 
232 
233 const std::string
234 MSStageTrip::setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived) {
235  MSStage::setArrived(net, transportable, now, vehicleArrived);
236  MSVehicleControl& vehControl = net->getVehicleControl();
237  std::vector<SUMOVehicleParameter*> pars;
238  for (StringTokenizer st(myVTypes); st.hasNext();) {
239  pars.push_back(new SUMOVehicleParameter());
240  pars.back()->vtypeid = st.next();
241  pars.back()->parametersSet |= VEHPARS_VTYPE_SET;
242  pars.back()->departProcedure = DEPART_TRIGGERED;
243  pars.back()->id = transportable->getID() + "_" + toString(pars.size() - 1);
244  }
245  if (pars.empty()) {
246  if ((myModeSet & SVC_PASSENGER) != 0) {
247  pars.push_back(new SUMOVehicleParameter());
248  pars.back()->id = transportable->getID() + "_0";
249  pars.back()->departProcedure = DEPART_TRIGGERED;
250  } else if ((myModeSet & SVC_TAXI) != 0) {
251  pars.push_back(new SUMOVehicleParameter());
252  pars.back()->vtypeid = DEFAULT_TAXITYPE_ID;
253  pars.back()->id = transportable->getID() + "_taxi";
254  pars.back()->line = "taxi";
255  } else if ((myModeSet & SVC_BICYCLE) != 0) {
256  pars.push_back(new SUMOVehicleParameter());
257  pars.back()->vtypeid = DEFAULT_BIKETYPE_ID;
258  pars.back()->id = transportable->getID() + "_b0";
259  pars.back()->departProcedure = DEPART_TRIGGERED;
260  } else {
261  // allow shortcut via busStop even when not intending to ride
262  pars.push_back(nullptr);
263  }
264  }
265  MSStage* previous;
267  if (transportable->getNumStages() == transportable->getNumRemainingStages()) { // this is a difficult way to check that we are the first stage
268  myDepartPos = transportable->getParameter().departPos;
271  }
272  previous = new MSStageWaiting(myOrigin, nullptr, -1, transportable->getParameter().depart, myDepartPos, "start", true);
273  time = transportable->getParameter().depart;
274  } else {
275  previous = transportable->getNextStage(-1);
276  myDepartPos = previous->getArrivalPos();
277  }
278  // TODO This works currently only for a single vehicle type
279  const int oldNumStages = transportable->getNumStages();
280  for (SUMOVehicleParameter* vehPar : pars) {
281  SUMOVehicle* vehicle = nullptr;
282  bool isTaxi = false;
283  if (vehPar != nullptr) {
284  isTaxi = vehPar->vtypeid == DEFAULT_TAXITYPE_ID && vehPar->line == "taxi";
285  if (myDepartPos != 0) {
286  vehPar->departPosProcedure = DepartPosDefinition::GIVEN;
287  vehPar->departPos = myDepartPos;
288  vehPar->parametersSet |= VEHPARS_DEPARTPOS_SET;
289  }
290  MSVehicleType* type = vehControl.getVType(vehPar->vtypeid);
291  if (type->getVehicleClass() != SVC_IGNORING && (myOrigin->getPermissions() & type->getVehicleClass()) == 0 && !isTaxi) {
292  WRITE_WARNING("Ignoring vehicle type '" + type->getID() + "' when routing person '" + transportable->getID() + "' because it is not allowed on the start edge.");
293  } else {
294  const MSRoute* const routeDummy = new MSRoute(vehPar->id, ConstMSEdgeVector({ myOrigin }), false, nullptr, std::vector<SUMOVehicleParameter::Stop>());
295  vehicle = vehControl.buildVehicle(vehPar, routeDummy, type, !MSGlobals::gCheckRoutes);
296  }
297  }
298  bool carUsed = false;
299  std::vector<MSNet::MSIntermodalRouter::TripItem> result;
300  int stageIndex = 1;
301  double departPos = previous->getArrivalPos();
302  MSStoppingPlace* const prevStop = previous->getDestinationStop();
303  if (MSGlobals::gUseMesoSim && prevStop != nullptr) {
304  departPos = (prevStop->getBeginLanePosition() + prevStop->getEndLanePosition()) / 2.;
305  }
307  departPos, myOriginStop == nullptr ? "" : myOriginStop->getID(),
309  transportable->getMaxSpeed() * myWalkFactor, vehicle, myModeSet, time, result)) {
310  for (std::vector<MSNet::MSIntermodalRouter::TripItem>::iterator it = result.begin(); it != result.end(); ++it) {
311  if (!it->edges.empty()) {
313  double localArrivalPos = bs != nullptr ? bs->getAccessPos(it->edges.back()) : it->edges.back()->getLength() / 2.;
314  if (it + 1 == result.end() && myHaveArrivalPos) {
315  localArrivalPos = myArrivalPos;
316  }
317  if (it->line == "") {
318  // determine walk departPos
319  double depPos = previous->getArrivalPos();
320  if (previous->getDestinationStop() != nullptr) {
321  depPos = previous->getDestinationStop()->getAccessPos(it->edges.front());
322  } else if (myOrigin->isTazConnector()) {
323  // walk the whole length of the first edge
324  const MSEdge* first = it->edges.front();
325  if (std::find(first->getPredecessors().begin(), first->getPredecessors().end(), myOrigin) != first->getPredecessors().end()) {
326  depPos = 0;
327  } else {
328  depPos = first->getLength();
329  }
330  } else if (previous->getDestination() != it->edges.front()) {
331  if ((previous->getDestination()->getToJunction() == it->edges.front()->getToJunction())
332  || (previous->getDestination()->getFromJunction() == it->edges.front()->getToJunction())) {
333  depPos = it->edges.front()->getLength();
334  } else {
335  depPos = 0.;
336  }
337  }
338  if (myDestination->isTazConnector()) {
339  // walk the whole length of the last edge
340  const MSEdge* last = it->edges.back();
341  if (std::find(last->getSuccessors().begin(), last->getSuccessors().end(), myDestination) != last->getSuccessors().end()) {
342  localArrivalPos = last->getLength();
343  } else {
344  localArrivalPos = 0;
345  }
346  }
347  previous = new MSPerson::MSPersonStage_Walking(transportable->getID(), it->edges, bs, myDuration, mySpeed, depPos, localArrivalPos, myDepartPosLat);
348  transportable->appendStage(previous, stageIndex++);
349  } else if (isTaxi) {
350  const ConstMSEdgeVector& prevEdges = previous->getEdges();
351  if (prevEdges.size() >= 2) {
352  // determine walking direction and let the previous
353  // stage end after entering its final edge
354  const MSEdge* last = prevEdges.back();
355  const MSEdge* prev = prevEdges[prevEdges.size() - 2];
356  if (last->getFromJunction() == prev->getToJunction() || prev->getFromJunction() == last->getFromJunction()) {
357  previous->setArrivalPos(MIN2(last->getLength(), 10.0));
358  } else {
359  previous->setArrivalPos(MAX2(0.0, last->getLength() - 10));
360  }
361  }
362  previous = new MSStageDriving(nullptr, it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ "taxi" }), myGroup);
363  transportable->appendStage(previous, stageIndex++);
364  } else if (vehicle != nullptr && it->line == vehicle->getID()) {
365  if (bs == nullptr && it + 1 != result.end()) {
366  // we have no defined endpoint and are in the middle of the trip, drive as far as possible
367  localArrivalPos = it->edges.back()->getLength();
368  }
369  previous = new MSStageDriving(nullptr, it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ it->line }));
370  transportable->appendStage(previous, stageIndex++);
371  vehicle->replaceRouteEdges(it->edges, -1, 0, "person:" + transportable->getID(), true);
372  vehicle->setArrivalPos(localArrivalPos);
373  vehControl.addVehicle(vehPar->id, vehicle);
374  carUsed = true;
375  } else {
376  previous = new MSStageDriving(nullptr, it->edges.back(), bs, localArrivalPos, std::vector<std::string>({ it->line }), myGroup, it->intended, TIME2STEPS(it->depart));
377  transportable->appendStage(previous, stageIndex++);
378  }
379  }
380  }
381  } else {
382  // append stage so the GUI won't crash due to inconsistent state
384  if (MSGlobals::gCheckRoutes) { // if not pedestrians will teleport
385  return "No connection found between edge '" + myOrigin->getID() + "' and edge '" + (myDestinationStop != nullptr ? myDestinationStop->getID() : myDestination->getID()) + "' for person '" + transportable->getID() + "'.";
386  }
387  }
388  if (vehicle != nullptr && (isTaxi || !carUsed)) {
389  vehControl.deleteVehicle(vehicle, true);
390  }
391  }
392  if (transportable->getNumStages() == oldNumStages) {
393  // append stage so the GUI won't crash due to inconsistent state
395  if (MSGlobals::gCheckRoutes) { // if not pedestrians will teleport
396  return "Empty route between edge '" + myOrigin->getID() + "' and edge '" + (myDestinationStop != nullptr ? myDestinationStop->getID() : myDestination->getID()) + "' for person '" + transportable->getID() + "'.";
397  }
398  }
399  return "";
400 }
401 
402 
403 void
404 MSStageTrip::proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* /* previous */) {
405  // just skip the stage, every interesting happens in setArrived
406  transportable->proceed(net, now);
407 }
408 
409 
410 std::string
411 MSStageTrip::getStageSummary(const bool) const {
412  return "trip from '" + myOrigin->getID() + "' to '" + getDestination()->getID() + "'";
413 }
414 
415 
416 /* -------------------------------------------------------------------------
417 * MSStageWaiting - methods
418 * ----------------------------------------------------------------------- */
420  SUMOTime duration, SUMOTime until, double pos, const std::string& actType,
421  const bool initial) :
422  MSStage(destination, toStop, SUMOVehicleParameter::interpretEdgePos(
423  pos, destination->getLength(), SUMO_ATTR_DEPARTPOS, "stopping at " + destination->getID()),
425  myWaitingDuration(duration),
426  myWaitingUntil(until),
427  myStopWaitPos(Position::INVALID),
428  myActType(actType),
429  myStopEndTime(-1) {
430 }
431 
432 
434 
435 MSStage*
438 }
439 
440 SUMOTime
442  return myWaitingUntil;
443 }
444 
445 SUMOTime
447  return myWaitingDuration;
448 }
449 
450 
451 Position
454  return myStopWaitPos;
455  }
458 }
459 
460 
461 double
464 }
465 
466 
467 void
468 MSStageWaiting::proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous) {
469  myDeparted = now;
471  if (myDestinationStop != nullptr) {
472  myDestinationStop->addTransportable(transportable);
474  }
475  if (dynamic_cast<MSPerson*>(transportable) != nullptr) {
476  previous->getEdge()->addPerson(transportable);
477  net->getPersonControl().setWaitEnd(myStopEndTime, transportable);
478  } else {
479  previous->getEdge()->addContainer(transportable);
480  net->getContainerControl().setWaitEnd(myStopEndTime, transportable);
481  }
482 }
483 
484 
485 void
489  os.writeAttr("duration", time2string(myArrived - myDeparted));
490  os.writeAttr("arrival", time2string(myArrived));
491  os.writeAttr("arrivalPos", toString(myArrivalPos));
492  os.writeAttr("actType", myActType == "" ? "waiting" : myActType);
493  os.closeTag();
494  }
495 }
496 
497 
498 void
499 MSStageWaiting::routeOutput(const bool /* isPerson */, OutputDevice& os, const bool, const MSStage* const /* previous */) const {
502  std::string comment = "";
503  if (myDestinationStop != nullptr) {
505  if (myDestinationStop->getMyName() != "") {
506  comment = " <!-- " + StringUtils::escapeXML(myDestinationStop->getMyName(), true) + " -->";
507  }
508  } else {
509  // lane index is arbitrary
510  os.writeAttr(SUMO_ATTR_LANE, getDestination()->getID() + "_0");
512  }
513  if (myWaitingDuration >= 0) {
515  }
516  if (myWaitingUntil >= 0) {
518  }
519  if (OptionsCont::getOptions().getBool("vehroute-output.exit-times")) {
522  }
523  if (myActType != "") {
525  }
526  os.closeTag(comment);
527  }
528 }
529 
530 
531 void
533  MSTransportableControl& tc = (t->isPerson() ?
536  tc.abortWaiting(t);
537 }
538 
539 std::string
540 MSStageWaiting::getStageDescription(const bool isPerson) const {
541  UNUSED_PARAMETER(isPerson);
542  if (myActType != "") {
543  return "waiting (" + myActType + ")";
544  } else {
545  return "waiting";
546  }
547 }
548 
549 std::string
550 MSStageWaiting::getStageSummary(const bool /* isPerson */) const {
551  std::string timeInfo;
552  if (myWaitingUntil >= 0) {
553  timeInfo += " until " + time2string(myWaitingUntil);
554  }
555  if (myWaitingDuration >= 0) {
556  timeInfo += " duration " + time2string(myWaitingDuration);
557  }
558  if (getDestinationStop() != nullptr) {
559  std::string nameMsg = "";
560  if (getDestinationStop()->getMyName() != "") {
561  nameMsg = "(" + getDestinationStop()->getMyName() + ") ";
562  }
563  return "stopping at stop '" + getDestinationStop()->getID() + "' " + nameMsg + timeInfo + " (" + myActType + ")";
564  }
565  return "stopping at edge '" + getDestination()->getID() + "' " + timeInfo + " (" + myActType + ")";
566 }
567 
568 void
569 MSStageWaiting::saveState(std::ostringstream& out) {
570  out << " " << myDeparted;
571 }
572 
573 void
574 MSStageWaiting::loadState(MSTransportable* transportable, std::istringstream& state) {
575  state >> myDeparted;
577  if (myDestinationStop != nullptr) {
578  myDestinationStop->addTransportable(transportable);
580  }
581  MSNet* net = MSNet::getInstance();
582  if (dynamic_cast<MSPerson*>(transportable) != nullptr) {
583  myDestination->addPerson(transportable);
584  net->getPersonControl().setWaitEnd(until, transportable);
585  } else {
586  myDestination->addContainer(transportable);
587  net->getContainerControl().setWaitEnd(until, transportable);
588  }
589 }
590 
591 /* -------------------------------------------------------------------------
592 * MSStageMoving - methods
593 * ----------------------------------------------------------------------- */
595  delete myState;
596 }
597 
598 const MSEdge*
600  if (myCurrentInternalEdge != nullptr) {
601  return myCurrentInternalEdge;
602  } else {
603  return myRouteStep == myRoute.end() ? nullptr : *myRouteStep;;
604  }
605 }
606 
607 const MSEdge*
609  return myRoute.front();
610 }
611 
614  return myRoute;
615 }
616 
617 
618 double
620  return myState == nullptr ? 0. : myState->getEdgePos(*this, now);
621 }
622 
623 int
625  return myState == nullptr ? MSPModel::UNDEFINED_DIRECTION : myState->getDirection(*this, MSNet::getInstance()->getCurrentTimeStep());
626 }
627 
628 
629 Position
631  return myState == nullptr ? Position::INVALID : myState->getPosition(*this, now);
632 }
633 
634 double
636  return myState == nullptr ? 0. : myState->getAngle(*this, now);
637 }
638 
639 SUMOTime
641  return myState == nullptr ? 0 : myState->getWaitingTime(*this, now);
642 }
643 
644 double
646  return myState == nullptr ? 0. : myState->getSpeed(*this);
647 }
648 
649 const MSLane*
651  return myState == nullptr ? nullptr : myState->getLane();
652 }
653 
654 void
655 MSStageMoving::setRouteIndex(MSTransportable* const transportable, int routeOffset) {
656  assert(routeOffset >= 0);
657  assert(routeOffset < (int)myRoute.size());
658  getEdge()->removePerson(transportable);
659  myRouteStep = myRoute.begin() + routeOffset;
660  getEdge()->addPerson(transportable);
661 }
662 
663 void
664 MSStageMoving::replaceRoute(MSTransportable* const transportable, const ConstMSEdgeVector& edges, int routeOffset) {
665  assert(routeOffset >= 0);
666  assert(routeOffset < (int)edges.size());
667  getEdge()->removePerson(transportable);
668  myRoute = edges;
669  myRouteStep = myRoute.begin() + routeOffset;
670  getEdge()->addPerson(transportable);
671 }
672 
673 /****************************************************************************/
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
MSStageType
Definition: MSStage.h:54
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:32
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
const std::string DEFAULT_TAXITYPE_ID
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const std::string DEFAULT_BIKETYPE_ID
@ RANDOM
The position is chosen randomly.
@ GIVEN
The position is given.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_VTYPE_SET
@ DEPART_TRIGGERED
The departure is person triggered.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_STOP
stop for vehicles
@ SUMO_ATTR_LANE
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_ACTTYPE
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_DURATION
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
T MIN2(T a, T b)
Definition: StdDefs.h:74
T MAX2(T a, T b)
Definition: StdDefs.h:80
T MAX3(T a, T b, T c)
Definition: StdDefs.h:94
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
bool compute(const E *from, const E *to, const double departPos, const std::string &originStopID, const double arrivalPos, const std::string &stopID, const double speed, const V *const vehicle, const SVCPermissions modeSet, const SUMOTime msTime, std::vector< TripItem > &into, const double externalFactor=0.)
Builds the route between the given edges using the minimum effort at the given time The definition of...
A road/street connecting two junctions.
Definition: MSEdge.h:77
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition: MSEdge.h:605
const MSEdgeVector & getPredecessors() const
Definition: MSEdge.h:392
virtual void addPerson(MSTransportable *p) const
Definition: MSEdge.cpp:1019
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
const MSJunction * getFromJunction() const
Definition: MSEdge.h:397
double getLength() const
return the length of the edge
Definition: MSEdge.h:641
bool isTazConnector() const
Definition: MSEdge.h:285
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
Definition: MSEdge.h:673
const MSJunction * getToJunction() const
Definition: MSEdge.h:401
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1084
virtual void removePerson(MSTransportable *p) const
Definition: MSEdge.cpp:1024
static bool gUseMesoSim
Definition: MSGlobals.h:94
static bool gCheckRoutes
Definition: MSGlobals.h:82
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:157
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:478
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:499
The simulated network and simulation perfomer.
Definition: MSNet.h:88
MSIntermodalRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1390
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:1068
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:376
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:318
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:1250
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1059
static const int UNDEFINED_DIRECTION
Definition: MSPModel.h:110
virtual ~MSStage()
destructor
Definition: MSStage.cpp:67
const MSEdge * getDestination() const
returns the destination edge
Definition: MSStage.cpp:70
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSStage.cpp:111
virtual double getEdgePos(SUMOTime now) const
Definition: MSStage.cpp:88
virtual int getDirection() const
Return the movement directon on the edge.
Definition: MSStage.cpp:93
virtual const MSEdge * getFromEdge() const
Definition: MSStage.cpp:82
MSStage(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, MSStageType type, const std::string &group="")
constructor
Definition: MSStage.cpp:57
virtual double getArrivalPos() const
Definition: MSStage.h:89
SUMOTime getDeparted() const
get departure time of stage
Definition: MSStage.cpp:126
void setDeparted(SUMOTime now)
logs end of the step
Definition: MSStage.cpp:119
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
Definition: MSStage.cpp:142
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition: MSStage.h:224
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition: MSStage.cpp:136
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition: MSStage.h:80
SUMOTime getArrived() const
get arrival time of stage
Definition: MSStage.cpp:131
void setArrivalPos(double arrivalPos)
Definition: MSStage.h:93
virtual double getSpeed() const
the speed of the transportable
Definition: MSStage.cpp:105
SUMOTime myArrived
the time at which this stage ended
Definition: MSStage.h:233
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
Definition: MSStage.cpp:164
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
Definition: MSStage.cpp:152
MSStageType myType
The type of this stage.
Definition: MSStage.h:236
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition: MSStage.cpp:158
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition: MSStage.cpp:76
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition: MSStage.h:242
double myArrivalPos
the position at which we want to arrive
Definition: MSStage.h:227
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition: MSStage.cpp:147
const MSEdge * myDestination
the next edge to reach by getting transported
Definition: MSStage.h:221
virtual SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSStage.cpp:99
SUMOTime myDeparted
the time at which this stage started
Definition: MSStage.h:230
double getAngle(SUMOTime now) const
Returns the angle of the container.
Definition: MSStage.cpp:635
const MSLane * getLane() const
Returns the current lane.
Definition: MSStage.cpp:650
double getEdgePos(SUMOTime now) const
Returns the offset from the start of the current edge measured in its natural direction.
Definition: MSStage.cpp:619
int getDirection() const
Return the movement directon on the edge.
Definition: MSStage.cpp:624
MSTransportableStateAdapter * myState
state that is to be manipulated by MSPModel
Definition: MSStage.h:545
ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition: MSStage.cpp:613
SUMOTime getWaitingTime(SUMOTime now) const
Returns the time the container spent waiting.
Definition: MSStage.cpp:640
double getSpeed() const
Returns the speed of the container.
Definition: MSStage.cpp:645
MSEdge * myCurrentInternalEdge
The current internal edge this transportable is on or nullptr.
Definition: MSStage.h:554
Position getPosition(SUMOTime now) const
Returns the position of the container.
Definition: MSStage.cpp:630
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSStage.cpp:599
virtual void setRouteIndex(MSTransportable *const transportable, int routeOffset)
place transportable on a previously passed edge
Definition: MSStage.cpp:655
std::vector< const MSEdge * > myRoute
The route of the container.
Definition: MSStage.h:548
const MSEdge * getFromEdge() const
Returns first edge of the containers route.
Definition: MSStage.cpp:608
virtual void replaceRoute(MSTransportable *const transportable, const ConstMSEdgeVector &edges, int routeOffset)
Definition: MSStage.cpp:664
std::vector< const MSEdge * >::iterator myRouteStep
current step
Definition: MSStage.h:551
virtual ~MSStageMoving()
destructor
Definition: MSStage.cpp:594
const bool myHaveArrivalPos
whether an arrivalPos was in the input
Definition: MSStage.h:361
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSStage.cpp:215
MSStageTrip(const MSEdge *origin, MSStoppingPlace *fromStop, const MSEdge *destination, MSStoppingPlace *toStop, const SUMOTime duration, const SVCPermissions modeSet, const std::string &vTypes, const double speed, const double walkFactor, const std::string &group, const double departPosLat, const bool hasArrivalPos, const double arrivalPos)
constructor
Definition: MSStage.cpp:177
void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSStage.cpp:404
const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition: MSStage.cpp:234
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSStage.cpp:411
const std::string myVTypes
The possible vehicles to use.
Definition: MSStage.h:343
double myDepartPos
The depart position.
Definition: MSStage.h:355
double getEdgePos(SUMOTime now) const
Definition: MSStage.cpp:228
MSStage * clone() const
Definition: MSStage.cpp:200
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSStage.cpp:222
const MSEdge * myOrigin
the origin edge
Definition: MSStage.h:331
const double mySpeed
The walking speed.
Definition: MSStage.h:346
MSStoppingPlace * myOriginStop
the origin edge
Definition: MSStage.h:334
SUMOTime myDuration
the time the trip should take (applies to only walking)
Definition: MSStage.h:337
const double myWalkFactor
The factor to apply to walking durations.
Definition: MSStage.h:349
const double myDepartPosLat
The lateral depart position.
Definition: MSStage.h:358
const SVCPermissions myModeSet
The allowed modes of transportation.
Definition: MSStage.h:340
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSStage.cpp:208
virtual ~MSStageTrip()
destructor
Definition: MSStage.cpp:197
std::string myGroup
The group for this personTrip.
Definition: MSStage.h:352
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state, standard implementation does nothing.
Definition: MSStage.cpp:574
void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
Definition: MSStage.cpp:499
SUMOTime getUntil() const
Definition: MSStage.cpp:441
SUMOTime myWaitingDuration
the time the person is waiting
Definition: MSStage.h:436
SUMOTime myWaitingUntil
the time until the person is waiting
Definition: MSStage.h:439
SUMOTime getDuration() const
Definition: MSStage.cpp:446
void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)
proceeds to the next step
Definition: MSStage.cpp:468
void saveState(std::ostringstream &out)
Saves the current state into the given stream, standard implementation does nothing.
Definition: MSStage.cpp:569
std::string getStageDescription(const bool isPerson) const
return (brief) string representation of the current stage
Definition: MSStage.cpp:540
double getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSStage.cpp:462
Position myStopWaitPos
waiting position at stopping place
Definition: MSStage.h:442
SUMOTime myStopEndTime
stores the actual end time of the stop (combination of duration and until)
Definition: MSStage.h:448
MSStage * clone() const
Definition: MSStage.cpp:436
std::string myActType
The type of activity.
Definition: MSStage.h:445
virtual ~MSStageWaiting()
destructor
Definition: MSStage.cpp:433
void abort(MSTransportable *)
abort this stage (TraCI)
Definition: MSStage.cpp:532
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
Definition: MSStage.cpp:550
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSStage.cpp:452
MSStageWaiting(const MSEdge *destination, MSStoppingPlace *toStop, SUMOTime duration, SUMOTime until, double pos, const std::string &actType, const bool initial)
constructor
Definition: MSStage.cpp:419
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Definition: MSStage.cpp:486
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
SumoXMLTag getElement() const
return the type of this stopping place
double getEndLanePosition() const
Returns the end position of this stop.
const std::string & getMyName() const
Position getWaitPosition(MSTransportable *person) const
Returns the next free waiting place for pedestrians / containers.
bool addTransportable(const MSTransportable *p)
adds a transportable to this stop
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
bool isPerson() const
Whether it is a person.
int getNumStages() const
Return the total number stages in this persons plan.
MSStage * getNextStage(int next) const
Return the current stage.
void appendStage(MSStage *stage, int next=-1)
Appends the given stage to the current plan.
double getMaxSpeed() const
Returns the object's maximum speed.
virtual double getSpeed(const MSStageMoving &stage) const =0
return the current speed of the transportable
virtual int getDirection(const MSStageMoving &stage, SUMOTime now) const =0
return the walking direction (FORWARD, BACKWARD)
virtual Position getPosition(const MSStageMoving &stage, SUMOTime now) const =0
return the network coordinate of the transportable
virtual SUMOTime getWaitingTime(const MSStageMoving &stage, SUMOTime now) const =0
return the time the transportable spent standing
virtual double getEdgePos(const MSStageMoving &stage, SUMOTime now) const =0
return the offset from the start of the current edge measured in its natural direction
virtual const MSLane * getLane() const
whether the transportable is jammed
Definition: MSPModel.h:180
virtual double getAngle(const MSStageMoving &stage, SUMOTime now) const =0
return the direction in which the transportable faces in degrees
The class responsible for building and deletion of vehicles.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
The car-following model and parameter.
Definition: MSVehicleType.h:62
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
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:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
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:248
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:293
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.h:119
Representation of a vehicle.
Definition: SUMOVehicle.h:60
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true, std::string *msgReturn=nullptr)=0
Replaces the current route by the given edges.
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle's desired arrivalPos for its current route.
Structure representing possible vehicle parameter.
double departPos
(optional) The position the vehicle shall depart from
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
bool hasNext()
returns the information whether further substrings exist
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
#define M_PI
Definition: odrSpiral.cpp:40