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-2017 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>
43 #include <mesosim/MELoop.h>
44 #include <mesosim/MESegment.h>
45 #include <mesosim/MEVehicle.h>
46 #include "MSInsertionControl.h"
47 #include "MSJunction.h"
48 #include "MSLane.h"
49 #include "MSLaneChanger.h"
50 #include "MSLaneChangerSublane.h"
51 #include "MSGlobals.h"
52 #include "MSNet.h"
53 #include "MSVehicle.h"
54 #include "MSLeaderInfo.h"
55 #include "MSContainer.h"
56 #include "MSEdgeWeightsStorage.h"
57 #include "MSEdge.h"
58 
59 #define BEST_LANE_LOOKAHEAD 3000.0
60 
61 // ===========================================================================
62 // static member definitions
63 // ===========================================================================
66 
67 
68 // ===========================================================================
69 // member method definitions
70 // ===========================================================================
71 MSEdge::MSEdge(const std::string& id, int numericalID,
72  const SumoXMLEdgeFunc function,
73  const std::string& streetName,
74  const std::string& edgeType,
75  int priority) :
76  Named(id), myNumericalID(numericalID), myLanes(0),
77  myLaneChanger(0), myFunction(function), myVaporizationRequests(0),
78  myLastFailedInsertionTime(-1),
79  myFromJunction(0), myToJunction(0),
80  myStreetName(streetName),
81  myEdgeType(edgeType),
82  myPriority(priority),
83  myWidth(0),
84  myLength(-1.),
85  myEmptyTraveltime(-1.),
86  myAmDelayed(false),
87  myAmRoundabout(false),
88  myAmFringe(true) {
89 }
90 
91 
93  delete myLaneChanger;
94  for (AllowedLanesCont::iterator i1 = myAllowed.begin(); i1 != myAllowed.end(); i1++) {
95  delete(*i1).second;
96  }
97  for (ClassedAllowedLanesCont::iterator i2 = myClassedAllowed.begin(); i2 != myClassedAllowed.end(); i2++) {
98  for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
99  delete(*i1).second;
100  }
101  }
102  delete myLanes;
103  // Note: Lanes are delete using MSLane::clear();
104 }
105 
106 
107 void
108 MSEdge::initialize(const std::vector<MSLane*>* lanes) {
109  assert(lanes != 0);
110  myLanes = lanes;
113  }
114  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
115  myWidth += (*i)->getWidth();
116  }
117  double widthBefore = 0;
118  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
119  (*i)->setRightSideOnEdge(widthBefore, (int)mySublaneSides.size());
120  MSLeaderInfo ahead(*i);
121  for (int j = 0; j < ahead.numSublanes(); ++j) {
122  mySublaneSides.push_back(widthBefore + j * MSGlobals::gLateralResolution);
123  }
124  widthBefore += (*i)->getWidth();
125  }
126 }
127 
128 
130  if (myLanes->empty()) {
131  return;
132  }
133  myLength = myLanes->front()->getLength();
135 
137  // add tls penalties to the minimum travel time
138  SUMOTime minPenalty = -1;
139  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
140  MSLane* l = *i;
141  const MSLinkCont& lc = l->getLinkCont();
142  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
143  MSLink* link = *j;
144  SUMOTime linkPenalty = link->getMesoTLSPenalty() + (link->havePriority() ? 0 : MSGlobals::gMesoMinorPenalty);
145  if (minPenalty == -1) {
146  minPenalty = linkPenalty;
147  } else {
148  minPenalty = MIN2(minPenalty, linkPenalty);
149  }
150  }
151  }
152  if (minPenalty > 0) {
153  myEmptyTraveltime += STEPS2TIME(minPenalty);
154  }
155  }
156 }
157 
158 
159 void
161  myAllowed[0] = new std::vector<MSLane*>();
162  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
163  myAllowed[0]->push_back(*i);
164  const MSLinkCont& lc = (*i)->getLinkCont();
165  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
166  (*j)->initParallelLinks();
167  MSLane* toL = (*j)->getLane();
168  if (toL != 0) {
169  MSEdge& to = toL->getEdge();
170  //
171  if (std::find(mySuccessors.begin(), mySuccessors.end(), &to) == mySuccessors.end()) {
172  mySuccessors.push_back(&to);
173  }
174  if (std::find(to.myPredecessors.begin(), to.myPredecessors.end(), this) == to.myPredecessors.end()) {
175  to.myPredecessors.push_back(this);
176  }
177  //
178  if (myAllowed.find(&to) == myAllowed.end()) {
179  myAllowed[&to] = new std::vector<MSLane*>();
180  }
181  myAllowed[&to]->push_back(*i);
182  if ((*j)->getDirection() != LINKDIR_TURN) {
183  myAmFringe = false;
184  }
185  }
186  toL = (*j)->getViaLane();
187  if (toL != 0) {
188  MSEdge& to = toL->getEdge();
189  if (std::find(to.myPredecessors.begin(), to.myPredecessors.end(), this) == to.myPredecessors.end()) {
190  to.myPredecessors.push_back(this);
191  }
192  }
193  }
194  }
195  std::sort(mySuccessors.begin(), mySuccessors.end(), by_id_sorter());
197  recalcCache();
198  // segment building depends on the finished list of successors (for multi-queue)
199  if (MSGlobals::gUseMesoSim && !myLanes->empty()) {
201  }
202 }
203 
204 
205 void
207  if (!myLanes->empty()) {
208  const bool allowChanging = allowsLaneChanging();
210  // may always initiate sublane-change
211  myLaneChanger = new MSLaneChangerSublane(myLanes, allowChanging);
212  } else {
214  myLaneChanger = new MSLaneChanger(myLanes, allowChanging);
215  } else if (myLanes->size() > 1 || canChangeToOpposite()) {
216  myLaneChanger = new MSLaneChanger(myLanes, allowChanging);
217  }
218  }
219  }
220 }
221 
222 
223 bool
225  if (isInternal()) {
226  // allow changing only if all links leading to this internal lane have priority
227  // or they are controlled by a traffic light
228  for (std::vector<MSLane*>::const_iterator it = myLanes->begin(); it != myLanes->end(); ++it) {
229  MSLane* pred = (*it)->getLogicalPredecessorLane();
230  MSLink* link = MSLinkContHelper::getConnectingLink(*pred, **it);
231  assert(link != 0);
232  LinkState state = link->getState();
233  if (state == LINKSTATE_MINOR
234  || state == LINKSTATE_EQUAL
235  || state == LINKSTATE_STOP
236  || state == LINKSTATE_ALLWAY_STOP
237  || state == LINKSTATE_DEADEND) {
238  return false;
239  }
240  }
241  }
242  return true;
243 }
244 
245 
246 void
248  // clear myClassedAllowed.
249  // it will be rebuilt on demand
250  for (ClassedAllowedLanesCont::iterator i2 = myClassedAllowed.begin(); i2 != myClassedAllowed.end(); i2++) {
251  for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
252  delete(*i1).second;
253  }
254  }
255  myClassedAllowed.clear();
256  myClassesSuccessorMap.clear();
257  // rebuild myMinimumPermissions and myCombinedPermissions
260  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
261  myMinimumPermissions &= (*i)->getPermissions();
262  myCombinedPermissions |= (*i)->getPermissions();
263  }
264 }
265 
266 
267 // ------------ Access to the edge's lanes
268 MSLane*
269 MSEdge::leftLane(const MSLane* const lane) const {
270  return parallelLane(lane, 1);
271 }
272 
273 
274 MSLane*
275 MSEdge::rightLane(const MSLane* const lane) const {
276  return parallelLane(lane, -1);
277 }
278 
279 
280 MSLane*
281 MSEdge::parallelLane(const MSLane* const lane, int offset) const {
282  const int index = (int)(find(myLanes->begin(), myLanes->end(), lane) - myLanes->begin());
283  if (index == (int)myLanes->size()) {
284  return 0;
285  }
286  const int resultIndex = index + offset;
287  if (resultIndex >= (int)myLanes->size() || resultIndex < 0) {
288  return 0;
289  } else {
290  return (*myLanes)[resultIndex];
291  }
292 }
293 
294 
295 const std::vector<MSLane*>*
296 MSEdge::allowedLanes(const MSEdge& destination, SUMOVehicleClass vclass) const {
297  return allowedLanes(&destination, vclass);
298 }
299 
300 
301 const std::vector<MSLane*>*
303  return allowedLanes(0, vclass);
304 }
305 
306 
307 const std::vector<MSLane*>*
309  AllowedLanesCont::const_iterator it = c.find(dest);
310  if (it == c.end()) {
311  return 0;
312  }
313  return it->second;
314 }
315 
316 
317 const std::vector<MSLane*>*
318 MSEdge::allowedLanes(const MSEdge* destination, SUMOVehicleClass vclass) const {
319  if (destination == 0 && (myMinimumPermissions & vclass) == vclass) {
320  // all lanes allow vclass
321  return getAllowedLanesWithDefault(myAllowed, destination);
322  }
323  // look up cached result in myClassedAllowed
324  ClassedAllowedLanesCont::const_iterator i = myClassedAllowed.find(vclass);
325  if (i != myClassedAllowed.end()) {
326  // can use cached value
327  const AllowedLanesCont& c = (*i).second;
328  return getAllowedLanesWithDefault(c, destination);
329  } else {
330  // this vclass is requested for the first time. rebuild all destinations
331  // go through connected edges
332 #ifdef HAVE_FOX
333  if (MSDevice_Routing::isParallel()) {
334  MSDevice_Routing::lock();
335  }
336 #endif
337  for (AllowedLanesCont::const_iterator i1 = myAllowed.begin(); i1 != myAllowed.end(); ++i1) {
338  const MSEdge* edge = i1->first;
339  const std::vector<MSLane*>* lanes = i1->second;
340  myClassedAllowed[vclass][edge] = new std::vector<MSLane*>();
341  // go through lanes approaching current edge
342  for (std::vector<MSLane*>::const_iterator i2 = lanes->begin(); i2 != lanes->end(); ++i2) {
343  // origin lane allows the current vehicle class?
344  if ((*i2)->allowsVehicleClass(vclass)) {
345  if (edge == 0) {
346  myClassedAllowed[vclass][edge]->push_back(*i2);
347  } else {
348  // target lane allows the current vehicle class?
349  const MSLinkCont& lc = (*i2)->getLinkCont();
350  for (MSLinkCont::const_iterator it_link = lc.begin(); it_link != lc.end(); ++it_link) {
351  const MSLane* targetLane = (*it_link)->getLane();
352  if ((&(targetLane->getEdge()) == edge) && targetLane->allowsVehicleClass(vclass)) {
353  // -> may be used
354  myClassedAllowed[vclass][edge]->push_back(*i2);
355  break;
356  }
357  }
358  }
359  }
360  }
361  // assert that 0 is returned if no connection is allowed for a class
362  if (myClassedAllowed[vclass][edge]->size() == 0) {
363  delete myClassedAllowed[vclass][edge];
364  myClassedAllowed[vclass][edge] = 0;
365  }
366  }
367 #ifdef HAVE_FOX
368  if (MSDevice_Routing::isParallel()) {
369  MSDevice_Routing::unlock();
370  }
371 #endif
372  return myClassedAllowed[vclass][destination];
373  }
374 }
375 
376 
377 // ------------
378 SUMOTime
381  return 0;
382 }
383 
384 
385 SUMOTime
388  return 0;
389 }
390 
391 
392 MSLane*
393 MSEdge::getFreeLane(const std::vector<MSLane*>* allowed, const SUMOVehicleClass vclass, double departPos) const {
394  if (allowed == 0) {
395  allowed = allowedLanes(vclass);
396  }
397  MSLane* res = 0;
398  if (allowed != 0) {
399  double largestGap = 0;
400  MSLane* resByGap = 0;
401  double leastOccupancy = std::numeric_limits<double>::max();;
402  for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
403  const double occupancy = (*i)->getBruttoOccupancy();
404  if (occupancy < leastOccupancy) {
405  res = (*i);
406  leastOccupancy = occupancy;
407  }
408  const MSVehicle* last = (*i)->getLastFullVehicle();
409  const double lastGap = (last != 0 ? last->getPositionOnLane() : myLength) - departPos;
410  if (lastGap > largestGap) {
411  largestGap = lastGap;
412  resByGap = (*i);
413  }
414  }
415  if (resByGap != 0) {
416  //if (res != resByGap) std::cout << SIMTIME << " edge=" << getID() << " departPos=" << departPos << " res=" << Named::getIDSecure(res) << " resByGap=" << Named::getIDSecure(resByGap) << " largestGap=" << largestGap << "\n";
417  res = resByGap;
418  }
419  }
420  return res;
421 }
422 
423 double
424 MSEdge::getDepartPosBound(const MSVehicle& veh, bool upper) const {
425  const SUMOVehicleParameter& pars = veh.getParameter();
426  double pos = getLength();
427  // determine the position
428  switch (pars.departPosProcedure) {
429  case DEPART_POS_GIVEN:
430  pos = pars.departPos;
431  if (pos < 0.) {
432  pos += myLength;
433  }
434  break;
435  case DEPART_POS_RANDOM:
436  // could be any position on the edge
437  break;
439  // could be any position on the edge due to multiple random attempts
440  break;
441  case DEPART_POS_FREE:
442  // many candidate positions, upper bound could be computed exactly
443  // with much effort
444  break;
445  case DEPART_POS_LAST:
446  if (upper) {
447  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
448  MSVehicle* last = (*i)->getLastFullVehicle();
449  if (last != 0) {
450  pos = MIN2(pos, last->getPositionOnLane());
451  }
452  }
453  } else {
454  pos = 0;
455  }
456  case DEPART_POS_BASE:
457  case DEPART_POS_DEFAULT:
458  break;
459  default:
460  pos = MIN2(pos, veh.getVehicleType().getLength());
461  break;
462  }
463  return pos;
464 }
465 
466 
467 MSLane*
469  switch (veh.getParameter().departLaneProcedure) {
470  case DEPART_LANE_GIVEN:
471  if ((int) myLanes->size() <= veh.getParameter().departLane || !(*myLanes)[veh.getParameter().departLane]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
472  return 0;
473  }
474  return (*myLanes)[veh.getParameter().departLane];
475  case DEPART_LANE_RANDOM:
477  case DEPART_LANE_FREE:
478  return getFreeLane(0, veh.getVehicleType().getVehicleClass(), getDepartPosBound(veh, false));
480  if (veh.getRoute().size() == 1) {
481  return getFreeLane(0, veh.getVehicleType().getVehicleClass(), getDepartPosBound(veh, false));
482  } else {
484  }
485  case DEPART_LANE_BEST_FREE: {
486  veh.updateBestLanes(false, myLanes->front());
487  const std::vector<MSVehicle::LaneQ>& bl = veh.getBestLanes();
488  double bestLength = -1;
489  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
490  if ((*i).length > bestLength) {
491  bestLength = (*i).length;
492  }
493  }
494  // beyond a certain length, all lanes are suitable
495  // however, we still need to check departPos to avoid unsuitable insertion
496  // (this is only possible in some cases)
497  double departPos = 0;
498  if (bestLength > BEST_LANE_LOOKAHEAD) {
499  departPos = getDepartPosBound(veh);
500  bestLength = MIN2(bestLength - departPos, BEST_LANE_LOOKAHEAD);
501  }
502  std::vector<MSLane*>* bestLanes = new std::vector<MSLane*>();
503  for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
504  if (((*i).length - departPos) >= bestLength) {
505  bestLanes->push_back((*i).lane);
506  }
507  }
508  MSLane* ret = getFreeLane(bestLanes, veh.getVehicleType().getVehicleClass(), getDepartPosBound(veh, false));
509  delete bestLanes;
510  return ret;
511  }
512  case DEPART_LANE_DEFAULT:
514  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
515  if ((*i)->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
516  return *i;
517  }
518  }
519  return 0;
520  default:
521  break;
522  }
523  if (!(*myLanes)[0]->allowsVehicleClass(veh.getVehicleType().getVehicleClass())) {
524  return 0;
525  }
526  return (*myLanes)[0];
527 }
528 
529 
530 bool
531 MSEdge::insertVehicle(SUMOVehicle& v, SUMOTime time, const bool checkOnly, const bool forceCheck) const {
532  // when vaporizing, no vehicles are inserted, but checking needs to be successful to trigger removal
533  if (isVaporizing() || isTazConnector()) {
534  return checkOnly;
535  }
536  const SUMOVehicleParameter& pars = v.getParameter();
537  const MSVehicleType& type = v.getVehicleType();
539  const std::vector<double>& speedFactorParams = type.getSpeedFactor().getParameter();
540  if (speedFactorParams[1] > 0.) {
542  if (v.getChosenSpeedFactor() > speedFactorParams[0] + 2 * speedFactorParams[1]) {
543  // only warn for significant deviation
544  WRITE_WARNING("Choosing new speed factor " + toString(v.getChosenSpeedFactor()) + " for vehicle '" + pars.id + "' to match departure speed.");
545  }
546  } else {
547  throw ProcessError("Departure speed for vehicle '" + pars.id +
548  "' is too high for the departure edge '" + getID() + "'.");
549  }
550  }
552  if (!forceCheck && myLastFailedInsertionTime == time) {
553  return false;
554  }
555  double pos = 0.0;
556  switch (pars.departPosProcedure) {
557  case DEPART_POS_GIVEN:
558  if (pars.departPos >= 0.) {
559  pos = pars.departPos;
560  } else {
561  pos = pars.departPos + getLength();
562  }
563  if (pos < 0 || pos > getLength()) {
564  WRITE_WARNING("Invalid departPos " + toString(pos) + " given for vehicle '" +
565  v.getID() + "'. Inserting at lane end instead.");
566  pos = getLength();
567  }
568  break;
569  case DEPART_POS_RANDOM:
571  pos = RandHelper::rand(getLength());
572  break;
573  default:
574  break;
575  }
576  bool result = false;
577  MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this, pos);
578  MEVehicle* veh = static_cast<MEVehicle*>(&v);
579  if (pars.departPosProcedure == DEPART_POS_FREE) {
580  while (segment != 0 && !result) {
581  if (checkOnly) {
582  result = segment->hasSpaceFor(veh, time, true);
583  } else {
584  result = segment->initialise(veh, time);
585  }
586  segment = segment->getNextSegment();
587  }
588  } else {
589  if (checkOnly) {
590  result = segment->hasSpaceFor(veh, time, true);
591  } else {
592  result = segment->initialise(veh, time);
593  }
594  }
595  return result;
596  }
597  if (checkOnly) {
598  switch (v.getParameter().departLaneProcedure) {
599  case DEPART_LANE_GIVEN:
600  case DEPART_LANE_DEFAULT:
602  MSLane* insertionLane = getDepartLane(static_cast<MSVehicle&>(v));
603  if (insertionLane == 0) {
604  WRITE_WARNING("could not insert vehicle '" + v.getID() + "' on any lane of edge '" + getID() + "', time=" + time2string(MSNet::getInstance()->getCurrentTimeStep()));
605  return false;
606  }
607  const double occupancy = insertionLane->getBruttoOccupancy();
608  return occupancy == 0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength;
609  }
610  default:
611  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
612  const double occupancy = (*i)->getBruttoOccupancy();
613  if (occupancy == 0 || occupancy * myLength + v.getVehicleType().getLengthWithGap() <= myLength) {
614  return true;
615  }
616  }
617  }
618  return false;
619  }
620  MSLane* insertionLane = getDepartLane(static_cast<MSVehicle&>(v));
621  if (insertionLane == 0) {
622  return false;
623  }
624 
625  if (!forceCheck) {
626  if (myLastFailedInsertionTime == time) {
627  if (myFailedInsertionMemory.count(insertionLane->getIndex())) {
628  // A vehicle was already rejected for the proposed insertionLane in this timestep
629  return false;
630  }
631  } else {
632  // last rejection occured in a previous timestep, clear cache
633  myFailedInsertionMemory.clear();
634  }
635  }
636 
637  bool success = insertionLane->insertVehicle(static_cast<MSVehicle&>(v));
638 
639  if (!success) {
640  myFailedInsertionMemory.insert(insertionLane->getIndex());
641  }
642  return success;
643 }
644 
645 
646 void
648  if (myLaneChanger == 0) {
649  return;
650  }
652 }
653 
654 
655 
656 const MSEdge*
657 MSEdge::getInternalFollowingEdge(const MSEdge* followerAfterInternal) const {
658  //@todo to be optimized
659  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
660  MSLane* l = *i;
661  const MSLinkCont& lc = l->getLinkCont();
662  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
663  MSLink* link = *j;
664  if (&link->getLane()->getEdge() == followerAfterInternal) {
665  if (link->getViaLane() != 0) {
666  return &link->getViaLane()->getEdge();
667  } else {
668  return 0; // network without internal links
669  }
670  }
671  }
672  }
673  return 0;
674 }
675 
676 double
677 MSEdge::getInternalFollowingLengthTo(const MSEdge* followerAfterInternal) const {
678  assert(followerAfterInternal != 0);
679  assert(!followerAfterInternal->isInternal());
680  double dist = 0.;
681  const MSEdge* edge = getInternalFollowingEdge(followerAfterInternal);
682  // Take into account non-internal lengths until next non-internal edge
683  while (edge != 0 && edge->isInternal()) {
684  dist += edge->getLength();
685  edge = edge->getInternalFollowingEdge(followerAfterInternal);
686  }
687  return dist;
688 }
689 
690 const MSEdge*
692  const MSEdge* result = this;
693  while (result->isInternal()) {
694  assert(myPredecessors.size() == 1);
695  result = myPredecessors.front();
696  }
697  return result;
698 }
699 
700 double
702  double v = 0;
703  double no = 0;
705  for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) {
706  const double vehNo = (double) segment->getCarNumber();
707  v += vehNo * segment->getMeanSpeed();
708  no += vehNo;
709  }
710  if (no == 0) {
711  return getLength() / myEmptyTraveltime; // may include tls-penalty
712  }
713  } else {
714  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
715  const double vehNo = (double)(*i)->getVehicleNumber();
716  v += vehNo * (*i)->getMeanSpeed();
717  no += vehNo;
718  }
719  if (no == 0) {
720  return getSpeedLimit();
721  }
722  }
723  return v / no;
724 }
725 
726 
727 double
728 MSEdge::getCurrentTravelTime(double minSpeed) const {
729  assert(minSpeed > 0);
730  if (!myAmDelayed) {
731  return myEmptyTraveltime;
732  }
733  return getLength() / MAX2(minSpeed, getMeanSpeed());
734 }
735 
736 
737 double
740 }
741 
742 
743 
744 bool
745 MSEdge::dictionary(const std::string& id, MSEdge* ptr) {
746  DictType::iterator it = myDict.find(id);
747  if (it == myDict.end()) {
748  // id not in myDict.
749  myDict[id] = ptr;
750  while ((int)myEdges.size() < ptr->getNumericalID() + 1) {
751  myEdges.push_back(0);
752  }
753  myEdges[ptr->getNumericalID()] = ptr;
754  return true;
755  }
756  return false;
757 }
758 
759 
760 MSEdge*
761 MSEdge::dictionary(const std::string& id) {
762  DictType::iterator it = myDict.find(id);
763  if (it == myDict.end()) {
764  // id not in myDict.
765  return 0;
766  }
767  return it->second;
768 }
769 
770 
771 int
773  return (int)myDict.size();
774 }
775 
776 
777 const MSEdgeVector&
779  return myEdges;
780 }
781 
782 
783 void
785  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
786  delete(*i).second;
787  }
788  myDict.clear();
789  myEdges.clear();
790 }
791 
792 
793 void
794 MSEdge::insertIDs(std::vector<std::string>& into) {
795  for (DictType::iterator i = myDict.begin(); i != myDict.end(); ++i) {
796  into.push_back((*i).first);
797  }
798 }
799 
800 
801 void
802 MSEdge::parseEdgesList(const std::string& desc, ConstMSEdgeVector& into,
803  const std::string& rid) {
804  if (desc[0] == BinaryFormatter::BF_ROUTE) {
805  std::istringstream in(desc, std::ios::binary);
806  char c;
807  in >> c;
808  FileHelpers::readEdgeVector(in, into, rid);
809  } else {
810  StringTokenizer st(desc);
811  parseEdgesList(st.getVector(), into, rid);
812  }
813 }
814 
815 
816 void
817 MSEdge::parseEdgesList(const std::vector<std::string>& desc, ConstMSEdgeVector& into,
818  const std::string& rid) {
819  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
820  const MSEdge* edge = MSEdge::dictionary(*i);
821  // check whether the edge exists
822  if (edge == 0) {
823  throw ProcessError("The edge '" + *i + "' within the route " + rid + " is not known."
824  + "\n The route can not be build.");
825  }
826  into.push_back(edge);
827  }
828 }
829 
830 
831 double
832 MSEdge::getDistanceTo(const MSEdge* other) const {
833  if (isTazConnector()) {
834  if (other->isTazConnector()) {
836  }
838  }
839  if (other->isTazConnector()) {
840  return other->myTazBoundary.distanceTo2D(getToJunction()->getPosition());
841  }
843 }
844 
845 
846 double
848  // @note lanes might have different maximum speeds in theory
849  return myLanes->empty() ? 1 : getLanes()[0]->getSpeedLimit();
850 }
851 
852 
853 double
855  return myLanes->empty() ? 1 : getLanes()[0]->getLengthGeometryFactor();
856 }
857 
858 double
859 MSEdge::getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
860  // @note lanes might have different maximum speeds in theory
861  return myLanes->empty() ? 1 : getLanes()[0]->getVehicleMaxSpeed(veh);
862 }
863 
864 
865 void
866 MSEdge::setMaxSpeed(double val) const {
867  if (myLanes != 0) {
868  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
869  (*i)->setMaxSpeed(val);
870  }
871  }
872 }
873 
874 
875 
876 std::vector<MSTransportable*>
877 MSEdge::getSortedPersons(SUMOTime timestep, bool includeRiding) const {
878  std::vector<MSTransportable*> result(myPersons.begin(), myPersons.end());
879  if (includeRiding) {
880  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
881  const MSLane::VehCont& vehs = (*i)->getVehiclesSecure();
882  for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
883  const std::vector<MSTransportable*>& persons = (*j)->getPersons();
884  result.insert(result.end(), persons.begin(), persons.end());
885  }
886  (*i)->releaseVehicles();
887  }
888  }
889  sort(result.begin(), result.end(), transportable_by_position_sorter(timestep));
890  return result;
891 }
892 
893 
894 std::vector<MSTransportable*>
895 MSEdge::getSortedContainers(SUMOTime timestep, bool /* includeRiding */) const {
896  std::vector<MSTransportable*> result(myContainers.begin(), myContainers.end());
897  sort(result.begin(), result.end(), transportable_by_position_sorter(timestep));
898  return result;
899 }
900 
901 
902 int
904  const double pos1 = c1->getCurrentStage()->getEdgePos(myTime);
905  const double pos2 = c2->getCurrentStage()->getEdgePos(myTime);
906  if (pos1 != pos2) {
907  return pos1 < pos2;
908  }
909  return c1->getID() < c2->getID();
910 }
911 
912 
913 void
915  mySuccessors.push_back(edge);
916  if (isTazConnector() && edge->getFromJunction() != 0) {
918  }
919 
920  edge->myPredecessors.push_back(this);
921  if (edge->isTazConnector() && getToJunction() != 0) {
922  edge->myTazBoundary.add(getToJunction()->getPosition());
923  }
924 }
925 
926 
927 const MSEdgeVector&
929  if (vClass == SVC_IGNORING || !MSNet::getInstance()->hasPermissions() || myFunction == EDGEFUNC_CONNECTOR) {
930  return mySuccessors;
931  }
932 #ifdef HAVE_FOX
933  if (MSDevice_Routing::isParallel()) {
934  MSDevice_Routing::lock();
935  }
936 #endif
937  std::map<SUMOVehicleClass, MSEdgeVector>::iterator i = myClassesSuccessorMap.find(vClass);
938  if (i == myClassesSuccessorMap.end()) {
939  // instantiate vector
940  myClassesSuccessorMap[vClass];
941  i = myClassesSuccessorMap.find(vClass);
942  // this vClass is requested for the first time. rebuild all successors
943  for (MSEdgeVector::const_iterator it = mySuccessors.begin(); it != mySuccessors.end(); ++it) {
944  if ((*it)->isTazConnector()) {
945  i->second.push_back(*it);
946  } else {
947  const std::vector<MSLane*>* allowed = allowedLanes(*it, vClass);
948  if (allowed != 0 && allowed->size() > 0) {
949  i->second.push_back(*it);
950  }
951  }
952  }
953  }
954  // can use cached value
955 #ifdef HAVE_FOX
956  if (MSDevice_Routing::isParallel()) {
957  MSDevice_Routing::unlock();
958  }
959 #endif
960  return i->second;
961 }
962 
963 
964 bool
966  return (!myLanes->empty() && myLanes->back()->getOpposite() != 0 &&
967  // do not change on curved internal lanes
968  (!isInternal() || myLanes->back()->getIncomingLanes()[0].viaLink->getDirection() == LINKDIR_STRAIGHT));
969 }
970 
971 
972 bool
974  for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
975  const MSLinkCont& lc = (*i)->getLinkCont();
976  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
977  if (!(*j)->havePriority()) {
978  return true;
979  }
980  }
981  }
982  return false;
983 }
984 
985 
988  if (getFunction() != EDGEFUNC_NORMAL) {
989  return;
990  }
992  for (ConstMSEdgeVector::const_iterator it = candidates.begin(); it != candidates.end(); it++) {
993  if ((*it)->getToJunction() == myFromJunction) { //reverse edge
994  if (myOppositingSuperposableEdge != 0 && isSuperposable(*it)) {
995  WRITE_WARNING("Ambiguous superposable edges between junction '" + myToJunction->getID() + "' and '" + myFromJunction->getID() + "'.");
996  break;
997  }
999  }
1000  }
1001 }
1002 
1003 
1004 bool MSEdge::isSuperposable(const MSEdge* other) {
1005  if (other == 0 || other->getLanes().size() != myLanes->size()) {
1006  return false;
1007  }
1008  std::vector<MSLane*>::const_iterator it1 = myLanes->begin();
1009  std::vector<MSLane*>::const_reverse_iterator it2 = other->getLanes().rbegin();
1010  do {
1011  if ((*it1)->getShape().reverse() != (*it2)->getShape()) {
1012  return false;
1013  }
1014  it1++;
1015  it2++;
1016  } while (it1 != myLanes->end());
1017 
1018  return true;
1019 }
1020 
1021 /****************************************************************************/
1022 
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge&#39;e lanes.
const SumoXMLEdgeFunc myFunction
the purpose of the edge
Definition: MSEdge.h:765
double getInternalFollowingLengthTo(const MSEdge *followerAfterInternal) const
returns the length of all internal edges on the junction until reaching the non-internal edge followe...
Definition: MSEdge.cpp:677
bool myAmDelayed
whether this edge had a vehicle with less than max speed on it
Definition: MSEdge.h:832
double getLength() const
return the length of the edge
Definition: MSEdge.h:570
static double gLateralResolution
Definition: MSGlobals.h:92
bool allowsLaneChanging()
Definition: MSEdge.cpp:224
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:582
virtual double getChosenSpeedFactor() const =0
std::set< MSTransportable * > myContainers
Containers on the edge.
Definition: MSEdge.h:795
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
static void insertIDs(std::vector< std::string > &into)
Inserts IDs of all known edges into the given vector.
Definition: MSEdge.cpp:794
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
Sorts edges by their ids.
Definition: MSEdge.h:708
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:250
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:52
void addSuccessor(MSEdge *edge)
Adds an edge to the list of edges which may be reached from this edge and to the incoming of the othe...
Definition: MSEdge.cpp:914
MSEdge(const std::string &id, int numericalID, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, int priority)
Constructor.
Definition: MSEdge.cpp:71
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal) const
Definition: MSEdge.cpp:657
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:290
int numSublanes() const
Definition: MSLeaderInfo.h:95
static double gMesoTLSPenalty
Definition: MSGlobals.h:107
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static int dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:772
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2288
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:108
bool initialise(MEVehicle *veh, SUMOTime time)
Inserts (emits) vehicle into the segment.
Definition: MESegment.cpp:288
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:168
bool isTazConnector() const
Definition: MSEdge.h:253
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.
static MSEdgeVector myEdges
Static list of edges.
Definition: MSEdge.h:857
std::vector< double > & getParameter()
Returns the parameters of this distribution.
The position is given.
double getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
Definition: MSEdge.cpp:847
ClassedAllowedLanesCont myClassedAllowed
From vehicle class to lanes allowed to be used by it.
Definition: MSEdge.h:805
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:65
The least occupied lane is used.
The link is a 180 degree turn.
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition: MELoop.cpp:262
void closeBuilding()
Definition: MSEdge.cpp:160
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:60
virtual ~MSEdge()
Destructor.
Definition: MSEdge.cpp:92
This is a dead end link.
const MSEdge * myOppositingSuperposableEdge
the oppositing superposble edge
Definition: MSEdge.h:870
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:169
T MAX2(T a, T b)
Definition: StdDefs.h:74
const MSRoute & getRoute() const
Returns the current route.
const std::string & getID() const
returns the id of the transportable
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge&#39;s persons sorted by pos.
Definition: MSEdge.cpp:877
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:745
std::vector< double > mySublaneSides
the right side for each sublane on this edge
Definition: MSEdge.h:841
double getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MSVehicle.h:375
This is an uncontrolled, right-before-left link.
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Definition: MSEdge.cpp:738
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
Definition: MSEdge.cpp:379
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
The lane is chosen randomly.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
bool hasMinorLink() const
whether any lane has a minor link
Definition: MSEdge.cpp:973
const SVCPermissions SVCAll
all VClasses are allowed
int myVaporizationRequests
Vaporizer counter.
Definition: MSEdge.h:768
The least occupied lane from best lanes.
The position is chosen randomly.
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
Definition: MSEdge.cpp:386
This is an uncontrolled, all-way stop 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:847
The car-following model and parameter.
Definition: MSVehicleType.h:73
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
Performs lane changing of vehicles.
The lane is given.
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
SumoXMLEdgeFunc getFunction() const
Returns the edge type (SumoXMLEdgeFunc)
Definition: MSEdge.h:225
void checkAndRegisterBiDirEdge()
check and register the opposite superposable edge if any
Definition: MSEdge.cpp:986
The link is a straight direction.
double getLengthWithGap() const
Get vehicle&#39;s length including the minimum gap [m].
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:55
double departSpeed
(optional) The initial speed of the vehicle
const std::string & getID() const
Returns the id.
Definition: Named.h:66
A road/street connecting two junctions.
Definition: MSEdge.h:81
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:455
SUMOTime myLastFailedInsertionTime
The time of last insertion failure.
Definition: MSEdge.h:771
std::map< SUMOVehicleClass, MSEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: MSEdge.h:862
void rebuildAllowedLanes()
Definition: MSEdge.cpp:247
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:859
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:2161
#define max(a, b)
Definition: polyfonts.c:65
#define BEST_LANE_LOOKAHEAD
Definition: MSEdge.cpp:59
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:714
virtual void setChosenSpeedFactor(const double factor)=0
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
Definition: MESegment.h:157
double myLength
the length of the edge (cached value for speedup)
Definition: MSEdge.h:826
std::vector< MSTransportable * > getSortedContainers(SUMOTime timestep, bool includeRiding=false) const
Returns this edge&#39;s containers sorted by pos.
Definition: MSEdge.cpp:895
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
double getDepartPosBound(const MSVehicle &veh, bool upper=true) const
return upper bound for the depart position on this edge
Definition: MSEdge.cpp:424
Representation of a vehicle.
Definition: SUMOVehicle.h:67
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:801
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
Definition: MSVehicle.cpp:3162
static void clear()
Clears the dictionary.
Definition: MSEdge.cpp:784
SVCPermissions myMinimumPermissions
The intersection of lane permissions for this edge.
Definition: MSEdge.h:808
int size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:86
double getDistanceTo(const MSEdge *other) const
optimistic air distance heuristic for use in routing
Definition: MSEdge.cpp:832
MSEdgeVector mySuccessors
The succeeding edges.
Definition: MSEdge.h:782
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:269
MSJunction * myToJunction
Definition: MSEdge.h:789
MSLaneChanger * myLaneChanger
This member will do the lane-change.
Definition: MSEdge.h:762
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
static SUMOTime gMesoMinorPenalty
Definition: MSGlobals.h:110
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
Definition: MSEdge.h:372
T MIN2(T a, T b)
Definition: StdDefs.h:68
bool myAmFringe
whether this edge is at the network fringe
Definition: MSEdge.h:838
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false, const bool forceCheck=false) const
Tries to insert the given vehicle into the network.
Definition: MSEdge.cpp:531
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:759
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
const ConstMSEdgeVector & getOutgoing() const
Definition: MSJunction.h:109
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:507
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:230
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:3156
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:91
bool isSuperposable(const MSEdge *other)
Definition: MSEdge.cpp:1004
bool canChangeToOpposite()
whether this edge allows changing to the opposite direction edge
Definition: MSEdge.cpp:965
MSLane * getDepartLane(MSVehicle &veh) const
Finds a depart lane for the given vehicle parameters.
Definition: MSEdge.cpp:468
Base class for objects which have an id.
Definition: Named.h:46
The rightmost lane the vehicle may use.
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:810
No information given; use default.
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
Definition: MSEdge.cpp:691
void buildLaneChanger()
Has to be called after all sucessors and predecessors have been set (after closeBuilding()) ...
Definition: MSEdge.cpp:206
double getLength() const
Get vehicle&#39;s length [m].
double departPos
(optional) The position the vehicle shall depart from
const Distribution_Parameterized & getSpeedFactor() const
Returns this type&#39;s speed factor.
Structure representing possible vehicle parameter.
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:260
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:281
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
Definition: Boundary.cpp:224
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:778
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
Definition: MSEdge.cpp:647
static const T & getRandomFrom(const std::vector< T > &v, std::mt19937 *rng=0)
Returns a random element from the given vector.
Definition: RandHelper.h:151
A single mesoscopic segment (cell)
Definition: MESegment.h:57
MSLane * getFreeLane(const std::vector< MSLane * > *allowed, const SUMOVehicleClass vclass, double departPos) const
Finds the emptiest lane allowing the vehicle class.
Definition: MSEdge.cpp:393
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:296
bool hasSpaceFor(const MEVehicle *veh, SUMOTime entryTime, bool init=false) const
Returns whether the given vehicle would still fit into the segment.
Definition: MESegment.cpp:261
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
double myWidth
Edge width [m].
Definition: MSEdge.h:823
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
MSJunction * myFromJunction
the junctions for this edge
Definition: MSEdge.h:788
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:113
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
std::map< const MSEdge *, std::vector< MSLane * > * > AllowedLanesCont
Suceeding edges (keys) and allowed lanes to reach these edges (values).
Definition: MSEdge.h:84
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
void setMaxSpeed(double val) const
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
Definition: MSEdge.cpp:866
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSEdge.h:852
static void readEdgeVector(std::istream &in, std::vector< const E * > &edges, const std::string &rid)
Reads an edge vector binary.
Definition: FileHelpers.h:274
Sorts transportables by their positions.
Definition: MSEdge.h:723
const MSJunction * getFromJunction() const
Definition: MSEdge.h:349
const MSEdgeVector & getSuccessors() const
Returns the following edges.
Definition: MSEdge.h:320
long long int SUMOTime
Definition: TraCIDefs.h:52
#define NUMERICAL_EPS
Definition: config.h:152
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1779
No information given; use default.
A free position is chosen.
double getLengthGeometryFactor() const
return shape.length() / myLength
Definition: MSEdge.cpp:854
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:275
Insert behind the last vehicle as close as possible to still allow the specified departSpeed. Fallback to DEPART_POS_BASE if there is no vehicle on the departLane yet.
static double getAssumedSpeed(const MSEdge *edge)
return current travel speed assumption
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
int operator()(const MSTransportable *const c1, const MSTransportable *const c2) const
comparing operator
Definition: MSEdge.cpp:903
Boundary myTazBoundary
The bounding rectangle of incoming or outgoing edges for taz connectors.
Definition: MSEdge.h:865
double getMeanSpeed() const
get the mean speed
Definition: MSEdge.cpp:701
const std::vector< MSLane * > * getAllowedLanesWithDefault(const AllowedLanesCont &c, const MSEdge *dest) const
lookup in map and return 0 if not found
Definition: MSEdge.cpp:308
static SUMOTime gLaneChangeDuration
Definition: MSGlobals.h:89
MSEdgeVector myPredecessors
The preceeding edges.
Definition: MSEdge.h:785
static bool gUseMesoSim
Definition: MSGlobals.h:98
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
double myEmptyTraveltime
the traveltime on the empty edge (cached value for speedup)
Definition: MSEdge.h:829
Back-at-zero position.
double getCurrentTravelTime(const double minSpeed=NUMERICAL_EPS) const
Computes and returns the current travel time for this edge.
Definition: MSEdge.cpp:728
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:802
vehicles ignoring classes
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:74
std::string id
The vehicle&#39;s id.
virtual double getEdgePos(SUMOTime now) const =0
std::set< int > myFailedInsertionMemory
A cache for the rejected insertion attempts. Used to assure that no further insertion attempts are ma...
Definition: MSEdge.h:776
const MSJunction * getToJunction() const
Definition: MSEdge.h:353
const Position & getPosition() const
Definition: MSJunction.cpp:63
std::set< MSTransportable * > myPersons
Persons on the edge for drawing and pushbutton.
Definition: MSEdge.h:792