53 myWaitingForDepartureNumber(0),
54 myWaitingForVehicleNumber(0),
55 myWaitingUntilNumber(0),
59 myTeleportsAbortWait(0),
60 myTeleportsWrongDest(0),
61 myHaveNewWaiting(false) {
66 const std::string& model = oc.
getString(
"pedestrian.model");
67 if (model ==
"striping") {
70 }
else if (model ==
"jupedsim") {
73 }
else if (model !=
"nonInteracting") {
78 if (oc.
isSet(
"vehroute-output")) {
81 if (oc.
isSet(
"personroute-output")) {
85 if (oc.
isSet(
"personinfo-output")) {
124 auto it = std::find(waiting.begin(), waiting.end(), transportable);
125 if (it != waiting.end()) {
127 if (waiting.size() == 0) {
137 std::map<std::string, MSTransportable*>::const_iterator i =
myTransportables.find(
id);
148 if (oc.
isSet(
"personinfo-output")) {
150 }
else if (oc.
isSet(
"tripinfo-output")) {
152 }
else if (oc.
getBool(
"duration-log.statistics")) {
157 if (oc.
isSet(
"vehroute-output") || oc.
isSet(
"personroute-output")) {
158 if (transportable->
hasArrived() || oc.
getBool(
"vehroute-output.write-unfinished")) {
159 if (oc.
getBool(
"vehroute-output.sorted")) {
170 const std::map<std::string, MSTransportable*>::iterator i =
myTransportables.find(transportable->
getID());
187 if (std::find(transportables.begin(), transportables.end(), transportable) == transportables.end()) {
200 for (
auto it = transportables.begin(); it != transportables.end();) {
204 nextStep.insert(nextStep.begin(), transportables.begin(), transportables.end());
205 transportables.clear();
208 it = transportables.erase(it);
210 const bool isPerson = t->
isPerson();
217 if (oc.
getBool(
"vehroute-output.sorted")) {
219 if (oc.
isSet(
"personroute-output")) {
237 if (!t->proceed(net, time)) {
267 if (t->isWaitingFor(vehicle)
285 for (TransportableVector::iterator i = transportables.begin(); i != transportables.end();) {
289 && timeToLoadNext -
DELTA_T <= currentTime
296 if (timeToLoadNext >= 0) {
299 if (timeToLoadNext > currentTime -
DELTA_T) {
300 timeToLoadNext += loadingDuration;
302 timeToLoadNext = currentTime + loadingDuration;
310 i = transportables.erase(i);
317 if (transportables.empty()) {
320 if (ret && timeToLoadNext >= 0) {
323 stopDuration =
MAX2(stopDuration, timeToLoadNext - currentTime);
367 const MSEdge* edge = it.first;
372 WRITE_WARNING(p->getObjectType() +
" '" + p->getID() +
"' aborted " + waitDescription +
".");
374 p->setAbortWaiting(-1);
389 auto it2 = std::find(waiting.begin(), waiting.end(), t);
390 if (it2 != waiting.end()) {
392 (*it2)->setAbortWaiting(-1);
403 TransportableVector::iterator it2 = std::find(ts.begin(), ts.end(), t);
404 if (it2 != ts.end()) {
410 TransportableVector::iterator it2 = std::find(ts.begin(), ts.end(), t);
411 if (it2 != ts.end()) {
422 return new MSPerson(pars, vtype, plan, speedFactor);
434 std::ostringstream oss;
439 it.second->saveState(out);
446 std::istringstream iss(state);
#define WRITE_WARNING(msg)
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
@ SUMO_ATTR_STATE
The state of a link.
static void writeSortedOutput(SortedRouteInfo *routeInfo, SUMOTime depart, const std::string &id, const std::string &xmlOutput)
static void registerTransportableDepart(SUMOTime depart)
A road/street connecting two junctions.
virtual void removeTransportable(MSTransportable *t) const
static double gStopTolerance
The tolerance to apply when matching waiting persons and vehicles.
The simulated network and simulation perfomer.
void informTransportableStateListener(const MSTransportable *const transportable, TransportableState to, const std::string &info="")
Informs all added listeners about a transportable's state change.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
@ CONTAINER_DEPARTED
The transportable container has departed (was inserted into the network)
@ PERSON_DEPARTED
The transportable person has departed (was inserted into the network)
@ PERSON_ARRIVED
The transportable person arrived at his destination (is deleted)
@ CONTAINER_ARRIVED
The transportable container arrived at his destination (is deleted)
A pedestrian following model that acts as a proxy for pedestrian models provided by the JuPedSim thir...
The pedestrian following model.
The pedestrian movement model using stripes on sidewalks.
virtual int getActiveNumber()=0
return the number of active objects
virtual void clearState()=0
Resets pedestrians when quick-loading state.
std::string getWaitingDescription() const
Return where the person waits and for what.
virtual MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
void removeTransportable(const MSTransportable *p)
Removes a transportable from this stop.
void loadState(const std::string &state)
Reconstruct the current state.
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
int getDepartedNumber() const
bool hasTransportables() const
checks whether any transportable waits to finish her plan
int myAccessNumber
The number of transportables currently in an access stage.
int myWaitingForDepartureNumber
The number of transportables waiting for departure.
void forceDeparture()
register forced (traci) departure
void fixLoadCount(const MSTransportable *transportable)
decrement counter to avoid double counting transportables loaded from state
void checkWaiting(MSNet *net, const SUMOTime time)
checks whether any transportables waiting time is over
MSPModel * myMovementModel
void saveState(OutputDevice &out)
Saves the current state into the given stream.
MSTransportableControl(const bool isPerson)
Constructor.
bool hasAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle) const
check whether any transportables are waiting for the given vehicle
int myLoadedNumber
The number of build transportables.
std::map< std::string, MSTransportable * > myTransportables
all currently created transportables by id
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
void abortWaitingForVehicle(MSTransportable *t)
let the given transportable abort waiting for a vehicle (when removing stage via TraCI)
void abortAnyWaitingForVehicle()
aborts the plan for any transportable that is still waiting for a ride
bool hasNonWaiting() const
checks whether any transportable is still engaged in walking / stopping
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
int myArrivedNumber
The number of transportables that arrived at their destination.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, SumoRNG *rng) const
Builds a new person.
std::map< const MSEdge *, TransportableVector, ComparatorNumericalIdLess > myWaiting4Vehicle
the lists of waiting transportables
int getMovingNumber() const
Returns the number of transportables moving by themselvs (i.e. walking)
void addWaiting(const MSEdge *edge, MSTransportable *person)
adds a transportable to the list of transportables waiting for a vehicle on the specified edge
SUMOTime myAbortWaitingTimeout
The time until waiting for a ride is aborted.
int myEndedNumber
The number of transportables that exited the simulation.
int myWaitingUntilNumber
The number of transportables waiting for a specified time.
void clearState()
Resets transportables when quick-loading state.
virtual void erase(MSTransportable *transportable)
removes a single transportable
int myDiscardedNumber
The number of discarded transportables.
std::map< SUMOTime, TransportableVector > myWaitingUntil
the lists of walking / stopping transportables
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occurred.
bool myHaveNewWaiting
whether a new transportable waiting for a vehicle has been added in the last step
virtual ~MSTransportableControl()
Destructor.
int myJammedNumber
The number of jammed transportables.
int myMaxTransportableNumber
maximum transportable count
std::map< SUMOTime, TransportableVector > myWaiting4Departure
Transportables waiting for departure.
bool loadAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle, SUMOTime &timeToLoadNext, SUMOTime &stopDuration, MSTransportable *const force=nullptr)
load any applicable transportables Loads any person / container that is waiting on that edge for the ...
std::vector< MSTransportable * > TransportableVector
Definition of a list of transportables.
int myRunningNumber
The number of transportables within the network (build and inserted but not removed)
int myWaitingForVehicleNumber
The number of transportables waiting for vehicles.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
MSPModel * myNonInteractingModel
MSDevice_Vehroutes::SortedRouteInfo myRouteInfos
Information needed to sort transportable output by departure time.
int getActiveCount()
return the number of active transportable objects
int getRidingNumber() const
Returns the number of transportables riding a vehicle.
virtual double getEdgePos() const
Return the position on the edge.
bool hasDeparted() const
return whether the transportable has started its plan
SUMOTime getDeparture() const
logs depart time of the current stage
void setAbortWaiting(const SUMOTime timeout)
void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
MSStage * getCurrentStage() const
Return the current stage.
void setDeparted(SUMOTime now)
logs depart time of the current stage
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
bool isPerson() const
Whether it is a person.
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
bool hasArrived() const
return whether the person has reached the end of its plan
void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
const MSEdge * getEdge() const
Returns the current edge.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle in the current step.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
The car-following model and parameter.
SUMOTime getLoadingDuration(const bool isPerson) const
Get this vehicle type's loading duration.
double getBoardingFactor() const
Get this person type's factor for loading/boarding duration.
double computeChosenSpeedDeviation(SumoRNG *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
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.
An output device that encapsulates an ofstream.
std::string getString() const
Returns the current content as a string.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
Representation of a vehicle.
virtual bool isStoppedInRange(const double pos, const double tolerance, bool checkFuture=false) const =0
Returns whether the vehicle is stopped in the range of the given position.
virtual void addTransportable(MSTransportable *transportable)=0
Adds a person or container to this vehicle.
virtual bool allowsBoarding(const MSTransportable *t) const =0
whether the given transportable is allowed to board this vehicle
Structure representing possible vehicle parameter.
std::string id
The vehicle's id.
std::map< const SUMOTime, int > departureCounts
Map needed to sort vehicles by departure time.
OutputDevice * routeOut
route output device