SUMO - Simulation of Urban MObility
MSEdge.cpp
Go to the documentation of this file.
1 /****************************************************************************/
13 // A road/street connecting two junctions
14 /****************************************************************************/
15 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
16 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
17 /****************************************************************************/
18 //
19 // This file is part of SUMO.
20 // SUMO is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 /****************************************************************************/
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <algorithm>
38 #include <iostream>
39 #include <cassert>
42 #include "MSEdge.h"
43 #include "MSInsertionControl.h"
44 #include "MSJunction.h"
45 #include "MSLane.h"
46 #include "MSLaneChanger.h"
47 #include "MSGlobals.h"
48 #include "MSNet.h"
49 #include "MSVehicle.h"
50 #include "MSContainer.h"
51 #include "MSEdgeWeightsStorage.h"
53 
54 #include <mesosim/MELoop.h>
55 #include <mesosim/MESegment.h>
56 #include <mesosim/MEVehicle.h>
57 
58 #ifdef CHECK_MEMORY_LEAKS
59 #include <foreign/nvwa/debug_new.h>
60 #endif // CHECK_MEMORY_LEAKS
61 
62 
63 // ===========================================================================
64 // static member definitions
65 // ===========================================================================
68 
69 
70 // ===========================================================================
71 // member method definitions
72 // ===========================================================================
73 MSEdge::MSEdge(const std::string& id, int numericalID,
74  const EdgeBasicFunction function,
75  const std::string& streetName,
76  const std::string& edgeType,
77  int priority) :
78  Named(id), myNumericalID(numericalID), myLanes(0),
79  myLaneChanger(0), myFunction(function), myVaporizationRequests(0),
80  myLastFailedInsertionTime(-1),
81  myFromJunction(0), myToJunction(0),
82  myStreetName(streetName),
83  myEdgeType(edgeType),
84  myPriority(priority),
85  myLength(-1.),
86  myEmptyTraveltime(-1.),
87  myAmDelayed(false),
88  myAmRoundabout(false) {}
89 
90 
92  delete myLaneChanger;
93  for (AllowedLanesCont::iterator i1 = myAllowed.begin(); i1 != myAllowed.end(); i1++) {
94  delete(*i1).second;
95  }
96  for (ClassedAllowedLanesCont::iterator i2 = myClassedAllowed.begin(); i2 != myClassedAllowed.end(); i2++) {
97  for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
98  delete(*i1).second;
99  }
100  }
101  delete myLanes;
102  // Note: Lanes are delete using MSLane::clear();
103 }
104 
105 
106 void
107 MSEdge::initialize(const std::vector<MSLane*>* lanes) {
108  assert(lanes != 0);
109  myLanes = lanes;
110  if (!lanes->empty()) {
111  recalcCache();
112  if (myLanes->size() > 1) {
113  myLaneChanger = new MSLaneChanger(myLanes, OptionsCont::getOptions().getBool("lanechange.allow-swap"));
114  }
115  }
118  }
119 }
120 
121 
123  myLength = myLanes->front()->getLength();
125 }
126 
127 
128 void
130  myAllowed[0] = new std::vector<MSLane*>();
131  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
132  myAllowed[0]->push_back(*i);
133  const MSLinkCont& lc = (*i)->getLinkCont();
134  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
135  MSLane* toL = (*j)->getLane();
136  if (toL != 0) {
137  MSEdge& to = toL->getEdge();
138  //
139  if (std::find(mySuccessors.begin(), mySuccessors.end(), &to) == mySuccessors.end()) {
140  mySuccessors.push_back(&to);
141  }
142  if (std::find(to.myPredecessors.begin(), to.myPredecessors.end(), this) == to.myPredecessors.end()) {
143  to.myPredecessors.push_back(this);
144  }
145  //
146  if (myAllowed.find(&to) == myAllowed.end()) {
147  myAllowed[&to] = new std::vector<MSLane*>();
148  }
149  myAllowed[&to]->push_back(*i);
150  }
151 #ifdef HAVE_INTERNAL_LANES
152  toL = (*j)->getViaLane();
153  if (toL != 0) {
154  MSEdge& to = toL->getEdge();
155  if (std::find(to.myPredecessors.begin(), to.myPredecessors.end(), this) == to.myPredecessors.end()) {
156  to.myPredecessors.push_back(this);
157  }
158  }
159 #endif
160  }
161  }
162  std::sort(mySuccessors.begin(), mySuccessors.end(), by_id_sorter());
164  // segment building depends on the finished list of successors (for multi-queue)
165  if (MSGlobals::gUseMesoSim && !myLanes->empty()) {
167  }
168 }
169 
170 
171 void
173  // clear myClassedAllowed.
174  // it will be rebuilt on demand
175  for (ClassedAllowedLanesCont::iterator i2 = myClassedAllowed.begin(); i2 != myClassedAllowed.end(); i2++) {
176  for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
177  delete(*i1).second;
178  }
179  }
180  myClassedAllowed.clear();
181  myClassesSuccessorMap.clear();
182  // rebuild myMinimumPermissions and myCombinedPermissions
185  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
186  myMinimumPermissions &= (*i)->getPermissions();
187  myCombinedPermissions |= (*i)->getPermissions();
188  }
189 }
190 
191 
192 // ------------ Access to the edge's lanes
193 MSLane*
194 MSEdge::leftLane(const MSLane* const lane) const {
195  return parallelLane(lane, 1);
196 }
197 
198 
199 MSLane*
200 MSEdge::rightLane(const MSLane* const lane) const {
201  return parallelLane(lane, -1);
202 }
203 
204 
205 MSLane*
206 MSEdge::parallelLane(const MSLane* const lane, int offset) const {
207  const int index = (int)(find(myLanes->begin(), myLanes->end(), lane) - myLanes->begin());
208  if (index == (int)myLanes->size()) {
209  return 0;
210  }
211  const int resultIndex = index + offset;
212  if (resultIndex >= (int)myLanes->size() || resultIndex < 0) {
213  return 0;
214  } else {
215  return (*myLanes)[resultIndex];
216  }
217 }
218 
219 
220 const std::vector<MSLane*>*
221 MSEdge::allowedLanes(const MSEdge& destination, SUMOVehicleClass vclass) const {
222  return allowedLanes(&destination, vclass);
223 }
224 
225 
226 const std::vector<MSLane*>*
228  return allowedLanes(0, vclass);
229 }
230 
231 
232 const std::vector<MSLane*>*
234  AllowedLanesCont::const_iterator it = c.find(dest);
235  if (it == c.end()) {
236  return 0;
237  }
238  return it->second;
239 }
240 
241 
242 const std::vector<MSLane*>*
243 MSEdge::allowedLanes(const MSEdge* destination, SUMOVehicleClass vclass) const {
244  if (destination == 0 && (myMinimumPermissions & vclass) == vclass) {
245  // all lanes allow vclass
246  return getAllowedLanesWithDefault(myAllowed, destination);
247  }
248  // look up cached result in myClassedAllowed
249  ClassedAllowedLanesCont::const_iterator i = myClassedAllowed.find(vclass);
250  if (i != myClassedAllowed.end()) {
251  // can use cached value
252  const AllowedLanesCont& c = (*i).second;
253  return getAllowedLanesWithDefault(c, destination);
254  } else {
255  // this vclass is requested for the first time. rebuild all destinations
256  // go through connected edges
257 #ifdef HAVE_FOX
258  if (MSDevice_Routing::isParallel()) {
259  MSDevice_Routing::lock();
260  }
261 #endif
262  for (AllowedLanesCont::const_iterator i1 = myAllowed.begin(); i1 != myAllowed.end(); ++i1) {
263  const MSEdge* edge = i1->first;
264  const std::vector<MSLane*>* lanes = i1->second;
265  myClassedAllowed[vclass][edge] = new std::vector<MSLane*>();
266  // go through lanes approaching current edge
267  for (std::vector<MSLane*>::const_iterator i2 = lanes->begin(); i2 != lanes->end(); ++i2) {
268  // origin lane allows the current vehicle class?
269  if ((*i2)->allowsVehicleClass(vclass)) {
270  if (edge == 0) {
271  myClassedAllowed[vclass][edge]->push_back(*i2);
272  } else {
273  // target lane allows the current vehicle class?
274  const MSLinkCont& lc = (*i2)->getLinkCont();
275  for (MSLinkCont::const_iterator it_link = lc.begin(); it_link != lc.end(); ++it_link) {
276  const MSLane* targetLane = (*it_link)->getLane();
277  if ((&(targetLane->getEdge()) == edge) && targetLane->allowsVehicleClass(vclass)) {
278  // -> may be used
279  myClassedAllowed[vclass][edge]->push_back(*i2);
280  break;
281  }
282  }
283  }
284  }
285  }
286  // assert that 0 is returned if no connection is allowed for a class
287  if (myClassedAllowed[vclass][edge]->size() == 0) {
288  delete myClassedAllowed[vclass][edge];
289  myClassedAllowed[vclass][edge] = 0;
290  }
291  }
292 #ifdef HAVE_FOX
293  if (MSDevice_Routing::isParallel()) {
294  MSDevice_Routing::unlock();
295  }
296 #endif
297  return myClassedAllowed[vclass][destination];
298  }
299 }
300 
301 
302 // ------------
303 SUMOTime
306  return 0;
307 }
308 
309 
310 SUMOTime
313  return 0;
314 }
315 
316 
317 MSLane*
318 MSEdge::getFreeLane(const std::vector<MSLane*>* allowed, const SUMOVehicleClass vclass) const {
319  if (allowed == 0) {
320  allowed = allowedLanes(vclass);
321  }
322  MSLane* res = 0;
323  if (allowed != 0) {
324  SUMOReal leastOccupancy = std::numeric_limits<SUMOReal>::max();;
325  for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
326  const SUMOReal occupancy = (*i)->getBruttoOccupancy();
327  if (occupancy < leastOccupancy) {
328  res = (*i);
329  leastOccupancy = occupancy;
330  }
331  }
332  }
333  return res;
334 }
335 
336 
337 MSLane*
339  switch (veh.getParameter().departLaneProcedure) {
340  case DEPART_LANE_GIVEN:
341  if ((int) myLanes->size() <= veh.getParameter().departLane || !(*myLanes)[veh.getParameter().departLane]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
342  return 0;
343  }
344  return (*myLanes)[veh.getParameter().departLane];
345  case DEPART_LANE_RANDOM:
347  case DEPART_LANE_FREE:
348  return getFreeLane(0, veh.getVehicleType().getVehicleClass());
350  if (veh.getRoute().size() == 1) {
351  return getFreeLane(0, veh.getVehicleType().getVehicleClass());
352  } else {
353  return getFreeLane(allowedLanes(**(veh.getRoute().begin() + 1)), veh.getVehicleType().getVehicleClass());
354  }
355  case DEPART_LANE_BEST_FREE: {
356  veh.updateBestLanes(false, myLanes->front());
357  const std::vector<MSVehicle::LaneQ>& bl = veh.getBestLanes();
358  SUMOReal bestLength = -1;
359  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
360  if ((*i).length > bestLength) {
361  bestLength = (*i).length;
362  }
363  }
364  std::vector<MSLane*>* bestLanes = new std::vector<MSLane*>();
365  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
366  if ((*i).length == bestLength) {
367  bestLanes->push_back((*i).lane);
368  }
369  }
370  MSLane* ret = getFreeLane(bestLanes, veh.getVehicleType().getVehicleClass());
371  delete bestLanes;
372  return ret;
373  }
374  case DEPART_LANE_DEFAULT:
376  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
377  if ((*i)->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
378  return *i;
379  }
380  }
381  return 0;
382  default:
383  break;
384  }
385  if (!(*myLanes)[0]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
386  return 0;
387  }
388  return (*myLanes)[0];
389 }
390 
391 
392 bool
393 MSEdge::insertVehicle(SUMOVehicle& v, SUMOTime time, const bool checkOnly) const {
394  // when vaporizing, no vehicles are inserted, but checking needs to be successful to trigger removal
395  if (isVaporizing()) {
396  return checkOnly;
397  }
398  const SUMOVehicleParameter& pars = v.getParameter();
399  const MSVehicleType& type = v.getVehicleType();
401  if (type.getSpeedDeviation() > 0 && pars.departSpeed <= type.getSpeedFactor() * getSpeedLimit() * (2 * type.getSpeedDeviation() + 1.)) {
402  WRITE_WARNING("Choosing new speed factor for vehicle '" + pars.id + "' to match departure speed.");
404  } else {
405  throw ProcessError("Departure speed for vehicle '" + pars.id +
406  "' is too high for the departure edge '" + getID() + "'.");
407  }
408  }
409  if (checkOnly && v.getEdge()->getPurpose() == MSEdge::EDGEFUNCTION_DISTRICT) {
410  return true;
411  }
412  if (!checkOnly) {
413  std::string msg;
414  if (!v.hasValidRoute(msg)) {
416  throw ProcessError("Vehicle '" + v.getID() + "' has no valid route. " + msg);
417  } else if (v.getEdge()->getPurpose() == MSEdge::EDGEFUNCTION_DISTRICT) {
418  WRITE_WARNING("Removing vehicle '" + pars.id + "' which has no valid route.");
420  return false;
421  }
422  }
423  }
425  SUMOReal pos = 0.0;
426  switch (pars.departPosProcedure) {
427  case DEPART_POS_GIVEN:
428  if (pars.departPos >= 0.) {
429  pos = pars.departPos;
430  } else {
431  pos = pars.departPos + getLength();
432  }
433  if (pos < 0 || pos > getLength()) {
434  WRITE_WARNING("Invalid departPos " + toString(pos) + " given for vehicle '" +
435  v.getID() + "'. Inserting at lane end instead.");
436  pos = getLength();
437  }
438  break;
439  case DEPART_POS_RANDOM:
441  pos = RandHelper::rand(getLength());
442  break;
443  default:
444  break;
445  }
446  bool result = false;
447  MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this, pos);
448  MEVehicle* veh = static_cast<MEVehicle*>(&v);
449  if (pars.departPosProcedure == DEPART_POS_FREE) {
450  while (segment != 0 && !result) {
451  if (checkOnly) {
452  result = segment->hasSpaceFor(veh, time, true);
453  } else {
454  result = segment->initialise(veh, time);
455  }
456  segment = segment->getNextSegment();
457  }
458  } else {
459  if (checkOnly) {
460  result = segment->hasSpaceFor(veh, time, true);
461  } else {
462  result = segment->initialise(veh, time);
463  }
464  }
465  return result;
466  }
467  if (checkOnly) {
468  switch (v.getParameter().departLaneProcedure) {
469  case DEPART_LANE_GIVEN:
470  case DEPART_LANE_DEFAULT:
472  const SUMOReal occupancy = getDepartLane(static_cast<MSVehicle&>(v))->getBruttoOccupancy();
473  return occupancy == (SUMOReal)0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength;
474  }
475  default:
476  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
477  const SUMOReal occupancy = (*i)->getBruttoOccupancy();
478  if (occupancy == (SUMOReal)0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength) {
479  return true;
480  }
481  }
482  }
483  return false;
484  }
485  MSLane* insertionLane = getDepartLane(static_cast<MSVehicle&>(v));
486  return insertionLane != 0 && insertionLane->insertVehicle(static_cast<MSVehicle&>(v));
487 }
488 
489 
490 void
492  if (myLaneChanger == 0) {
493  return;
494  }
496  // allow changing only if all links leading to this internal lane have priority
497  // or they are controlled by a traffic light
498  for (std::vector<MSLane*>::const_iterator it = myLanes->begin(); it != myLanes->end(); ++it) {
499  MSLane* pred = (*it)->getLogicalPredecessorLane();
500  MSLink* link = MSLinkContHelper::getConnectingLink(*pred, **it);
501  assert(link != 0);
502  LinkState state = link->getState();
503  if (state == LINKSTATE_MINOR
504  || state == LINKSTATE_EQUAL
505  || state == LINKSTATE_STOP
506  || state == LINKSTATE_ALLWAY_STOP
507  || state == LINKSTATE_ZIPPER
508  || state == LINKSTATE_DEADEND) {
509  return;
510  }
511  }
512  }
514 }
515 
516 
517 
518 #ifdef HAVE_INTERNAL_LANES
519 const MSEdge*
520 MSEdge::getInternalFollowingEdge(const MSEdge* followerAfterInternal) const {
521  //@todo to be optimized
522  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
523  MSLane* l = *i;
524  const MSLinkCont& lc = l->getLinkCont();
525  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
526  MSLink* link = *j;
527  if (&link->getLane()->getEdge() == followerAfterInternal) {
528  if (link->getViaLane() != 0) {
529  return &link->getViaLane()->getEdge();
530  } else {
531  return 0; // network without internal links
532  }
533  }
534  }
535  }
536  return 0;
537 }
538 #endif
539 
540 
541 SUMOReal
543  SUMOReal v = 0;
544  SUMOReal no = 0;
545  for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) {
546  SUMOReal vehNo = (SUMOReal) segment->getCarNumber();
547  v += vehNo * segment->getMeanSpeed();
548  no += vehNo;
549  }
550  if (no == 0) {
551  return getSpeedLimit();
552  }
553  return v / no;
554 }
555 
556 
557 
558 SUMOReal
560  assert(minSpeed > 0);
561  if (!myAmDelayed) {
562  return myEmptyTraveltime;
563  }
564  SUMOReal v = 0;
566  v = getMesoMeanSpeed();
567  } else {
568  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
569  v += (*i)->getMeanSpeed();
570  }
571  v /= (SUMOReal) myLanes->size();
572  }
573  return getLength() / MAX2(minSpeed, v);
574 }
575 
576 
577 bool
578 MSEdge::dictionary(const std::string& id, MSEdge* ptr) {
579  DictType::iterator it = myDict.find(id);
580  if (it == myDict.end()) {
581  // id not in myDict.
582  myDict[id] = ptr;
583  while ((int)myEdges.size() < ptr->getNumericalID() + 1) {
584  myEdges.push_back(0);
585  }
586  myEdges[ptr->getNumericalID()] = ptr;
587  return true;
588  }
589  return false;
590 }
591 
592 
593 MSEdge*
594 MSEdge::dictionary(const std::string& id) {
595  DictType::iterator it = myDict.find(id);
596  if (it == myDict.end()) {
597  // id not in myDict.
598  return 0;
599  }
600  return it->second;
601 }
602 
603 
604 size_t
606  return myDict.size();
607 }
608 
609 
610 const MSEdgeVector&
612  return myEdges;
613 }
614 
615 
616 void
618  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
619  delete(*i).second;
620  }
621  myDict.clear();
622 }
623 
624 
625 void
626 MSEdge::insertIDs(std::vector<std::string>& into) {
627  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
628  into.push_back((*i).first);
629  }
630 }
631 
632 
633 void
634 MSEdge::parseEdgesList(const std::string& desc, ConstMSEdgeVector& into,
635  const std::string& rid) {
636  if (desc[0] == BinaryFormatter::BF_ROUTE) {
637  std::istringstream in(desc, std::ios::binary);
638  char c;
639  in >> c;
640  FileHelpers::readEdgeVector(in, into, rid);
641  } else {
642  StringTokenizer st(desc);
643  parseEdgesList(st.getVector(), into, rid);
644  }
645 }
646 
647 
648 void
649 MSEdge::parseEdgesList(const std::vector<std::string>& desc, ConstMSEdgeVector& into,
650  const std::string& rid) {
651  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
652  const MSEdge* edge = MSEdge::dictionary(*i);
653  // check whether the edge exists
654  if (edge == 0) {
655  throw ProcessError("The edge '" + *i + "' within the route " + rid + " is not known."
656  + "\n The route can not be build.");
657  }
658  into.push_back(edge);
659  }
660 }
661 
662 
663 SUMOReal
664 MSEdge::getDistanceTo(const MSEdge* other) const {
665  if (getLanes().size() > 0 && other->getLanes().size() > 0) {
667  } else {
668  return 0; // optimism is just right for astar
669  }
670 }
671 
672 
673 SUMOReal
675  // @note lanes might have different maximum speeds in theory
676  return getLanes()[0]->getSpeedLimit();
677 }
678 
679 
680 SUMOReal
681 MSEdge::getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
682  // @note lanes might have different maximum speeds in theory
683  return getLanes()[0]->getVehicleMaxSpeed(veh);
684 }
685 
686 
687 void
689  if (myLanes != 0) {
690  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
691  (*i)->setMaxSpeed(val);
692  }
693  }
694 }
695 
696 
697 
698 std::vector<MSTransportable*>
700  std::vector<MSTransportable*> result(myPersons.begin(), myPersons.end());
701  sort(result.begin(), result.end(), transportable_by_position_sorter(timestep));
702  return result;
703 }
704 
705 
706 std::vector<MSTransportable*>
708  std::vector<MSTransportable*> result(myContainers.begin(), myContainers.end());
709  sort(result.begin(), result.end(), transportable_by_position_sorter(timestep));
710  return result;
711 }
712 
713 
714 int
716  const SUMOReal pos1 = c1->getCurrentStage()->getEdgePos(myTime);
717  const SUMOReal pos2 = c2->getCurrentStage()->getEdgePos(myTime);
718  if (pos1 != pos2) {
719  return pos1 < pos2;
720  }
721  return c1->getID() < c2->getID();
722 }
723 
724 const MSEdgeVector&
726  if (vClass == SVC_IGNORING || !MSNet::getInstance()->hasPermissions() || myFunction == EDGEFUNCTION_DISTRICT) {
727  return mySuccessors;
728  }
729 #ifdef HAVE_FOX
730  if (MSDevice_Routing::isParallel()) {
731  MSDevice_Routing::lock();
732  }
733 #endif
734  std::map<SUMOVehicleClass, MSEdgeVector>::iterator i = myClassesSuccessorMap.find(vClass);
735  if (i == myClassesSuccessorMap.end()) {
736  // instantiate vector
737  myClassesSuccessorMap[vClass];
738  i = myClassesSuccessorMap.find(vClass);
739  // this vClass is requested for the first time. rebuild all successors
740  for (MSEdgeVector::const_iterator it = mySuccessors.begin(); it != mySuccessors.end(); ++it) {
741  if ((*it)->getPurpose() == EDGEFUNCTION_DISTRICT) {
742  i->second.push_back(*it);
743  } else {
744  const std::vector<MSLane*>* allowed = allowedLanes(*it, vClass);
745  if (allowed != 0 && allowed->size() > 0) {
746  i->second.push_back(*it);
747  }
748  }
749  }
750  }
751  // can use cached value
752 #ifdef HAVE_FOX
753  if (MSDevice_Routing::isParallel()) {
754  MSDevice_Routing::unlock();
755  }
756 #endif
757  return i->second;
758 }
759 
760 
761 /****************************************************************************/
762 
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge&#39;e lanes.
bool myAmDelayed
whether this edge had a vehicle with less than max speed on it
Definition: MSEdge.h:794
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:467
std::set< MSTransportable * > myContainers
Containers on the edge.
Definition: MSEdge.h:760
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
static void insertIDs(std::vector< std::string > &into)
Inserts IDs of all known edges into the given vector.
Definition: MSEdge.cpp:626
long long int SUMOTime
Definition: SUMOTime.h:43
SUMOReal myLength
the length of the edge (cached value for speedup)
Definition: MSEdge.h:788
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle
Sorts edges by their ids.
Definition: MSEdge.h:682
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:52
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false) const
Tries to insert the given vehicle into the network.
Definition: MSEdge.cpp:393
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
SUMOReal getDistanceTo(const MSEdge *other) const
optimistic air distance heuristic for use in routing
Definition: MSEdge.cpp:664
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:107
bool initialise(MEVehicle *veh, SUMOTime time)
Inserts (emits) vehicle into the segment.
Definition: MESegment.cpp:238
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:185
virtual bool hasValidRoute(std::string &msg) const =0
Validates the current route.
SUMOReal getLengthWithGap() const
Get vehicle&#39;s length including the minimum gap [m].
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
void recalcCache()
Recalculates the cached values.
Definition: MSEdge.cpp:122
This is an uncontrolled, minor link, has to stop.
SUMOReal departSpeed
(optional) The initial speed of the vehicle
static MSEdgeVector myEdges
Static list of edges.
Definition: MSEdge.h:813
const EdgeBasicFunction myFunction
the purpose of the edge
Definition: MSEdge.h:735
The position is given.
ClassedAllowedLanesCont myClassedAllowed
From vehicle class to lanes allowed to be used by it.
Definition: MSEdge.h:770
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
The least occupied lane is used.
virtual SUMOReal getEdgePos(SUMOTime now) const =0
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition: MELoop.cpp:254
void closeBuilding()
Definition: MSEdge.cpp:129
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
virtual ~MSEdge()
Destructor.
Definition: MSEdge.cpp:91
This is a dead end link.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:160
T MAX2(T a, T b)
Definition: StdDefs.h:75
const MSRoute & getRoute() const
Returns the current route.
Definition: MSBaseVehicle.h:85
const std::string & getID() const
returns the id of the transportable
SUMOReal computeChosenSpeedDeviation(MTRand *rng, const SUMOReal minDevFactor=0.2) const
Computes and returns the speed deviation.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:578
This is an uncontrolled, right-before-left link.
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:304
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
MSLane * getFreeLane(const std::vector< MSLane * > *allowed, const SUMOVehicleClass vclass) const
Finds the emptiest lane allowing the vehicle class.
Definition: MSEdge.cpp:318
The lane is chosen randomly.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
static T getRandomFrom(const std::vector< T > &v)
Returns a random element from the given vector.
Definition: RandHelper.h:119
const SVCPermissions SVCAll
int myVaporizationRequests
Vaporizer counter.
Definition: MSEdge.h:738
EdgeBasicFunction
Defines possible edge types.
Definition: MSEdge.h:89
The least occupied lane from best lanes.
The position is chosen randomly.
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
Definition: MSEdge.cpp:311
This is an uncontrolled, all-way stop link.
This is an uncontrolled, zipper-merge link.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The speed is given.
std::map< std::string, MSEdge * > DictType
definition of the static dictionary type
Definition: MSEdge.h:803
The car-following model and parameter.
Definition: MSVehicleType.h:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
The lane is given.
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:55
const std::string & getID() const
Returns the id.
Definition: Named.h:65
A road/street connecting two junctions.
Definition: MSEdge.h:80
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:273
std::map< SUMOVehicleClass, MSEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: MSEdge.h:818
void rebuildAllowedLanes()
Definition: MSEdge.cpp:172
SUMOReal getLength() const
return the length of the edge
Definition: MSEdge.h:562
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:1308
#define max(a, b)
Definition: polyfonts.c:65
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
SUMOReal getSpeedDeviation() const
Returns this type&#39;s speed deviation.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:576
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
Definition: MESegment.h:158
The edge is a district edge.
Definition: MSEdge.h:99
virtual void setChosenSpeedFactor(const SUMOReal factor)=0
Representation of a vehicle.
Definition: SUMOVehicle.h:65
static bool gCheckRoutes
Definition: MSGlobals.h:78
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
The least occupied lane from lanes which allow the continuation.
This is an uncontrolled, minor link, has to brake.
AllowedLanesCont myAllowed
Associative container from destination-edge to allowed-lanes.
Definition: MSEdge.h:766
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
Definition: MSVehicle.cpp:2043
static void clear()
Clears the dictionary.
Definition: MSEdge.cpp:617
SVCPermissions myMinimumPermissions
The intersection of lane permissions for this edge.
Definition: MSEdge.h:773
MSEdgeVector mySuccessors
The succeeding edges.
Definition: MSEdge.h:747
MSLane * leftLane(const MSLane *const lane) const
Returns the lane left to the one given, 0 if the given lane is leftmost.
Definition: MSEdge.cpp:194
MSLaneChanger * myLaneChanger
This member will do the lane-change.
Definition: MSEdge.h:732
MSEdge(const std::string &id, int numericalID, const EdgeBasicFunction function, const std::string &streetName, const std::string &edgeType, int priority)
Constructor.
Definition: MSEdge.cpp:73
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
Definition: MSEdge.h:395
const std::vector< MSLane * > * myLanes
Container for the edge&#39;s lane; should be sorted: (right-hand-traffic) the more left the lane...
Definition: MSEdge.h:729
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:54
SUMOReal getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
Definition: MSEdge.cpp:674
If a fixed number of random choices fails, a free position is chosen.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
Definition: MSVehicle.cpp:2037
MSLane * getDepartLane(MSVehicle &veh) const
Finds a depart lane for the given vehicle parameters.
Definition: MSEdge.cpp:338
Base class for objects which have an id.
Definition: Named.h:45
The rightmost lane the vehicle may use.
std::vector< MSTransportable * > getSortedContainers(SUMOTime timestep) const
Returns this edge&#39;s containers sorted by pos.
Definition: MSEdge.cpp:707
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
std::vector< std::string > getVector()
SUMOReal getMesoMeanSpeed() const
get the mean speed for mesoscopic simulation
Definition: MSEdge.cpp:542
SVCPermissions myCombinedPermissions
The union of lane permissions for this edge.
Definition: MSEdge.h:775
SUMOReal getSpeedFactor() const
Returns this type&#39;s speed factor.
No information given; use default.
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
Definition: MSEdge.h:242
Structure representing possible vehicle parameter.
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:264
MSLane * parallelLane(const MSLane *const lane, int offset) const
Returns the lane with the given offset parallel to the given lane one or 0 if it does not exist...
Definition: MSEdge.cpp:206
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:349
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:611
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
Definition: MSEdge.cpp:491
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
SUMOReal myEmptyTraveltime
the traveltime on the empty edge (cached value for speedup)
Definition: MSEdge.h:791
A single mesoscopic segment (cell)
Definition: MESegment.h:57
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
Definition: MSEdge.cpp:221
bool hasSpaceFor(const MEVehicle *veh, SUMOTime entryTime, bool init=false) const
Returns whether the given vehicle would still fit into the segment.
Definition: MESegment.cpp:215
static size_t dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:605
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:93
MESegment * getSegmentForEdge(const MSEdge &e, SUMOReal pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:288
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:99
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
SUMOReal departPos
(optional) The position the vehicle shall depart from
std::map< const MSEdge *, std::vector< MSLane * > * > AllowedLanesCont
Suceeding edges (keys) and allowed lanes to reach these edges (values).
Definition: MSEdge.h:108
unsigned size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:90
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:232
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSEdge.h:808
static void readEdgeVector(std::istream &in, std::vector< const E * > &edges, const std::string &rid)
Reads an edge vector binary.
Definition: FileHelpers.h:283
#define SUMOReal
Definition: config.h:213
Sorts transportables by their positions.
Definition: MSEdge.h:697
const MSJunction * getFromJunction() const
Definition: MSEdge.h:372
const MSEdgeVector & getSuccessors() const
Returns the following edges.
Definition: MSEdge.h:342
#define NUMERICAL_EPS
Definition: config.h:160
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:681
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:947
A free position is chosen.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:77
MSLane * rightLane(const MSLane *const lane) const
Returns the lane right to the one given, 0 if the given lane is rightmost.
Definition: MSEdge.cpp:200
int operator()(const MSTransportable *const c1, const MSTransportable *const c2) const
comparing operator
Definition: MSEdge.cpp:715
The edge is an internal edge.
Definition: MSEdge.h:97
const std::vector< MSLane * > * getAllowedLanesWithDefault(const AllowedLanesCont &c, const MSEdge *dest) const
lookup in map and return 0 if not found
Definition: MSEdge.cpp:233
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:1395
MSEdgeVector myPredecessors
The preceeding edges.
Definition: MSEdge.h:750
static bool gUseMesoSim
Definition: MSGlobals.h:87
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
SUMOReal getCurrentTravelTime(const SUMOReal minSpeed=NUMERICAL_EPS) const
Computes and returns the current travel time for this edge.
Definition: MSEdge.cpp:559
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
Definition: MSEdge.cpp:634
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
vehicles ignoring classes
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep) const
Returns this edge&#39;s persons sorted by pos.
Definition: MSEdge.cpp:699
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:78
std::string id
The vehicle&#39;s id.
void setMaxSpeed(SUMOReal val) const
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
Definition: MSEdge.cpp:688
const MSJunction * getToJunction() const
Definition: MSEdge.h:376
const Position & getPosition() const
Definition: MSJunction.cpp:67
std::set< MSTransportable * > myPersons
Persons on the edge for drawing and pushbutton.
Definition: MSEdge.h:757
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.