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-2014 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 "MSPerson.h"
49 #include "MSEdgeWeightsStorage.h"
50 
51 #ifdef HAVE_INTERNAL
52 #include <mesosim/MELoop.h>
53 #include <mesosim/MESegment.h>
54 #include <mesosim/MEVehicle.h>
55 #endif
56 
57 #ifdef CHECK_MEMORY_LEAKS
58 #include <foreign/nvwa/debug_new.h>
59 #endif // CHECK_MEMORY_LEAKS
60 
61 
62 // ===========================================================================
63 // static member definitions
64 // ===========================================================================
66 std::vector<MSEdge*> MSEdge::myEdges;
67 
68 
69 // ===========================================================================
70 // member method definitions
71 // ===========================================================================
72 MSEdge::MSEdge(const std::string& id, int numericalID,
73  const EdgeBasicFunction function,
74  const std::string& streetName,
75  const std::string& edgeType,
76  int priority) :
77  Named(id), myNumericalID(numericalID), myLanes(0),
78  myLaneChanger(0), myFunction(function), myVaporizationRequests(0),
79  myLastFailedInsertionTime(-1),
80  myFromJunction(0), myToJunction(0),
81  myStreetName(streetName),
82  myEdgeType(edgeType),
83  myPriority(priority),
84  myLength(-1.),
85  myEmptyTraveltime(-1.),
86  myAmDelayed(false),
87  myAmRoundabout(false) {}
88 
89 
91  delete myLaneChanger;
92  for (AllowedLanesCont::iterator i1 = myAllowed.begin(); i1 != myAllowed.end(); i1++) {
93  delete(*i1).second;
94  }
95  for (ClassedAllowedLanesCont::iterator i2 = myClassedAllowed.begin(); i2 != myClassedAllowed.end(); i2++) {
96  for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
97  delete(*i1).second;
98  }
99  }
100  delete myLanes;
101  // Note: Lanes are delete using MSLane::clear();
102 }
103 
104 
105 void
106 MSEdge::initialize(const std::vector<MSLane*>* lanes) {
107  assert(lanes != 0);
108  myLanes = lanes;
109  if (!lanes->empty()) {
110  recalcCache();
111  if (myLanes->size() > 1) {
112  myLaneChanger = new MSLaneChanger(myLanes, OptionsCont::getOptions().getBool("lanechange.allow-swap"));
113  }
114  }
117  }
118 }
119 
120 
122  myLength = myLanes->front()->getLength();
124 }
125 
126 
127 void
129  myAllowed[0] = new std::vector<MSLane*>();
130  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
131  myAllowed[0]->push_back(*i);
132  const MSLinkCont& lc = (*i)->getLinkCont();
133  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
134  MSLane* toL = (*j)->getLane();
135  if (toL != 0) {
136  MSEdge& to = toL->getEdge();
137  //
138  if (std::find(mySuccessors.begin(), mySuccessors.end(), &to) == mySuccessors.end()) {
139  mySuccessors.push_back(&to);
140  }
141  if (std::find(to.myPredecessors.begin(), to.myPredecessors.end(), this) == to.myPredecessors.end()) {
142  to.myPredecessors.push_back(this);
143  }
144  //
145  if (myAllowed.find(&to) == myAllowed.end()) {
146  myAllowed[&to] = new std::vector<MSLane*>();
147  }
148  myAllowed[&to]->push_back(*i);
149  }
150 #ifdef HAVE_INTERNAL_LANES
151  toL = (*j)->getViaLane();
152  if (toL != 0) {
153  MSEdge& to = toL->getEdge();
154  if (std::find(to.myPredecessors.begin(), to.myPredecessors.end(), this) == to.myPredecessors.end()) {
155  to.myPredecessors.push_back(this);
156  }
157  }
158 #endif
159  }
160  }
161  std::sort(mySuccessors.begin(), mySuccessors.end(), by_id_sorter());
163 }
164 
165 
166 void
168  // clear myClassedAllowed.
169  // it will be rebuilt on demand
170  for (ClassedAllowedLanesCont::iterator i2 = myClassedAllowed.begin(); i2 != myClassedAllowed.end(); i2++) {
171  for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
172  delete(*i1).second;
173  }
174  }
175  myClassedAllowed.clear();
176  // rebuild myMinimumPermissions and myCombinedPermissions
179  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
180  myMinimumPermissions &= (*i)->getPermissions();
181  myCombinedPermissions |= (*i)->getPermissions();
182  }
183 }
184 
185 
186 // ------------ Access to the edge's lanes
187 MSLane*
188 MSEdge::leftLane(const MSLane* const lane) const {
189  return parallelLane(lane, 1);
190 }
191 
192 
193 MSLane*
194 MSEdge::rightLane(const MSLane* const lane) const {
195  return parallelLane(lane, -1);
196 }
197 
198 
199 MSLane*
200 MSEdge::parallelLane(const MSLane* const lane, int offset) const {
201  const int index = (int)(find(myLanes->begin(), myLanes->end(), lane) - myLanes->begin());
202  if (index == (int)myLanes->size()) {
203  return 0;
204  }
205  const int resultIndex = index + offset;
206  if (resultIndex >= (int)myLanes->size() || resultIndex < 0) {
207  return 0;
208  } else {
209  return (*myLanes)[resultIndex];
210  }
211 }
212 
213 
214 const std::vector<MSLane*>*
215 MSEdge::allowedLanes(const MSEdge& destination, SUMOVehicleClass vclass) const {
216  return allowedLanes(&destination, vclass);
217 }
218 
219 
220 const std::vector<MSLane*>*
222  return allowedLanes(0, vclass);
223 }
224 
225 
226 const std::vector<MSLane*>*
228  AllowedLanesCont::const_iterator it = c.find(dest);
229  if (it == c.end()) {
230  return 0;
231  }
232  return it->second;
233 }
234 
235 
236 const std::vector<MSLane*>*
237 MSEdge::allowedLanes(const MSEdge* destination, SUMOVehicleClass vclass) const {
238  if ((myMinimumPermissions & vclass) == vclass) {
239  // all lanes allow vclass
240  return getAllowedLanesWithDefault(myAllowed, destination);
241  }
242  // look up cached result in myClassedAllowed
243  ClassedAllowedLanesCont::const_iterator i = myClassedAllowed.find(vclass);
244  if (i != myClassedAllowed.end()) {
245  // can use cached value
246  const AllowedLanesCont& c = (*i).second;
247  return getAllowedLanesWithDefault(c, destination);
248  } else {
249  // this vclass is requested for the first time. rebuild all destinations
250  // go through connected edges
251  for (AllowedLanesCont::const_iterator i1 = myAllowed.begin(); i1 != myAllowed.end(); ++i1) {
252  const MSEdge* edge = i1->first;
253  const std::vector<MSLane*>* lanes = i1->second;
254  myClassedAllowed[vclass][edge] = new std::vector<MSLane*>();
255  // go through lanes approaching current edge
256  for (std::vector<MSLane*>::const_iterator i2 = lanes->begin(); i2 != lanes->end(); ++i2) {
257  // allows the current vehicle class?
258  if ((*i2)->allowsVehicleClass(vclass)) {
259  // -> may be used
260  myClassedAllowed[vclass][edge]->push_back(*i2);
261  }
262  }
263  // assert that 0 is returned if no connection is allowed for a class
264  if (myClassedAllowed[vclass][edge]->size() == 0) {
265  delete myClassedAllowed[vclass][edge];
266  myClassedAllowed[vclass][edge] = 0;
267  }
268  }
269  return myClassedAllowed[vclass][destination];
270  }
271 }
272 
273 
274 // ------------
275 SUMOTime
278  return 0;
279 }
280 
281 
282 SUMOTime
285  return 0;
286 }
287 
288 
289 MSLane*
290 MSEdge::getFreeLane(const std::vector<MSLane*>* allowed, const SUMOVehicleClass vclass) const {
291  if (allowed == 0) {
292  allowed = allowedLanes(vclass);
293  }
294  MSLane* res = 0;
295  if (allowed != 0) {
296  SUMOReal leastOccupancy = std::numeric_limits<SUMOReal>::max();;
297  for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
298  const SUMOReal occupancy = (*i)->getBruttoOccupancy();
299  if (occupancy < leastOccupancy) {
300  res = (*i);
301  leastOccupancy = occupancy;
302  }
303  }
304  }
305  return res;
306 }
307 
308 
309 MSLane*
311  switch (veh.getParameter().departLaneProcedure) {
312  case DEPART_LANE_GIVEN:
313  if ((int) myLanes->size() <= veh.getParameter().departLane || !(*myLanes)[veh.getParameter().departLane]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
314  return 0;
315  }
316  return (*myLanes)[veh.getParameter().departLane];
317  case DEPART_LANE_RANDOM:
319  case DEPART_LANE_FREE:
320  return getFreeLane(0, veh.getVehicleType().getVehicleClass());
322  if (veh.getRoute().size() == 1) {
323  return getFreeLane(0, veh.getVehicleType().getVehicleClass());
324  } else {
325  return getFreeLane(allowedLanes(**(veh.getRoute().begin() + 1)), veh.getVehicleType().getVehicleClass());
326  }
327  case DEPART_LANE_BEST_FREE: {
328  veh.updateBestLanes(false, myLanes->front());
329  const std::vector<MSVehicle::LaneQ>& bl = veh.getBestLanes();
330  SUMOReal bestLength = -1;
331  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
332  if ((*i).length > bestLength) {
333  bestLength = (*i).length;
334  }
335  }
336  std::vector<MSLane*>* bestLanes = new std::vector<MSLane*>();
337  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
338  if ((*i).length == bestLength) {
339  bestLanes->push_back((*i).lane);
340  }
341  }
342  MSLane* ret = getFreeLane(bestLanes, veh.getVehicleType().getVehicleClass());
343  delete bestLanes;
344  return ret;
345  }
346  case DEPART_LANE_DEFAULT:
348  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
349  if ((*i)->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
350  return *i;
351  }
352  }
353  return 0;
354  default:
355  break;
356  }
357  if (!(*myLanes)[0]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
358  return 0;
359  }
360  return (*myLanes)[0];
361 }
362 
363 
364 bool
365 MSEdge::insertVehicle(SUMOVehicle& v, SUMOTime time, const bool checkOnly) const {
366  // when vaporizing, no vehicles are inserted, but checking needs to be successful to trigger removal
367  if (isVaporizing()) {
368  return checkOnly;
369  }
370  const SUMOVehicleParameter& pars = v.getParameter();
371  const MSVehicleType& type = v.getVehicleType();
373  if (type.getSpeedDeviation() > 0 && pars.departSpeed <= type.getSpeedFactor() * getSpeedLimit() * (2 * type.getSpeedDeviation() + 1.)) {
374  WRITE_WARNING("Choosing new speed factor for vehicle '" + pars.id + "' to match departure speed.");
376  } else {
377  throw ProcessError("Departure speed for vehicle '" + pars.id +
378  "' is too high for the departure edge '" + getID() + "'.");
379  }
380  }
381 #ifdef HAVE_INTERNAL
383  SUMOReal pos = 0.0;
384  switch (pars.departPosProcedure) {
385  case DEPART_POS_GIVEN:
386  if (pars.departPos >= 0.) {
387  pos = pars.departPos;
388  } else {
389  pos = pars.departPos + getLength();
390  }
391  if (pos < 0 || pos > getLength()) {
392  WRITE_WARNING("Invalid departPos " + toString(pos) + " given for vehicle '" +
393  v.getID() + "'. Inserting at lane end instead.");
394  pos = getLength();
395  }
396  break;
397  case DEPART_POS_RANDOM:
399  pos = RandHelper::rand(getLength());
400  break;
401  default:
402  break;
403  }
404  bool result = false;
405  MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this, pos);
406  MEVehicle* veh = static_cast<MEVehicle*>(&v);
407  if (pars.departPosProcedure == DEPART_POS_FREE) {
408  while (segment != 0 && !result) {
409  if (checkOnly) {
410  result = segment->hasSpaceFor(veh, time, true);
411  } else {
412  result = segment->initialise(veh, time);
413  }
414  segment = segment->getNextSegment();
415  }
416  } else {
417  if (checkOnly) {
418  result = segment->hasSpaceFor(veh, time, true);
419  } else {
420  result = segment->initialise(veh, time);
421  }
422  }
423  return result;
424  }
425 #else
426  UNUSED_PARAMETER(time);
427 #endif
428  if (checkOnly) {
429  switch (v.getParameter().departLaneProcedure) {
430  case DEPART_LANE_GIVEN:
431  case DEPART_LANE_DEFAULT:
433  return getDepartLane(static_cast<MSVehicle&>(v))->getBruttoOccupancy() * myLength + v.getVehicleType().getLengthWithGap() <= myLength;
434  default:
435  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
436  if ((*i)->getBruttoOccupancy() * myLength + v.getVehicleType().getLengthWithGap() <= myLength) {
437  return true;
438  }
439  }
440  }
441  return false;
442  }
443  MSLane* insertionLane = getDepartLane(static_cast<MSVehicle&>(v));
444  return insertionLane != 0 && insertionLane->insertVehicle(static_cast<MSVehicle&>(v));
445 }
446 
447 
448 void
450  if (myLaneChanger == 0) {
451  return;
452  }
454  // allow changing only if all links leading to this internal lane have priority
455  for (std::vector<MSLane*>::const_iterator it = myLanes->begin(); it != myLanes->end(); ++it) {
456  MSLane* pred = (*it)->getLogicalPredecessorLane();
457  MSLink* link = MSLinkContHelper::getConnectingLink(*pred, **it);
458  assert(link != 0);
459  if (!link->havePriority()) {
460  return;
461  }
462  }
463  }
465 }
466 
467 
468 
469 #ifdef HAVE_INTERNAL_LANES
470 const MSEdge*
471 MSEdge::getInternalFollowingEdge(MSEdge* followerAfterInternal) const {
472  //@todo to be optimized
473  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
474  MSLane* l = *i;
475  const MSLinkCont& lc = l->getLinkCont();
476  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
477  MSLink* link = *j;
478  if (&link->getLane()->getEdge() == followerAfterInternal) {
479  if (link->getViaLane() != 0) {
480  return &link->getViaLane()->getEdge();
481  } else {
482  return 0; // network without internal links
483  }
484  }
485  }
486  }
487  return 0;
488 }
489 #endif
490 
491 
492 SUMOReal
494  assert(minSpeed > 0);
495  if (!myAmDelayed) {
496  return myEmptyTraveltime;
497  }
498  SUMOReal v = 0;
499 #ifdef HAVE_INTERNAL
501  MESegment* first = MSGlobals::gMesoNet->getSegmentForEdge(*this);
502  unsigned segments = 0;
503  do {
504  v += first->getMeanSpeed();
505  first = first->getNextSegment();
506  segments++;
507  } while (first != 0);
508  v /= (SUMOReal) segments;
509  } else {
510 #endif
511  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
512  v += (*i)->getMeanSpeed();
513  }
514  v /= (SUMOReal) myLanes->size();
515 #ifdef HAVE_INTERNAL
516  }
517 #endif
518  return getLength() / MAX2(minSpeed, v);
519 }
520 
521 
522 bool
523 MSEdge::dictionary(const std::string& id, MSEdge* ptr) {
524  DictType::iterator it = myDict.find(id);
525  if (it == myDict.end()) {
526  // id not in myDict.
527  myDict[id] = ptr;
528  while ((int)myEdges.size() < ptr->getNumericalID() + 1) {
529  myEdges.push_back(0);
530  }
531  myEdges[ptr->getNumericalID()] = ptr;
532  return true;
533  }
534  return false;
535 }
536 
537 
538 MSEdge*
539 MSEdge::dictionary(const std::string& id) {
540  DictType::iterator it = myDict.find(id);
541  if (it == myDict.end()) {
542  // id not in myDict.
543  return 0;
544  }
545  return it->second;
546 }
547 
548 
549 MSEdge*
550 MSEdge::dictionary(size_t id) {
551  assert(myEdges.size() > id);
552  return myEdges[id];
553 }
554 
555 
556 size_t
558  return myDict.size();
559 }
560 
561 
562 size_t
564  return myEdges.size();
565 }
566 
567 
568 void
570  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
571  delete(*i).second;
572  }
573  myDict.clear();
574 }
575 
576 
577 void
578 MSEdge::insertIDs(std::vector<std::string>& into) {
579  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
580  into.push_back((*i).first);
581  }
582 }
583 
584 
585 void
586 MSEdge::parseEdgesList(const std::string& desc, std::vector<const MSEdge*>& into,
587  const std::string& rid) {
588  if (desc[0] == BinaryFormatter::BF_ROUTE) {
589  std::istringstream in(desc, std::ios::binary);
590  char c;
591  in >> c;
592  FileHelpers::readEdgeVector(in, into, rid);
593  } else {
594  StringTokenizer st(desc);
595  parseEdgesList(st.getVector(), into, rid);
596  }
597 }
598 
599 
600 void
601 MSEdge::parseEdgesList(const std::vector<std::string>& desc, std::vector<const MSEdge*>& into,
602  const std::string& rid) {
603  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
604  const MSEdge* edge = MSEdge::dictionary(*i);
605  // check whether the edge exists
606  if (edge == 0) {
607  throw ProcessError("The edge '" + *i + "' within the route " + rid + " is not known."
608  + "\n The route can not be build.");
609  }
610  into.push_back(edge);
611  }
612 }
613 
614 
615 SUMOReal
616 MSEdge::getDistanceTo(const MSEdge* other) const {
617  if (getLanes().size() > 0 && other->getLanes().size() > 0) {
619  } else {
620  return 0; // optimism is just right for astar
621  }
622 }
623 
624 
625 SUMOReal
627  // @note lanes might have different maximum speeds in theory
628  return getLanes()[0]->getSpeedLimit();
629 }
630 
631 
632 SUMOReal
633 MSEdge::getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
634  // @note lanes might have different maximum speeds in theory
635  return getLanes()[0]->getVehicleMaxSpeed(veh);
636 }
637 
638 
639 std::vector<MSPerson*>
641  std::vector<MSPerson*> result(myPersons.begin(), myPersons.end());
642  sort(result.begin(), result.end(), person_by_offset_sorter(timestep));
643  return result;
644 }
645 
646 
647 int
648 MSEdge::person_by_offset_sorter::operator()(const MSPerson* const p1, const MSPerson* const p2) const {
649  const SUMOReal pos1 = p1->getCurrentStage()->getEdgePos(myTime);
650  const SUMOReal pos2 = p2->getCurrentStage()->getEdgePos(myTime);
651  if (pos1 != pos2) {
652  return pos1 < pos2;
653  }
654  return p1->getID() < p2->getID();
655 }
656 
657 /****************************************************************************/
658 
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:719
const std::string & getID() const
returns the person id
Definition: MSPerson.cpp:551
std::set< MSPerson * > myPersons
Persons on the edge (only for drawing)
Definition: MSEdge.h:685
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:455
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:78
static void insertIDs(std::vector< std::string > &into)
Inserts IDs of all known edges into the given vector.
Definition: MSEdge.cpp:578
SUMOReal myLength
the length of the edge (cached value for speedup)
Definition: MSEdge.h:713
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
Sorts edges by their ids.
Definition: MSEdge.h:613
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false) const
Tries to insert the given vehicle into the network.
Definition: MSEdge.cpp:365
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:616
static size_t numericalDictSize()
Returns the number of edges with a numerical id.
Definition: MSEdge.cpp:563
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:106
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:180
SUMOReal getLengthWithGap() const
Get vehicle&#39;s length including the minimum gap [m].
std::vector< MSEdge * > mySuccessors
The succeeding edges.
Definition: MSEdge.h:675
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
void recalcCache()
Recalculates the cached values.
Definition: MSEdge.cpp:121
SUMOReal departSpeed
(optional) The initial speed of the vehicle
const EdgeBasicFunction myFunction
the purpose of the edge
Definition: MSEdge.h:666
The position is given.
ClassedAllowedLanesCont myClassedAllowed
From vehicle class to lanes allowed to be used by it.
Definition: MSEdge.h:695
The least occupied lane is used.
void closeBuilding()
Definition: MSEdge.cpp:128
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
virtual ~MSEdge()
Destructor.
Definition: MSEdge.cpp:90
T MAX2(T a, T b)
Definition: StdDefs.h:74
const MSRoute & getRoute() const
Returns the current route.
Definition: MSBaseVehicle.h:82
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:523
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:276
MSLane * getFreeLane(const std::vector< MSLane * > *allowed, const SUMOVehicleClass vclass) const
Finds the emptiest lane allowing the vehicle class.
Definition: MSEdge.cpp:290
The lane is chosen randomly.
static T getRandomFrom(const std::vector< T > &v)
Returns a random element from the given vector.
Definition: RandHelper.h:102
const SVCPermissions SVCAll
int myVaporizationRequests
Vaporizer counter.
Definition: MSEdge.h:669
EdgeBasicFunction
Defines possible edge types.
Definition: MSEdge.h:84
The least occupied lane from best lanes.
The position is chosen randomly.
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
Definition: MSEdge.cpp:283
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
std::vector< MSEdge * > myPredecessors
The preceeding edges.
Definition: MSEdge.h:678
#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:728
The car-following model and parameter.
Definition: MSVehicleType.h:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
The lane is given.
static std::vector< MSEdge * > myEdges
Static list of edges.
Definition: MSEdge.h:738
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:75
static void parseEdgesList(const std::string &desc, std::vector< const MSEdge * > &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
Definition: MSEdge.cpp:586
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:366
void rebuildAllowedLanes()
Definition: MSEdge.cpp:167
Sorts edges by their ids.
Definition: MSEdge.h:628
SUMOReal getLength() const
return the length of the edge
Definition: MSEdge.h:514
MSLane * getLogicalPredecessorLane() const
Definition: MSLane.cpp:1351
#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.
The edge is a district edge.
Definition: MSEdge.h:94
virtual void setChosenSpeedFactor(const SUMOReal factor)=0
Representation of a vehicle.
Definition: SUMOVehicle.h:64
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:691
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
Definition: MSVehicle.cpp:1819
static void clear()
Clears the dictionary.
Definition: MSEdge.cpp:569
SVCPermissions myMinimumPermissions
The intersection of lane permissions for this edge.
Definition: MSEdge.h:698
MSPersonStage * getCurrentStage() const
Definition: MSPerson.h:593
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:188
MSLaneChanger * myLaneChanger
This member will do the lane-change.
Definition: MSEdge.h:663
MSEdge(const std::string &id, int numericalID, const EdgeBasicFunction function, const std::string &streetName, const std::string &edgeType, int priority)
Constructor.
Definition: MSEdge.cpp:72
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
Definition: MSEdge.h:347
int operator()(const MSPerson *const p1, const MSPerson *const p2) const
comparing operator
Definition: MSEdge.cpp:648
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:660
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:626
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:1813
MSLane * getDepartLane(MSVehicle &veh) const
Finds a depart lane for the given vehicle parameters.
Definition: MSEdge.cpp:310
Base class for objects which have an id.
Definition: Named.h:45
The rightmost lane the vehicle may use.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
virtual SUMOReal getEdgePos(SUMOTime now) const =0
std::vector< std::string > getVector()
SVCPermissions myCombinedPermissions
The union of lane permissions for this edge.
Definition: MSEdge.h:700
SUMOReal getSpeedFactor() const
Returns this type&#39;s speed factor.
No information given; use default.
Structure representing possible vehicle parameter.
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:244
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:200
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
Definition: MSEdge.cpp:449
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:716
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:215
static size_t dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:557
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
Definition: MSBaseVehicle.h:90
int SUMOTime
Definition: SUMOTime.h:43
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:103
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:733
static void readEdgeVector(std::istream &in, std::vector< const E * > &edges, const std::string &rid)
Reads an edge vector binary.
Definition: FileHelpers.h:279
#define SUMOReal
Definition: config.h:218
static const bool gUseMesoSim
Definition: MSGlobals.h:102
const MSJunction * getFromJunction() const
Definition: MSEdge.h:324
#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:633
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1039
A free position is chosen.
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:194
The edge is an internal edge.
Definition: MSEdge.h:92
const std::vector< MSLane * > * getAllowedLanesWithDefault(const AllowedLanesCont &c, const MSEdge *dest) const
lookup in map and return 0 if not found
Definition: MSEdge.cpp:227
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:1426
std::vector< MSPerson * > getSortedPersons(SUMOTime timestep) const
Returns this edge&#39;s persons sorted by pos.
Definition: MSEdge.cpp:640
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:493
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
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:328
const Position & getPosition() const
Definition: MSJunction.cpp:61
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.