Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
ROPerson.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2002-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// A vehicle as used by router
22/****************************************************************************/
23#include <config.h>
24
25#include <string>
26#include <iostream>
36#include "RORouteDef.h"
37#include "RORoute.h"
38#include "ROVehicle.h"
39#include "ROHelper.h"
40#include "RONet.h"
41#include "ROLane.h"
42#include "ROPerson.h"
43
46
47// ===========================================================================
48// method definitions
49// ===========================================================================
51 : RORoutable(pars, type) {
52}
53
54
56 for (PlanItem* const it : myPlan) {
57 delete it;
58 }
59}
60
61
62void
63ROPerson::addTrip(std::vector<PlanItem*>& plan, const std::string& id,
64 const ROEdge* const from, const ROEdge* const to, const SVCPermissions modeSet,
65 const std::string& vTypes,
66 const double departPos, const std::string& stopOrigin,
67 const double arrivalPos, const std::string& busStop,
68 double walkFactor, const std::string& group) {
69 PersonTrip* trip = new PersonTrip(from, to, modeSet, departPos, stopOrigin, arrivalPos, busStop, walkFactor, group);
73 if (departPos != 0) {
75 pars.departPos = departPos;
77 }
78 for (StringTokenizer st(vTypes); st.hasNext();) {
79 pars.vtypeid = st.next();
81 const SUMOVTypeParameter* type = net->getVehicleTypeSecure(pars.vtypeid);
82 if (type == nullptr) {
83 delete trip;
84 throw InvalidArgument("The vehicle type '" + pars.vtypeid + "' in a trip for person '" + id + "' is not known.");
85 }
86 pars.id = id + "_" + toString(trip->getVehicles().size());
87 trip->addVehicle(new ROVehicle(pars, new RORouteDef("!" + pars.id, 0, false, false), type, net));
88 // update modeset with routing-category vClass
89 if (type->vehicleClass == SVC_BICYCLE) {
91 } else {
93 }
94 }
95 if (trip->getVehicles().empty()) {
96 if ((modeSet & SVC_PASSENGER) != 0) {
97 pars.id = id + "_0";
98 trip->addVehicle(new ROVehicle(pars, new RORouteDef("!" + pars.id, 0, false, false), net->getVehicleTypeSecure(DEFAULT_VTYPE_ID), net));
99 }
100 if ((modeSet & SVC_BICYCLE) != 0) {
101 pars.id = id + "_b0";
104 trip->addVehicle(new ROVehicle(pars, new RORouteDef("!" + pars.id, 0, false, false), net->getVehicleTypeSecure(DEFAULT_BIKETYPE_ID), net));
105 }
106 if ((modeSet & SVC_TAXI) != 0) {
107 // add dummy taxi for routing (never added to output)
108 pars.id = "taxi"; // id is written as 'line'
110 trip->addVehicle(new ROVehicle(pars, new RORouteDef("!" + pars.id, 0, false, false), net->getVehicleTypeSecure(DEFAULT_TAXITYPE_ID), net));
111 }
112 }
113 plan.push_back(trip);
114}
115
116
117void
118ROPerson::addRide(std::vector<PlanItem*>& plan, const ROEdge* const from, const ROEdge* const to, const std::string& lines,
119 double arrivalPos, const std::string& destStop, const std::string& group) {
120 plan.push_back(new PersonTrip(to, destStop));
121 plan.back()->addTripItem(new Ride(-1, from, to, lines, group, -1., arrivalPos, -1., destStop));
122}
123
124
125void
126ROPerson::addWalk(std::vector<PlanItem*>& plan, const ConstROEdgeVector& edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string& busStop) {
127 if (plan.empty() || plan.back()->isStop()) {
128 plan.push_back(new PersonTrip(edges.back(), busStop));
129 }
130 plan.back()->addTripItem(new Walk(-1, edges, -1., duration, speed, departPos, arrivalPos, busStop));
131}
132
133
134void
135ROPerson::addStop(std::vector<PlanItem*>& plan, const SUMOVehicleParameter::Stop& stopPar, const ROEdge* const stopEdge) {
136 plan.push_back(new Stop(stopPar, stopEdge));
137}
138
139
140void
141ROPerson::Ride::saveAsXML(OutputDevice& os, const bool extended, OptionsCont& options) const {
143 std::string comment = "";
144 if ((extended || options.getBool("write-costs")) && myCost >= 0.) {
146 }
147 if (from != nullptr) {
149 }
150 if (to != nullptr) {
152 }
153 if (destStop != "") {
154 const std::string element = RONet::getInstance()->getStoppingPlaceElement(destStop);
155 os.writeAttr(element, destStop);
156 const std::string name = RONet::getInstance()->getStoppingPlaceName(destStop);
157 if (name != "") {
158 comment = " <!-- " + name + " -->";
159 }
160 } else if (arrPos != 0 && arrPos != std::numeric_limits<double>::infinity()) {
162 }
163 if (lines != LINE_ANY) {
164 // no need to write the default
166 }
167 if (group != "") {
169 }
170 if (intended != "" && intended != lines) {
172 }
173 if (depart >= 0) {
175 }
176 if (options.getBool("exit-times")) {
177 os.writeAttr("started", time2string(getStart()));
178 os.writeAttr("ended", time2string(getStart() + getDuration()));
179 }
180 if (options.getBool("route-length") && length != -1) {
181 os.writeAttr("routeLength", length);
182 }
183 os.closeTag(comment);
184}
185
186
187void
188ROPerson::Stop::saveAsXML(OutputDevice& os, const bool /*extended*/, const bool /*asTrip*/, OptionsCont& /*options*/) const {
189 stopDesc.write(os, false);
190 std::string comment = "";
191 for (std::string sID : stopDesc.getStoppingPlaceIDs()) {
192 const std::string name = RONet::getInstance()->getStoppingPlaceName(sID);
193 if (name != "") {
194 comment += name + " ";
195 }
196 }
197 if (comment != "") {
198 comment = " <!-- " + comment + " -->";
199 }
200 XMLHelpers::writeParams(os, stopDesc);
201 os.closeTag(comment);
202}
203
204void
205ROPerson::Walk::saveAsXML(OutputDevice& os, const bool extended, OptionsCont& options) const {
207 std::string comment = "";
208 if ((extended || options.getBool("write-costs")) && myCost >= 0.) {
209 os.writeAttr(SUMO_ATTR_COST, myCost);
210 }
211 if (dur > 0) {
213 }
214 if (v > 0) {
216 }
217 os.writeAttr(SUMO_ATTR_EDGES, edges);
218 if (options.getBool("exit-times")) {
219 os.writeAttr("started", time2string(getStart()));
220 os.writeAttr("ended", time2string(getStart() + getDuration()));
221 if (!exitTimes.empty()) {
222 os.writeAttr("exitTimes", exitTimes);
223 }
224 }
225 if (options.getBool("route-length")) {
226 double length = 0;
227 for (const ROEdge* roe : edges) {
228 length += roe->getLength();
229 }
230 os.writeAttr("routeLength", length);
231 }
232 if (destStop != "") {
233 const std::string element = RONet::getInstance()->getStoppingPlaceElement(destStop);
234 os.writeAttr(element, destStop);
235 const std::string name = RONet::getInstance()->getStoppingPlaceName(destStop);
236 if (name != "") {
237 comment = " <!-- " + name + " -->";
238 }
239 } else if (arr != 0 && arr != std::numeric_limits<double>::infinity()) {
241 }
242 os.closeTag(comment);
243}
244
247 PersonTrip* result = new PersonTrip(from, to, modes, dep, stopOrigin, arr, stopDest, walkFactor, group);
248 for (auto* item : myTripItems) {
249 result->myTripItems.push_back(item->clone());
250 }
251 return result;
252}
253
254void
255ROPerson::PersonTrip::saveVehicles(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const {
256 for (ROVehicle* veh : myVehicles) {
257 if (!RONet::getInstance()->knowsVehicle(veh->getID())) {
258 veh->saveAsXML(os, typeos, asAlternatives, options);
259 }
260 }
261}
262
263void
264ROPerson::PersonTrip::saveAsXML(OutputDevice& os, const bool extended, const bool asTrip, OptionsCont& options) const {
265 if ((asTrip || extended) && from != nullptr) {
266 const bool writeGeoTrip = asTrip && options.getBool("write-trips.geo");
268 if (writeGeoTrip) {
269 Position fromPos = from->getLanes()[0]->getShape().positionAtOffset2D(getDepartPos());
270 if (GeoConvHelper::getFinal().usingGeoProjection()) {
273 os.writeAttr(SUMO_ATTR_FROMLONLAT, fromPos);
275 } else {
276 os.writeAttr(SUMO_ATTR_FROMXY, fromPos);
277 }
278 } else {
279 os.writeAttr(SUMO_ATTR_FROM, from->getID());
280 }
281 if (writeGeoTrip) {
282 Position toPos = to->getLanes()[0]->getShape().positionAtOffset2D(MIN2(getArrivalPos(), to->getLanes()[0]->getShape().length2D()));
283 if (GeoConvHelper::getFinal().usingGeoProjection()) {
286 os.writeAttr(SUMO_ATTR_TOLONLAT, toPos);
288 } else {
289 os.writeAttr(SUMO_ATTR_TOXY, toPos);
290 }
291 } else {
292 os.writeAttr(SUMO_ATTR_TO, to->getID());
293 }
294 std::vector<std::string> allowedModes;
295 if ((modes & SVC_BUS) != 0) {
296 allowedModes.push_back("public");
297 }
298 if ((modes & SVC_PASSENGER) != 0) {
299 allowedModes.push_back("car");
300 }
301 if ((modes & SVC_TAXI) != 0) {
302 allowedModes.push_back("taxi");
303 }
304 if ((modes & SVC_BICYCLE) != 0) {
305 allowedModes.push_back("bicycle");
306 }
307 if (allowedModes.size() > 0) {
308 os.writeAttr(SUMO_ATTR_MODES, toString(allowedModes));
309 }
310 if (!writeGeoTrip) {
311 if (dep != 0 && dep != std::numeric_limits<double>::infinity()) {
313 }
314 if (arr != 0 && arr != std::numeric_limits<double>::infinity()) {
316 }
317 }
318 if (getStopDest() != "") {
319 os.writeAttr(SUMO_ATTR_BUS_STOP, getStopDest());
320 }
321 if (walkFactor != 1) {
322 os.writeAttr(SUMO_ATTR_WALKFACTOR, walkFactor);
323 }
324 if (extended && myTripItems.size() != 0) {
325 std::vector<double> costs;
326 for (const TripItem* const tripItem : myTripItems) {
327 costs.push_back(tripItem->getCost());
328 }
329 os.writeAttr(SUMO_ATTR_COSTS, costs);
330 }
331 os.closeTag();
332 } else {
333 for (const TripItem* const it : myTripItems) {
334 it->saveAsXML(os, extended, options);
335 }
336 }
337}
338
341 SUMOTime result = 0;
342 for (TripItem* tItem : myTripItems) {
343 result += tItem->getDuration();
344 }
345 return result;
346}
347
348bool
350 const PersonTrip* const trip, const ROVehicle* const veh,
351 std::vector<TripItem*>& resultItems, MsgHandler* const errorHandler) {
352 const double speed = getMaxSpeed() * trip->getWalkFactor();
353 std::vector<ROIntermodalRouter::TripItem> result;
354 provider.getIntermodalRouter().compute(trip->getOrigin(), trip->getDestination(),
355 trip->getDepartPos(), trip->getStopOrigin(),
356 trip->getArrivalPos(), trip->getStopDest(),
357 speed, veh, *getType(), trip->getModes(), time, result);
358 bool carUsed = false;
359 SUMOTime start = time;
360 int index = 0;
361 const int lastIndex = (int)result.size() - 1;
362 for (const ROIntermodalRouter::TripItem& item : result) {
363 if (!item.edges.empty()) {
364 if (item.line == "") {
365 double depPos = trip->getDepartPos(false);
366 double arrPos = trip->getArrivalPos(false);
367 if (trip->getOrigin()->isTazConnector()) {
368 // walk the whole length of the first edge
369 const ROEdge* first = item.edges.front();
370 if (std::find(first->getPredecessors().begin(), first->getPredecessors().end(), trip->getOrigin()) != first->getPredecessors().end()) {
371 depPos = 0;
372 } else {
373 depPos = first->getLength();
374 }
375 }
376 if (trip->getDestination()->isTazConnector()) {
377 // walk the whole length of the last edge
378 const ROEdge* last = item.edges.back();
379 if (std::find(last->getSuccessors().begin(), last->getSuccessors().end(), trip->getDestination()) != last->getSuccessors().end()) {
380 arrPos = last->getLength();
381 } else {
382 arrPos = 0;
383 }
384 }
385 if (&item == &result.back() && trip->getStopDest() == "") {
386 resultItems.push_back(new Walk(start, item.edges, item.cost, item.exitTimes, depPos, arrPos));
387 } else {
388 resultItems.push_back(new Walk(start, item.edges, item.cost, item.exitTimes, depPos, arrPos, item.destStop));
389 }
390 } else if (veh != nullptr && item.line == veh->getID()) {
391 double cost = item.cost;
392 if (veh->getVClass() != SVC_TAXI) {
393 std::shared_ptr<RORoute> route = std::make_shared<RORoute>(veh->getID() + "_RouteDef", item.edges);
394 route->setProbability(1);
396 carUsed = true;
397 } else if (resultItems.empty()) {
398 // if this is the first plan item the initial taxi waiting time wasn't added yet
399 const double taxiWait = STEPS2TIME(string2time(OptionsCont::getOptions().getString("persontrip.taxi.waiting-time")));
400 cost += taxiWait;
401 }
402 double arrPos = index == lastIndex ? trip->getArrivalPos(false) : item.arrivalPos;
403 resultItems.push_back(new Ride(start, item.edges.front(), item.edges.back(), veh->getID(), trip->getGroup(), cost, arrPos, item.length, item.destStop));
404 } else {
405 // write origin for first element of the plan
406 const ROEdge* origin = trip == myPlan.front() && resultItems.empty() ? trip->getOrigin() : nullptr;
407 const std::string line = OptionsCont::getOptions().getBool("persontrip.ride-public-line") ? item.line : LINE_ANY;
408 resultItems.push_back(new Ride(start, origin, nullptr, line, trip->getGroup(), item.cost, item.arrivalPos, item.length, item.destStop, item.intended, TIME2STEPS(item.depart)));
409 }
410 }
411 start += TIME2STEPS(item.cost);
412 index++;
413 }
414 if (result.empty()) {
415 errorHandler->informf(TL("No route for trip in person '%'."), getID());
416 myRoutingSuccess = false;
417 }
418 return carUsed;
419}
420
421
422void
424 const bool /* removeLoops */, MsgHandler* errorHandler) {
425 myRoutingSuccess = true;
427 for (PlanItem* const it : myPlan) {
428 if (it->needsRouting()) {
429 PersonTrip* trip = static_cast<PersonTrip*>(it);
430 const std::vector<ROVehicle*>& vehicles = trip->getVehicles();
431 std::vector<TripItem*> resultItems;
432 std::vector<TripItem*> best;
433 const ROVehicle* bestVeh = nullptr;
434 if (vehicles.empty()) {
435 computeIntermodal(time, provider, trip, nullptr, best, errorHandler);
436 } else {
437 double bestCost = std::numeric_limits<double>::infinity();
438 for (const ROVehicle* const v : vehicles) {
439 const bool carUsed = computeIntermodal(time, provider, trip, v, resultItems, errorHandler);
440 double cost = 0.;
441 for (const TripItem* const tripIt : resultItems) {
442 cost += tripIt->getCost();
443 }
444 if (cost < bestCost) {
445 bestCost = cost;
446 bestVeh = carUsed ? v : nullptr;
447 best.swap(resultItems);
448 }
449 for (const TripItem* const tripIt : resultItems) {
450 delete tripIt;
451 }
452 resultItems.clear();
453 }
454 }
455 trip->setItems(best, bestVeh);
456
457 // test after routing to ensuer network was initialized
458 if (!myHaveWarnedPTMissing && (trip->getModes() & SVC_BUS) != 0) {
460 if (!provider.getIntermodalRouter().getNetwork()->hasPTSchedules()) {
461 WRITE_WARNINGF("Person '%' is configured to use public transport but no schedules are loaded.", getID());
462 }
463 }
464 } else if (!it->isStop()) {
465 const PersonTrip* const trip = static_cast<const PersonTrip*>(it);
466 const SUMOVehicleClass svc = getType() != nullptr ? getType()->vehicleClass : SVC_PEDESTRIAN;
467 for (const TripItem* const tIt : trip->getTripItems()) {
468 const Walk* const walk = dynamic_cast<const Walk*>(tIt);
469 if (walk == nullptr || walk->getEdges().empty()) {
470 continue;
471 }
472 const ConstROEdgeVector& edges = walk->getEdges();
473 for (const ROEdge* const e : edges) {
474 if (!e->isTazConnector() && (e->getPermissions() & svc) == 0) {
475 errorHandler->informf(TL("Person '%' is not allowed to walk on edge '%'."), getID(), e->getID());
476 myRoutingSuccess = false;
477 }
478 }
479 if (edges.size() > 1) {
480 const ROEdge* failPrev = nullptr;
481 const ROEdge* failNext = nullptr;
482 auto canWalk = [&](bool startForward) -> bool {
483 const RONode* junction = startForward ? edges.front()->getToJunction() : edges.front()->getFromJunction();
484 for (size_t i = 1; i < edges.size(); ++i) {
485 const ROEdge* const prev = edges[i - 1];
486 const ROEdge* const cur = edges[i];
487 if (cur == prev || cur->isTazConnector() || prev->isTazConnector()) {
488 junction = cur->getToJunction();
489 } else if (junction != nullptr && cur->getFromJunction() == junction) {
490 junction = cur->getToJunction();
491 } else if (junction != nullptr && cur->getToJunction() == junction) {
492 junction = cur->getFromJunction();
493 } else {
494 if (failPrev == nullptr) {
495 failPrev = prev;
496 failNext = cur;
497 }
498 return false;
499 }
500 }
501 return true;
502 };
503 if (!canWalk(true) && !canWalk(false)) {
504 errorHandler->informf(TL("Invalid walk route for person '%' (edge '%' is not connected to edge '%')."),
505 getID(), failPrev->getID(), failNext->getID());
506 myRoutingSuccess = false;
507 }
508 }
509 if (walk->getStopDest() != "") {
510 static const SumoXMLTag stopTags[] = {
513 };
514 const SUMOVehicleParameter::Stop* sp = nullptr;
515 for (SumoXMLTag tag : stopTags) {
516 sp = RONet::getInstance()->getStoppingPlace(walk->getStopDest(), tag);
517 if (sp != nullptr) {
518 break;
519 }
520 }
521 if (sp != nullptr) {
522 const std::string& arrEdgeID = edges.back()->getID();
523 bool connected = (SUMOXMLDefinitions::getEdgeIDFromLane(sp->lane) == arrEdgeID);
524 if (!connected) {
525 for (const auto& acc : sp->accessPos) {
526 if (SUMOXMLDefinitions::getEdgeIDFromLane(std::get<0>(acc)) == arrEdgeID) {
527 connected = true;
528 break;
529 }
530 }
531 }
532 if (!connected) {
533 errorHandler->informf(TL("Bus stop '%' is not connected to arrival edge '%' for person '%' walking from edge '%'."),
534 walk->getStopDest(), arrEdgeID, getID(), edges.front()->getID());
535 myRoutingSuccess = false;
536 }
537 }
538 }
539 }
540 }
541 time += it->getDuration();
542 }
544 double costs = STEPS2TIME(time - getParameter().depart);
545 if (costs > RONet::getInstance()->getMaxTraveltime()) {
546 errorHandler->informf(TL("Person '%' has no valid route (traveltime % exceeds max-traveltime)."), getID(), time2string(TIME2STEPS(costs)));
547 myRoutingSuccess = false;
548 return;
549 }
550 }
551}
552
553
554void
555ROPerson::saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options, int cloneIndex) const {
556 // write the person's vehicles
557 const bool writeTrip = options.exists("write-trips") && options.getBool("write-trips");
558 const bool writeFlow = options.exists("keep-flows") && options.getBool("keep-flows") && isPartOfFlow();
559 if (!writeTrip) {
560 for (const PlanItem* const it : myPlan) {
561 it->saveVehicles(os, typeos, asAlternatives, options);
562 }
563 }
564
565 if (typeos != nullptr && getType() != nullptr && !getType()->saved) {
566 getType()->write(*typeos);
567 getType()->saved = true;
568 }
569 if (getType() != nullptr && !getType()->saved) {
570 getType()->write(os);
571 getType()->saved = asAlternatives;
572 }
573 const SumoXMLTag tag = writeFlow ? SUMO_TAG_PERSONFLOW : SUMO_TAG_PERSON;
574 // write the person
575 if (cloneIndex == 0) {
576 getParameter().write(os, options, tag);
577 } else {
579 // @note id collisions may occur if scale-suffic occurs in other vehicle ids
580 p.id += options.getString("scale-suffix") + toString(cloneIndex);
581 p.write(os, options, tag);
582 }
583
584 for (const PlanItem* const it : myPlan) {
585 it->saveAsXML(os, asAlternatives, writeTrip, options);
586 }
587
588 // write params
590 os.closeTag();
591}
592
593
594/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:299
#define TL(string)
Definition MsgHandler.h:316
std::vector< const ROEdge * > ConstROEdgeVector
Definition ROEdge.h:57
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:47
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:107
#define STEPS2TIME(x)
Definition SUMOTime.h:58
constexpr SUMOTime TIME2STEPS(double x)
Definition SUMOTime.h:60
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const std::string DEFAULT_TAXITYPE_ID
const std::string DEFAULT_VTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ 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
@ SVC_PEDESTRIAN
pedestrian
const std::string DEFAULT_BIKETYPE_ID
@ GIVEN
The position is given.
const std::string LINE_ANY
const long long int VEHPARS_DEPARTPOS_SET
const long long int VEHPARS_VTYPE_SET
@ TRIGGERED
The departure is person triggered.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_WALK
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_RIDE
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_TAG_PERSON
@ SUMO_TAG_PERSONTRIP
@ SUMO_TAG_PERSONFLOW
@ SUMO_ATTR_COSTS
@ SUMO_ATTR_LINES
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_TOLONLAT
@ SUMO_ATTR_MODES
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_GROUP
@ SUMO_ATTR_COST
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_FROMXY
@ SUMO_ATTR_WALKFACTOR
@ SUMO_ATTR_TOXY
@ SUMO_ATTR_DURATION
@ SUMO_ATTR_FROMLONLAT
@ SUMO_ATTR_INTENDED
int gPrecision
the precision for floating point outputs
Definition StdDefs.cpp:27
int gPrecisionGeo
Definition StdDefs.cpp:29
T MIN2(T a, T b)
Definition StdDefs.h:80
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
Definition MsgHandler.h:128
const std::string & getID() const
Returns the id.
Definition Named.h:73
A storage for options typed value containers)
Definition OptionsCont.h:92
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
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, const bool escape=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A basic edge for routing applications.
Definition ROEdge.h:73
const RONode * getToJunction() const
Definition ROEdge.h:561
bool isTazConnector() const
Definition ROEdge.h:174
const RONode * getFromJunction() const
Definition ROEdge.h:557
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
Definition ROEdge.h:366
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition ROEdge.cpp:391
double getLength() const
Returns the length of the edge.
Definition ROEdge.h:225
The router's network representation.
Definition RONet.h:63
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition RONet.cpp:410
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
Definition RONet.cpp:56
bool knowsVehicle(const std::string &id) const
returns whether a vehicle with the given id was already loaded
Definition RONet.cpp:534
double getMaxTraveltime() const
Definition RONet.h:478
const std::string getStoppingPlaceElement(const std::string &id) const
return the element name for the given stopping place id
Definition RONet.cpp:990
const SUMOVehicleParameter::Stop * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Retrieves a stopping place from the network.
Definition RONet.h:238
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
Definition RONet.cpp:978
Base class for nodes used by the router.
Definition RONode.h:46
A planItem can be a Trip which contains multiple tripItems.
Definition ROPerson.h:304
double getDepartPos(bool replaceDefault=true) const
Definition ROPerson.h:349
void saveVehicles(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
Definition ROPerson.cpp:255
const std::string & getStopOrigin() const
Definition ROPerson.h:366
SVCPermissions getModes() const
Definition ROPerson.h:355
const std::string & getStopDest() const
Definition ROPerson.h:370
double getWalkFactor() const
Definition ROPerson.h:394
const ROEdge * getDestination() const
Definition ROPerson.h:339
SUMOTime getDuration() const
return duration sum of all trip items
Definition ROPerson.cpp:340
double getArrivalPos(bool replaceDefault=true) const
Definition ROPerson.h:352
std::vector< ROVehicle * > & getVehicles()
Definition ROPerson.h:330
const std::string & getGroup() const
Definition ROPerson.h:362
void saveAsXML(OutputDevice &os, const bool extended, const bool asTrip, OptionsCont &options) const
Definition ROPerson.cpp:264
const ROEdge * getOrigin() const
Definition ROPerson.h:336
const std::vector< TripItem * > & getTripItems() const
Definition ROPerson.h:333
PlanItem * clone() const
Definition ROPerson.cpp:246
std::vector< TripItem * > myTripItems
the fully specified trips
Definition ROPerson.h:409
void setItems(std::vector< TripItem * > &newItems, const ROVehicle *const veh)
Definition ROPerson.h:377
void addVehicle(ROVehicle *veh)
Definition ROPerson.h:327
void updateModes(SVCPermissions additionalModes)
Definition ROPerson.h:358
Every person has a plan comprising of multiple planItems.
Definition ROPerson.h:83
static const std::string UNDEFINED_STOPPING_PLACE
Definition ROPerson.h:113
A ride is part of a trip, e.g., go from here to here by car or bus.
Definition ROPerson.h:202
const double length
Definition ROPerson.h:243
const std::string lines
Definition ROPerson.h:237
const std::string destStop
Definition ROPerson.h:239
const std::string group
Definition ROPerson.h:238
const std::string intended
Definition ROPerson.h:240
const SUMOTime depart
Definition ROPerson.h:241
const ROEdge *const to
Definition ROPerson.h:236
void saveAsXML(OutputDevice &os, const bool extended, OptionsCont &options) const
Definition ROPerson.cpp:141
const double arrPos
Definition ROPerson.h:242
const ROEdge *const from
Definition ROPerson.h:235
A planItem can be a Stop.
Definition ROPerson.h:120
void saveAsXML(OutputDevice &os, const bool extended, const bool asTrip, OptionsCont &options) const
Definition ROPerson.cpp:188
A TripItem is part of a trip, e.g., go from here to here by car.
Definition ROPerson.h:167
SUMOTime getStart() const
Definition ROPerson.h:182
SUMOTime getDuration() const
Definition ROPerson.h:186
const double myCost
Definition ROPerson.h:195
A walk is part of a trip, e.g., go from here to here by foot.
Definition ROPerson.h:255
void saveAsXML(OutputDevice &os, const bool extended, OptionsCont &options) const
Definition ROPerson.cpp:205
const std::string & getStopDest() const
Definition ROPerson.h:280
const ConstROEdgeVector & getEdges() const
Definition ROPerson.h:277
static bool myHaveWarnedPTMissing
Definition ROPerson.h:464
virtual ~ROPerson()
Destructor.
Definition ROPerson.cpp:55
bool computeIntermodal(SUMOTime time, const RORouterProvider &provider, const PersonTrip *const trip, const ROVehicle *const veh, std::vector< TripItem * > &resultItems, MsgHandler *const errorHandler)
Definition ROPerson.cpp:349
ROPerson(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
Definition ROPerson.cpp:50
static void addTrip(std::vector< PlanItem * > &plan, const std::string &id, const ROEdge *const from, const ROEdge *const to, const SVCPermissions modeSet, const std::string &vTypes, const double departPos, const std::string &stopOrigin, const double arrivalPos, const std::string &busStop, double walkFactor, const std::string &group)
Definition ROPerson.cpp:63
static void addStop(std::vector< PlanItem * > &plan, const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
Definition ROPerson.cpp:135
static void addRide(std::vector< PlanItem * > &plan, const ROEdge *const from, const ROEdge *const to, const std::string &lines, double arrivalPos, const std::string &destStop, const std::string &group)
Definition ROPerson.cpp:118
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
Definition ROPerson.cpp:423
void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options, int cloneIndex=0) const
Saves the complete person description.
Definition ROPerson.cpp:555
static void addWalk(std::vector< PlanItem * > &plan, const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &busStop)
Definition ROPerson.cpp:126
std::vector< PlanItem * > myPlan
The plan of the person.
Definition ROPerson.h:462
A routable thing such as a vehicle or person.
Definition RORoutable.h:53
SUMOVehicleClass getVClass() const
Definition RORoutable.h:127
bool isPartOfFlow() const
Definition RORoutable.h:151
bool myRoutingSuccess
Whether the last routing was successful.
Definition RORoutable.h:214
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition RORoutable.h:89
const std::string & getID() const
Returns the id of the routable.
Definition RORoutable.h:98
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition RORoutable.h:75
double getMaxSpeed() const
Returns the vehicle's maximum speed.
Definition RORoutable.h:139
Base class for a vehicle's route definition.
Definition RORouteDef.h:54
void addLoadedAlternative(std::shared_ptr< RORoute > alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
Definition RORouteDef.h:71
A vehicle as used by router.
Definition ROVehicle.h:51
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
Definition ROVehicle.h:74
IntermodalRouter< E, L, N, V > & getIntermodalRouter() const
Structure representing possible vehicle parameter.
void write(OutputDevice &dev) const
Writes the vtype.
bool saved
Information whether this type was already saved (needed by routers)
SUMOVehicleClass vehicleClass
The vehicle's class.
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
std::vector< std::tuple< std::string, double, double > > accessPos
lanes and positions connected to this stop (only used by duarouter where Stop is used to store stoppi...
Structure representing possible vehicle parameter.
std::string vtypeid
The vehicle's type id.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
double departPos
(optional) The position the vehicle shall depart from
std::string id
The vehicle's id.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
bool hasNext()
returns the information whether further substrings exist
static OutputDevice & writeParams(OutputDevice &device, const Parameterised &params)
write the parameters of the given object as param tags