50 myWaitingForDepartureNumber(0),
51 myWaitingForVehicleNumber(0),
52 myWaitingUntilNumber(0),
55 myHaveNewWaiting(false) {
59 const std::string model = oc.
getString(
"pedestrian.model");
61 if (model ==
"striping") {
63 }
else if (model ==
"nonInteracting") {
66 throw ProcessError(
"Unknown pedestrian model '" + model +
"'");
100 std::map<std::string, MSTransportable*>::const_iterator i =
myTransportables.find(
id);
111 if (oc.
isSet(
"tripinfo-output")) {
113 }
else if (oc.
getBool(
"duration-log.statistics")) {
118 if (oc.
isSet(
"vehroute-output")) {
119 if (oc.
getBool(
"vehroute-output.sorted")) {
128 const std::map<std::string, MSTransportable*>::iterator i =
myTransportables.find(transportable->
getID());
145 if (std::find(transportables.begin(), transportables.end(), transportable) == transportables.end()) {
158 for (
auto it = transportables.begin(); it != transportables.end();) {
160 it = transportables.erase(it);
162 const bool isPerson = t->
isPerson();
179 for (
int i = 0; i < (int)transportables.size(); ++i) {
181 if (!transportables[i]->proceed(net, time)) {
182 erase(transportables[i]);
208 for (TransportableVector::iterator i = wait.begin(); i != wait.end();) {
209 if ((*i)->isWaitingFor(vehicle)
211 && timeToBoardNextPerson -
DELTA_T <= currentTime
215 if (timeToBoardNextPerson >= 0) {
218 if (timeToBoardNextPerson > currentTime -
DELTA_T) {
219 timeToBoardNextPerson += boardingDuration;
221 timeToBoardNextPerson = currentTime + boardingDuration;
225 static_cast<MSStageDriving*
>((*i)->getCurrentStage())->setVehicle(vehicle);
226 if ((*i)->getCurrentStage()->getOriginStop() !=
nullptr) {
236 if (wait.size() == 0) {
239 if (ret && timeToBoardNextPerson >= 0) {
242 stopDuration =
MAX2(stopDuration, timeToBoardNextPerson - currentTime);
255 for (TransportableVector::iterator i = waitContainers.begin(); i != waitContainers.end();) {
256 if ((*i)->isWaitingFor(vehicle)
258 && timeToLoadNextContainer -
DELTA_T <= currentTime
262 if (timeToLoadNextContainer >= 0) {
267 if (timeToLoadNextContainer > currentTime -
DELTA_T) {
268 timeToLoadNextContainer += loadingDuration;
270 timeToLoadNextContainer = currentTime + loadingDuration;
274 static_cast<MSStageDriving*
>((*i)->getCurrentStage())->setVehicle(vehicle);
275 if ((*i)->getCurrentStage()->getOriginStop() !=
nullptr) {
278 i = waitContainers.erase(i);
285 if (waitContainers.size() == 0) {
288 if (ret && timeToLoadNextContainer >= 0) {
291 stopDuration =
MAX2(stopDuration, timeToLoadNextContainer - currentTime);
334 const MSEdge* edge = (*i).first;
336 std::string transportableType;
339 transportableType =
"Person";
341 transportableType =
"Container";
346 WRITE_WARNING(transportableType +
" '" + p->
getID() +
"' aborted " + waitDescription +
".");
360 auto it2 = std::find(waiting.begin(), waiting.end(), t);
361 if (it2 != waiting.end()) {
371 TransportableVector::iterator it2 = std::find(ts.begin(), ts.end(), t);
372 if (it2 != ts.end()) {
378 TransportableVector::iterator it2 = std::find(ts.begin(), ts.end(), t);
379 if (it2 != ts.end()) {
390 return new MSPerson(pars, vtype, plan, speedFactor);
402 std::ostringstream oss;
407 it.second->saveState(out);
414 std::istringstream iss(state);
#define WRITE_WARNING(msg)
@ SUMO_ATTR_STATE
The state of a link.
static void writeSortedOutput(OutputDevice &routeOut, SUMOTime depart, const std::string &id, const std::string &xmlOutput)
static void registerTransportableDepart(SUMOTime depart)
A road/street connecting two junctions.
virtual void removeContainer(MSTransportable *container) const
Remove container from myContainers.
virtual void removePerson(MSTransportable *p) 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).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
@ 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)
The pedestrian following model.
The pedestrian following model.
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.
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 myWaitingForDepartureNumber
The number of transportables waiting for departure.
void forceDeparture()
register forced (traci) departure
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.
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.
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
int myEndedNumber
The number of transportables that exited the simulation.
std::map< const MSEdge *, TransportableVector > myWaiting4Vehicle
the lists of waiting transportables
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.
bool boardAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle, SUMOTime &timeToBoardNextPerson, SUMOTime &stopDuration)
board any applicable persons Boards any people who wait on that edge for the given vehicle and remove...
std::map< SUMOTime, TransportableVector > myWaiting4Departure
Transportables waiting for departure.
bool loadAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle, SUMOTime &timeToLoadNextContainer, SUMOTime &stopDuration)
load any applicable containers Loads any container that is waiting on that edge for the given vehicle...
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
int getActiveCount()
return the number of active transportable objects
int getRidingNumber() const
Returns the number of transportables riding a vehicle.
SUMOTime getDeparture() const
logs depart time of the current stage
void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
bool isPerson() const
Whether it is a person.
const MSEdge * getEdge() const
Returns the current edge.
MSStage * getCurrentStage() const
Return the current stage.
void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
The car-following model and parameter.
SUMOTime getLoadingDuration() const
Get this vehicle type's loading duration.
SUMOTime getBoardingDuration() const
Get this vehicle type's 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.
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 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 void addTransportable(MSTransportable *transportable)=0
Adds a person or container to this vehicle.
virtual bool isStoppedInRange(const double pos, const double tolerance) const =0
Returns whether the vehicle is stopped in the range of the given position.
virtual bool allowsBoarding(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.