54 myWaitingForDepartureNumber(0),
55 myWaitingForVehicleNumber(0),
56 myWaitingUntilNumber(0),
60 myTeleportsAbortWait(0),
61 myTeleportsWrongDest(0),
62 myHaveNewWaiting(false) {
67 const std::string& model = oc.
getString(
"pedestrian.model");
68 if (model ==
"striping") {
71 }
else if (model ==
"jupedsim") {
74 }
else if (model !=
"nonInteracting") {
79 if (oc.
isSet(
"vehroute-output")) {
82 if (oc.
isSet(
"personroute-output")) {
86 if (oc.
isSet(
"personinfo-output")) {
125 auto it = std::find(waiting.begin(), waiting.end(), transportable);
126 if (it != waiting.end()) {
128 if (waiting.size() == 0) {
138 std::map<std::string, MSTransportable*>::const_iterator i =
myTransportables.find(
id);
149 if (oc.
isSet(
"personinfo-output")) {
151 }
else if (oc.
isSet(
"tripinfo-output")) {
153 }
else if (oc.
getBool(
"duration-log.statistics")) {
158 if (oc.
isSet(
"vehroute-output") || oc.
isSet(
"personroute-output")) {
159 if (transportable->
hasArrived() || oc.
getBool(
"vehroute-output.write-unfinished")) {
161 if (transportable->
getBoolParam(
"has.vehroute.person-device",
false,
true)) {
162 if (oc.
getBool(
"vehroute-output.sorted")) {
174 const std::map<std::string, MSTransportable*>::iterator i =
myTransportables.find(transportable->
getID());
176 if (i->second->hasDeparted()) {
203 if (std::find(transportables.begin(), transportables.end(), transportable) == transportables.end()) {
216 for (
auto it = transportables.begin(); it != transportables.end();) {
220 nextStep.insert(nextStep.begin(), transportables.begin(), transportables.end());
221 transportables.clear();
225 it = transportables.erase(it);
228 it = transportables.erase(it);
230 const bool isPerson = t->
isPerson();
237 if (oc.
getBool(
"vehroute-output.sorted")) {
239 if (oc.
isSet(
"personroute-output")) {
257 if (!t->proceed(net, time)) {
287 if (t->isWaitingFor(vehicle)
305 for (TransportableVector::iterator i = transportables.begin(); i != transportables.end();) {
309 && timeToLoadNext -
DELTA_T <= currentTime
316 if (timeToLoadNext >= 0) {
319 if (timeToLoadNext > currentTime -
DELTA_T) {
320 timeToLoadNext += loadingDuration;
322 timeToLoadNext = currentTime + loadingDuration;
330 i = transportables.erase(i);
337 if (transportables.empty()) {
340 if (ret && timeToLoadNext >= 0) {
343 stopDuration =
MAX2(stopDuration, timeToLoadNext - currentTime);
387 const MSEdge* edge = it.first;
392 WRITE_WARNING(p->getObjectType() +
" '" + p->getID() +
"' aborted " + waitDescription +
".");
394 p->setAbortWaiting(-1);
409 auto it2 = std::find(waiting.begin(), waiting.end(), t);
410 if (it2 != waiting.end()) {
412 (*it2)->setAbortWaiting(-1);
424 TransportableVector::iterator it2 = std::find(ts.begin(), ts.end(), t);
425 if (it2 != ts.end()) {
431 TransportableVector::iterator it2 = std::find(ts.begin(), ts.end(), t);
432 if (it2 != ts.end()) {
443 return new MSPerson(pars, vtype, plan, speedFactor);
455 std::ostringstream oss;
460 it.second->saveState(out);
467 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 allCustomersErased()
signal the end of the simulation and the removal of all customers
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.
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
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
void eraseAll()
@removes all transportables
int myLoadedNumber
The number of build transportables.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
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 override
Whether it is a person.
const SUMOVehicleParameter & getParameter() const override
Returns the vehicle's parameter (including departure definition)
const MSVehicleType & getVehicleType() const override
Returns the object's "vehicle" type.
void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
const MSEdge * getEdge() const override
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.
bool hasArrived() const override
return whether the person has reached the end of its plan
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.
bool getBoolParam(const std::string ¶mName, const bool required=false, const bool deflt=false) const
Retrieve a boolean parameter for the traffic object.
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