 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
49 bool eagerInsertionCheck,
53 myMaxDepartDelay(maxDepartDelay),
54 myEagerInsertionCheck(eagerInsertionCheck),
55 myMaxVehicleNumber(maxVehicleNumber),
63 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end(); ++i) {
77 const bool loadingFromState = index >= 0;
79 if (loadingFromState) {
87 if (flow.pars->id == pars->
id && flow.pars->repetitionNumber == -1 && flow.pars->repetitionProbability == -1) {
100 flow.
index = loadingFromState ? index : 0;
123 MSVehicleContainer::VehicleVector::const_iterator veh;
126 refusedEmits.push_back(*veh);
128 numEmitted +=
tryInsert(time, *veh, refusedEmits);
153 }
else if (edge.isVaporizing()) {
162 refusedEmits.push_back(veh);
164 edge.setLastFailedInsertionTime(time);
177 MSVehicleContainer::VehicleVector::const_iterator veh;
185 if (dev !=
nullptr) {
197 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end();) {
209 tryEmitByProb =
false;
224 while (--quota > 0) {
243 throw ProcessError(
"Another vehicle with the id '" + newPars->
id +
"' exists.");
286 MSVehicleContainer::VehicleVector::iterator veh;
288 if ((*veh)->getRoute().getID() == route || route ==
"") {
304 const MSLane*
const vlane = veh->getLane();
305 if (vlane !=
nullptr) {
325 if (f.pars->line !=
"") {
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
The car-following model and parameter.
std::vector< Flow > myFlows
Container for periodical vehicle parameters.
SUMOTime myMaxDepartDelay
The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion)
SUMOVehicleParameter * pars
The parameters.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color)
A device that performs vehicle rerouting based on current edge speeds.
bool myEagerInsertionCheck
Whether an edge on which a vehicle could not depart should be ignored in the same step.
Representation of a lane in the micro simulation.
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 pop()
Removes the uppermost vehicle vector.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
Static storage of an output device and its base (abstract) implementation.
int getPendingFlowCount() const
Returns the number of flows that are still active.
MSVehicleContainer::VehicleVector myPendingEmits
Buffers for vehicles that could not be inserted.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
void discountStateLoaded(bool removed=false)
avoid counting a vehicle twice if it was loaded from state and route input
static bool gStateLoaded
Information whether a state has been loaded.
std::string vtypeid
The vehicle's type id.
const int VEHPARS_FORCE_REROUTE
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
SUMOTime myPendingEmitsUpdateTime
Last time at which pending emits for each edge where counted.
Representation of a vehicle.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
MSVehicleControl & myVehicleControl
The assigned vehicle control (needed for vehicle re-insertion and deletion)
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=nullptr)
std::set< SUMOVehicle * > myEmitCandidates
Buffer for vehicles that may be inserted in the current step.
Structure representing possible vehicle parameter.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
std::mt19937 myFlowRNG
A random number generator for probabilistic flows.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
int myMaxVehicleNumber
Storage for maximum vehicle number.
SUMOTime computeRandomDepartOffset() const
compute (optional) random offset to the departure time
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.
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
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.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
MSInsertionControl(MSVehicleControl &vc, SUMOTime maxDepartDelay, bool checkEdgesOnce, int maxVehicleNumber, SUMOTime randomDepartOffset)
Constructor.
void remove(SUMOVehicle *veh)
Removes a single vehicle.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
int index
the running index
void saveState(OutputDevice &out)
Saves the current state into the given stream.
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
std::set< std::string > myFlowIDs
Cache for periodical vehicle ids for quicker checking.
std::string id
The vehicle's id.
std::set< const SUMOVehicle * > myAbortedEmits
Set of vehicles which shall not be inserted anymore.
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
double repetitionProbability
The probability for emitting a vehicle per second.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
void determineCandidates(SUMOTime time)
Checks for all vehicles whether they can be emitted.
std::map< const MSLane *, int > myPendingEmitsForLane
the number of pending emits for each edge in the current time step
int repetitionsDone
The number of times the vehicle was already inserted.
A road/street connecting two junctions.
std::vector< SUMOVehicle * > VehicleVector
definition of a list of vehicles which have the same departure time
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
std::string routeid
The vehicle's route id.
void checkCandidates(SUMOTime time, const bool preCheck)
Adds all vehicles that should have been emitted earlier to the refuse container.
static void initRandGlobal(std::mt19937 *which=0)
Reads the given random number options and initialises the random number generator in accordance.
void skipRouting(const SUMOTime currentTime)
Labels the current time step as "unroutable".
MSEdge & getEdge() const
Returns the lane's edge.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false, const bool forceCheck=false) const
Tries to insert the given vehicle into the network.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
a flow state definition (used when saving and loading simulatino state)
static bool isEnabled()
returns whether any routing actions take place
void clearPendingVehicles(const std::string &route)
clears out all pending vehicles from a route, "" for all routes
static std::mt19937 * getParsingRNG()
get parsing RNG
bool anyWaitingBefore(SUMOTime time) const
Returns the information whether any vehicles want to depart before the given time.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
bool addFlow(SUMOVehicleParameter *const pars, int index=-1)
Adds parameter for a vehicle flow for departure.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
The class responsible for building and deletion of vehicles.
const VehicleVector & top()
Returns the uppermost vehicle vector.
SUMOTime myMaxRandomDepartOffset
The maximum random offset to be added to vehicles departure times (non-negative)
MSVehicleContainer myAllVeh
All loaded vehicles sorted by their departure time.
Network * getNetwork() const
void add(SUMOVehicle *veh)
Adds a single vehicle.
Definition of vehicle flow with the current index for vehicle numbering.
int tryInsert(SUMOTime time, SUMOVehicle *veh, MSVehicleContainer::VehicleVector &refusedEmits)
Tries to emit the vehicle.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
~MSInsertionControl()
Destructor.
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)