SUMO - Simulation of Urban MObility
MSInsertionControl.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // Inserts vehicles into the network when their departure time is reached
21 /****************************************************************************/
22 #ifndef MSInsertionControl_h
23 #define MSInsertionControl_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <map>
37 #include <string>
38 #include "MSNet.h"
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(const 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 
157 
158 private:
173  int tryInsert(SUMOTime time, SUMOVehicle* veh,
174  MSVehicleContainer::VehicleVector& refusedEmits);
175 
176 
182  void checkCandidates(SUMOTime time, const bool preCheck);
183 
184 
185 private:
188 
191 
194 
196  std::set<SUMOVehicle*> myEmitCandidates;
197 
199  std::set<const SUMOVehicle*> myAbortedEmits;
200 
204  struct Flow {
208  int index;
209  };
210 
212  std::vector<Flow> myFlows;
213 
215  std::set<std::string> myFlowIDs;
216 
219 
222 
225 
228 
230  std::map<const MSLane*, int> myPendingEmitsForLane;
231 
232 
233 private:
236 
239 
240 
241 };
242 
243 
244 #endif
245 
246 /****************************************************************************/
247 
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
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
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.
MSVehicleContainer myAllVeh
All loaded vehicles sorted by their departure time.
~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:66
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.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
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)
long long int SUMOTime
Definition: TraCIDefs.h:51
The class responsible for building and deletion of vehicles.
int index
the running index
SUMOVehicleParameter * pars
The parameters.
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:77
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.
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.