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-2015 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 "MSVehicleContainer.h"
37 #include <vector>
38 #include <map>
39 #include <string>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class MSVehicle;
46 class MSVehicleControl;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
68 public:
76  MSInsertionControl(MSVehicleControl& vc, SUMOTime maxDepartDelay, bool checkEdgesOnce, int maxVehicleNumber);
77 
78 
81 
82 
99  unsigned int emitVehicles(SUMOTime time);
100 
101 
108  void add(SUMOVehicle* veh);
109 
110 
116  bool add(SUMOVehicleParameter* const pars);
117 
118 
126  unsigned int getWaitingVehicleNo() const;
127 
128 
133  int getPendingFlowCount() const;
134 
135 
137  void descheduleDeparture(SUMOVehicle* veh);
138 
139 
141  void clearPendingVehicles(std::string& route);
142 
143 
148  void determineCandidates(SUMOTime time);
149 
150 
151 private:
166  unsigned int tryInsert(SUMOTime time, SUMOVehicle* veh,
167  MSVehicleContainer::VehicleVector& refusedEmits);
168 
169 
174  void checkFlowWait(SUMOVehicle* veh);
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<SUMOVehicle*> myAbortedEmits;
200 
204  struct Flow {
212  unsigned int index;
213  };
214 
216  std::vector<Flow> myFlows;
217 
219  std::set<std::string> myFlowIDs;
220 
223 
226 
229 
230 
231 private:
234 
237 
238 
239 };
240 
241 
242 #endif
243 
244 /****************************************************************************/
245 
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.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
long long int SUMOTime
Definition: SUMOTime.h:43
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle
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.
SUMOVehicle * vehicle
The last created vehicle.
unsigned int index
the running index
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.
unsigned int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
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.
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.
bool isVolatile
whether it has route or vehicle type distribution
Inserts vehicles into the network when their departure time is reached.
std::vector< Flow > myFlows
Container for periodical vehicle parameters.
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)
unsigned int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
The class responsible for building and deletion of vehicles.
SUMOVehicleParameter * pars
The paramters.
MSInsertionControl & operator=(const MSInsertionControl &)
Invalidated assignment operator.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
std::set< std::string > myFlowIDs
Cache for periodical vehicle ids for quicker checking.
void determineCandidates(SUMOTime time)
Checks for all vehicles whether they can be emitted.