49 myWaitingForDepartureNumber(0),
50 myWaitingForVehicleNumber(0),
51 myWaitingUntilNumber(0),
54 myHaveNewWaiting(false) {
58 const std::string model = oc.
getString(
"pedestrian.model");
60 if (model ==
"striping") {
62 }
else if (model ==
"nonInteracting") {
65 throw ProcessError(
"Unknown pedestrian model '" + model +
"'");
103 std::map<std::string, MSTransportable*>::const_iterator i =
myTransportables.find(
id);
123 const std::map<std::string, MSTransportable*>::iterator i =
myTransportables.find(transportable->
getID());
138 if (std::find(transportables.begin(), transportables.end(), transportable) == transportables.end()) {
151 for (
int i = 0; i < (int)transportables.size(); ++i) {
153 if (transportables[i]->proceed(net, time)) {
156 erase(transportables[i]);
164 for (
int i = 0; i < (int)transportables.size(); ++i) {
166 if (!transportables[i]->proceed(net, time)) {
167 erase(transportables[i]);
194 for (TransportableVector::iterator i = wait.begin(); i != wait.end();) {
195 if ((*i)->isWaitingFor(vehicle)
197 && timeToBoardNextPerson -
DELTA_T <= currentTime
201 if (timeToBoardNextPerson >= 0) {
204 if (timeToBoardNextPerson > currentTime -
DELTA_T) {
205 timeToBoardNextPerson += boardingDuration;
207 timeToBoardNextPerson = currentTime + boardingDuration;
211 static_cast<MSStageDriving*
>((*i)->getCurrentStage())->setVehicle(vehicle);
212 if ((*i)->getCurrentStage()->getOriginStop() !=
nullptr) {
222 if (wait.size() == 0) {
225 if (ret && timeToBoardNextPerson >= 0) {
228 stopDuration =
MAX2(stopDuration, timeToBoardNextPerson - currentTime);
229 timeToBoardNextPerson -=
DELTA_T;
242 for (TransportableVector::iterator i = waitContainers.begin(); i != waitContainers.end();) {
243 if ((*i)->isWaitingFor(vehicle)
245 && timeToLoadNextContainer -
DELTA_T <= currentTime
246 && stop.
startPos <= (*i)->getEdgePos()
247 && (*i)->getEdgePos() <= stop.
endPos) {
250 if (timeToLoadNextContainer >= 0) {
255 if (timeToLoadNextContainer > currentTime -
DELTA_T) {
256 timeToLoadNextContainer += loadingDuration;
258 timeToLoadNextContainer = currentTime + loadingDuration;
262 static_cast<MSStageDriving*
>((*i)->getCurrentStage())->setVehicle(vehicle);
263 if ((*i)->getCurrentStage()->getOriginStop() !=
nullptr) {
266 i = waitContainers.erase(i);
273 if (waitContainers.size() == 0) {
276 if (ret && timeToLoadNextContainer >= 0) {
279 stopDuration =
MAX2(stopDuration, timeToLoadNextContainer - currentTime);
280 timeToLoadNextContainer -=
DELTA_T;
323 const MSEdge* edge = (*i).first;
325 std::string transportableType;
328 transportableType =
"Person";
330 transportableType =
"Container";
335 WRITE_WARNING(transportableType +
" '" + p->
getID() +
"' aborted " + waitDescription +
".");
349 auto it2 = std::find(waiting.begin(), waiting.end(), t);
350 if (it2 != waiting.end()) {
360 TransportableVector::iterator it2 = std::find(ts.begin(), ts.end(), t);
361 if (it2 != ts.end()) {
367 TransportableVector::iterator it2 = std::find(ts.begin(), ts.end(), t);
368 if (it2 != ts.end()) {
377 std::mt19937* rng)
const {
379 return new MSPerson(pars, vtype, plan, speedFactor);
391 std::ostringstream oss;
396 it.second->saveState(out);
403 std::istringstream iss(state);
#define WRITE_WARNING(msg)
@ SUMO_ATTR_STATE
The state of a link.
#define UNUSED_PARAMETER(x)
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.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
The pedestrian following model.
The pedestrian following model.
virtual int getActiveNumber()=0
return the number of active objects
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(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.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
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.
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.
bool loadAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToLoadNextContainer, SUMOTime &stopDuration)
load any applicable containers Loads any container that is waiting on that edge for the given vehicle...
std::map< const MSEdge *, TransportableVector > myWaiting4Vehicle
the lists of waiting transportables
int myWaitingUntilNumber
The number of transportables waiting for a specified time.
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.
std::map< SUMOTime, TransportableVector > myWaiting4Departure
Transportables waiting for departure.
bool boardAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToBoardNextPerson, SUMOTime &stopDuration)
board any applicable persons Boards any people who wait on that edge for the given vehicle and remove...
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.
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)
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.
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
SUMOTime getBoardingDuration() const
Get this vehicle type's boarding duration.
int getContainerCapacity() const
Get this vehicle type's container capacity.
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static OptionsCont & getOptions()
Retrieves the options.
An output device that encapsulates an ofstream.
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 int getContainerNumber() const =0
Returns the number of containers.
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
Definition of vehicle stop (position and duration)
double startPos
The stopping position start.
double endPos
The stopping position end.
Structure representing possible vehicle parameter.
std::string id
The vehicle's id.