Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSStageTrip.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 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// An intermodal routing request (to be transformed into a sequence of walks and rides)
22/****************************************************************************/
23#include <config.h>
24
31#include <microsim/MSEdge.h>
32#include <microsim/MSLane.h>
33#include <microsim/MSNet.h>
43
44
45// ===========================================================================
46// method definitions
47// ===========================================================================
48
49/* -------------------------------------------------------------------------
50* MSStageTrip - methods
51* ----------------------------------------------------------------------- */
53 const MSEdge* destination, MSStoppingPlace* toStop,
54 const SUMOTime duration, const SVCPermissions modeSet,
55 const std::string& vTypes, const double speed, const double walkFactor,
56 const std::string& group,
57 const double departPosLat, const bool hasArrivalPos, const double arrivalPos):
58 MSStage(MSStageType::TRIP, destination, toStop, arrivalPos, 0.0, group),
59 myOrigin(origin),
60 myOriginStop(fromStop),
61 myDuration(duration),
62 myModeSet(modeSet),
63 myVTypes(vTypes),
64 mySpeed(speed),
65 myWalkFactor(walkFactor),
66 myDepartPosLat(departPosLat),
67 myHaveArrivalPos(hasArrivalPos) {
68}
69
70
72
82
83
86 // may be called concurrently while the trip is still being routed
88}
89
90
91double
93 // may be called concurrently while the trip is still being routed
94 return getEdgeAngle(myOrigin, myDepartPos) + M_PI / 2 * (MSGlobals::gLefthand ? -1 : 1);
95}
96
97
98const MSEdge*
100 return myOrigin;
101}
102
103
104double
106 return myDepartPos;
107}
108
109
110std::vector<SUMOVehicle*>
111MSStageTrip::getVehicles(MSVehicleControl& vehControl, MSTransportable* transportable, const MSEdge* origin) {
112 std::vector<SUMOVehicleParameter*> pars;
113 for (StringTokenizer st(myVTypes); st.hasNext();) {
114 pars.push_back(new SUMOVehicleParameter());
115 pars.back()->vtypeid = st.next();
116 pars.back()->parametersSet |= VEHPARS_VTYPE_SET;
117 pars.back()->departProcedure = DepartDefinition::TRIGGERED;
118 pars.back()->id = transportable->getID() + "_" + toString(pars.size() - 1);
119 }
120 if (pars.empty()) {
121 if ((myModeSet & SVC_PASSENGER) != 0) {
122 pars.push_back(new SUMOVehicleParameter());
123 pars.back()->id = transportable->getID() + "_0";
124 pars.back()->departProcedure = DepartDefinition::TRIGGERED;
125 }
126 if ((myModeSet & SVC_TAXI) != 0) {
127 for (const auto& item : MSDevice_Taxi::getTaxiTypes()) {
128 pars.push_back(new SUMOVehicleParameter());
129 pars.back()->vtypeid = item.second;
130 pars.back()->id = transportable->getID() + "_taxi_" + item.second;
131 pars.back()->line = "taxi";
132 }
133 }
134 if ((myModeSet & SVC_BICYCLE) != 0) {
135 pars.push_back(new SUMOVehicleParameter());
136 pars.back()->vtypeid = DEFAULT_BIKETYPE_ID;
137 pars.back()->id = transportable->getID() + "_b0";
138 pars.back()->departProcedure = DepartDefinition::TRIGGERED;
139 }
140 }
141 ConstMSRoutePtr const routeDummy = std::make_shared<MSRoute>(transportable->getID() + "_0", ConstMSEdgeVector({ origin }), false, nullptr, StopParVector());
142 std::vector<SUMOVehicle*> result;
143 for (SUMOVehicleParameter* vehPar : pars) {
144 const bool isTaxi = vehPar->line == "taxi" && (myModeSet & SVC_TAXI) != 0;
145 if (myDepartPos != 0) {
146 vehPar->departPosProcedure = DepartPosDefinition::GIVEN;
147 vehPar->departPos = myDepartPos;
148 vehPar->parametersSet |= VEHPARS_DEPARTPOS_SET;
149 }
150 vehPar->parametersSet |= VEHPARS_ARRIVALPOS_SET;
151 vehPar->arrivalPosProcedure = ArrivalPosDefinition::GIVEN;
152 vehPar->parametersSet |= VEHPARS_ARRIVALSPEED_SET;
153 vehPar->arrivalSpeedProcedure = ArrivalSpeedDefinition::GIVEN;
154 vehPar->arrivalSpeed = 0;
155 MSVehicleType* type = vehControl.getVType(vehPar->vtypeid);
156 if (type->getVehicleClass() != SVC_IGNORING && (origin->getPermissions() & type->getVehicleClass()) == 0 && !isTaxi) {
157 WRITE_WARNINGF(TL("Ignoring vehicle type '%' when routing person '%' because it is not allowed on the start edge."), type->getID(), transportable->getID());
158 delete vehPar;
159 } else {
160 result.push_back(vehControl.buildVehicle(vehPar, routeDummy, type, !MSGlobals::gCheckRoutes));
161 }
162 }
163 if (result.empty()) {
164 // walking only but may use access infrastructure
165 result.push_back(nullptr);
166 }
167 return result;
168}
169
170
171const std::string
172MSStageTrip::reroute(const SUMOTime time, MSTransportableRouter& router, MSTransportable* const transportable,
173 MSStage* previous, const MSEdge* origin, const MSEdge* destination, std::vector<MSStage*>& stages) {
174 if (origin->isTazConnector() && origin->getSuccessors().size() == 0) {
175 // previous stage ended at a taz sink-edge
176 origin = transportable->getNextStage(-1)->getDestination();
177 }
179 double minCost = std::numeric_limits<double>::max();
180 std::vector<MSTransportableRouter::TripItem> minResult;
181 SUMOVehicle* minVehicle = nullptr;
182 for (SUMOVehicle* vehicle : getVehicles(vehControl, transportable, origin)) {
183 std::vector<MSTransportableRouter::TripItem> result;
184 double departPos = previous->getArrivalPos();
185 MSStoppingPlace* const prevStop = previous->getDestinationStop();
186 if (MSGlobals::gUseMesoSim && prevStop != nullptr) {
187 departPos = (prevStop->getBeginLanePosition() + prevStop->getEndLanePosition()) / 2.;
188 }
189 if (router.compute(origin, destination, departPos, prevStop == nullptr ? "" : prevStop->getID(),
190 myArrivalPos, myDestinationStop == nullptr ? "" : myDestinationStop->getID(),
191 transportable->getMaxSpeed() * myWalkFactor, vehicle, transportable->getVTypeParameter(), myModeSet, time, result)) {
192 double totalCost = 0;
193 for (const MSTransportableRouter::TripItem& item : result) {
194 totalCost += item.cost;
195 }
196 if (totalCost < minCost) {
197 minCost = totalCost;
198 minResult.swap(result);
199 std::swap(minVehicle, vehicle);
200 }
201 }
202 if (vehicle != nullptr) {
203 vehControl.deleteVehicle(vehicle, true);
204 vehControl.discountRoutingVehicle();
205 }
206 }
207 if (minCost != std::numeric_limits<double>::max()) {
208 const bool isTaxi = minVehicle != nullptr && (myModeSet & SVC_TAXI) != 0 && minVehicle->getParameter().line == "taxi";
209 bool carUsed = false;
210 for (std::vector<MSTransportableRouter::TripItem>::iterator it = minResult.begin(); it != minResult.end(); ++it) {
211 if (!it->edges.empty()) {
213 double localArrivalPos = bs != nullptr ? bs->getAccessPos(it->edges.back()) : it->arrivalPos;
214 const MSEdge* const first = it->edges.front();
215 const MSEdge* const rideOrigin = origin->isTazConnector() && stages.empty() ? first : nullptr;
216 if (it + 1 == minResult.end() && myHaveArrivalPos) {
217 localArrivalPos = myArrivalPos;
218 }
219 if (it->line == "") {
220 // determine walk departPos
221 double depPos = previous->getArrivalPos();
222 if (previous->getDestinationStop() != nullptr) {
223 depPos = previous->getDestinationStop()->getAccessPos(first, first->getLanes()[0]->getRNG());
224 } else if (origin->isTazConnector()) {
225 // walk the whole length of the first edge
226 if (std::find(first->getPredecessors().begin(), first->getPredecessors().end(), origin) != first->getPredecessors().end()) {
227 depPos = 0;
228 } else {
229 depPos = first->getLength();
230 }
231 } else if (previous->getDestination() != first) {
232 if ((previous->getDestination()->getToJunction() == first->getToJunction())
233 || (previous->getDestination()->getFromJunction() == first->getToJunction())) {
234 depPos = first->getLength();
235 } else {
236 depPos = 0.;
237 }
238 }
239 if (destination->isTazConnector()) {
240 // walk the whole length of the last edge
241 const MSEdge* last = it->edges.back();
242 if (std::find(last->getSuccessors().begin(), last->getSuccessors().end(), destination) != last->getSuccessors().end()) {
243 localArrivalPos = last->getLength();
244 } else {
245 localArrivalPos = 0;
246 }
247 }
248 previous = new MSStageWalking(transportable->getID(), it->edges, bs, myDuration, mySpeed, depPos, localArrivalPos, myDepartPosLat);
249 previous->setParameters(*this);
250 previous->setCosts(it->cost);
251 previous->setTrip(this);
252 stages.push_back(previous);
253 } else if (isTaxi && it->line == minVehicle->getID()) {
254 const ConstMSEdgeVector& prevEdges = previous->getEdges();
255 if (prevEdges.size() >= 2 && previous->getDestinationStop() == nullptr) {
256 // determine walking direction and let the previous
257 // stage end after entering its final edge
258 const MSEdge* last = prevEdges.back();
259 const MSEdge* prev = prevEdges[prevEdges.size() - 2];
260 if (last->getFromJunction() == prev->getToJunction() || prev->getFromJunction() == last->getFromJunction()) {
261 previous->setArrivalPos(MIN2(last->getLength(), 10.0));
262 } else {
263 previous->setArrivalPos(MAX2(0.0, last->getLength() - 10));
264 }
265 }
266 previous = new MSStageDriving(rideOrigin, it->edges.back(), bs, localArrivalPos, 0.0, std::vector<std::string>({ "taxi" }), myGroup);
267 previous->setParameters(*this);
268 previous->setCosts(it->cost);
269 previous->setTrip(this);
270 stages.push_back(previous);
271 } else if (minVehicle != nullptr && it->line == minVehicle->getID()) {
272 previous = new MSStageDriving(rideOrigin, it->edges.back(), bs, localArrivalPos, 0.0, std::vector<std::string>({ it->line }));
273 previous->setParameters(*this);
274 previous->setCosts(it->cost);
275 previous->setTrip(this);
276 stages.push_back(previous);
277 minVehicle->replaceRouteEdges(it->edges, -1, 0, "person:" + transportable->getID(), true);
278 minVehicle->setArrivalPos(localArrivalPos);
279 const_cast<SUMOVehicleParameter&>(minVehicle->getParameter()).arrivalPos = localArrivalPos;
280 vehControl.addVehicle(minVehicle->getID(), minVehicle);
281 carUsed = true;
282 } else {
283 const std::string line = OptionsCont::getOptions().getBool("persontrip.ride-public-line") ? it->line : LINE_ANY;
284 previous = new MSStageDriving(rideOrigin, it->edges.back(), bs, localArrivalPos, 0.0, std::vector<std::string>({ line }), myGroup, it->intended, TIME2STEPS(it->depart));
285 previous->setParameters(*this);
286 previous->setCosts(it->cost);
287 previous->setTrip(this);
288 stages.push_back(previous);
289 }
290 }
291 }
292 if (wasSet(VEHPARS_ARRIVALPOS_SET) && !stages.empty()) {
293 // mark the last stage
294 stages.back()->markSet(VEHPARS_ARRIVALPOS_SET);
295 }
296 setCosts(minCost);
297 if (minVehicle != nullptr && (isTaxi || !carUsed)) {
298 vehControl.deleteVehicle(minVehicle, true);
299 vehControl.discountRoutingVehicle();
300 }
301 } else {
302 // append stage so the GUI won't crash due to inconsistent state
303 previous = new MSStageWalking(transportable->getID(), ConstMSEdgeVector({ origin, destination }), myDestinationStop, myDuration, mySpeed, previous->getArrivalPos(), myArrivalPos, myDepartPosLat);
304 previous->setParameters(*this);
305 stages.push_back(previous);
306 if (MSGlobals::gCheckRoutes) { // if not pedestrians will teleport
307 return "No connection found between " + getOriginDescription() + " and " + getDestinationDescription() + " for person '" + transportable->getID() + "'.";
308 }
309 }
310 if (stages.empty()) {
311 // append stage so the GUI won't crash due to inconsistent state
312 if (myOriginStop != nullptr && myOriginStop == myDestinationStop) {
313 stages.push_back(new MSStageWaiting(destination, myDestinationStop, 0, -1, previous->getArrivalPos(), "sameStop", false));
314 } else {
315 stages.push_back(new MSStageWalking(transportable->getID(), ConstMSEdgeVector({ origin, destination }), myDestinationStop, myDuration, mySpeed, previous->getArrivalPos(), myArrivalPos, myDepartPosLat));
316 if (MSGlobals::gCheckRoutes) { // if not pedestrians will teleport
317 return "Empty route between " + getOriginDescription() + " and " + getDestinationDescription() + " for person '" + transportable->getID() + "'.";
318 }
319 }
320 }
321 return "";
322}
323
324
325const std::string
326MSStageTrip::setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived) {
327 MSStage::setArrived(net, transportable, now, vehicleArrived);
328 std::vector<MSStage*> stages;
329 std::string result;
330 if (transportable->getCurrentStageIndex() == 0) {
331 myDepartPos = transportable->getParameter().departPos;
333 // TODO we should probably use the rng of the lane here
334 myDepartPos = RandHelper::rand(myOrigin->getLength());
335 }
336 MSStageWaiting start(myOrigin, myOriginStop, -1, transportable->getParameter().depart, myDepartPos, "start", true);
337 result = reroute(transportable->getParameter().depart, net->getIntermodalRouter(0), transportable, &start, myOrigin, myDestination, stages);
338 } else {
339 MSStage* previous = transportable->getNextStage(-1);
340 myDepartPos = previous->getArrivalPos();
341 result = reroute(now, net->getIntermodalRouter(0), transportable, previous, myOrigin, myDestination, stages);
342 }
343 int idx = 1;
344 for (MSStage* stage : stages) {
345 transportable->appendStage(stage, idx++);
346 }
347 return result;
348}
349
350
351void
352MSStageTrip::proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* /* previous */) {
353 // just skip the stage, every interesting happens in setArrived
354 transportable->proceed(net, now);
355}
356
357
358std::string
360 return (myOriginStop != nullptr
361 ? toString(myOriginStop->getElement()) + " '" + myOriginStop->getID()
362 : "edge '" + myOrigin->getID()) + "'";
363}
364
365std::string
367 return (myDestinationStop != nullptr
368 ? toString(myDestinationStop->getElement()) + " '" + myDestinationStop->getID()
369 : "edge '" + myDestination->getID()) + "'";
370}
371
372std::string
374 return "trip from " + getOriginDescription() + " to " + getDestinationDescription();
375}
376
377void
378MSStageTrip::routeOutput(const bool /*isPerson*/, OutputDevice& os, const bool /*withRouteLength*/, const MSStage* const previous, const bool /*withTiming*/, const bool /*saveState*/) const {
379 if (myArrived < 0) {
380 const bool walkFactorSet = myWalkFactor != OptionsCont::getOptions().getFloat("persontrip.walkfactor");
381 const bool groupSet = myGroup != OptionsCont::getOptions().getString("persontrip.default.group");
382 // could still be a persontrip but most likely it was a walk in the input
383 SumoXMLTag tag = myModeSet == 0 && !walkFactorSet && !groupSet ? SUMO_TAG_WALK : SUMO_TAG_PERSONTRIP;
384 os.openTag(tag);
385 if (previous == nullptr || previous->getStageType() == MSStageType::WAITING_FOR_DEPART) {
386 os.writeAttr(SUMO_ATTR_FROM, myOrigin->getID());
387 }
388 if (myDestinationStop == nullptr) {
392 }
393 } else {
394 os.writeAttr(toString(myDestinationStop->getElement()), myDestinationStop->getID());
395 }
396 std::vector<std::string> modes;
397 if ((myModeSet & SVC_PASSENGER) != 0) {
398 modes.push_back("car");
399 }
400 if ((myModeSet & SVC_BICYCLE) != 0) {
401 modes.push_back("bicycle");
402 }
403 if ((myModeSet & SVC_TAXI) != 0) {
404 modes.push_back("taxi");
405 }
406 if ((myModeSet & SVC_BUS) != 0) {
407 modes.push_back("public");
408 }
409 if (modes.size() > 0) {
410 os.writeAttr(SUMO_ATTR_MODES, modes);
411 }
412 if (myVTypes.size() > 0) {
414 }
415 if (groupSet) {
417 }
418 if (walkFactorSet) {
420 }
421 if (OptionsCont::getOptions().getBool("vehroute-output.cost")) {
423 }
424 os.closeTag();
425 }
426}
427
428/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
IntermodalRouter< MSEdge, MSLane, MSJunction, SUMOVehicle > MSTransportableRouter
MSStageType
Definition MSStage.h:55
@ WAITING_FOR_DEPART
Definition MSStage.h:56
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:304
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
#define TIME2STEPS(x)
Definition SUMOTime.h:60
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ 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
@ SVC_BUS
vehicle is a bus
const std::string DEFAULT_BIKETYPE_ID
const long long int VEHPARS_ARRIVALSPEED_SET
@ GIVEN
The speed is given.
@ RANDOM
A random position is chosen.
@ GIVEN
The position is given.
const std::string LINE_ANY
std::vector< SUMOVehicleParameter::Stop > StopParVector
const long long int VEHPARS_DEPARTPOS_SET
const long long int VEHPARS_ARRIVALPOS_SET
const long long int VEHPARS_VTYPE_SET
@ GIVEN
The arrival position is given.
@ TRIGGERED
The departure is person triggered.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_WALK
@ SUMO_TAG_PERSONTRIP
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_MODES
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_GROUP
@ SUMO_ATTR_COST
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_WALKFACTOR
T MIN2(T a, T b)
Definition StdDefs.h:80
T MAX2(T a, T b)
Definition StdDefs.h:86
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
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 SUMOVTypeParameter &pars, 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...
static const std::map< SUMOVehicleClass, std::string > & getTaxiTypes()
return all types that are known to carry a taxi device (or the default type if no devices are initial...
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:658
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
const MSJunction * getToJunction() const
Definition MSEdge.h:427
double getLength() const
return the length of the edge
Definition MSEdge.h:694
const MSJunction * getFromJunction() const
Definition MSEdge.h:423
bool isTazConnector() const
Definition MSEdge.h:292
const MSEdgeVector & getPredecessors() const
Definition MSEdge.h:418
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1292
static bool gUseMesoSim
Definition MSGlobals.h:106
static bool gCheckRoutes
Definition MSGlobals.h:91
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition MSGlobals.h:174
The simulated network and simulation perfomer.
Definition MSNet.h:89
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:199
MSTransportableRouter & getIntermodalRouter(int rngIndex, const int routingMode=0, const Prohibitions &prohibited={}) const
Definition MSNet.cpp:1680
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition MSNet.cpp:1501
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:402
const MSEdge * getDestination() const
returns the destination edge
Definition MSStage.cpp:65
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition MSStage.cpp:107
virtual double getArrivalPos() const
Definition MSStage.h:97
void setTrip(MSStageTrip *trip)
Definition MSStage.h:291
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition MSStage.h:309
const std::string myGroup
The id of the group of transportables traveling together.
Definition MSStage.h:327
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition MSStage.cpp:167
double getCosts() const
Returns the costs of the stage.
Definition MSStage.h:275
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition MSStage.h:88
bool wasSet(int what) const
Definition MSStage.h:263
MSStageType getStageType() const
Definition MSStage.h:138
void setArrivalPos(double arrivalPos)
Definition MSStage.h:108
void setCosts(double costs)
Sets the costs of the stage.
Definition MSStage.h:283
MSStage(const MSStageType type, const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double arrivalPosLat=0.0, const std::string &group="")
constructor
Definition MSStage.cpp:47
SUMOTime myArrived
the time at which this stage ended
Definition MSStage.h:321
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition MSStage.cpp:189
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition MSStage.h:338
double myArrivalPos
the longitudinal position at which we want to arrive
Definition MSStage.h:312
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition MSStage.cpp:178
const MSEdge * myDestination
the next edge to reach by getting transported
Definition MSStage.h:306
const bool myHaveArrivalPos
whether an arrivalPos was in the input
double getAngle(SUMOTime now) const
returns the angle of the transportable
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
void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)
proceeds to the next step
const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
std::string getOriginDescription() const
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
const std::string myVTypes
The possible vehicles to use.
double myDepartPos
The depart position.
double getEdgePos(SUMOTime now) const
const std::string reroute(const SUMOTime time, MSTransportableRouter &router, MSTransportable *const transportable, MSStage *previous, const MSEdge *origin, const MSEdge *destination, std::vector< MSStage * > &stages)
void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous, const bool withTiming, const bool saveState=false) const
Called on writing vehroute output.
MSStage * clone() const
const MSEdge * getEdge() const
Returns the current edge.
const MSEdge * myOrigin
the origin edge
const double mySpeed
The walking speed.
MSStoppingPlace * myOriginStop
the origin edge
std::vector< SUMOVehicle * > getVehicles(MSVehicleControl &vehControl, MSTransportable *transportable, const MSEdge *origin)
std::string getDestinationDescription() const
SUMOTime myDuration
the time the trip should take (applies to only walking)
const double myWalkFactor
The factor to apply to walking durations.
const double myDepartPosLat
The lateral depart position.
const SVCPermissions myModeSet
The allowed modes of transportation.
Position getPosition(SUMOTime now) const
returns the position of the transportable
virtual ~MSStageTrip()
destructor
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
double getAccessPos(const MSEdge *edge, SumoRNG *rng=nullptr) const
the position on the given edge which is connected to this stop, -1 on failure
MSStage * getNextStage(int offset) const
Return the next (or previous) stage denoted by the offset.
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
double getMaxSpeed() const override
Returns the maximum speed (the minimum of desired and physical maximum speed).
const SUMOVTypeParameter & getVTypeParameter() const override
Returns the object's "vehicle" type parameter.
int getCurrentStageIndex() const
Return the index of the current stage.
const SUMOVehicleParameter & getParameter() const override
Returns the vehicle's parameter (including departure definition).
void appendStage(MSStage *stage, int next=-1)
Appends the given stage to the current plan.
The class responsible for building and deletion of vehicles.
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, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const VehicleDefinitionSource source=ROUTEFILE, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false)
Deletes the vehicle.
The car-following model and parameter.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
const std::string & getID() const
Returns the name of the vehicle type.
const std::string & getID() const
Returns the id.
Definition Named.h:73
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float).
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String).
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.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setParameters(const Parameterised &params)
set the given key/value map in map<string, string> format
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1).
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition).
Representation of a vehicle.
Definition SUMOVehicle.h:63
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
double arrivalPos
(optional) The position the vehicle shall arrive on
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport).
bool hasNext()
returns the information whether further substrings exist
#define M_PI
Definition odrSpiral.cpp:45