47 #ifdef CHECK_MEMORY_LEAKS
49 #endif // CHECK_MEMORY_LEAKS
58 : myVehicleControl(vc), myMaxDepartDelay(maxDepartDelay),
59 myCheckEdgesOnce(checkEdgesOnce) {}
63 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end(); ++i) {
89 const std::vector<const MSRoute*>& routes = dist->
getVals();
91 for (std::vector<const MSRoute*>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
93 e = (*i)->getEdges()[0];
95 if (e != (*i)->getEdges()[0]) {
117 unsigned int numEmitted = 0;
125 MSVehicleContainer::VehicleVector::const_iterator veh;
128 refusedEmits.push_back(*veh);
130 numEmitted +=
tryInsert(time, *veh, refusedEmits);
144 if ((!
myCheckEdgesOnce || edge.getLastFailedInsertionTime() != time) && edge.insertVehicle(*veh, time)) {
154 }
else if (edge.isVaporizing()) {
165 refusedEmits.push_back(veh);
167 edge.setLastFailedInsertionTime(time);
174 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end(); ++i) {
175 if (i->vehicle == veh) {
191 MSVehicleContainer::VehicleVector::const_iterator veh;
211 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end();) {
228 tryEmitByProb =
false;
237 i->vehicle = vehControl.
buildVehicle(newPars, route, vtype,
false);
238 unsigned int quota = vehControl.
getQuota();
243 while (--quota > 0) {
247 i->vehicle = vehControl.
buildVehicle(quotaPars, route, vtype,
false);
261 throw ProcessError(
"Another vehicle with the id '" + newPars->
id +
"' exists.");
296 MSVehicleContainer::VehicleVector::iterator veh;
298 if ((*veh)->getRoute().getID() == route || route ==
"") {
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
SUMOReal repetitionProbability
The probability for emitting a vehicle per second.
int getPendingFlowCount() const
Returns the number of flows that are still active.
void checkFlowWait(SUMOVehicle *veh)
Checks whether any flow is blocked due to this vehicle and clears the block.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false) const
Tries to insert the given vehicle into the network.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::set< SUMOVehicle * > myAbortedEmits
Set of vehicles which shall not be inserted anymore.
std::string vtypeid
The vehicle's type id.
virtual void onDepart()=0
Called when the vehicle is inserted into the network.
void checkCandidates(SUMOTime time, const bool preCheck)
Adds all vehicles that should have been emitted earlier to the refuse container.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
static MTRand * getParsingRNG()
static bool gStateLoaded
Information whether a state has been loaded.
static SUMOReal rand()
Returns a random real number in [0, 1)
A device that performs vehicle rerouting based on current edge speeds.
int repetitionsDone
The number of times the vehicle was already inserted.
SUMOVehicle * vehicle
The last created vehicle.
unsigned int index
the running index
MSVehicleContainer myAllVeh
All loaded vehicles sorted by their departure time.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
The lane is chosen randomly.
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
void skipRouting(const SUMOTime currentTime)
Labels the current time step as "unroutable".
SUMOReal repetitionOffset
The time offset between vehicle reinsertions.
The position is chosen randomly.
~MSInsertionControl()
Destructor.
The car-following model and parameter.
const std::vector< T > & getVals() const
Returns the members of the distribution.
std::vector< SUMOVehicle * > VehicleVector
definition of a list of vehicles which have the same departure time
A road/street connecting two junctions.
void pop()
Removes the uppermost vehicle vector.
unsigned int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
std::string routeid
The vehicle's route id.
Representation of a vehicle.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
bool myCheckEdgesOnce
Whether an edge on which a vehicle could not depart should be ignored in the same step...
MSVehicleContainer::VehicleVector myPendingEmits
Buffers for vehicles that could not be inserted.
unsigned int tryInsert(SUMOTime time, SUMOVehicle *veh, MSVehicleContainer::VehicleVector &refusedEmits)
Tries to emit the vehicle.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
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.
SUMOTime myMaxDepartDelay
The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion)
void clearPendingVehicles(std::string &route)
clears out all pending vehicles from a route, "" for all routes
std::set< SUMOVehicle * > myEmitCandidates
Buffer for vehicles that may be inserted in the current step.
void add(SUMOVehicle *veh)
Adds a single vehicle.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
static bool isEnabled()
returns whether any routing actions take place
const VehicleVector & top()
Returns the uppermost vehicle vector.
bool isVolatile
whether it has route or vehicle type distribution
std::vector< Flow > myFlows
Container for periodical vehicle parameters.
Structure representing possible vehicle parameter.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
MSVehicleControl & myVehicleControl
The assigned vehicle control (needed for vehicle re-insertion and deletion)
MSInsertionControl(MSVehicleControl &vc, SUMOTime maxDepartDelay, bool checkEdgesOnce)
Constructor.
unsigned int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
SUMOTime getLastFailedInsertionTime() const
Returns the last time a vehicle could not be inserted.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
bool anyWaitingBefore(SUMOTime time) const
Returns the information whether any vehicles want to depart before the given time.
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
The class responsible for building and deletion of vehicles.
SUMOVehicleParameter * pars
The paramters.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, MTRand *rng=0)
Returns the named vehicle type or a sample from the named distribution.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
std::set< std::string > myFlowIDs
Cache for periodical vehicle ids for quicker checking.
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
unsigned int getQuota(SUMOReal frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
void determineCandidates(SUMOTime time)
Checks for all vehicles whether they can be emitted.
std::string id
The vehicle's id.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.