37 #define PARALLEL_PLAN_MOVE 47 myLanes(
MSLane::dictSize()),
48 myWithVehicles2Integrate(
MSGlobals::gNumSimThreads > 1),
49 myLastLaneChange(
MSEdge::dictSize()) {
51 for (std::vector< MSEdge* >::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
52 const std::vector<MSLane*>& lanes = (*i)->getLanes();
53 if (!(*i)->hasLaneChanger()) {
54 int pos = (*lanes.begin())->getNumericalID();
55 myLanes[pos].lane = *(lanes.begin());
57 myLanes[pos].haveNeighbors =
false;
59 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
60 int pos = (*j)->getNumericalID();
63 myLanes[pos].haveNeighbors =
true;
80 if (!lu.
amActive && (*i)->getVehicleNumber() > 0) {
103 #ifdef LOAD_BALANCING 104 myRNGLoad = std::priority_queue<std::pair<int, int> >();
110 const int vehNum = (*i)->getVehicleNumber();
112 myLanes[(*i)->getNumericalID()].amActive =
false;
115 #ifdef LOAD_BALANCING 116 std::pair<int, int> minRNG =
myRNGLoad.top();
117 (*i)->setRNGIndex(minRNG.second);
119 minRNG.first -= vehNum;
124 myThreadPool.add((*i)->getPlanMoveTask(t), (*i)->getRNGIndex() % myThreadPool.size());
129 (*i)->planMovements(t);
135 myThreadPool.waitAll(
false);
144 lane->setJunctionApproaches(t);
154 #ifdef PARALLEL_EXEC_MOVE 156 #ifdef LOAD_BALANCING 157 myRNGLoad = std::priority_queue<std::pair<int, int> >();
163 #ifdef LOAD_BALANCING 164 std::pair<int, int> minRNG =
myRNGLoad.top();
165 lane->setRNGIndex(minRNG.second);
167 minRNG.first -= lane->getVehicleNumber();
170 myThreadPool.add(lane->getExecuteMoveTask(t), lane->getRNGIndex() % myThreadPool.size());
172 myThreadPool.waitAll(
false);
178 #ifdef PARALLEL_EXEC_MOVE
181 (*i)->getVehicleNumber() > 0) {
182 (*i)->executeMovements(t);
184 if ((*i)->getVehicleNumber() == 0) {
185 myLanes[(*i)->getNumericalID()].amActive =
false;
191 for (
MSLane* lane : wasActive) {
192 lane->updateLengthSum();
198 for (
MSLane*
const lane : toIntegrate) {
199 const bool wasInactive = lane->getVehicleNumber() == 0;
200 lane->integrateNewVehicles();
201 if (wasInactive && lane->getVehicleNumber() > 0) {
218 std::vector<MSLane*> toAdd;
219 #ifdef PARALLEL_CHANGE_LANES 220 std::vector<MSEdge*> recheckLaneUsage;
226 MSEdge& edge = (*i)->getEdge();
229 #ifdef PARALLEL_CHANGE_LANES 232 myThreadPool.add(lane->getLaneChangeTask(t), lane->
getRNGIndex() % myThreadPool.size());
233 recheckLaneUsage.push_back(&edge);
237 const std::vector<MSLane*>& lanes = edge.
getLanes();
238 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
244 if ((*i)->getVehicleNumber() > 0 && !lu.
amActive) {
249 #ifdef PARALLEL_CHANGE_LANES 259 #ifdef PARALLEL_CHANGE_LANES 261 myThreadPool.waitAll(
false);
262 for (
MSEdge* e : recheckLaneUsage) {
263 const std::vector<MSLane*>& lanes = e->getLanes();
264 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
266 if ((*i)->getVehicleNumber() > 0 && !lu.
amActive) {
276 for (std::vector<MSLane*>::iterator i = toAdd.begin(); i != toAdd.end(); ++i) {
281 for (LaneUsageVector::iterator it =
myLanes.begin(); it !=
myLanes.end(); ++it) {
282 (*it).lane->sortManeuverReservations();
292 if (lane->needsCollisionCheck()) {
293 lane->detectCollisions(timestep, stage);
298 lane->detectCollisions(timestep, stage);
300 myInactiveCheckCollisions.clear();
317 for (MSEdgeVector::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
318 const std::vector<MSLane*>& lanes = (*i)->getLanes();
319 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
320 (*j)->initRestrictions();
std::list< MSLane * > myActiveLanes
The list of active (not empty) lanes.
static double gLateralResolution
static int getNumRNGs()
return the number of RNGs
int getRNGIndex() const
returns the associated RNG index
~MSEdgeControl()
Destructor.
std::set< MSLane *, ComparatorNumericalIdLess > myChangedStateLanes
Lanes which changed the state without informing the control.
void checkCollisionForInactive(MSLane *l)
trigger collision checking for inactive lane
void patchActiveLanes()
Resets information whether a lane is active for all lanes.
static bool gComputeLC
whether the simulationLoop is in the lane changing phase
std::set< MSLane *, ComparatorNumericalIdLess > myInactiveCheckCollisions
Additional lanes for which collision checking must be performed.
LaneUsageVector myLanes
Information about lanes' number of vehicles and neighbors.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
bool amActive
Information whether this lane is active.
A structure holding some basic information about a simulated lane.
void gotActive(MSLane *l)
Informs the control that the given lane got active.
void detectCollisions(SUMOTime timestep, const std::string &stage)
Detect collisions.
int getNumericalID() const
Returns the numerical id of the edge.
void setAdditionalRestrictions()
apply additional restrictions
FXSynchQue< MSLane *, std::vector< MSLane * > > myWithVehicles2Integrate
A storage for lanes which shall be integrated because vehicles have moved onto them.
Container & getContainer()
void setJunctionApproaches(SUMOTime t)
Register junction approaches for all vehicles after velocities have been planned. This is a prerequis...
A road/street connecting two junctions.
std::priority_queue< std::pair< int, int > > myRNGLoad
static int gNumSimThreads
how many threads to use for simulation
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
std::vector< SUMOTime > myLastLaneChange
The list of active (not empty) lanes.
void changeLanes(const SUMOTime t)
Moves (precomputes) critical vehicles.
MSEdgeVector myEdges
Loaded edges.
void planMovements(SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step...
void executeMovements(SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
void removePending()
Removes a vehicle after it has ended.
bool haveNeighbors
Information whether this lane belongs to a multi-lane edge.
A thread repeatingly calculating incoming tasks.
Function-object for stable sorting of objects acting like Named without being derived (SUMOVehicle) ...
MSEdgeControl(const std::vector< MSEdge * > &edges)
Constructor.
Representation of a lane in the micro simulation.