53 myTeleportsWrongLane(0),
55 myTotalDepartureDelay(0),
57 myDefaultVTypeMayBeDeleted(true),
58 myDefaultPedTypeMayBeDeleted(true),
59 myDefaultBikeTypeMayBeDeleted(true),
60 myWaitingForPerson(0),
61 myWaitingForContainer(0),
98 const bool ignoreStopErrors,
const bool fromRouteFile) {
114 dev->generateOutput();
157 it->second->getParameter().write(out);
166 (*it).second->saveState(out);
212 if (veh !=
nullptr) {
265 assert(vehType != 0);
279 std::vector<MSVehicleType*> vehTypes = vehTypeDistribution->
getVals();
280 for (
auto vehType : vehTypes) {
313 return it2->second->get(rng);
328 into.push_back((*i).first);
331 into.push_back((*i).first);
336 std::set<std::string>
338 std::map<std::string, std::set<std::string>>::const_iterator it =
myVTypeToDist.find(
id);
340 return std::set<std::string>();
349 myWaiting[edge] = std::vector<SUMOVehicle*>();
358 std::vector<SUMOVehicle*>::iterator it = std::find(
myWaiting[edge].begin(),
myWaiting[edge].end(), vehicle);
370 std::vector<SUMOVehicle*> waitingTooFarAway;
371 for (std::vector<SUMOVehicle*>::const_iterator it =
myWaiting[edge].begin(); it !=
myWaiting[edge].end(); ++it) {
372 const std::string& line = (*it)->
getParameter().
line ==
"" ? (*it)->getParameter().id : (*it)->getParameter().line;
373 double vehiclePosition = (*it)->getPositionOnLane();
376 if (lines.count(line)) {
377 if ((position - 10 <= vehiclePosition) && (vehiclePosition <= position + 10)) {
379 }
else if ((*it)->isStoppedTriggered() ||
382 if ((*it)->isStoppedInRange(position)) {
385 waitingTooFarAway.push_back(*it);
390 for (std::vector<SUMOVehicle*>::iterator it = waitingTooFarAway.begin(); it != waitingTooFarAway.end(); ++it) {
391 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.");
401 WRITE_WARNING(
"Vehicle " + i->first +
" aborted waiting for a person or a container that will never come.");
420 std::pair<double, double>
423 double relSpeedSum = 0;
434 return std::make_pair(speedSum / count, relSpeedSum / count);
436 return std::make_pair(-1, -1);
443 frac = frac < 0 ?
myScale : frac;
444 if (frac < 0 || frac == 1.) {
449 const int base = (int)frac;
450 const int resolution = 1000;
451 const int intFrac = (int)floor((frac - base) * resolution + 0.5);
453 if (((loaded % resolution) * intFrac) % resolution < intFrac) {
The departure is person triggered.
The vehicle has departed (was inserted into the network)
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
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.
int myTeleportsWrongLane
The number of teleports due to vehicles stuck on the wrong lane.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
const ConstMSEdgeVector & getEdges() const
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
int myEndedVehNo
The number of removed vehicles.
static bool teleportOnCollision()
virtual const MSRoute & getRoute() const =0
Returns the current route.
Represents a generic random distribution.
int myDiscarded
The number of vehicles which were discarded while loading.
vehicle is a not electrified rail
The departure is container triggered.
Structure representing possible vehicle parameter.
std::map< const MSEdge *const, std::vector< SUMOVehicle * > > myWaiting
the lists of waiting vehicles to a given edge
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
MSVehicleControl()
Constructor.
weights: time range begin
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
VehicleDictType myVehicleDict
Dictionary of vehicles.
const std::string DEFAULT_BIKETYPE_ID
const std::vector< T > & getVals() const
Returns the members of the distribution.
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.
const std::string & getID() const
Returns the id.
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
bool hasVType(const std::string &id) const
Asks for existence of a vehicle type.
double myMaxSpeedFactor
The maximum speed factor for all vehicles in the network.
const std::string DEFAULT_VTYPE_ID
double getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
void setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime)
Sets the current state variables as loaded from the stream.
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
vehicle is a (possibly fast moving) electric rail
#define WRITE_WARNING(msg)
The car-following model and parameter.
static OptionsCont & getOptions()
Retrieves the options.
static std::mt19937 * getParsingRNG()
virtual std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
A road/street connecting two junctions.
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle's access class.
std::set< std::string > getVTypeDistributionMembership(const std::string &id) const
Return the distribution IDs the vehicle type is a member of.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
The vehicle arrived at his destination (is deleted)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
Representation of a vehicle.
void registerOneWaiting(const bool isPerson)
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
virtual const std::vector< MSVehicleDevice * > & getDevices() const =0
Returns this vehicle's devices.
void removeVType(const MSVehicleType *vehType)
double myTotalTravelTime
The aggregated time vehicles needed to aacomplish their route (in seconds)
SUMOTime depart
The vehicle's departure time.
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
int myLoadedVehNo
The number of build vehicles.
SUMOVehicle * getWaitingVehicle(const MSEdge *const edge, const std::set< std::string > &lines, const double position, const std::string ridingID)
void saveState(OutputDevice &out)
Saves the current state into the given stream.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
int myRunningVehNo
The number of vehicles within the network (build and inserted but not removed)
virtual double getChosenSpeedFactor() const =0
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
vehicle is a passenger car (a "normal" car)
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector...
std::string line
The vehicle's line (mainly for public transport)
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=0)
Returns the named vehicle type or a sample from the named distribution.
int parametersSet
Information for the router which parameter were set.
The vehicle was built, but has not yet departed.
bool addVType(MSVehicleType *vehType)
Adds a vehicle type.
double myTotalDepartureDelay
The aggregated time vehicles had to wait for departure (in seconds)
double departPos
(optional) The position the vehicle shall depart from
trigger: the time of the step
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.
std::map< std::string, std::set< std::string > > myVTypeToDist
Inverse lookup from vehicle type to distributions it is a member of.
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=nullptr)
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
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)
bool addVTypeDistribution(const std::string &id, RandomDistributor< MSVehicleType *> *vehTypeDistribution)
Adds a vehicle type distribution.
const std::string & getID() const
Returns the name of the vehicle type.
Abstract in-vehicle device.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop.
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
double myScale
The scaling factor (especially for inc-dua)
double myMinDeceleration
The minimum deceleration capability for all vehicles in the network.
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
int myTeleportsYield
The number of teleports due to vehicles stuck on a minor road.
const int VTYPEPARS_VEHICLECLASS_SET
distribution of a vehicle type
virtual double getSpeed() const =0
Returns the vehicle's current speed.
int getTeleportCount() const
return the number of teleports (including collisions)
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
virtual const std::string & getID() const =0
Get the vehicle's ID.
vehicles ignoring classes
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Network * getNetwork() const
void removeWaiting(const MSEdge *const edge, const SUMOVehicle *vehicle)
Removes a vehicle from the list of waiting vehicles to a given edge.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
std::vector< SUMOVehicle * > myPTVehicles
List of vehicles which belong to public transport.