 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
57 myTeleportsWrongLane(0),
59 myTotalDepartureDelay(0),
61 myDefaultVTypeMayBeDeleted(true),
62 myDefaultPedTypeMayBeDeleted(true),
63 myDefaultBikeTypeMayBeDeleted(true),
64 myWaitingForPerson(0),
65 myWaitingForContainer(0),
68 myPendingRemovals(
MSGlobals::gNumSimThreads > 1) {
105 const bool ignoreStopErrors,
const bool fromRouteFile) {
117 if (!checkDuplicate ||
143 dev->generateOutput();
145 if (tripinfoOut !=
nullptr) {
152 if (tripinfoOut !=
nullptr) {
154 tripinfoOut->
flush();
195 it->second->getParameter().write(out);
204 (*it).second->saveState(out);
250 if (veh !=
nullptr) {
307 assert(vehType != 0);
321 std::vector<MSVehicleType*> vehTypes = vehTypeDistribution->
getVals();
322 for (
auto vehType : vehTypes) {
355 return it2->second->get(rng);
370 into.push_back((*i).first);
373 into.push_back((*i).first);
378 const std::set<std::string>
380 std::map<std::string, std::set<std::string>>::const_iterator it =
myVTypeToDist.find(
id);
382 return std::set<std::string>();
391 myWaiting[edge] = std::vector<SUMOVehicle*>();
400 std::vector<SUMOVehicle*>::iterator it = std::find(
myWaiting[edge].begin(),
myWaiting[edge].end(), vehicle);
414 (!vehicle->hasDeparted() &&
420 WRITE_WARNING(transportable->
getID() +
" at edge '" + edge->getID() +
"' position " +
toString(position) +
" cannot use waiting vehicle '"
421 + vehicle->getID() +
"' at position " +
toString(vehicle->getPositionOnLane()) +
" because it is too far away.");
432 WRITE_WARNING(
"Vehicle " + i->first +
" aborted waiting for a person or a container that will never come.");
451 std::pair<double, double>
454 double relSpeedSum = 0;
465 return std::make_pair(speedSum / count, relSpeedSum / count);
467 return std::make_pair(-1, -1);
474 frac = frac < 0 ?
myScale : frac;
475 if (frac < 0 || frac == 1.) {
480 const int base = (int)frac;
481 const int resolution = 1000;
482 const int intFrac = (int)floor((frac - base) * resolution + 0.5);
484 if (((loaded % resolution) * intFrac) % resolution < intFrac) {
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
The car-following model and parameter.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
const std::string & getID() const
Returns the name of the vehicle type.
void registerOneWaiting(const bool isPerson)
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
static bool teleportOnCollision()
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
The vehicle has departed (was inserted into the network)
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
#define WRITE_WARNING(msg)
const std::string DEFAULT_PEDTYPE_ID
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
void removeVType(const MSVehicleType *vehType)
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
Static storage of an output device and its base (abstract) implementation.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
virtual ~MSVehicleControl()
Destructor.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
virtual const std::string & getID() const =0
Get the vehicle's ID.
void removeWaiting(const MSEdge *const edge, const SUMOVehicle *vehicle)
Removes a vehicle from the list of waiting vehicles for the given edge.
double myTotalTravelTime
The aggregated time vehicles needed to aacomplish their route (in seconds)
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
int myDiscarded
The number of vehicles which were discarded while loading.
Representation of a vehicle.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle's access class.
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=nullptr)
static OptionsCont & getOptions()
Retrieves the options.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
bool addVTypeDistribution(const std::string &id, RandomDistributor< MSVehicleType * > *vehTypeDistribution)
Adds a vehicle type distribution.
const ConstMSEdgeVector & getEdges() const
classes which (normally) do not drive on normal roads
Structure representing possible vehicle parameter.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
The vehicle arrived at his destination (is deleted)
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Adds a vehicle to the list of waiting vehicles for the given edge.
VTypeDictType myVTypeDict
Dictionary of vehicle types.
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
weights: time range begin
int myLoadedVehNo
The number of build vehicles.
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
virtual double getChosenSpeedFactor() const =0
std::map< std::string, std::set< std::string > > myVTypeToDist
Inverse lookup from vehicle type to distributions it is a member of.
int parametersSet
Information for the router which parameter were set.
std::string line
The vehicle's line (mainly for public transport)
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.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual const MSRoute & getRoute() const =0
Returns the current route.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
double myMaxSpeedFactor
The maximum speed factor for all vehicles in the network.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
void setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime)
Sets the current state variables as loaded from the stream.
const 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)
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
int myRunningVehNo
The number of vehicles within the network (build and inserted but not removed)
Structure representing possible vehicle parameter.
bool addVType(MSVehicleType *vehType)
Adds a vehicle type.
const std::string DEFAULT_VTYPE_ID
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
VehicleDictType myVehicleDict
Dictionary of vehicles.
vehicle is a passenger car (a "normal" car)
int myTeleportsJam
The number of teleports due to jam.
double myStopTolerance
The tolerance to apply when matching waiting persons and vehicles.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
The vehicle was built, but has not yet departed.
std::map< const MSEdge *const, std::vector< SUMOVehicle * > > myWaiting
the lists of waiting vehicles to a given edge
A storage for options typed value containers)
A road/street connecting two junctions.
The departure is person triggered.
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
double myTotalDepartureDelay
The aggregated time vehicles had to wait for departure (in seconds)
trigger: the time of the step
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle in the current step.
std::vector< SUMOVehicle * > myPTVehicles
List of vehicles which belong to public transport.
double myScale
The scaling factor (especially for inc-dua)
int myTeleportsYield
The number of teleports due to vehicles stuck on a minor road.
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
void removePending()
Removes a vehicle after it has ended.
double myMinDeceleration
The minimum deceleration capability for all vehicles in the network.
MSVehicleControl()
Constructor.
static std::mt19937 * getParsingRNG()
get parsing RNG
int myCollisions
The number of collisions.
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
const std::string & getID() const
returns the id of the transportable
Function-object for stable sorting of objects with numerical ids.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
virtual std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
int myTeleportsWrongLane
The number of teleports due to vehicles stuck on the wrong lane.
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
std::vector< SUMOVehicle * > myPendingRemovals
List of vehicles which are going to be removed.
bool hasVType(const std::string &id) const
Asks for existence of a vehicle type.
SUMOVehicle * getWaitingVehicle(MSTransportable *transportable, const MSEdge *const edge, const double position)
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
int getTeleportCount() const
return the number of teleports (including collisions)
The departure is container triggered.
Network * getNetwork() const
int myEndedVehNo
The number of removed vehicles.
vehicles ignoring classes
const std::string DEFAULT_BIKETYPE_ID
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
distribution of a vehicle type
double departPos
(optional) The position the vehicle shall depart from
const std::vector< T > & getVals() const
Returns the members of the distribution.
const int VTYPEPARS_VEHICLECLASS_SET
virtual double getSpeed() const =0
Returns the vehicle's current speed.
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop.
Representation of a vehicle in the micro simulation.
Abstract in-vehicle device.