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-2015 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 #ifdef HAVE_INTERNAL
55 #include <mesosim/MELoop.h>
56 #include <mesosim/MESegment.h>
57 #include <mesosim/MEVehicle.h>
58 #endif
59 
60 #ifdef CHECK_MEMORY_LEAKS
61 #include <foreign/nvwa/debug_new.h>
62 #endif // CHECK_MEMORY_LEAKS
63 
64 
65 // ===========================================================================
66 // static member definitions
67 // ===========================================================================
70 
71 
72 // ===========================================================================
73 // member method definitions
74 // ===========================================================================
75 MSEdge::MSEdge(const std::string& id, int numericalID,
76  const EdgeBasicFunction function,
77  const std::string& streetName,
78  const std::string& edgeType,
79  int priority) :
80  Named(id), myNumericalID(numericalID), myLanes(0),
81  myLaneChanger(0), myFunction(function), myVaporizationRequests(0),
82  myLastFailedInsertionTime(-1),
83  myFromJunction(0), myToJunction(0),
84  myStreetName(streetName),
85  myEdgeType(edgeType),
86  myPriority(priority),
87  myLength(-1.),
88  myEmptyTraveltime(-1.),
89  myAmDelayed(false),
90  myAmRoundabout(false) {}
91 
92 
94  delete myLaneChanger;
95  for (AllowedLanesCont::iterator i1 = myAllowed.begin(); i1 != myAllowed.end(); i1++) {
96  delete(*i1).second;
97  }
98  for (ClassedAllowedLanesCont::iterator i2 = myClassedAllowed.begin(); i2 != myClassedAllowed.end(); i2++) {
99  for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
100  delete(*i1).second;
101  }
102  }
103  delete myLanes;
104  // Note: Lanes are delete using MSLane::clear();
105 }
106 
107 
108 void
109 MSEdge::initialize(const std::vector<MSLane*>* lanes) {
110  assert(lanes != 0);
111  myLanes = lanes;
112  if (!lanes->empty()) {
113  recalcCache();
114  if (myLanes->size() > 1) {
115  myLaneChanger = new MSLaneChanger(myLanes, OptionsCont::getOptions().getBool("lanechange.allow-swap"));
116  }
117  }
120  }
121 #ifdef HAVE_INTERNAL
122  if (MSGlobals::gUseMesoSim && !lanes->empty()) {
123  MSGlobals::gMesoNet->buildSegmentsFor(*this, OptionsCont::getOptions());
124  }
125 #endif
126 }
127 
128 
130  myLength = myLanes->front()->getLength();
132 }
133 
134 
135 void
137  myAllowed[0] = new std::vector<MSLane*>();
138  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
139  myAllowed[0]->push_back(*i);
140  const MSLinkCont& lc = (*i)->getLinkCont();
141  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
142  MSLane* toL = (*j)->getLane();
143  if (toL != 0) {
144  MSEdge& to = toL->getEdge();
145  //
146  if (std::find(mySuccessors.begin(), mySuccessors.end(), &to) == mySuccessors.end()) {
147  mySuccessors.push_back(&to);
148  }
149  if (std::find(to.myPredecessors.begin(), to.myPredecessors.end(), this) == to.myPredecessors.end()) {
150  to.myPredecessors.push_back(this);
151  }
152  //
153  if (myAllowed.find(&to) == myAllowed.end()) {
154  myAllowed[&to] = new std::vector<MSLane*>();
155  }
156  myAllowed[&to]->push_back(*i);
157  }
158 #ifdef HAVE_INTERNAL_LANES
159  toL = (*j)->getViaLane();
160  if (toL != 0) {
161  MSEdge& to = toL->getEdge();
162  if (std::find(to.myPredecessors.begin(), to.myPredecessors.end(), this) == to.myPredecessors.end()) {
163  to.myPredecessors.push_back(this);
164  }
165  }
166 #endif
167  }
168  }
169  std::sort(mySuccessors.begin(), mySuccessors.end(), by_id_sorter());
171 }
172 
173 
174 void
176  // clear myClassedAllowed.
177  // it will be rebuilt on demand
178  for (ClassedAllowedLanesCont::iterator i2 = myClassedAllowed.begin(); i2 != myClassedAllowed.end(); i2++) {
179  for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
180  delete(*i1).second;
181  }
182  }
183  myClassedAllowed.clear();
184  myClassesSuccessorMap.clear();
185  // rebuild myMinimumPermissions and myCombinedPermissions
188  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
189  myMinimumPermissions &= (*i)->getPermissions();
190  myCombinedPermissions |= (*i)->getPermissions();
191  }
192 }
193 
194 
195 // ------------ Access to the edge's lanes
196 MSLane*
197 MSEdge::leftLane(const MSLane* const lane) const {
198  return parallelLane(lane, 1);
199 }
200 
201 
202 MSLane*
203 MSEdge::rightLane(const MSLane* const lane) const {
204  return parallelLane(lane, -1);
205 }
206 
207 
208 MSLane*
209 MSEdge::parallelLane(const MSLane* const lane, int offset) const {
210  const int index = (int)(find(myLanes->begin(), myLanes->end(), lane) - myLanes->begin());
211  if (index == (int)myLanes->size()) {
212  return 0;
213  }
214  const int resultIndex = index + offset;
215  if (resultIndex >= (int)myLanes->size() || resultIndex < 0) {
216  return 0;
217  } else {
218  return (*myLanes)[resultIndex];
219  }
220 }
221 
222 
223 const std::vector<MSLane*>*
224 MSEdge::allowedLanes(const MSEdge& destination, SUMOVehicleClass vclass) const {
225  return allowedLanes(&destination, vclass);
226 }
227 
228 
229 const std::vector<MSLane*>*
231  return allowedLanes(0, vclass);
232 }
233 
234 
235 const std::vector<MSLane*>*
237  AllowedLanesCont::const_iterator it = c.find(dest);
238  if (it == c.end()) {
239  return 0;
240  }
241  return it->second;
242 }
243 
244 
245 const std::vector<MSLane*>*
246 MSEdge::allowedLanes(const MSEdge* destination, SUMOVehicleClass vclass) const {
247  if (destination == 0 && (myMinimumPermissions & vclass) == vclass) {
248  // all lanes allow vclass
249  return getAllowedLanesWithDefault(myAllowed, destination);
250  }
251  // look up cached result in myClassedAllowed
252  ClassedAllowedLanesCont::const_iterator i = myClassedAllowed.find(vclass);
253  if (i != myClassedAllowed.end()) {
254  // can use cached value
255  const AllowedLanesCont& c = (*i).second;
256  return getAllowedLanesWithDefault(c, destination);
257  } else {
258  // this vclass is requested for the first time. rebuild all destinations
259  // go through connected edges
260 #ifdef HAVE_FOX
261  if (MSDevice_Routing::isParallel()) {
262  MSDevice_Routing::lock();
263  }
264 #endif
265  for (AllowedLanesCont::const_iterator i1 = myAllowed.begin(); i1 != myAllowed.end(); ++i1) {
266  const MSEdge* edge = i1->first;
267  const std::vector<MSLane*>* lanes = i1->second;
268  myClassedAllowed[vclass][edge] = new std::vector<MSLane*>();
269  // go through lanes approaching current edge
270  for (std::vector<MSLane*>::const_iterator i2 = lanes->begin(); i2 != lanes->end(); ++i2) {
271  // origin lane allows the current vehicle class?
272  if ((*i2)->allowsVehicleClass(vclass)) {
273  if (edge == 0) {
274  myClassedAllowed[vclass][edge]->push_back(*i2);
275  } else {
276  // target lane allows the current vehicle class?
277  const MSLinkCont& lc = (*i2)->getLinkCont();
278  for (MSLinkCont::const_iterator it_link = lc.begin(); it_link != lc.end(); ++it_link) {
279  const MSLane* targetLane = (*it_link)->getLane();
280  if ((&(targetLane->getEdge()) == edge) && targetLane->allowsVehicleClass(vclass)) {
281  // -> may be used
282  myClassedAllowed[vclass][edge]->push_back(*i2);
283  break;
284  }
285  }
286  }
287  }
288  }
289  // assert that 0 is returned if no connection is allowed for a class
290  if (myClassedAllowed[vclass][edge]->size() == 0) {
291  delete myClassedAllowed[vclass][edge];
292  myClassedAllowed[vclass][edge] = 0;
293  }
294  }
295 #ifdef HAVE_FOX
296  if (MSDevice_Routing::isParallel()) {
297  MSDevice_Routing::unlock();
298  }
299 #endif
300  return myClassedAllowed[vclass][destination];
301  }
302 }
303 
304 
305 // ------------
306 SUMOTime
309  return 0;
310 }
311 
312 
313 SUMOTime
316  return 0;
317 }
318 
319 
320 MSLane*
321 MSEdge::getFreeLane(const std::vector<MSLane*>* allowed, const SUMOVehicleClass vclass) const {
322  if (allowed == 0) {
323  allowed = allowedLanes(vclass);
324  }
325  MSLane* res = 0;
326  if (allowed != 0) {
327  SUMOReal leastOccupancy = std::numeric_limits<SUMOReal>::max();;
328  for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
329  const SUMOReal occupancy = (*i)->getBruttoOccupancy();
330  if (occupancy < leastOccupancy) {
331  res = (*i);
332  leastOccupancy = occupancy;
333  }
334  }
335  }
336  return res;
337 }
338 
339 
340 MSLane*
342  switch (veh.getParameter().departLaneProcedure) {
343  case DEPART_LANE_GIVEN:
344  if ((int) myLanes->size() <= veh.getParameter().departLane || !(*myLanes)[veh.getParameter().departLane]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
345  return 0;
346  }
347  return (*myLanes)[veh.getParameter().departLane];
348  case DEPART_LANE_RANDOM:
350  case DEPART_LANE_FREE:
351  return getFreeLane(0, veh.getVehicleType().getVehicleClass());
353  if (veh.getRoute().size() == 1) {
354  return getFreeLane(0, veh.getVehicleType().getVehicleClass());
355  } else {
356  return getFreeLane(allowedLanes(**(veh.getRoute().begin() + 1)), veh.getVehicleType().getVehicleClass());
357  }
358  case DEPART_LANE_BEST_FREE: {
359  veh.updateBestLanes(false, myLanes->front());
360  const std::vector<MSVehicle::LaneQ>& bl = veh.getBestLanes();
361  SUMOReal bestLength = -1;
362  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
363  if ((*i).length > bestLength) {
364  bestLength = (*i).length;
365  }
366  }
367  std::vector<MSLane*>* bestLanes = new std::vector<MSLane*>();
368  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
369  if ((*i).length == bestLength) {
370  bestLanes->push_back((*i).lane);
371  }
372  }
373  MSLane* ret = getFreeLane(bestLanes, veh.getVehicleType().getVehicleClass());
374  delete bestLanes;
375  return ret;
376  }
377  case DEPART_LANE_DEFAULT:
379  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
380  if ((*i)->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
381  return *i;
382  }
383  }
384  return 0;
385  default:
386  break;
387  }
388  if (!(*myLanes)[0]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
389  return 0;
390  }
391  return (*myLanes)[0];
392 }
393 
394 
395 bool
396 MSEdge::insertVehicle(SUMOVehicle& v, SUMOTime time, const bool checkOnly) const {
397  // when vaporizing, no vehicles are inserted, but checking needs to be successful to trigger removal
398  if (isVaporizing()) {
399  return checkOnly;
400  }
401  const SUMOVehicleParameter& pars = v.getParameter();
402  const MSVehicleType& type = v.getVehicleType();
404  if (type.getSpeedDeviation() > 0 && pars.departSpeed <= type.getSpeedFactor() * getSpeedLimit() * (2 * type.getSpeedDeviation() + 1.)) {
405  WRITE_WARNING("Choosing new speed factor for vehicle '" + pars.id + "' to match departure speed.");
407  } else {
408  throw ProcessError("Departure speed for vehicle '" + pars.id +
409  "' is too high for the departure edge '" + getID() + "'.");
410  }
411  }
412  if (checkOnly && v.getEdge()->getPurpose() == MSEdge::EDGEFUNCTION_DISTRICT) {
413  return true;
414  }
415  if (!checkOnly) {
416  std::string msg;
417  if (!v.hasValidRoute(msg)) {
419  throw ProcessError("Vehicle '" + v.getID() + "' has no valid route. " + msg);
420  } else if (v.getEdge()->getPurpose() == MSEdge::EDGEFUNCTION_DISTRICT) {
421  WRITE_WARNING("Removing vehicle '" + pars.id + "' which has no valid route.");
423  return false;
424  }
425  }
426  }
427 #ifdef HAVE_INTERNAL
429  SUMOReal pos = 0.0;
430  switch (pars.departPosProcedure) {
431  case DEPART_POS_GIVEN:
432  if (pars.departPos >= 0.) {
433  pos = pars.departPos;
434  } else {
435  pos = pars.departPos + getLength();
436  }
437  if (pos < 0 || pos > getLength()) {
438  WRITE_WARNING("Invalid departPos " + toString(pos) + " given for vehicle '" +
439  v.getID() + "'. Inserting at lane end instead.");
440  pos = getLength();
441  }
442  break;
443  case DEPART_POS_RANDOM:
445  pos = RandHelper::rand(getLength());
446  break;
447  default:
448  break;
449  }
450  bool result = false;
451  MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this, pos);
452  MEVehicle* veh = static_cast<MEVehicle*>(&v);
453  if (pars.departPosProcedure == DEPART_POS_FREE) {
454  while (segment != 0 && !result) {
455  if (checkOnly) {
456  result = segment->hasSpaceFor(veh, time, true);
457  } else {
458  result = segment->initialise(veh, time);
459  }
460  segment = segment->getNextSegment();
461  }
462  } else {
463  if (checkOnly) {
464  result = segment->hasSpaceFor(veh, time, true);
465  } else {
466  result = segment->initialise(veh, time);
467  }
468  }
469  return result;
470  }
471 #else
472  UNUSED_PARAMETER(time);
473 #endif
474  if (checkOnly) {
475  switch (v.getParameter().departLaneProcedure) {
476  case DEPART_LANE_GIVEN:
477  case DEPART_LANE_DEFAULT:
479  const SUMOReal occupancy = getDepartLane(static_cast<MSVehicle&>(v))->getBruttoOccupancy();
480  return occupancy == (SUMOReal)0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength;
481  }
482  default:
483  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
484  const SUMOReal occupancy = (*i)->getBruttoOccupancy();
485  if (occupancy == (SUMOReal)0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength) {
486  return true;
487  }
488  }
489  }
490  return false;
491  }
492  MSLane* insertionLane = getDepartLane(static_cast<MSVehicle&>(v));
493  return insertionLane != 0 && insertionLane->insertVehicle(static_cast<MSVehicle&>(v));
494 }
495 
496 
497 void
499  if (myLaneChanger == 0) {
500  return;
501  }
503  // allow changing only if all links leading to this internal lane have priority
504  // or they are controlled by a traffic light
505  for (std::vector<MSLane*>::const_iterator it = myLanes->begin(); it != myLanes->end(); ++it) {
506  MSLane* pred = (*it)->getLogicalPredecessorLane();
507  MSLink* link = MSLinkContHelper::getConnectingLink(*pred, **it);
508  assert(link != 0);
509  LinkState state = link->getState();
510  if (state == LINKSTATE_MINOR
511  || state == LINKSTATE_EQUAL
512  || state == LINKSTATE_STOP
513  || state == LINKSTATE_ALLWAY_STOP
514  || state == LINKSTATE_ZIPPER
515  || state == LINKSTATE_DEADEND) {
516  return;
517  }
518  }
519  }
521 }
522 
523 
524 
525 #ifdef HAVE_INTERNAL_LANES
526 const MSEdge*
527 MSEdge::getInternalFollowingEdge(MSEdge* followerAfterInternal) const {
528  //@todo to be optimized
529  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
530  MSLane* l = *i;
531  const MSLinkCont& lc = l->getLinkCont();
532  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
533  MSLink* link = *j;
534  if (&link->getLane()->getEdge() == followerAfterInternal) {
535  if (link->getViaLane() != 0) {
536  return &link->getViaLane()->getEdge();
537  } else {
538  return 0; // network without internal links
539  }
540  }
541  }
542  }
543  return 0;
544 }
545 #endif
546 
547 
548 SUMOReal
550  assert(minSpeed > 0);
551  if (!myAmDelayed) {
552  return myEmptyTraveltime;
553  }
554  SUMOReal v = 0;
555 #ifdef HAVE_INTERNAL
557  MESegment* first = MSGlobals::gMesoNet->getSegmentForEdge(*this);
558  unsigned segments = 0;
559  do {
560  v += first->getMeanSpeed();
561  first = first->getNextSegment();
562  segments++;
563  } while (first != 0);
564  v /= (SUMOReal) segments;
565  } else {
566 #endif
567  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
568  v += (*i)->getMeanSpeed();
569  }
570  v /= (SUMOReal) myLanes->size();
571 #ifdef HAVE_INTERNAL
572  }
573 #endif
574  return getLength() / MAX2(minSpeed, v);
575 }
576 
577 
578 bool
579 MSEdge::dictionary(const std::string& id, MSEdge* ptr) {
580  DictType::iterator it = myDict.find(id);
581  if (it == myDict.end()) {
582  // id not in myDict.
583  myDict[id] = ptr;
584  while ((int)myEdges.size() < ptr->getNumericalID() + 1) {
585  myEdges.push_back(0);
586  }
587  myEdges[ptr->getNumericalID()] = ptr;
588  return true;
589  }
590  return false;
591 }
592 
593 
594 MSEdge*
595 MSEdge::dictionary(const std::string& id) {
596  DictType::iterator it = myDict.find(id);
597  if (it == myDict.end()) {
598  // id not in myDict.
599  return 0;
600  }
601  return it->second;
602 }
603 
604 
605 MSEdge*
606 MSEdge::dictionary(size_t id) {
607  assert(myEdges.size() > id);
608  return myEdges[id];
609 }
610 
611 
612 size_t
614  return myDict.size();
615 }
616 
617 
618 size_t
620  return myEdges.size();
621 }
622 
623 
624 void
626  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
627  delete(*i).second;
628  }
629  myDict.clear();
630 }
631 
632 
633 void
634 MSEdge::insertIDs(std::vector<std::string>& into) {
635  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
636  into.push_back((*i).first);
637  }
638 }
639 
640 
641 void
642 MSEdge::parseEdgesList(const std::string& desc, ConstMSEdgeVector& into,
643  const std::string& rid) {
644  if (desc[0] == BinaryFormatter::BF_ROUTE) {
645  std::istringstream in(desc, std::ios::binary);
646  char c;
647  in >> c;
648  FileHelpers::readEdgeVector(in, into, rid);
649  } else {
650  StringTokenizer st(desc);
651  parseEdgesList(st.getVector(), into, rid);
652  }
653 }
654 
655 
656 void
657 MSEdge::parseEdgesList(const std::vector<std::string>& desc, ConstMSEdgeVector& into,
658  const std::string& rid) {
659  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
660  const MSEdge* edge = MSEdge::dictionary(*i);
661  // check whether the edge exists
662  if (edge == 0) {
663  throw ProcessError("The edge '" + *i + "' within the route " + rid + " is not known."
664  + "\n The route can not be build.");
665  }
666  into.push_back(edge);
667  }
668 }
669 
670 
671 SUMOReal
672 MSEdge::getDistanceTo(const MSEdge* other) const {
673  if (getLanes().size() > 0 && other->getLanes().size() > 0) {
675  } else {
676  return 0; // optimism is just right for astar
677  }
678 }
679 
680 
681 SUMOReal
683  // @note lanes might have different maximum speeds in theory
684  return getLanes()[0]->getSpeedLimit();
685 }
686 
687 
688 SUMOReal
689 MSEdge::getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
690  // @note lanes might have different maximum speeds in theory
691  return getLanes()[0]->getVehicleMaxSpeed(veh);
692 }
693 
694 
695 std::vector<MSTransportable*>
697  std::vector<MSTransportable*> result(myPersons.begin(), myPersons.end());
698  sort(result.begin(), result.end(), transportable_by_position_sorter(timestep));
699  return result;
700 }
701 
702 
703 std::vector<MSTransportable*>
705  std::vector<MSTransportable*> result(myContainers.begin(), myContainers.end());
706  sort(result.begin(), result.end(), transportable_by_position_sorter(timestep));
707  return result;
708 }
709 
710 
711 int
713  const SUMOReal pos1 = c1->getCurrentStage()->getEdgePos(myTime);
714  const SUMOReal pos2 = c2->getCurrentStage()->getEdgePos(myTime);
715  if (pos1 != pos2) {
716  return pos1 < pos2;
717  }
718  return c1->getID() < c2->getID();
719 }
720 
721 const MSEdgeVector&
723  if (vClass == SVC_IGNORING || !MSNet::getInstance()->hasPermissions() || myFunction == EDGEFUNCTION_DISTRICT) {
724  return mySuccessors;
725  }
726 #ifdef HAVE_FOX
727  if (MSDevice_Routing::isParallel()) {
728  MSDevice_Routing::lock();
729  }
730 #endif
731  std::map<SUMOVehicleClass, MSEdgeVector>::iterator i = myClassesSuccessorMap.find(vClass);
732  if (i == myClassesSuccessorMap.end()) {
733  // instantiate vector
734  myClassesSuccessorMap[vClass];
735  i = myClassesSuccessorMap.find(vClass);
736  // this vClass is requested for the first time. rebuild all successors
737  for (MSEdgeVector::const_iterator it = mySuccessors.begin(); it != mySuccessors.end(); ++it) {
738  if ((*it)->getPurpose() == EDGEFUNCTION_DISTRICT) {
739  i->second.push_back(*it);
740  } else {
741  const std::vector<MSLane*>* allowed = allowedLanes(*it, vClass);
742  if (allowed != 0 && allowed->size() > 0) {
743  i->second.push_back(*it);
744  }
745  }
746  }
747  }
748  // can use cached value
749 #ifdef HAVE_FOX
750  if (MSDevice_Routing::isParallel()) {
751  MSDevice_Routing::unlock();
752  }
753 #endif
754  return i->second;
755 }
756 
757 
758 /****************************************************************************/
759 
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:754
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:461
std::set< MSTransportable * > myContainers
Containers on the edge.
Definition: MSEdge.h:720
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:634
long long int SUMOTime
Definition: SUMOTime.h:43
SUMOReal myLength
the length of the edge (cached value for speedup)
Definition: MSEdge.h:748
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:645
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false) const
Tries to insert the given vehicle into the network.
Definition: MSEdge.cpp:396
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:672
static size_t numericalDictSize()
Returns the number of edges with a numerical id.
Definition: MSEdge.cpp:619
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:109
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:186
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:129
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:773
const EdgeBasicFunction myFunction
the purpose of the edge
Definition: MSEdge.h:698
The position is given.
ClassedAllowedLanesCont myClassedAllowed
From vehicle class to lanes allowed to be used by it.
Definition: MSEdge.h:730
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 closeBuilding()
Definition: MSEdge.cpp:136
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
virtual ~MSEdge()
Destructor.
Definition: MSEdge.cpp:93
This is a dead end link.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:162
T MAX2(T a, T b)
Definition: StdDefs.h:79
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:579
This is an uncontrolled, right-before-left link.
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:307
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:321
The lane is chosen randomly.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
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:701
EdgeBasicFunction
Defines possible edge types.
Definition: MSEdge.h:90
The least occupied lane from best lanes.
The position is chosen randomly.
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
Definition: MSEdge.cpp:314
This is an uncontrolled, all-way stop link.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
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:763
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:81
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:386
std::map< SUMOVehicleClass, MSEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: MSEdge.h:778
void rebuildAllowedLanes()
Definition: MSEdge.cpp:175
SUMOReal getLength() const
return the length of the edge
Definition: MSEdge.h:535
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:1420
#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:577
The edge is a district edge.
Definition: MSEdge.h:100
virtual void setChosenSpeedFactor(const SUMOReal factor)=0
Representation of a vehicle.
Definition: SUMOVehicle.h:65
static bool gCheckRoutes
Definition: MSGlobals.h:80
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:726
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
Definition: MSVehicle.cpp:1922
static void clear()
Clears the dictionary.
Definition: MSEdge.cpp:625
SVCPermissions myMinimumPermissions
The intersection of lane permissions for this edge.
Definition: MSEdge.h:733
MSEdgeVector mySuccessors
The succeeding edges.
Definition: MSEdge.h:707
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:197
MSLaneChanger * myLaneChanger
This member will do the lane-change.
Definition: MSEdge.h:695
MSEdge(const std::string &id, int numericalID, const EdgeBasicFunction function, const std::string &streetName, const std::string &edgeType, int priority)
Constructor.
Definition: MSEdge.cpp:75
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:368
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:692
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
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:682
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:1916
MSLane * getDepartLane(MSVehicle &veh) const
Finds a depart lane for the given vehicle parameters.
Definition: MSEdge.cpp:341
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:704
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
std::vector< std::string > getVector()
SVCPermissions myCombinedPermissions
The union of lane permissions for this edge.
Definition: MSEdge.h:735
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:235
Structure representing possible vehicle parameter.
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:257
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:209
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:349
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
Definition: MSEdge.cpp:498
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:751
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:224
static size_t dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:613
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:93
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:109
unsigned size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:87
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:768
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:214
static const bool gUseMesoSim
Definition: MSGlobals.h:102
Sorts transportables by their positions.
Definition: MSEdge.h:660
const MSJunction * getFromJunction() const
Definition: MSEdge.h:345
const MSEdgeVector & getSuccessors() const
Returns the following edges.
Definition: MSEdge.h:315
#define NUMERICAL_EPS
Definition: config.h:161
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:689
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1059
A free position is chosen.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:78
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:203
int operator()(const MSTransportable *const c1, const MSTransportable *const c2) const
comparing operator
Definition: MSEdge.cpp:712
The edge is an internal edge.
Definition: MSEdge.h:98
const std::vector< MSLane * > * getAllowedLanesWithDefault(const AllowedLanesCont &c, const MSEdge *dest) const
lookup in map and return 0 if not found
Definition: MSEdge.cpp:236
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:1507
MSEdgeVector myPredecessors
The preceeding edges.
Definition: MSEdge.h:710
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:549
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:642
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:696
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:75
std::string id
The vehicle&#39;s id.
const MSJunction * getToJunction() const
Definition: MSEdge.h:349
const Position & getPosition() const
Definition: MSJunction.cpp:67
std::set< MSTransportable * > myPersons
Persons on the edge (only for drawing)
Definition: MSEdge.h:717
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.