SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 "MSJunction.h"
44 #include "MSLane.h"
45 #include "MSLaneChanger.h"
46 #include "MSGlobals.h"
47 #include "MSVehicle.h"
48 #include "MSContainer.h"
49 #include "MSEdgeWeightsStorage.h"
51 
52 #ifdef HAVE_INTERNAL
53 #include <mesosim/MELoop.h>
54 #include <mesosim/MESegment.h>
55 #include <mesosim/MEVehicle.h>
56 #endif
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 }
165 
166 
167 void
169  // clear myClassedAllowed.
170  // it will be rebuilt on demand
171  for (ClassedAllowedLanesCont::iterator i2 = myClassedAllowed.begin(); i2 != myClassedAllowed.end(); i2++) {
172  for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
173  delete(*i1).second;
174  }
175  }
176  myClassedAllowed.clear();
177  myClassesSuccessorMap.clear();
178  // rebuild myMinimumPermissions and myCombinedPermissions
181  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
182  myMinimumPermissions &= (*i)->getPermissions();
183  myCombinedPermissions |= (*i)->getPermissions();
184  }
185 }
186 
187 
188 // ------------ Access to the edge's lanes
189 MSLane*
190 MSEdge::leftLane(const MSLane* const lane) const {
191  return parallelLane(lane, 1);
192 }
193 
194 
195 MSLane*
196 MSEdge::rightLane(const MSLane* const lane) const {
197  return parallelLane(lane, -1);
198 }
199 
200 
201 MSLane*
202 MSEdge::parallelLane(const MSLane* const lane, int offset) const {
203  const int index = (int)(find(myLanes->begin(), myLanes->end(), lane) - myLanes->begin());
204  if (index == (int)myLanes->size()) {
205  return 0;
206  }
207  const int resultIndex = index + offset;
208  if (resultIndex >= (int)myLanes->size() || resultIndex < 0) {
209  return 0;
210  } else {
211  return (*myLanes)[resultIndex];
212  }
213 }
214 
215 
216 const std::vector<MSLane*>*
217 MSEdge::allowedLanes(const MSEdge& destination, SUMOVehicleClass vclass) const {
218  return allowedLanes(&destination, vclass);
219 }
220 
221 
222 const std::vector<MSLane*>*
224  return allowedLanes(0, vclass);
225 }
226 
227 
228 const std::vector<MSLane*>*
230  AllowedLanesCont::const_iterator it = c.find(dest);
231  if (it == c.end()) {
232  return 0;
233  }
234  return it->second;
235 }
236 
237 
238 const std::vector<MSLane*>*
239 MSEdge::allowedLanes(const MSEdge* destination, SUMOVehicleClass vclass) const {
240  if (destination == 0 && (myMinimumPermissions & vclass) == vclass) {
241  // all lanes allow vclass
242  return getAllowedLanesWithDefault(myAllowed, destination);
243  }
244  // look up cached result in myClassedAllowed
245  ClassedAllowedLanesCont::const_iterator i = myClassedAllowed.find(vclass);
246  if (i != myClassedAllowed.end()) {
247  // can use cached value
248  const AllowedLanesCont& c = (*i).second;
249  return getAllowedLanesWithDefault(c, destination);
250  } else {
251  // this vclass is requested for the first time. rebuild all destinations
252  // go through connected edges
253 #ifdef HAVE_FOX
254  if (MSDevice_Routing::isParallel()) {
255  MSDevice_Routing::lock();
256  }
257 #endif
258  for (AllowedLanesCont::const_iterator i1 = myAllowed.begin(); i1 != myAllowed.end(); ++i1) {
259  const MSEdge* edge = i1->first;
260  const std::vector<MSLane*>* lanes = i1->second;
261  myClassedAllowed[vclass][edge] = new std::vector<MSLane*>();
262  // go through lanes approaching current edge
263  for (std::vector<MSLane*>::const_iterator i2 = lanes->begin(); i2 != lanes->end(); ++i2) {
264  // origin lane allows the current vehicle class?
265  if ((*i2)->allowsVehicleClass(vclass)) {
266  if (edge == 0) {
267  myClassedAllowed[vclass][edge]->push_back(*i2);
268  } else {
269  // target lane allows the current vehicle class?
270  const MSLinkCont& lc = (*i2)->getLinkCont();
271  for (MSLinkCont::const_iterator it_link = lc.begin(); it_link != lc.end(); ++it_link) {
272  const MSLane* targetLane = (*it_link)->getLane();
273  if ((&(targetLane->getEdge()) == edge) && targetLane->allowsVehicleClass(vclass)) {
274  // -> may be used
275  myClassedAllowed[vclass][edge]->push_back(*i2);
276  break;
277  }
278  }
279  }
280  }
281  }
282  // assert that 0 is returned if no connection is allowed for a class
283  if (myClassedAllowed[vclass][edge]->size() == 0) {
284  delete myClassedAllowed[vclass][edge];
285  myClassedAllowed[vclass][edge] = 0;
286  }
287  }
288 #ifdef HAVE_FOX
289  if (MSDevice_Routing::isParallel()) {
290  MSDevice_Routing::unlock();
291  }
292 #endif
293  return myClassedAllowed[vclass][destination];
294  }
295 }
296 
297 
298 // ------------
299 SUMOTime
302  return 0;
303 }
304 
305 
306 SUMOTime
309  return 0;
310 }
311 
312 
313 MSLane*
314 MSEdge::getFreeLane(const std::vector<MSLane*>* allowed, const SUMOVehicleClass vclass) const {
315  if (allowed == 0) {
316  allowed = allowedLanes(vclass);
317  }
318  MSLane* res = 0;
319  if (allowed != 0) {
320  SUMOReal leastOccupancy = std::numeric_limits<SUMOReal>::max();;
321  for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
322  const SUMOReal occupancy = (*i)->getBruttoOccupancy();
323  if (occupancy < leastOccupancy) {
324  res = (*i);
325  leastOccupancy = occupancy;
326  }
327  }
328  }
329  return res;
330 }
331 
332 
333 MSLane*
335  switch (veh.getParameter().departLaneProcedure) {
336  case DEPART_LANE_GIVEN:
337  if ((int) myLanes->size() <= veh.getParameter().departLane || !(*myLanes)[veh.getParameter().departLane]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
338  return 0;
339  }
340  return (*myLanes)[veh.getParameter().departLane];
341  case DEPART_LANE_RANDOM:
343  case DEPART_LANE_FREE:
344  return getFreeLane(0, veh.getVehicleType().getVehicleClass());
346  if (veh.getRoute().size() == 1) {
347  return getFreeLane(0, veh.getVehicleType().getVehicleClass());
348  } else {
349  return getFreeLane(allowedLanes(**(veh.getRoute().begin() + 1)), veh.getVehicleType().getVehicleClass());
350  }
351  case DEPART_LANE_BEST_FREE: {
352  veh.updateBestLanes(false, myLanes->front());
353  const std::vector<MSVehicle::LaneQ>& bl = veh.getBestLanes();
354  SUMOReal bestLength = -1;
355  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
356  if ((*i).length > bestLength) {
357  bestLength = (*i).length;
358  }
359  }
360  std::vector<MSLane*>* bestLanes = new std::vector<MSLane*>();
361  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
362  if ((*i).length == bestLength) {
363  bestLanes->push_back((*i).lane);
364  }
365  }
366  MSLane* ret = getFreeLane(bestLanes, veh.getVehicleType().getVehicleClass());
367  delete bestLanes;
368  return ret;
369  }
370  case DEPART_LANE_DEFAULT:
372  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
373  if ((*i)->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
374  return *i;
375  }
376  }
377  return 0;
378  default:
379  break;
380  }
381  if (!(*myLanes)[0]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
382  return 0;
383  }
384  return (*myLanes)[0];
385 }
386 
387 
388 bool
389 MSEdge::insertVehicle(SUMOVehicle& v, SUMOTime time, const bool checkOnly) const {
390  // when vaporizing, no vehicles are inserted, but checking needs to be successful to trigger removal
391  if (isVaporizing()) {
392  return checkOnly;
393  }
394  const SUMOVehicleParameter& pars = v.getParameter();
395  const MSVehicleType& type = v.getVehicleType();
397  if (type.getSpeedDeviation() > 0 && pars.departSpeed <= type.getSpeedFactor() * getSpeedLimit() * (2 * type.getSpeedDeviation() + 1.)) {
398  WRITE_WARNING("Choosing new speed factor for vehicle '" + pars.id + "' to match departure speed.");
400  } else {
401  throw ProcessError("Departure speed for vehicle '" + pars.id +
402  "' is too high for the departure edge '" + getID() + "'.");
403  }
404  }
405 #ifdef HAVE_INTERNAL
407  SUMOReal pos = 0.0;
408  switch (pars.departPosProcedure) {
409  case DEPART_POS_GIVEN:
410  if (pars.departPos >= 0.) {
411  pos = pars.departPos;
412  } else {
413  pos = pars.departPos + getLength();
414  }
415  if (pos < 0 || pos > getLength()) {
416  WRITE_WARNING("Invalid departPos " + toString(pos) + " given for vehicle '" +
417  v.getID() + "'. Inserting at lane end instead.");
418  pos = getLength();
419  }
420  break;
421  case DEPART_POS_RANDOM:
423  pos = RandHelper::rand(getLength());
424  break;
425  default:
426  break;
427  }
428  bool result = false;
429  MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this, pos);
430  MEVehicle* veh = static_cast<MEVehicle*>(&v);
431  if (pars.departPosProcedure == DEPART_POS_FREE) {
432  while (segment != 0 && !result) {
433  if (checkOnly) {
434  result = segment->hasSpaceFor(veh, time, true);
435  } else {
436  result = segment->initialise(veh, time);
437  }
438  segment = segment->getNextSegment();
439  }
440  } else {
441  if (checkOnly) {
442  result = segment->hasSpaceFor(veh, time, true);
443  } else {
444  result = segment->initialise(veh, time);
445  }
446  }
447  return result;
448  }
449 #else
450  UNUSED_PARAMETER(time);
451 #endif
452  if (checkOnly) {
454  return true;
455  }
456  switch (v.getParameter().departLaneProcedure) {
457  case DEPART_LANE_GIVEN:
458  case DEPART_LANE_DEFAULT:
460  const SUMOReal occupancy = getDepartLane(static_cast<MSVehicle&>(v))->getBruttoOccupancy();
461  return occupancy == (SUMOReal)0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength;
462  }
463  default:
464  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
465  const SUMOReal occupancy = (*i)->getBruttoOccupancy();
466  if (occupancy == (SUMOReal)0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength) {
467  return true;
468  }
469  }
470  }
471  return false;
472  }
473  MSLane* insertionLane = getDepartLane(static_cast<MSVehicle&>(v));
474  return insertionLane != 0 && insertionLane->insertVehicle(static_cast<MSVehicle&>(v));
475 }
476 
477 
478 void
480  if (myLaneChanger == 0) {
481  return;
482  }
484  // allow changing only if all links leading to this internal lane have priority
485  for (std::vector<MSLane*>::const_iterator it = myLanes->begin(); it != myLanes->end(); ++it) {
486  MSLane* pred = (*it)->getLogicalPredecessorLane();
487  MSLink* link = MSLinkContHelper::getConnectingLink(*pred, **it);
488  assert(link != 0);
489  if (!link->havePriority()) {
490  return;
491  }
492  }
493  }
495 }
496 
497 
498 
499 #ifdef HAVE_INTERNAL_LANES
500 const MSEdge*
501 MSEdge::getInternalFollowingEdge(MSEdge* followerAfterInternal) const {
502  //@todo to be optimized
503  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
504  MSLane* l = *i;
505  const MSLinkCont& lc = l->getLinkCont();
506  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
507  MSLink* link = *j;
508  if (&link->getLane()->getEdge() == followerAfterInternal) {
509  if (link->getViaLane() != 0) {
510  return &link->getViaLane()->getEdge();
511  } else {
512  return 0; // network without internal links
513  }
514  }
515  }
516  }
517  return 0;
518 }
519 #endif
520 
521 
522 SUMOReal
524  assert(minSpeed > 0);
525  if (!myAmDelayed) {
526  return myEmptyTraveltime;
527  }
528  SUMOReal v = 0;
529 #ifdef HAVE_INTERNAL
531  MESegment* first = MSGlobals::gMesoNet->getSegmentForEdge(*this);
532  unsigned segments = 0;
533  do {
534  v += first->getMeanSpeed();
535  first = first->getNextSegment();
536  segments++;
537  } while (first != 0);
538  v /= (SUMOReal) segments;
539  } else {
540 #endif
541  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
542  v += (*i)->getMeanSpeed();
543  }
544  v /= (SUMOReal) myLanes->size();
545 #ifdef HAVE_INTERNAL
546  }
547 #endif
548  return getLength() / MAX2(minSpeed, v);
549 }
550 
551 
552 bool
553 MSEdge::dictionary(const std::string& id, MSEdge* ptr) {
554  DictType::iterator it = myDict.find(id);
555  if (it == myDict.end()) {
556  // id not in myDict.
557  myDict[id] = ptr;
558  while ((int)myEdges.size() < ptr->getNumericalID() + 1) {
559  myEdges.push_back(0);
560  }
561  myEdges[ptr->getNumericalID()] = ptr;
562  return true;
563  }
564  return false;
565 }
566 
567 
568 MSEdge*
569 MSEdge::dictionary(const std::string& id) {
570  DictType::iterator it = myDict.find(id);
571  if (it == myDict.end()) {
572  // id not in myDict.
573  return 0;
574  }
575  return it->second;
576 }
577 
578 
579 MSEdge*
580 MSEdge::dictionary(size_t id) {
581  assert(myEdges.size() > id);
582  return myEdges[id];
583 }
584 
585 
586 size_t
588  return myDict.size();
589 }
590 
591 
592 size_t
594  return myEdges.size();
595 }
596 
597 
598 void
600  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
601  delete(*i).second;
602  }
603  myDict.clear();
604 }
605 
606 
607 void
608 MSEdge::insertIDs(std::vector<std::string>& into) {
609  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
610  into.push_back((*i).first);
611  }
612 }
613 
614 
615 void
616 MSEdge::parseEdgesList(const std::string& desc, ConstMSEdgeVector& into,
617  const std::string& rid) {
618  if (desc[0] == BinaryFormatter::BF_ROUTE) {
619  std::istringstream in(desc, std::ios::binary);
620  char c;
621  in >> c;
622  FileHelpers::readEdgeVector(in, into, rid);
623  } else {
624  StringTokenizer st(desc);
625  parseEdgesList(st.getVector(), into, rid);
626  }
627 }
628 
629 
630 void
631 MSEdge::parseEdgesList(const std::vector<std::string>& desc, ConstMSEdgeVector& into,
632  const std::string& rid) {
633  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
634  const MSEdge* edge = MSEdge::dictionary(*i);
635  // check whether the edge exists
636  if (edge == 0) {
637  throw ProcessError("The edge '" + *i + "' within the route " + rid + " is not known."
638  + "\n The route can not be build.");
639  }
640  into.push_back(edge);
641  }
642 }
643 
644 
645 SUMOReal
646 MSEdge::getDistanceTo(const MSEdge* other) const {
647  if (getLanes().size() > 0 && other->getLanes().size() > 0) {
649  } else {
650  return 0; // optimism is just right for astar
651  }
652 }
653 
654 
655 SUMOReal
657  // @note lanes might have different maximum speeds in theory
658  return getLanes()[0]->getSpeedLimit();
659 }
660 
661 
662 SUMOReal
663 MSEdge::getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
664  // @note lanes might have different maximum speeds in theory
665  return getLanes()[0]->getVehicleMaxSpeed(veh);
666 }
667 
668 
669 std::vector<MSTransportable*>
671  std::vector<MSTransportable*> result(myPersons.begin(), myPersons.end());
672  sort(result.begin(), result.end(), transportable_by_position_sorter(timestep));
673  return result;
674 }
675 
676 
677 std::vector<MSTransportable*>
679  std::vector<MSTransportable*> result(myContainers.begin(), myContainers.end());
680  sort(result.begin(), result.end(), transportable_by_position_sorter(timestep));
681  return result;
682 }
683 
684 
685 int
687  const SUMOReal pos1 = c1->getCurrentStage()->getEdgePos(myTime);
688  const SUMOReal pos2 = c2->getCurrentStage()->getEdgePos(myTime);
689  if (pos1 != pos2) {
690  return pos1 < pos2;
691  }
692  return c1->getID() < c2->getID();
693 }
694 
695 const MSEdgeVector&
697  if (vClass == SVC_IGNORING || !MSNet::getInstance()->hasPermissions()) {
698  return mySuccessors;
699  }
700 #ifdef HAVE_FOX
701  if (MSDevice_Routing::isParallel()) {
702  MSDevice_Routing::lock();
703  }
704 #endif
705  std::map<SUMOVehicleClass, MSEdgeVector>::const_iterator i = myClassesSuccessorMap.find(vClass);
706  if (i != myClassesSuccessorMap.end()) {
707  // can use cached value
708 #ifdef HAVE_FOX
709  if (MSDevice_Routing::isParallel()) {
710  MSDevice_Routing::unlock();
711  }
712 #endif
713  return i->second;
714  } else {
715  // this vClass is requested for the first time. rebuild all successors
716  for (MSEdgeVector::const_iterator it = mySuccessors.begin(); it != mySuccessors.end(); ++it) {
717  const std::vector<MSLane*>* allowed = allowedLanes(*it, vClass);
718  if (allowed != 0 && allowed->size() > 0) {
719  myClassesSuccessorMap[vClass].push_back(*it);
720  }
721  }
722 #ifdef HAVE_FOX
723  if (MSDevice_Routing::isParallel()) {
724  MSDevice_Routing::unlock();
725  }
726 #endif
727  return myClassesSuccessorMap[vClass];
728  }
729 }
730 
731 
732 /****************************************************************************/
733 
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:608
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.
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:389
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:646
static size_t numericalDictSize()
Returns the number of edges with a numerical id.
Definition: MSEdge.cpp:593
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:107
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:186
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
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:129
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
virtual ~MSEdge()
Destructor.
Definition: MSEdge.cpp:91
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:74
const MSRoute & getRoute() const
Returns the current route.
Definition: MSBaseVehicle.h:82
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:553
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:300
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:314
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:307
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
#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:60
A road/street connecting two junctions.
Definition: MSEdge.h:81
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:387
std::map< SUMOVehicleClass, MSEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: MSEdge.h:778
void rebuildAllowedLanes()
Definition: MSEdge.cpp:168
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:1426
#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
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
The least occupied lane from lanes which allow the continuation.
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:1894
static void clear()
Clears the dictionary.
Definition: MSEdge.cpp:599
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:190
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:73
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:656
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:1888
MSLane * getDepartLane(MSVehicle &veh) const
Finds a depart lane for the given vehicle parameters.
Definition: MSEdge.cpp:334
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:678
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:202
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
Definition: MSEdge.cpp:479
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:217
static size_t dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:587
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:90
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:240
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:215
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:162
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:663
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1065
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:196
int operator()(const MSTransportable *const c1, const MSTransportable *const c2) const
comparing operator
Definition: MSEdge.cpp:686
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:229
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:1513
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:523
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:616
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:670
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:61
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.