47 #ifdef CHECK_MEMORY_LEAKS 49 #endif // CHECK_MEMORY_LEAKS 63 myTeleportsWrongLane(0),
65 myTotalDepartureDelay(0),
67 myDefaultVTypeMayBeDeleted(true),
68 myDefaultPedTypeMayBeDeleted(true),
69 myWaitingForPerson(0),
70 myWaitingForContainer(0),
80 if (oc.
isSet(
"scale")) {
119 const bool ignoreStopErrors,
const bool fromRouteFile) {
137 for (std::vector<MSDevice*>::const_iterator i = veh->
getDevices().begin(); i != veh->
getDevices().end(); ++i) {
138 (*i)->generateOutput();
178 it->second->getParameter().write(out);
187 (*it).second->saveState(out);
287 return it2->second->get(rng);
302 into.push_back((*i).first);
305 into.push_back((*i).first);
313 myWaiting[edge] = std::vector<SUMOVehicle*>();
322 std::vector<SUMOVehicle*>::iterator it = std::find(
myWaiting[edge].begin(),
myWaiting[edge].end(), vehicle);
334 std::vector<SUMOVehicle*> waitingTooFarAway;
335 for (std::vector<SUMOVehicle*>::const_iterator it =
myWaiting[edge].begin(); it !=
myWaiting[edge].end(); ++it) {
336 const std::string& line = (*it)->
getParameter().
line ==
"" ? (*it)->getParameter().id : (*it)->getParameter().line;
337 SUMOReal vehiclePosition = (*it)->getPositionOnLane();
340 if (lines.count(line)) {
341 if ((position - 10 <= vehiclePosition) && (vehiclePosition <= position + 10)) {
343 }
else if ((*it)->isStoppedTriggered() ||
350 waitingTooFarAway.push_back(*it);
355 for (std::vector<SUMOVehicle*>::iterator it = waitingTooFarAway.begin(); it != waitingTooFarAway.end(); ++it) {
356 WRITE_WARNING(ridingID +
" at edge '" + edge->
getID() +
"' position " +
toString(position) +
" cannot use waiting vehicle '" + (*it)->getID() +
"' at position " +
toString((*it)->getPositionOnLane()) +
" because it is too far away.");
366 WRITE_WARNING(
"Vehicle " + i->first +
" aborted waiting for a person or a container that will never come.");
373 frac = frac < 0 ?
myScale : frac;
374 if (frac < 0 || frac == 1.) {
379 const int base = (int)frac;
380 const int resolution = 1000;
381 const int intFrac = (int)floor((frac - base) * resolution + 0.5);
383 if (((loaded % resolution) * intFrac) % resolution < intFrac) {
The departure is person triggered.
The vehicle has departed (was inserted into the network)
bool myDefaultPedTypeMayBeDeleted
Whether no pedestrian type was loaded.
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
SUMOReal myMaxSpeedFactor
The maximum speed factor for all vehicles in the network.
int getTeleportCount() const
return the number of teleports (including collisions)
bool addVTypeDistribution(const std::string &id, RandomDistributor< MSVehicleType * > *vehTypeDistribution)
Adds a vehicle type distribution.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Adds a vehicle to the list of waiting vehiclse to a given edge.
Representation of a vehicle in the micro simulation.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
SUMOReal myTotalDepartureDelay
The aggregated time vehicles had to wait for departure (in seconds)
int myTeleportsWrongLane
The number of teleports due to vehicles stuck on the wrong lane.
SUMOReal myMinDeceleration
The minimum deceleration capability for all vehicles in the network.
int myEndedVehNo
The number of removed vehicles.
int getQuota(SUMOReal frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
static bool teleportOnCollision()
SUMOReal myTotalTravelTime
The aggregated time vehicles needed to aacomplish their route (in seconds)
int myDiscarded
The number of vehicles which were discarded while loading.
Structure representing possible vehicle parameter.
std::map< const MSEdge *const, std::vector< SUMOVehicle * > > myWaiting
the lists of waiting vehicles to a given edge
static MTRand * getParsingRNG()
MSVehicleControl()
Constructor.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
VehicleDictType myVehicleDict
Dictionary of vehicles.
SUMOReal computeChosenSpeedDeviation(MTRand *rng, const SUMOReal minDevFactor=0.2) const
Computes and returns the speed deviation.
SUMOVehicle * getWaitingVehicle(const MSEdge *const edge, const std::set< std::string > &lines, const SUMOReal position, const std::string ridingID)
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
VTypeDictType myVTypeDict
Dictionary of vehicle types.
int myTeleportsJam
The number of teleports due to jam.
void removeWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Removes a vehicle from the list of waiting vehicles to a given edge.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector...
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type was loaded.
const std::string DEFAULT_VTYPE_ID
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
#define WRITE_WARNING(msg)
The car-following model and parameter.
static OptionsCont & getOptions()
Retrieves the options.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
virtual SUMOReal getChosenSpeedFactor() const =0
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
virtual const std::vector< MSDevice * > & getDevices() const =0
Returns this vehicle's devices.
The vehicle arrived at his destination (is deleted)
SUMOTime computeRandomDepartOffset() const
compute (optional) random offset to the departure time
Representation of a vehicle.
SUMOReal myScale
The scaling factor (especially for inc-dua)
bool isStoppedInRange(SUMOReal pos) const
return whether the given position is within range of the current stop
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
SUMOTime depart
The vehicle's departure time.
int myLoadedVehNo
The number of build vehicles.
SUMOTime string2time(const std::string &r)
SUMOTime myMaxRandomDepartOffset
The maximum random offset to be added to vehicles departure times (non-negative)
void saveState(OutputDevice &out)
Saves the current state into the given stream.
void setState(int runningVehNo, int loadedVehNo, int endedVehNo, SUMOReal totalDepartureDelay, SUMOReal totalTravelTime)
Sets the current state variables as loaded from the stream.
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
int myRunningVehNo
The number of vehicles within the network (build and inserted but not removed)
vehicle is a passenger car (a "normal" car)
std::string line
The vehicle's line (mainly for public transport)
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
The vehicle was built, but has not yet departed.
bool addVType(MSVehicleType *vehType)
Adds a vehicle type.
int setParameter
Information for the router which parameter were set.
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
void scheduleVehicleRemoval(SUMOVehicle *veh)
Removes a vehicle after it has ended.
Structure representing possible vehicle parameter.
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
int myCollisions
The number of collisions.
const std::string DEFAULT_PEDTYPE_ID
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual ~MSVehicleControl()
Destructor.
A storage for options typed value containers)
const std::string & getID() const
Returns the name of the vehicle type.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to)
Informs all added listeners about a vehicle's state change.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
int myTeleportsYield
The number of teleports due to vehicles stuck on a minor road.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, MTRand *rng=0)
Returns the named vehicle type or a sample from the named distribution.
const int VTYPEPARS_VEHICLECLASS_SET
virtual const std::string & getID() const =0
Get the vehicle's ID.
vehicles ignoring classes
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.