63 const std::string& vTypes,
64 const double departPos,
const std::string& stopOrigin,
65 const double arrivalPos,
const std::string& busStop,
66 double walkFactor,
const std::string& group) {
67 PersonTrip* trip =
new PersonTrip(from, to, modeSet, departPos, stopOrigin, arrivalPos, busStop, walkFactor, group);
80 if (type ==
nullptr) {
82 throw InvalidArgument(
"The vehicle type '" + pars.
vtypeid +
"' in a trip for person '" +
id +
"' is not known.");
111 plan.push_back(trip);
117 double arrivalPos,
const std::string& destStop,
const std::string& group) {
119 plan.back()->addTripItem(
new Ride(-1, from, to, lines, group, -1., arrivalPos, -1., destStop));
124ROPerson::addWalk(std::vector<PlanItem*>& plan,
const ConstROEdgeVector& edges,
const double duration,
const double speed,
const double departPos,
const double arrivalPos,
const std::string& busStop) {
125 if (plan.empty() || plan.back()->isStop()) {
126 plan.push_back(
new PersonTrip(edges.back(), busStop));
128 plan.back()->addTripItem(
new Walk(-1, edges, -1., duration, speed, departPos, arrivalPos, busStop));
134 plan.push_back(
new Stop(stopPar, stopEdge));
141 std::string comment =
"";
142 if ((extended || options.
getBool(
"write-costs")) &&
myCost >= 0.) {
145 if (
from !=
nullptr) {
156 comment =
" <!-- " + name +
" -->";
158 }
else if (
arrPos != 0 &&
arrPos != std::numeric_limits<double>::infinity()) {
171 if (options.
getBool(
"exit-times")) {
184 stopDesc.write(os,
false);
185 std::string comment =
"";
186 for (std::string sID : stopDesc.getStoppingPlaceIDs()) {
189 comment += name +
" ";
193 comment =
" <!-- " + comment +
" -->";
195 stopDesc.writeParams(os);
202 std::string comment =
"";
203 if ((extended || options.
getBool(
"write-costs")) && myCost >= 0.) {
213 if (options.
getBool(
"exit-times")) {
216 if (!exitTimes.empty()) {
220 if (options.
getBool(
"route-length")) {
222 for (
const ROEdge* roe : edges) {
223 length += roe->getLength();
227 if (destStop !=
"") {
232 comment =
" <!-- " + name +
" -->";
234 }
else if (arr != 0 && arr != std::numeric_limits<double>::infinity()) {
242 PersonTrip* result =
new PersonTrip(from, to, modes, dep, stopOrigin, arr, stopDest, walkFactor, group);
243 for (
auto* item : myTripItems) {
253 veh->
saveAsXML(os, typeos, asAlternatives, options);
260 if ((asTrip || extended) && from !=
nullptr) {
261 const bool writeGeoTrip = asTrip && options.
getBool(
"write-trips.geo");
264 Position fromPos = from->getLanes()[0]->getShape().positionAtOffset2D(getDepartPos());
277 Position toPos = to->getLanes()[0]->getShape().positionAtOffset2D(
MIN2(getArrivalPos(), to->getLanes()[0]->getShape().length2D()));
289 std::vector<std::string> allowedModes;
291 allowedModes.push_back(
"public");
294 allowedModes.push_back(
"car");
297 allowedModes.push_back(
"taxi");
300 allowedModes.push_back(
"bicycle");
302 if (allowedModes.size() > 0) {
306 if (dep != 0 && dep != std::numeric_limits<double>::infinity()) {
309 if (arr != 0 && arr != std::numeric_limits<double>::infinity()) {
313 if (getStopDest() !=
"") {
316 if (walkFactor != 1) {
319 if (extended && myTripItems.size() != 0) {
320 std::vector<double> costs;
321 for (
const TripItem*
const tripItem : myTripItems) {
322 costs.push_back(tripItem->getCost());
328 for (
const TripItem*
const it : myTripItems) {
329 it->saveAsXML(os, extended, options);
337 for (
TripItem* tItem : myTripItems) {
338 result += tItem->getDuration();
346 std::vector<TripItem*>& resultItems,
MsgHandler*
const errorHandler) {
348 std::vector<ROIntermodalRouter::TripItem> result;
352 speed, veh, trip->
getModes(), time, result);
353 bool carUsed =
false;
356 if (!item.edges.empty()) {
357 if (item.line ==
"") {
362 const ROEdge* first = item.edges.front();
371 const ROEdge* last = item.edges.back();
378 if (&item == &result.back() && trip->
getStopDest() ==
"") {
379 resultItems.push_back(
new Walk(start, item.edges, item.cost, item.exitTimes, depPos, arrPos));
381 resultItems.push_back(
new Walk(start, item.edges, item.cost, item.exitTimes, depPos, arrPos, item.destStop));
383 }
else if (veh !=
nullptr && item.line == veh->
getID()) {
384 double cost = item.cost;
390 }
else if (resultItems.empty()) {
395 resultItems.push_back(
new Ride(start, item.edges.front(), item.edges.back(), veh->
getID(), trip->
getGroup(), cost, item.arrivalPos, item.length, item.destStop));
399 resultItems.push_back(
new Ride(start, origin,
nullptr, item.line, trip->
getGroup(), item.cost, item.arrivalPos, item.length, item.destStop, item.intended,
TIME2STEPS(item.depart)));
404 if (result.empty()) {
405 errorHandler->
inform(
"No route for trip in person '" +
getID() +
"'.");
418 if (it->needsRouting()) {
420 const std::vector<ROVehicle*>& vehicles = trip->
getVehicles();
421 std::vector<TripItem*> resultItems;
422 std::vector<TripItem*> best;
424 if (vehicles.empty()) {
427 double bestCost = std::numeric_limits<double>::infinity();
428 for (
const ROVehicle*
const v : vehicles) {
429 const bool carUsed =
computeIntermodal(time, provider, trip, v, resultItems, errorHandler);
431 for (
const TripItem*
const tripIt : resultItems) {
432 cost += tripIt->getCost();
434 if (cost < bestCost) {
436 bestVeh = carUsed ? v :
nullptr;
437 best.swap(resultItems);
439 for (
const TripItem*
const tripIt : resultItems) {
447 time += it->getDuration();
455 const bool writeTrip = options.
exists(
"write-trips") && options.
getBool(
"write-trips");
458 it->saveVehicles(os, typeos, asAlternatives, options);
475 it->saveAsXML(os, asAlternatives, writeTrip, options);
std::vector< const ROEdge * > ConstROEdgeVector
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
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
@ 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
@ GIVEN
The position is given.
const long long int VEHPARS_DEPARTPOS_SET
const long long int VEHPARS_VTYPE_SET
@ TRIGGERED
The departure is person triggered.
@ SUMO_ATTR_EDGES
the edges of a route
int gPrecision
the precision for floating point outputs
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
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 & 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 setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
A basic edge for routing applications.
bool isTazConnector() const
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
double getLength() const
Returns the length of the edge.
The router's network representation.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
bool knowsVehicle(const std::string &id) const
returns whether a vehicle with the given id was already loaded
const std::string getStoppingPlaceElement(const std::string &id) const
return the element name for the given stopping place id
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
A planItem can be a Trip which contains multiple tripItems.
double getDepartPos(bool replaceDefault=true) const
void saveVehicles(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
const std::string & getStopOrigin() const
SVCPermissions getModes() const
const std::string & getStopDest() const
double getWalkFactor() const
const ROEdge * getDestination() const
SUMOTime getDuration() const
return duration sum of all trip items
double getArrivalPos(bool replaceDefault=true) const
std::vector< ROVehicle * > & getVehicles()
const std::string & getGroup() const
void saveAsXML(OutputDevice &os, const bool extended, const bool asTrip, OptionsCont &options) const
const ROEdge * getOrigin() const
std::vector< TripItem * > myTripItems
the fully specified trips
void setItems(std::vector< TripItem * > &newItems, const ROVehicle *const veh)
void addVehicle(ROVehicle *veh)
void updateModes(SVCPermissions additionalModes)
Every person has a plan comprising of multiple planItems.
static const std::string UNDEFINED_STOPPING_PLACE
A ride is part of a trip, e.g., go from here to here by car or bus.
const std::string destStop
const std::string intended
void saveAsXML(OutputDevice &os, const bool extended, OptionsCont &options) const
A planItem can be a Stop.
void saveAsXML(OutputDevice &os, const bool extended, const bool asTrip, OptionsCont &options) const
A TripItem is part of a trip, e.g., go from here to here by car.
SUMOTime getStart() const
SUMOTime getDuration() const
A walk is part of a trip, e.g., go from here to here by foot.
void saveAsXML(OutputDevice &os, const bool extended, OptionsCont &options) const
virtual ~ROPerson()
Destructor.
bool computeIntermodal(SUMOTime time, const RORouterProvider &provider, const PersonTrip *const trip, const ROVehicle *const veh, std::vector< TripItem * > &resultItems, MsgHandler *const errorHandler)
ROPerson(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
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)
static void addStop(std::vector< PlanItem * > &plan, const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
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)
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
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)
void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
Saves the complete person description.
std::vector< PlanItem * > myPlan
The plan of the person.
A routable thing such as a vehicle or person.
SUMOVehicleClass getVClass() const
bool myRoutingSuccess
Whether the last routing was successful.
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
const std::string & getID() const
Returns the id of the routable.
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
double getMaxSpeed() const
Returns the vehicle's maximum speed.
Base class for a vehicle's route definition.
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
A complete router's route.
void setProbability(double prob)
Sets the probability of the route.
A vehicle as used by router.
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
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)
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.
bool hasNext()
returns the information whether further substrings exist