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-2025 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>
42
43
44// ===========================================================================
45// method definitions
46// ===========================================================================
47
48/* -------------------------------------------------------------------------
49* MSStageTrip - methods
50* ----------------------------------------------------------------------- */
52 const MSEdge* destination, MSStoppingPlace* toStop,
53 const SUMOTime duration, const SVCPermissions modeSet,
54 const std::string& vTypes, const double speed, const double walkFactor,
55 const std::string& group,
56 const double departPosLat, const bool hasArrivalPos, const double arrivalPos):
57 MSStage(MSStageType::TRIP, destination, toStop, arrivalPos, 0.0, group),
58 myOrigin(origin),
59 myOriginStop(fromStop),
60 myDuration(duration),
61 myModeSet(modeSet),
62 myVTypes(vTypes),
63 mySpeed(speed),
64 myWalkFactor(walkFactor),
65 myDepartPosLat(departPosLat),
66 myHaveArrivalPos(hasArrivalPos) {
67}
68
69
71
81
82
85 // may be called concurrently while the trip is still being routed
87}
88
89
90double
92 // may be called concurrently while the trip is still being routed
93 return getEdgeAngle(myOrigin, myDepartPos) + M_PI / 2 * (MSGlobals::gLefthand ? -1 : 1);
94}
95
96
97const MSEdge*
99 return myOrigin;
100}
101
102
103double
105 return myDepartPos;
106}
107
108
109std::vector<SUMOVehicle*>
110MSStageTrip::getVehicles(MSVehicleControl& vehControl, MSTransportable* transportable, const MSEdge* origin) {
111 std::vector<SUMOVehicleParameter*> pars;
112 for (StringTokenizer st(myVTypes); st.hasNext();) {
113 pars.push_back(new SUMOVehicleParameter());
114 pars.back()->vtypeid = st.next();
115 pars.back()->parametersSet |= VEHPARS_VTYPE_SET;
116 pars.back()->departProcedure = DepartDefinition::TRIGGERED;
117 pars.back()->id = transportable->getID() + "_" + toString(pars.size() - 1);
118 }
119 if (pars.empty()) {
120 if ((myModeSet & SVC_PASSENGER) != 0) {
121 pars.push_back(new SUMOVehicleParameter());
122 pars.back()->id = transportable->getID() + "_0";
123 pars.back()->departProcedure = DepartDefinition::TRIGGERED;
124 }
125 if ((myModeSet & SVC_TAXI) != 0) {
126 pars.push_back(new SUMOVehicleParameter());
127 pars.back()->vtypeid = DEFAULT_TAXITYPE_ID;
128 pars.back()->id = transportable->getID() + "_taxi";
129 pars.back()->line = "taxi";
130 }
131 if ((myModeSet & SVC_BICYCLE) != 0) {
132 pars.push_back(new SUMOVehicleParameter());
133 pars.back()->vtypeid = DEFAULT_BIKETYPE_ID;
134 pars.back()->id = transportable->getID() + "_b0";
135 pars.back()->departProcedure = DepartDefinition::TRIGGERED;
136 }
137 }
138 ConstMSRoutePtr const routeDummy = std::make_shared<MSRoute>(transportable->getID() + "_0", ConstMSEdgeVector({ origin }), false, nullptr, StopParVector());
139 std::vector<SUMOVehicle*> result;
140 for (SUMOVehicleParameter* vehPar : pars) {
141 const bool isTaxi = vehPar->vtypeid == DEFAULT_TAXITYPE_ID && vehPar->line == "taxi";
142 if (myDepartPos != 0) {
143 vehPar->departPosProcedure = DepartPosDefinition::GIVEN;
144 vehPar->departPos = myDepartPos;
145 vehPar->parametersSet |= VEHPARS_DEPARTPOS_SET;
146 }
147 vehPar->parametersSet |= VEHPARS_ARRIVALPOS_SET;
148 vehPar->arrivalPosProcedure = ArrivalPosDefinition::GIVEN;
149 vehPar->parametersSet |= VEHPARS_ARRIVALSPEED_SET;
150 vehPar->arrivalSpeedProcedure = ArrivalSpeedDefinition::GIVEN;
151 vehPar->arrivalSpeed = 0;
152 MSVehicleType* type = vehControl.getVType(vehPar->vtypeid);
153 if (type->getVehicleClass() != SVC_IGNORING && (origin->getPermissions() & type->getVehicleClass()) == 0 && !isTaxi) {
154 WRITE_WARNINGF(TL("Ignoring vehicle type '%' when routing person '%' because it is not allowed on the start edge."), type->getID(), transportable->getID());
155 delete vehPar;
156 } else {
157 result.push_back(vehControl.buildVehicle(vehPar, routeDummy, type, !MSGlobals::gCheckRoutes));
158 }
159 }
160 if (result.empty()) {
161 // walking only but may use access infrastructure
162 result.push_back(nullptr);
163 }
164 return result;
165}
166
167
168const std::string
169MSStageTrip::reroute(const SUMOTime time, MSTransportableRouter& router, MSTransportable* const transportable,
170 MSStage* previous, const MSEdge* origin, const MSEdge* destination, std::vector<MSStage*>& stages) {
171 if (origin->isTazConnector() && origin->getSuccessors().size() == 0) {
172 // previous stage ended at a taz sink-edge
173 origin = transportable->getNextStage(-1)->getDestination();
174 }
176 double minCost = std::numeric_limits<double>::max();
177 std::vector<MSTransportableRouter::TripItem> minResult;
178 SUMOVehicle* minVehicle = nullptr;
179 for (SUMOVehicle* vehicle : getVehicles(vehControl, transportable, origin)) {
180 std::vector<MSTransportableRouter::TripItem> result;
181 double departPos = previous->getArrivalPos();
182 MSStoppingPlace* const prevStop = previous->getDestinationStop();
183 if (MSGlobals::gUseMesoSim && prevStop != nullptr) {
184 departPos = (prevStop->getBeginLanePosition() + prevStop->getEndLanePosition()) / 2.;
185 }
186 if (router.compute(origin, destination, departPos, prevStop == nullptr ? "" : prevStop->getID(),
187 myArrivalPos, myDestinationStop == nullptr ? "" : myDestinationStop->getID(),
188 transportable->getMaxSpeed() * myWalkFactor, vehicle, transportable->getVTypeParameter(), myModeSet, time, result)) {
189 double totalCost = 0;
190 for (const MSTransportableRouter::TripItem& item : result) {
191 totalCost += item.cost;
192 }
193 if (totalCost < minCost) {
194 minCost = totalCost;
195 minResult.swap(result);
196 std::swap(minVehicle, vehicle);
197 }
198 }
199 if (vehicle != nullptr) {
200 vehControl.deleteVehicle(vehicle, true);
201 vehControl.discountRoutingVehicle();
202 }
203 }
204 if (minCost != std::numeric_limits<double>::max()) {
205 const bool isTaxi = minVehicle != nullptr && minVehicle->getParameter().vtypeid == DEFAULT_TAXITYPE_ID && minVehicle->getParameter().line == "taxi";
206 bool carUsed = false;
207 for (std::vector<MSTransportableRouter::TripItem>::iterator it = minResult.begin(); it != minResult.end(); ++it) {
208 if (!it->edges.empty()) {
210 double localArrivalPos = bs != nullptr ? bs->getAccessPos(it->edges.back()) : it->arrivalPos;
211 const MSEdge* const first = it->edges.front();
212 const MSEdge* const rideOrigin = origin->isTazConnector() && stages.empty() ? first : nullptr;
213 if (it + 1 == minResult.end() && myHaveArrivalPos) {
214 localArrivalPos = myArrivalPos;
215 }
216 if (it->line == "") {
217 // determine walk departPos
218 double depPos = previous->getArrivalPos();
219 if (previous->getDestinationStop() != nullptr) {
220 depPos = previous->getDestinationStop()->getAccessPos(first, first->getLanes()[0]->getRNG());
221 } else if (origin->isTazConnector()) {
222 // walk the whole length of the first edge
223 if (std::find(first->getPredecessors().begin(), first->getPredecessors().end(), origin) != first->getPredecessors().end()) {
224 depPos = 0;
225 } else {
226 depPos = first->getLength();
227 }
228 } else if (previous->getDestination() != first) {
229 if ((previous->getDestination()->getToJunction() == first->getToJunction())
230 || (previous->getDestination()->getFromJunction() == first->getToJunction())) {
231 depPos = first->getLength();
232 } else {
233 depPos = 0.;
234 }
235 }
236 if (destination->isTazConnector()) {
237 // walk the whole length of the last edge
238 const MSEdge* last = it->edges.back();
239 if (std::find(last->getSuccessors().begin(), last->getSuccessors().end(), destination) != last->getSuccessors().end()) {
240 localArrivalPos = last->getLength();
241 } else {
242 localArrivalPos = 0;
243 }
244 }
245 previous = new MSStageWalking(transportable->getID(), it->edges, bs, myDuration, mySpeed, depPos, localArrivalPos, myDepartPosLat);
246 previous->setParameters(*this);
247 previous->setCosts(it->cost);
248 previous->setTrip(this);
249 stages.push_back(previous);
250 } else if (isTaxi && it->line == minVehicle->getID()) {
251 const ConstMSEdgeVector& prevEdges = previous->getEdges();
252 if (prevEdges.size() >= 2 && previous->getDestinationStop() == nullptr) {
253 // determine walking direction and let the previous
254 // stage end after entering its final edge
255 const MSEdge* last = prevEdges.back();
256 const MSEdge* prev = prevEdges[prevEdges.size() - 2];
257 if (last->getFromJunction() == prev->getToJunction() || prev->getFromJunction() == last->getFromJunction()) {
258 previous->setArrivalPos(MIN2(last->getLength(), 10.0));
259 } else {
260 previous->setArrivalPos(MAX2(0.0, last->getLength() - 10));
261 }
262 }
263 previous = new MSStageDriving(rideOrigin, it->edges.back(), bs, localArrivalPos, 0.0, std::vector<std::string>({ "taxi" }), myGroup);
264 previous->setParameters(*this);
265 previous->setCosts(it->cost);
266 previous->setTrip(this);
267 stages.push_back(previous);
268 } else if (minVehicle != nullptr && it->line == minVehicle->getID()) {
269 previous = new MSStageDriving(rideOrigin, it->edges.back(), bs, localArrivalPos, 0.0, std::vector<std::string>({ it->line }));
270 previous->setParameters(*this);
271 previous->setCosts(it->cost);
272 previous->setTrip(this);
273 stages.push_back(previous);
274 minVehicle->replaceRouteEdges(it->edges, -1, 0, "person:" + transportable->getID(), true);
275 minVehicle->setArrivalPos(localArrivalPos);
276 const_cast<SUMOVehicleParameter&>(minVehicle->getParameter()).arrivalPos = localArrivalPos;
277 vehControl.addVehicle(minVehicle->getID(), minVehicle);
278 carUsed = true;
279 } else {
280 const std::string line = OptionsCont::getOptions().getBool("persontrip.ride-public-line") ? it->line : LINE_ANY;
281 previous = new MSStageDriving(rideOrigin, it->edges.back(), bs, localArrivalPos, 0.0, std::vector<std::string>({ line }), myGroup, it->intended, TIME2STEPS(it->depart));
282 previous->setParameters(*this);
283 previous->setCosts(it->cost);
284 previous->setTrip(this);
285 stages.push_back(previous);
286 }
287 }
288 }
289 if (wasSet(VEHPARS_ARRIVALPOS_SET) && !stages.empty()) {
290 // mark the last stage
291 stages.back()->markSet(VEHPARS_ARRIVALPOS_SET);
292 }
293 setCosts(minCost);
294 if (minVehicle != nullptr && (isTaxi || !carUsed)) {
295 vehControl.deleteVehicle(minVehicle, true);
296 vehControl.discountRoutingVehicle();
297 }
298 } else {
299 // append stage so the GUI won't crash due to inconsistent state
300 previous = new MSStageWalking(transportable->getID(), ConstMSEdgeVector({ origin, destination }), myDestinationStop, myDuration, mySpeed, previous->getArrivalPos(), myArrivalPos, myDepartPosLat);
301 previous->setParameters(*this);
302 stages.push_back(previous);
303 if (MSGlobals::gCheckRoutes) { // if not pedestrians will teleport
304 return "No connection found between " + getOriginDescription() + " and " + getDestinationDescription() + " for person '" + transportable->getID() + "'.";
305 }
306 }
307 if (stages.empty()) {
308 // append stage so the GUI won't crash due to inconsistent state
309 if (myOriginStop != nullptr && myOriginStop == myDestinationStop) {
310 stages.push_back(new MSStageWaiting(destination, myDestinationStop, 0, -1, previous->getArrivalPos(), "sameStop", false));
311 } else {
312 stages.push_back(new MSStageWalking(transportable->getID(), ConstMSEdgeVector({ origin, destination }), myDestinationStop, myDuration, mySpeed, previous->getArrivalPos(), myArrivalPos, myDepartPosLat));
313 if (MSGlobals::gCheckRoutes) { // if not pedestrians will teleport
314 return "Empty route between " + getOriginDescription() + " and " + getDestinationDescription() + " for person '" + transportable->getID() + "'.";
315 }
316 }
317 }
318 return "";
319}
320
321
322const std::string
323MSStageTrip::setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived) {
324 MSStage::setArrived(net, transportable, now, vehicleArrived);
325 std::vector<MSStage*> stages;
326 std::string result;
327 if (transportable->getCurrentStageIndex() == 0) {
328 myDepartPos = transportable->getParameter().departPos;
330 // TODO we should probably use the rng of the lane here
331 myDepartPos = RandHelper::rand(myOrigin->getLength());
332 }
333 MSStageWaiting start(myOrigin, myOriginStop, -1, transportable->getParameter().depart, myDepartPos, "start", true);
334 result = reroute(transportable->getParameter().depart, net->getIntermodalRouter(0), transportable, &start, myOrigin, myDestination, stages);
335 } else {
336 MSStage* previous = transportable->getNextStage(-1);
337 myDepartPos = previous->getArrivalPos();
338 result = reroute(now, net->getIntermodalRouter(0), transportable, previous, myOrigin, myDestination, stages);
339 }
340 int idx = 1;
341 for (MSStage* stage : stages) {
342 transportable->appendStage(stage, idx++);
343 }
344 return result;
345}
346
347
348void
349MSStageTrip::proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* /* previous */) {
350 // just skip the stage, every interesting happens in setArrived
351 transportable->proceed(net, now);
352}
353
354
355std::string
357 return (myOriginStop != nullptr
358 ? toString(myOriginStop->getElement()) + " '" + myOriginStop->getID()
359 : "edge '" + myOrigin->getID()) + "'";
360}
361
362std::string
364 return (myDestinationStop != nullptr
365 ? toString(myDestinationStop->getElement()) + " '" + myDestinationStop->getID()
366 : "edge '" + myDestination->getID()) + "'";
367}
368
369std::string
371 return "trip from " + getOriginDescription() + " to " + getDestinationDescription();
372}
373
374void
375MSStageTrip::routeOutput(const bool /*isPerson*/, OutputDevice& os, const bool /*withRouteLength*/, const MSStage* const previous) const {
376 if (myArrived < 0) {
377 const bool walkFactorSet = myWalkFactor != OptionsCont::getOptions().getFloat("persontrip.walkfactor");
378 const bool groupSet = myGroup != OptionsCont::getOptions().getString("persontrip.default.group");
379 // could still be a persontrip but most likely it was a walk in the input
380 SumoXMLTag tag = myModeSet == 0 && !walkFactorSet && !groupSet ? SUMO_TAG_WALK : SUMO_TAG_PERSONTRIP;
381 os.openTag(tag);
382 if (previous == nullptr || previous->getStageType() == MSStageType::WAITING_FOR_DEPART) {
383 os.writeAttr(SUMO_ATTR_FROM, myOrigin->getID());
384 }
385 if (myDestinationStop == nullptr) {
389 }
390 } else {
391 os.writeAttr(toString(myDestinationStop->getElement()), myDestinationStop->getID());
392 }
393 std::vector<std::string> modes;
394 if ((myModeSet & SVC_PASSENGER) != 0) {
395 modes.push_back("car");
396 }
397 if ((myModeSet & SVC_BICYCLE) != 0) {
398 modes.push_back("bicycle");
399 }
400 if ((myModeSet & SVC_TAXI) != 0) {
401 modes.push_back("taxi");
402 }
403 if ((myModeSet & SVC_BUS) != 0) {
404 modes.push_back("public");
405 }
406 if (modes.size() > 0) {
407 os.writeAttr(SUMO_ATTR_MODES, modes);
408 }
409 if (myVTypes.size() > 0) {
411 }
412 if (groupSet) {
414 }
415 if (walkFactorSet) {
417 }
418 if (OptionsCont::getOptions().getBool("vehroute-output.cost")) {
420 }
421 os.closeTag();
422 }
423}
424
425/****************************************************************************/
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:57
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const std::string DEFAULT_TAXITYPE_ID
@ 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: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 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...
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:657
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
const MSJunction * getToJunction() const
Definition MSEdge.h:426
double getLength() const
return the length of the edge
Definition MSEdge.h:693
const MSJunction * getFromJunction() const
Definition MSEdge.h:422
bool isTazConnector() const
Definition MSEdge.h:291
const MSEdgeVector & getPredecessors() const
Definition MSEdge.h:417
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1268
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:186
MSTransportableRouter & getIntermodalRouter(int rngIndex, const int routingMode=0, const Prohibitions &prohibited={}) const
Definition MSNet.cpp:1633
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition MSNet.cpp:1459
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:392
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:287
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition MSStage.h:305
const std::string myGroup
The id of the group of transportables traveling together.
Definition MSStage.h:323
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition MSStage.cpp:160
double getCosts() const
Returns the costs of the stage.
Definition MSStage.h:271
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition MSStage.h:88
bool wasSet(int what) const
Definition MSStage.h:259
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:279
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:317
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition MSStage.cpp:182
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition MSStage.h:334
double myArrivalPos
the longitudinal position at which we want to arrive
Definition MSStage.h:308
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition MSStage.cpp:171
const MSEdge * myDestination
the next edge to reach by getting transported
Definition MSStage.h:302
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)
MSStage * clone() const
const MSEdge * getEdge() const
Returns the current edge.
void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
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:74
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 & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
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:62
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.
std::string vtypeid
The vehicle's type id.
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