53 : myDestination(destination), myDestinationStop(toStop), myArrivalPos(arrivalPos), myDeparted(-1), myArrived(-1), myType(type) {}
135 return e->
getLanes()[0]->getShape().rotationAtOffset(at);
143 if (newDestStop !=
nullptr) {
156 const std::string& vTypes,
const double speed,
const double walkFactor,
157 const double departPosLat,
const bool hasArrivalPos,
const double arrivalPos):
160 myOriginStop(fromStop),
161 myDuration(duration),
165 myWalkFactor(walkFactor),
166 myDepartPosLat(departPosLat),
167 myHaveArrivalPos(hasArrivalPos) {
211 std::vector<SUMOVehicleParameter*> pars;
214 pars.back()->vtypeid = st.next();
217 pars.back()->id = transportable->
getID() +
"_" +
toString(pars.size() - 1);
222 pars.back()->id = transportable->
getID() +
"_0";
227 pars.back()->id = transportable->
getID() +
"_b0";
231 pars.push_back(
nullptr);
250 if (vehPar !=
nullptr) {
258 WRITE_WARNING(
"Ignoring vehicle type '" + type->
getID() +
"' when routing person '" + transportable->
getID() +
"' because it is not allowed on the start edge.");
264 bool carUsed =
false;
265 std::vector<MSNet::MSIntermodalRouter::TripItem> result;
269 for (std::vector<MSNet::MSIntermodalRouter::TripItem>::iterator it = result.begin(); it != result.end(); ++it) {
270 if (!it->edges.empty()) {
272 double localArrivalPos = bs !=
nullptr ? bs->
getAccessPos(it->edges.back()) : it->edges.back()->getLength() / 2.;
276 if (it->line ==
"") {
280 }
else if (previous->
getEdge() != it->edges.front()) {
288 transportable->
appendStage(previous, stageIndex++);
289 }
else if (vehicle !=
nullptr && it->line == vehicle->getID()) {
290 if (bs ==
nullptr && it + 1 != result.end()) {
292 localArrivalPos = it->edges.back()->getLength();
295 transportable->
appendStage(previous, stageIndex++);
296 vehicle->replaceRouteEdges(it->edges, -1, 0,
"person:" + transportable->
getID(),
true);
297 vehicle->setArrivalPos(localArrivalPos);
302 transportable->
appendStage(previous, stageIndex++);
310 const std::string error =
"No connection found between edge '" +
myOrigin->
getID() +
"' and edge '" + (myDestinationStop !=
nullptr ? myDestinationStop->getID() :
myDestination->
getID()) +
"' for person '" + transportable->
getID() +
"'.";
317 if (vehicle !=
nullptr && !carUsed) {
327 transportable->
proceed(net, now);
363 const bool initial) :
367 myWaitingDuration(duration),
368 myWaitingUntil(until),
406 if (dynamic_cast<MSPerson*>(transportable) !=
nullptr) {
476 std::string timeInfo;
491 MSStoppingPlace* toStop,
const double arrivalPos,
const std::vector<std::string>& lines,
492 const std::string& intendedVeh,
SUMOTime intendedDepart) :
494 myLines(lines.begin(), lines.end()),
498 myVehicleDistance(-1.),
500 myWaitingEdge(nullptr),
502 myIntendedVehicleID(intendedVeh),
503 myIntendedDepart(intendedDepart) {
554 if (veh !=
nullptr) {
681 for (MSTransportablePlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
705 (*myStep)->setDeparted(now);
730 return (*myStep)->getSpeed();
741 return (
int)
myPlan->size();
751 if (stepIndex + next > (
int)
myPlan->size()) {
754 myPlan->insert(
myPlan->begin() + stepIndex + next, stage);
762 assert(
myStep + next < myPlan->end());
775 (*myStep)->abort(
this);
783 for (MSTransportablePlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
784 (*i)->setSpeed(speed);
815 const Position back = p +
Position(-cos(angle) * length, -sin(angle) * length);
816 centerLine.push_back(p);
817 centerLine.push_back(back);
829 assert(stageIndex < (
int)
myPlan->size());
830 assert(stageIndex >= 0);
831 return (*
myPlan)[stageIndex]->getStageSummary();
842 return myPlan->size() > 0 &&
myPlan->front()->getDeparted() >= 0;
852 if (dynamic_cast<MSPerson*>(
this) ==
nullptr) {
853 WRITE_WARNING(
"parkingAreaReroute not support for containers");
879 const Stage*
const futureStage = *it;
880 Stage*
const prevStage = *(it - 1);
889 replacement, -1, 0,
"", -1, 1, 0,
true, stage->
getArrivalPos());
890 int prevStageRelIndex = (int)(it - 1 -
myStep);
904 if (
typeid(*dev) == type) {
915 const double gp = edge->
getLanes()[0]->interpolateLanePosToGeometryPos(ep);
916 return edge->
getLanes()[0]->getShape().slopeDegreeAtOffset(gp);
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
The departure is person triggered.
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
bool compute(const E *from, const E *to, const double departPos, const double arrivalPos, const std::string stopID, const double speed, const V *const vehicle, const SVCPermissions modeSet, const SUMOTime msTime, std::vector< TripItem > &into, const double externalFactor=0.)
Builds the route between the given edges using the minimum effort at the given time The definition of...
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, Stage *previous)
proceeds to the next step
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void abort(MSTransportable *)
abort this stage (TraCI)
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, Stage *previous)
proceeds to the next step
Stage(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, StageType type)
constructor
std::string getStageSummary() const
return string summary of the current stage
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
double getBeginLanePosition() const
Returns the begin position of this stop.
std::string getWaitingDescription() const
Return where the person waits and for what.
std::string myActType
The type of activity.
double getAngle(SUMOTime now) const
returns the angle of the transportable
double getAngle() const
Returns the vehicle's direction in radians.
virtual const MSEdge * getFromEdge() const
void append(const PositionVector &v, double sameThreshold=2.0)
virtual void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
logs end of the step
double getMaxSpeed() const
Returns the vehicle's maximum speed.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
virtual const std::string & getID() const =0
Get the vehicle's ID.
const MSEdge * getEdge() const
Returns the current edge.
const SVCPermissions myModeSet
The allowed modes of transportation.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
virtual const MSRoute & getRoute() const =0
Returns the current route.
A lane area vehicles can halt at.
static void buildTransportableDevices(MSTransportable &p, std::vector< MSTransportableDevice *> &into)
Build devices for the given person, if needed.
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
virtual double getEdgePos() const
Return the position on the edge.
double getAngle(SUMOTime now) const
returns the angle of the transportable
bool hasArrived() const
return whether the person has reached the end of its plan
PositionVector getBoundingBox() const
return the bounding box of the person
const MSEdge * getDestination() const
returns the destination edge
Stage_Waiting(const MSEdge *destination, MSStoppingPlace *toStop, SUMOTime duration, SUMOTime until, double pos, const std::string &actType, const bool initial)
constructor
void abort(MSTransportable *)
abort this stage (TraCI)
const std::set< std::string > & getLines() const
virtual const MSEdge * getEdge() const
Returns the current edge.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
const MSEdge * getEdge() const
Returns the current edge.
virtual double getEdgePos(SUMOTime now) const
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
double getSlope() const
Returns the slope of the road at vehicle's position.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
MSIntermodalRouter & getIntermodalRouter(const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
std::string time2string(SUMOTime t)
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
ConstMSEdgeVector getEdges() const
the edges of the current stage
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
Position getPosition(SUMOTime now) const
returns the position of the transportable
double getEdgePos(SUMOTime now) const
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Stage_Trip(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 double departPosLat, const bool hasArrivalPos, const double arrivalPos)
constructor
const PositionVector & getShape() const
Returns this lane's shape.
const std::set< std::string > myLines
the lines to choose from
double getSpeed() const
the speed of the transportable
PositionVector reverse() const
reverse position vector
const std::string DEFAULT_BIKETYPE_ID
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle's access class.
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
std::vector< const MSEdge * > ConstMSEdgeVector
virtual bool proceed(MSNet *net, SUMOTime time)=0
SUMOTime myDuration
the time the trip should take (applies to only walking)
const std::string & getID() const
Returns the id.
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
virtual double getSpeed() const
the current speed of the transportable
const MSEdge * myDestination
the next edge to reach by getting transported
SUMOTime getUntil() const
bool hasNext()
returns the information whether further substrings exist
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
const SUMOVehicleParameter & getParameter() const
MSTransportablePlan::iterator myStep
the iterator over the route
double getEdgePos(SUMOTime now) const
double getLength() const
return the length of the edge
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
The position is chosen randomly.
const MSEdge * getFromEdge() const
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
SUMOTime getWaitingTime() const
std::string myVehicleLine
#define WRITE_WARNING(msg)
The simulated network and simulation perfomer.
The car-following model and parameter.
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
marks arrival time and records driven distance
virtual MSTransportableControl & getContainerControl()
Returns the container control.
const SUMOVehicleParameter * myParameter
the plan of the transportable
void removeStage(int next)
removes the nth next stage
std::string getStageSummary() const
return string summary of the current stage
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
SUMOTime myWaitingSince
The time since which this person is waiting for a ride.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
A road/street connecting two junctions.
double myDepartPos
The depart position.
const double myWalkFactor
The factor to apply to walking durations.
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
double getEndLanePosition() const
Returns the end position of this stop.
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
std::vector< MSTransportableDevice * > myDevices
The devices this transportable has.
MSTransportable::Stage * getNextStage(int next) const
Return the current stage.
virtual SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
MSVehicleType * myVType
This transportable's type. (mainly used for drawing related information Note sure if it is really nec...
SUMOTime myArrived
the time at which this stage ended
virtual void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
logs end of the step
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
SUMOTime myDeparted
the time at which this stage started
void setDeparted(SUMOTime now)
logs depart time of the current stage
Representation of a vehicle.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
virtual MSTransportableControl & getPersonControl()
Returns the person control.
A point in 2D or 3D with translation and scaling methods.
SUMOTime getDesiredDepart() const
Returns the desired departure time.
Position getPosition(SUMOTime now) const
returns the position of the transportable
void setVehicle(SUMOVehicle *v)
virtual double getAngle() const
return the current angle of the transportable
virtual void addPerson(MSTransportable *p) const
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
bool hasDeparted() const
return whether the transportable has started it's plan
virtual ~Stage_Trip()
destructor
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
SUMOTime getDeparted() const
get departure time of stage
void removeVType(const MSVehicleType *vehType)
virtual ~MSTransportable()
destructor
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
Abstract in-person device.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
double getArrivalPos() const
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
std::string myVehicleID
cached vehicle data for output after the vehicle has been removed
const std::string & getID() const
returns the id of the transportable
const double mySpeed
The walking speed.
virtual ~Stage_Driving()
destructor
SUMOTime myWaitingUntil
the time until the person is waiting
SUMOVehicle * myVehicle
The taken vehicle.
SUMOVehicleClass myVehicleVClass
Position getPosition(SUMOTime now) const
returns the position of the transportable
std::string getStageSummary(int stageIndex) const
return textual summary for the given stage
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
bool lefthand() const
return whether the network was built for lefthand traffic
vehicle is a passenger car (a "normal" car)
bool addTransportable(MSTransportable *p)
adds a transportable to this stop
std::string line
The vehicle's line (mainly for public transport)
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
virtual double getSpeed() const
the speed of the transportable
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
virtual double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
double getAngle(SUMOTime now) const
returns the angle of the transportable
void rerouteParkingArea(MSStoppingPlace *orig, MSStoppingPlace *replacement)
adapt plan when the vehicle reroutes and now stops at replacement instead of orig ...
double departPos
(optional) The position the vehicle shall depart from
StageType myType
The type of this stage.
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
Structure representing possible vehicle parameter.
MSTransportable(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportablePlan *plan)
constructor
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
void abortWaitingForVehicle(MSTransportable *t)
let the given transportable abort waiting for a vehicle (when removing stage via TraCI) ...
virtual Position getPosition() const
Return the Network coordinate of the transportable.
Stage_Driving(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const std::vector< std::string > &lines, const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
MSTransportableDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
SUMOVehicle * getVehicle() const
Whether the transportable waits for a vehicle.
StageType getStageType() const
double interpolateLanePosToGeometryPos(double lanePos) const
const std::string & getID() const
Returns the name of the vehicle type.
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
const MSEdge * myOrigin
the origin edge
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
double getLength() const
Get vehicle's length [m].
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
const std::string myVTypes
The possible vehicles to use.
const int VEHPARS_VTYPE_SET
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type.
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
virtual double getPositionOnLane() const =0
Get the vehicle's position along the lane.
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setDeparted(SUMOTime now)
logs end of the step
const double myDepartPosLat
The lateral depart position.
const MSEdge * getDestination() const
Returns the current destination.
MSTransportablePlan * myPlan
the plan of the transportable
virtual ~Stage_Waiting()
destructor
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
const MSEdge * myWaitingEdge
The class responsible for building and deletion of vehicles.
const int VEHPARS_DEPARTPOS_SET
SVCPermissions getPermissions() const
virtual ~Stage()
destructor
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
const bool myHaveArrivalPos
whether an arrivalPos was in the input
const MSLane & getLane() const
Returns the lane this stop is located at.
const MSStoppingPlace * myOriginStop
the origin edge
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
const MSEdge * getEdge() const
Returns the current edge.
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
virtual double getSpeed() const =0
Returns the vehicle's current speed.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Representation of a lane in the micro simulation.
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop.
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the person waits for the given vehicle.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
vehicles ignoring classes
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
SUMOTime myWaitingDuration
the time the person is waiting
int getNumStages() const
Return the total number stages in this persons plan.
std::string id
The vehicle's id.
static const Position INVALID
used to indicate that a position is valid
virtual bool stopsAt(MSStoppingPlace *stop) const =0
Returns whether the vehicle stops at the given stopping place.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
double myArrivalPos
the position at which we want to arrive
StageType getCurrentStageType() const
the current stage type of the transportable
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...