SUMO - Simulation of Urban MObility
MSInsertionControl.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Inserts vehicles into the network when their departure time is reached
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSInsertionControl_h
24 #define MSInsertionControl_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include <map>
38 #include <string>
39 #include "MSVehicleContainer.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class MSVehicle;
46 class MSVehicleControl;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
69 public:
77  MSInsertionControl(MSVehicleControl& vc, SUMOTime maxDepartDelay, bool checkEdgesOnce, int maxVehicleNumber);
78 
79 
82 
83 
100  int emitVehicles(SUMOTime time);
101 
102 
109  void add(SUMOVehicle* veh);
110 
111 
117  bool add(SUMOVehicleParameter* const pars);
118 
119 
127  int getWaitingVehicleNo() const;
128 
129 
134  int getPendingFlowCount() const;
135 
137  void alreadyDeparted(SUMOVehicle* veh);
138 
140  void descheduleDeparture(SUMOVehicle* veh);
141 
142 
144  void clearPendingVehicles(std::string& route);
145 
146 
151  void determineCandidates(SUMOTime time);
152 
154  int getPendingEmits(const MSLane* lane);
155 
156 private:
171  int tryInsert(SUMOTime time, SUMOVehicle* veh,
172  MSVehicleContainer::VehicleVector& refusedEmits);
173 
174 
180  void checkCandidates(SUMOTime time, const bool preCheck);
181 
182 
183 private:
186 
189 
192 
194  std::set<SUMOVehicle*> myEmitCandidates;
195 
197  std::set<SUMOVehicle*> myAbortedEmits;
198 
202  struct Flow {
206  int index;
207  };
208 
210  std::vector<Flow> myFlows;
211 
213  std::set<std::string> myFlowIDs;
214 
217 
220 
223 
226 
228  std::map<const MSLane*, int> myPendingEmitsForLane;
229 
230 
231 private:
234 
237 
238 
239 };
240 
241 
242 #endif
243 
244 /****************************************************************************/
245 
std::map< const MSLane *, int > myPendingEmitsForLane
the number of pending emits for each edge in the current time step
int getPendingFlowCount() const
Returns the number of flows that are still active.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
std::set< SUMOVehicle * > myAbortedEmits
Set of vehicles which shall not be inserted anymore.
void checkCandidates(SUMOTime time, const bool preCheck)
Adds all vehicles that should have been emitted earlier to the refuse container.
MSVehicleContainer myAllVeh
All loaded vehicles sorted by their departure time.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
~MSInsertionControl()
Destructor.
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.
Representation of a vehicle.
Definition: SUMOVehicle.h:67
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.
bool myEagerInsertionCheck
Whether an edge on which a vehicle could not depart should be ignored in the same step...
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.
SUMOTime myPendingEmitsUpdateTime
Last time at which pending emits for each edge where counted.
Inserts vehicles into the network when their departure time is reached.
std::vector< Flow > myFlows
Container for periodical vehicle parameters.
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
int myMaxVehicleNumber
Storage for maximum vehicle number.
Structure representing possible vehicle parameter.
MSVehicleControl & myVehicleControl
The assigned vehicle control (needed for vehicle re-insertion and deletion)
long long int SUMOTime
Definition: TraCIDefs.h:52
The class responsible for building and deletion of vehicles.
int index
the running index
SUMOVehicleParameter * pars
The paramters.
MSInsertionControl & operator=(const MSInsertionControl &)
Invalidated assignment operator.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
std::set< std::string > myFlowIDs
Cache for periodical vehicle ids for quicker checking.
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.