54 bool eagerInsertionCheck,
55 int maxVehicleNumber) :
57 myMaxDepartDelay(maxDepartDelay),
58 myEagerInsertionCheck(eagerInsertionCheck),
59 myMaxVehicleNumber(maxVehicleNumber),
65 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end(); ++i) {
106 MSVehicleContainer::VehicleVector::const_iterator veh;
109 refusedEmits.push_back(*veh);
111 numEmitted +=
tryInsert(time, *veh, refusedEmits);
136 }
else if (edge.isVaporizing()) {
145 refusedEmits.push_back(veh);
147 edge.setLastFailedInsertionTime(time);
160 MSVehicleContainer::VehicleVector::const_iterator veh;
180 for (std::vector<Flow>::iterator i =
myFlows.begin(); i !=
myFlows.end();) {
192 tryEmitByProb =
false;
207 while (--quota > 0) {
225 throw ProcessError(
"Another vehicle with the id '" + newPars->
id +
"' exists.");
268 MSVehicleContainer::VehicleVector::iterator veh;
270 if ((*veh)->getRoute().getID() == route || route ==
"") {
286 const MSLane* lane = (*veh)->getLane();
292 const MSEdge* edge = (*veh)->getEdge();
293 const std::vector<MSLane*>& lanes = edge->
getLanes();
294 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
309 if (f.pars->line !=
"") {
311 const std::vector<SUMOVehicleParameter::Stop>* addStops = 0;
std::map< const MSLane *, int > myPendingEmitsForLane
the number of pending emits for each edge in the current time step
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
void discountStateLoaded(bool removed=false)
avoid counting a vehicle twice if it was loaded from state and route input
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false, const bool forceCheck=false) const
Tries to insert the given vehicle into the network.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
void remove(SUMOVehicle *veh)
Removes a single vehicle.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::string vtypeid
The vehicle's type id.
void checkCandidates(SUMOTime time, const bool preCheck)
Adds all vehicles that should have been emitted earlier to the refuse container.
Definition of vehicle flow with the current index for vehicle numbering.
double repetitionProbability
The probability for emitting a vehicle per second.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
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.
static bool gStateLoaded
Information whether a state has been loaded.
A device that performs vehicle rerouting based on current edge speeds.
int repetitionsDone
The number of times the vehicle was already inserted.
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
MSVehicleContainer myAllVeh
All loaded vehicles sorted by their departure time.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
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.
void skipRouting(const SUMOTime currentTime)
Labels the current time step as "unroutable".
~MSInsertionControl()
Destructor.
bool anyWaitingBefore(SUMOTime time) const
Returns the information whether any vehicles want to depart before the given time.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
The car-following model and parameter.
static std::mt19937 * getParsingRNG()
std::vector< SUMOVehicle * > VehicleVector
definition of a list of vehicles which have the same departure time
MSInsertionControl(MSVehicleControl &vc, SUMOTime maxDepartDelay, bool checkEdgesOnce, int maxVehicleNumber)
Constructor.
A road/street connecting two junctions.
void pop()
Removes the uppermost vehicle vector.
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=0)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::string routeid
The vehicle's route id.
Representation of a vehicle.
int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
MSVehicleContainer::VehicleVector myPendingEmits
Buffers for vehicles that could not be inserted.
int tryInsert(SUMOTime time, SUMOVehicle *veh, MSVehicleContainer::VehicleVector &refusedEmits)
Tries to emit the vehicle.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
bool myEagerInsertionCheck
Whether an edge on which a vehicle could not depart should be ignored in the same step...
SUMOTime depart
The vehicle's departure time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
SUMOTime myMaxDepartDelay
The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion)
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
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.
static bool isEnabled()
returns whether any routing actions take place
SUMOTime myPendingEmitsUpdateTime
Last time at which pending emits for each edge where counted.
const VehicleVector & top()
Returns the uppermost vehicle vector.
std::vector< Flow > myFlows
Container for periodical vehicle parameters.
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
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 myMaxVehicleNumber
Storage for maximum vehicle number.
Structure representing possible vehicle parameter.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
int getPendingFlowCount() const
Returns the number of flows that are still active.
MSVehicleControl & myVehicleControl
The assigned vehicle control (needed for vehicle re-insertion and deletion)
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.
int index
the running index
SUMOVehicleParameter * pars
The parameters.
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 add(SUMOVehicle *veh)
Adds a single vehicle for departure.
Representation of a lane in the micro simulation.
std::set< const SUMOVehicle * > myAbortedEmits
Set of vehicles which shall not be inserted anymore.
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.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
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.