Eclipse SUMO - Simulation of Urban MObility
MSLane.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
25 // Representation of a lane in the micro simulation
26 /****************************************************************************/
27 #pragma once
28 #include <config.h>
29 
30 #include <memory>
31 #include <vector>
32 #include <map>
33 #include <deque>
34 #include <cassert>
35 #include <utils/common/Named.h>
42 #include "MSGlobals.h"
43 #include "MSLeaderInfo.h"
44 #include "MSMoveReminder.h"
45 #include "MSVehicle.h"
46 
48 #ifdef HAVE_FOX
50 #endif
51 #include <utils/common/StopWatch.h>
52 
53 
54 // ===========================================================================
55 // class declarations
56 // ===========================================================================
57 class MSEdge;
58 class MSBaseVehicle;
59 class MSLaneChanger;
60 class MSLink;
61 class MSVehicleTransfer;
62 class MSVehicleControl;
63 class OutputDevice;
64 class MSLeaderInfo;
65 class MSJunction;
66 
67 
68 // ===========================================================================
69 // type definitions
70 // ===========================================================================
72 typedef std::map<const MSLane*, std::pair<double, double> > LaneCoverageInfo;
73 
74 // ===========================================================================
75 // class definitions
76 // ===========================================================================
84 class MSLane : public Named, public Parameterised {
85 public:
87  public:
89  StoringVisitor(std::set<const Named*>& objects, const PositionVector& shape,
90  const double range, const int domain)
91  : myObjects(objects), myShape(shape), myRange(range), myDomain(domain) {}
92 
94  void add(const MSLane* const l) const;
95 
96  private:
98  std::set<const Named*>& myObjects;
100  const double myRange;
101  const int myDomain;
102 
103  private:
106 
109  };
110 
112  friend class MSLaneChanger;
113  friend class MSLaneChangerSublane;
114 
115  friend class MSQueueExport;
116  friend class AnyVehicleIterator;
117 
119  typedef std::vector<MSVehicle*> VehCont;
120 
121  // TODO: Better documentation
130  public:
132  const MSLane* lane,
133  int i1,
134  int i2,
135  int i3,
136  const int i1End,
137  const int i2End,
138  const int i3End,
139  bool downstream = true) :
140  myLane(lane),
141  myI1(i1),
142  myI2(i2),
143  myI3(i3),
144  myI1End(i1End),
145  myI2End(i2End),
146  myI3End(i3End),
147  myDownstream(downstream),
148  myDirection(downstream ? 1 : -1) {
149  }
150 
151  bool operator== (AnyVehicleIterator const& other) const {
152  return (myI1 == other.myI1
153  && myI2 == other.myI2
154  && myI3 == other.myI3
155  && myI1End == other.myI1End
156  && myI2End == other.myI2End
157  && myI3End == other.myI3End);
158  }
159 
160  bool operator!= (AnyVehicleIterator const& other) const {
161  return !(*this == other);
162  }
163 
165  return **this;
166  }
167 
168  const MSVehicle* operator*();
169 
171 
172  private:
173  bool nextIsMyVehicles() const;
174 
176  const MSLane* myLane;
178  int myI1;
180  int myI2;
182  int myI3;
184  int myI1End;
186  int myI2End;
188  int myI3End;
193 
194  };
195 
196 
197 public:
206  };
207 
223  MSLane(const std::string& id, double maxSpeed, double friction, double length, MSEdge* const edge,
224  int numericalID, const PositionVector& shape, double width,
225  SVCPermissions permissions,
226  SVCPermissions changeLeft, SVCPermissions changeRight,
227  int index, bool isRampAccel,
228  const std::string& type,
229  const PositionVector& outlineShape);
230 
231 
233  virtual ~MSLane();
234 
236  inline int getThreadIndex() const {
238  }
239 
241  inline int getRNGIndex() const {
242  return myRNGIndex;
243  }
244 
246  SumoRNG* getRNG() const {
247  return &myRNGs[myRNGIndex];
248  }
249 
251  static int getNumRNGs() {
252  return (int)myRNGs.size();
253  }
254 
256  static void saveRNGStates(OutputDevice& out);
257 
259  static void loadRNGState(int index, const std::string& state);
260 
263 
271  void addLink(MSLink* link);
272 
277  void setOpposite(MSLane* oppositeLane);
278 
283  void setBidiLane(MSLane* bidyLane);
285 
288  virtual void addSecondaryShape(const PositionVector& /*shape*/) {}
289 
290  virtual double getLengthGeometryFactor(bool /*secondaryShape*/) const {
291  return myLengthGeometryFactor;
292  }
293 
294  virtual const PositionVector& getShape(bool /*secondaryShape*/) const {
295  return myShape;
296  }
298 
299 
302 
309  virtual void addMoveReminder(MSMoveReminder* rem);
310 
311 
315  inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
316  return myMoveReminders;
317  }
319 
320 
321 
324 
340  bool insertVehicle(MSVehicle& v);
341 
342 
361  bool isInsertionSuccess(MSVehicle* vehicle, double speed, double pos, double posLat,
362  bool recheckNextLanes,
363  MSMoveReminder::Notification notification);
364 
365  // XXX: Documentation?
366  bool checkFailure(const MSVehicle* aVehicle, double& speed, double& dist, const double nspeed, const bool patchSpeed, const std::string errorMsg, InsertionCheck check) const;
367 
371  bool lastInsertion(MSVehicle& veh, double mspeed, double posLat, bool patchSpeed);
372 
380  bool freeInsertion(MSVehicle& veh, double speed, double posLat,
382 
383 
393  void forceVehicleInsertion(MSVehicle* veh, double pos, MSMoveReminder::Notification notification, double posLat = 0);
395 
396 
397 
401 
408  virtual double setPartialOccupation(MSVehicle* v);
409 
413  virtual void resetPartialOccupation(MSVehicle* v);
414 
417  virtual void setManeuverReservation(MSVehicle* v);
418 
422  virtual void resetManeuverReservation(MSVehicle* v);
423 
434  const MSLeaderInfo getLastVehicleInformation(const MSVehicle* ego, double latOffset, double minPos = 0, bool allowCached = true) const;
435 
437  const MSLeaderInfo getFirstVehicleInformation(const MSVehicle* ego, double latOffset, bool onlyFrontOnLane, double maxPos = std::numeric_limits<double>::max(), bool allowCached = true) const;
438 
440 
443 
448  int getVehicleNumber() const {
449  return (int)myVehicles.size();
450  }
451 
457  return (int)myVehicles.size() + (int)myPartialVehicles.size();
458  }
459 
465  return (int)myPartialVehicles.size();
466  }
467 
468 
475  virtual const VehCont& getVehiclesSecure() const {
476  return myVehicles;
477  }
478 
479 
482  return AnyVehicleIterator(this, 0, 0, 0,
483  (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
484  }
485 
488  return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(),
489  (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myTmpVehicles.size(), true);
490  }
491 
494  return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, (int)myTmpVehicles.size() - 1,
495  -1, -1, -1, false);
496  }
497 
500  return AnyVehicleIterator(this, -1, -1, -1, -1, -1, -1, false);
501  }
502 
505  virtual void releaseVehicles() const { }
507 
508 
509 
512 
513 
517  inline int getNumericalID() const {
518  return myNumericalID;
519  }
520 
521 
525  inline const PositionVector& getShape() const {
526  return myShape;
527  }
528 
530  inline double getLengthGeometryFactor() const {
531  return myLengthGeometryFactor;
532  }
533 
535  inline bool isAccelLane() const {
536  return myIsRampAccel;
537  }
538 
540  const std::string& getLaneType() const {
541  return myLaneType;
542  }
543 
544  /* @brief fit the given lane position to a visibly suitable geometry position
545  * (lane length might differ from geometry length) */
546  inline double interpolateLanePosToGeometryPos(double lanePos) const {
547  return lanePos * myLengthGeometryFactor;
548  }
549 
550  /* @brief fit the given lane position to a visibly suitable geometry position
551  * and return the coordinates */
552  inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
553  return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
554  }
555 
556  /* @brief fit the given geometry position to a valid lane position
557  * (lane length might differ from geometry length) */
558  inline double interpolateGeometryPosToLanePos(double geometryPos) const {
559  return geometryPos / myLengthGeometryFactor;
560  }
561 
566  inline double getVehicleMaxSpeed(const SUMOTrafficObject* const veh) const {
567  if (myRestrictions != nullptr) {
568  std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(veh->getVClass());
569  if (r != myRestrictions->end()) {
570  if (mySpeedByVSS || mySpeedByTraCI) {
571  return MIN2(myMaxSpeed, MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor()));
572  } else {
573  return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
574  }
575  }
576  }
577  return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
578  }
579 
580 
584  inline double getSpeedLimit() const {
585  return myMaxSpeed;
586  }
587 
591  inline double getFrictionCoefficient() const {
592  return myFrictionCoefficient;
593  }
594 
598  inline double getLength() const {
599  return myLength;
600  }
601 
602 
607  return myPermissions;
608  }
609 
613  inline SVCPermissions getChangeLeft() const {
614  return myChangeLeft;
615  }
616 
621  return myChangeRight;
622  }
623 
627  double getWidth() const {
628  return myWidth;
629  }
630 
634  int getIndex() const {
635  return myIndex;
636  }
638 
640  int getCrossingIndex() const;
641 
642 
645 
653  virtual void planMovements(const SUMOTime t);
654 
660  virtual void setJunctionApproaches(const SUMOTime t) const;
661 
670  void updateLeaderInfo(const MSVehicle* veh, VehCont::reverse_iterator& vehPart, VehCont::reverse_iterator& vehRes, MSLeaderInfo& ahead) const;
671 
682  virtual void executeMovements(const SUMOTime t);
683 
685  virtual void integrateNewVehicles();
686 
688  void updateLengthSum();
690 
691 
693  inline bool needsCollisionCheck() const {
694  return myNeedsCollisionCheck;
695  }
696 
698  inline void requireCollisionCheck() {
699  myNeedsCollisionCheck = true;
700  }
701 
703  virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
704 
705 
708  virtual bool appropriate(const MSVehicle* veh) const;
709 
710 
712  const std::vector<MSLink*>& getLinkCont() const {
713  return myLinks;
714  }
715 
717  const MSLink* getLinkTo(const MSLane* const) const;
718 
720  const MSLane* getInternalFollowingLane(const MSLane* const) const;
721 
723  const MSLink* getEntryLink() const;
724 
725 
727  bool empty() const {
728  assert(myVehBuffer.size() == 0);
729  return myVehicles.empty();
730  }
731 
737  void setMaxSpeed(double val, bool byVSS = false, bool byTraCI = false, double jamThreshold = -1);
738 
742  void setFrictionCoefficient(double val);
743 
747  void setLength(double val);
748 
752  MSEdge& getEdge() const {
753  return *myEdge;
754  }
755 
756 
760  const MSEdge* getNextNormal() const;
761 
762 
768  const MSLane* getFirstInternalInConnection(double& offset) const;
769 
770 
773 
784  static bool dictionary(const std::string& id, MSLane* lane);
785 
786 
793  static MSLane* dictionary(const std::string& id);
794 
795 
797  static void clear();
798 
799 
803  static int dictSize() {
804  return (int)myDict.size();
805  }
806 
807 
811  static void insertIDs(std::vector<std::string>& into);
812 
813 
818  template<class RTREE>
819  static void fill(RTREE& into);
820 
821 
823  static void initRNGs(const OptionsCont& oc);
825 
826 
827 
828  // XXX: succLink does not exist... Documentation?
833  static std::vector<MSLink*>::const_iterator succLinkSec(const SUMOVehicle& veh,
834  int nRouteSuccs,
835  const MSLane& succLinkSource,
836  const std::vector<MSLane*>& conts);
837 
838 
841  inline bool isLinkEnd(std::vector<MSLink*>::const_iterator& i) const {
842  return i == myLinks.end();
843  }
844 
847  inline bool isLinkEnd(std::vector<MSLink*>::iterator& i) {
848  return i == myLinks.end();
849  }
850 
853  inline bool isEmpty() const {
854  return myVehicles.empty() && myPartialVehicles.empty();
855  }
856 
858  bool isInternal() const;
859 
861  bool isNormal() const;
862 
864  bool isCrossing() const;
865 
867  bool isWalkingArea() const;
868 
870  MSVehicle* getLastFullVehicle() const;
871 
874 
876  MSVehicle* getLastAnyVehicle() const;
877 
879  MSVehicle* getFirstAnyVehicle() const;
880 
881  /* @brief remove the vehicle from this lane
882  * @param[notify] whether moveReminders of the vehicle shall be triggered
883  */
884  virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
885 
886  void leftByLaneChange(MSVehicle* v);
888 
892  MSLane* getParallelLane(int offset, bool includeOpposite = true) const;
893 
894 
899  void setPermissions(SVCPermissions permissions, long long transientID);
900  void resetPermissions(long long transientID);
901  bool hadPermissionChanges() const;
902 
906  void setChangeLeft(SVCPermissions permissions);
907 
911  void setChangeRight(SVCPermissions permissions);
912 
913  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
914  return (myPermissions & vclass) == vclass;
915  }
916 
918  inline bool allowsChangingLeft(SUMOVehicleClass vclass) const {
919  return (myChangeLeft & vclass) == vclass;
920  }
921 
923  inline bool allowsChangingRight(SUMOVehicleClass vclass) const {
924  return (myChangeRight & vclass) == vclass;
925  }
926 
927  void addIncomingLane(MSLane* lane, MSLink* viaLink);
928 
929 
932  double length;
934  };
935 
936  const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
937  return myIncomingLanes;
938  }
939 
940 
941  void addApproachingLane(MSLane* lane, bool warnMultiCon);
942  inline bool isApproachedFrom(MSEdge* const edge) {
943  return myApproachingLanes.find(edge) != myApproachingLanes.end();
944  }
945  bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
946 
948  double getVehicleStopOffset(const MSVehicle* veh) const;
949 
951  const StopOffset& getLaneStopOffsets() const;
952 
954  void setLaneStopOffset(const StopOffset& stopOffset);
955 
963  };
964 
966  MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, double backOffset,
967  bool allSublanes, double searchDist = -1, MinorLinkMode mLinkMode = FOLLOW_ALWAYS) const;
968 
970  double getMissingRearGap(const MSVehicle* leader, double backOffset, double leaderSpeed) const;
971 
984  std::pair<MSVehicle* const, double> getLeader(const MSVehicle* veh, const double vehPos, const std::vector<MSLane*>& bestLaneConts, double dist = -1, bool checkTmpVehicles = false) const;
985 
1008  std::pair<MSVehicle* const, double> getLeaderOnConsecutive(double dist, double seen,
1009  double speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
1010 
1012  void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle* ego,
1013  const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result, bool oppositeDirection = false) const;
1014 
1015 
1017  void addLeaders(const MSVehicle* vehicle, double vehPos, MSLeaderDistanceInfo& result, bool oppositeDirection = false);
1018 
1019 
1037  std::pair<MSVehicle* const, double> getCriticalLeader(double dist, double seen, double speed, const MSVehicle& veh) const;
1038 
1039  /* @brief return the partial vehicle closest behind ego or 0
1040  * if no such vehicle exists */
1041  MSVehicle* getPartialBehind(const MSVehicle* ego) const;
1042 
1045 
1056  std::set<MSVehicle*> getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr<LaneCoverageInfo> checkedLanes) const;
1057 
1060  std::set<MSVehicle*> getVehiclesInRange(const double a, const double b) const;
1061 
1063  std::vector<const MSJunction*> getUpcomingJunctions(double pos, double range, const std::vector<MSLane*>& contLanes) const;
1064 
1066  std::vector<const MSLink*> getUpcomingLinks(double pos, double range, const std::vector<MSLane*>& contLanes) const;
1067 
1072 
1076  const MSLane* getNormalPredecessorLane() const;
1077 
1081  const MSLane* getNormalSuccessorLane() const;
1082 
1085  MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
1086 
1087 
1094 
1095 
1102 
1105 
1107  const std::vector<std::pair<const MSLane*, const MSEdge*> > getOutgoingViaLanes() const;
1108 
1110  std::vector<const MSLane*> getNormalIncomingLanes() const;
1111 
1113 
1114 
1118  double getMeanSpeed() const;
1119 
1121  double getMeanSpeedBike() const;
1122 
1126  double getWaitingSeconds() const;
1127 
1128 
1132  double getBruttoOccupancy() const;
1133 
1134 
1138  double getNettoOccupancy() const;
1139 
1140 
1144  inline double getBruttoVehLenSum() const {
1145  return myBruttoVehicleLengthSum;
1146  }
1147 
1148 
1153  template<PollutantsInterface::EmissionType ET>
1154  double getEmissions() const {
1155  double ret = 0;
1156  for (MSVehicle* const v : getVehiclesSecure()) {
1157  ret += v->getEmissions<ET>();
1158  }
1159  releaseVehicles();
1160  return ret;
1161  }
1162 
1163 
1167  double getHarmonoise_NoiseEmissions() const;
1169 
1170  void setRightSideOnEdge(double value, int rightmostSublane) {
1171  myRightSideOnEdge = value;
1172  myRightmostSublane = rightmostSublane;
1173  }
1174 
1176  void initRestrictions();
1177 
1178  void checkBufferType();
1179 
1180  double getRightSideOnEdge() const {
1181  return myRightSideOnEdge;
1182  }
1183 
1184  int getRightmostSublane() const {
1185  return myRightmostSublane;
1186  }
1187 
1188  double getCenterOnEdge() const {
1189  return myRightSideOnEdge + 0.5 * myWidth;
1190  }
1191 
1193  void sortPartialVehicles();
1194 
1196  void sortManeuverReservations();
1197 
1199  MSLane* getOpposite() const;
1200 
1202  MSLane* getParallelOpposite() const;
1203 
1205  double getOppositePos(double pos) const;
1206 
1207  /* @brief find leader for a vehicle depending on the relative driving direction
1208  * @param[in] ego The ego vehicle
1209  * @param[in] dist The look-ahead distance when looking at consecutive lanes
1210  * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
1211  * @return the leader vehicle and its gap to ego
1212  */
1213  std::pair<MSVehicle* const, double> getOppositeLeader(const MSVehicle* ego, double dist, bool oppositeDir, MinorLinkMode mLinkMode = MinorLinkMode::FOLLOW_NEVER) const;
1214 
1215  /* @brief find follower for a vehicle that is located on the opposite of this lane
1216  * @param[in] ego The ego vehicle
1217  * @return the follower vehicle and its gap to ego
1218  */
1219  std::pair<MSVehicle* const, double> getOppositeFollower(const MSVehicle* ego) const;
1220 
1221 
1229  std::pair<MSVehicle* const, double> getFollower(const MSVehicle* ego, double egoPos, double dist, MinorLinkMode mLinkMode) const;
1230 
1231 
1233  void addParking(MSBaseVehicle* veh);
1234 
1236  virtual void removeParking(MSBaseVehicle* veh);
1237 
1239  const std::set<const MSBaseVehicle*>& getParkingVehicles() const {
1240  return myParkingVehicles;
1241  }
1242 
1244  virtual bool isSelected() const {
1245  return false;
1246  }
1247 
1249  MSLane* getBidiLane() const;
1250 
1252  bool mustCheckJunctionCollisions() const;
1253 
1254 #ifdef HAVE_FOX
1255  MFXWorkerThread::Task* getPlanMoveTask(const SUMOTime time) {
1256  mySimulationTask.init(&MSLane::planMovements, time);
1257  return &mySimulationTask;
1258  }
1259 
1260  MFXWorkerThread::Task* getExecuteMoveTask(const SUMOTime time) {
1261  mySimulationTask.init(&MSLane::executeMovements, time);
1262  return &mySimulationTask;
1263  }
1264 
1265  MFXWorkerThread::Task* getLaneChangeTask(const SUMOTime time) {
1266  mySimulationTask.init(&MSLane::changeLanes, time);
1267  return &mySimulationTask;
1268  }
1269 #endif
1270 
1271  std::vector<StopWatch<std::chrono::nanoseconds> >& getStopWatch() {
1272  return myStopWatch;
1273  }
1274 
1275  void changeLanes(const SUMOTime time);
1276 
1279 
1287  void saveState(OutputDevice& out);
1288 
1290  void clearState();
1291 
1303  void loadState(const std::vector<std::string>& vehIDs, MSVehicleControl& vc);
1304 
1305 
1306  /* @brief helper function for state saving: checks whether any outgoing
1307  * links are being approached */
1308  bool hasApproaching() const;
1309 
1311 
1312 
1320  void visit(const MSLane::StoringVisitor& cont) const {
1321  cont.add(this);
1322  }
1323 
1325  bool hasPedestrians() const;
1326 
1328  std::pair<const MSPerson*, double> nextBlocking(double minPos, double minRight, double maxLeft, double stopTime = 0, bool bidi = false) const;
1329 
1331  double getSpaceTillLastStanding(const MSVehicle* ego, bool& foundStopped) const;
1332 
1334  double getMaximumBrakeDist() const;
1335 
1336  inline const PositionVector* getOutlineShape() const {
1337  return myOutlineShape;
1338  }
1339 
1340  static void initCollisionOptions(const OptionsCont& oc);
1341  static void initCollisionAction(const OptionsCont& oc, const std::string& option, CollisionAction& myAction);
1342 
1344  return myCollisionAction;
1345  }
1346 
1349  }
1350 
1351  static const long CHANGE_PERMISSIONS_PERMANENT = 0;
1352  static const long CHANGE_PERMISSIONS_GUI = 1;
1353 
1354 protected:
1356  virtual void swapAfterLaneChange(SUMOTime t);
1357 
1369  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
1370  const MSLane::VehCont::iterator& at,
1372 
1374  void detectPedestrianJunctionCollision(const MSVehicle* collider, const PositionVector& colliderBoundary, const MSLane* foeLane,
1375  SUMOTime timestep, const std::string& stage,
1376  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1377  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport);
1378 
1380  bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1381  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1382  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1383 
1385  void handleCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
1386  double gap, double latGap,
1387  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1388  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1389 
1390  void handleIntermodalCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSTransportable* victim,
1391  double gap, const std::string& collisionType,
1392  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1393  std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) const;
1394 
1395  /* @brief determine depart speed and whether it may be patched
1396  * @param[in] veh The departing vehicle
1397  * @param[out] whether the speed may be patched to account for safety
1398  * @return the depart speed
1399  */
1400  double getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1401 
1402  /* @brief determine the lateral depart position
1403  * @param[in] veh The departing vehicle
1404  * @return the lateral depart position
1405  */
1406  double getDepartPosLat(const MSVehicle& veh);
1407 
1410  double safeInsertionSpeed(const MSVehicle* veh, double seen, const MSLeaderInfo& leaders, double speed);
1411 
1413  bool checkForPedestrians(const MSVehicle* aVehicle, double& speed, double& dist, double pos, bool patchSpeed) const;
1414 
1416  bool hasApproaching(const std::vector<MSLink*>& links) const;
1417 
1419  double getFractionalVehicleLength(bool brutto) const;
1420 
1423 
1426 
1429 
1431  int myIndex;
1432 
1445 
1457 
1461 
1465 
1473 
1474  /* @brief list of vehicles that are parking near this lane
1475  * (not necessarily on the road but having reached their stop on this lane)
1476  * */
1477  std::set<const MSBaseVehicle*> myParkingVehicles;
1478 
1480  double myLength;
1481 
1483  const double myWidth;
1484 
1489 
1491  MSEdge* const myEdge;
1492 
1494  double myMaxSpeed;
1497 
1500 
1503 
1506 
1510 
1513 
1515  const std::map<SUMOVehicleClass, double>* myRestrictions;
1516 
1518  std::vector<IncomingLaneInfo> myIncomingLanes;
1519 
1522 
1525 
1528 
1531 
1534 
1537 
1540 
1543  std::vector<MSLink*> myLinks;
1544 
1546  std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1547 
1552 
1557 
1560 
1562  const bool myIsRampAccel;
1563 
1565  const std::string myLaneType;
1566 
1571 
1574 
1575  // @brief the neighboring opposite direction or nullptr
1577 
1578  // @brief bidi lane or nullptr
1580 
1581  // @brief transient changes in permissions
1582  std::map<long long, SVCPermissions> myPermissionChanges;
1583 
1584  // @brief index of the associated thread-rng
1586 
1588  typedef std::map< std::string, MSLane* > DictType;
1589 
1592 
1593  static std::vector<SumoRNG> myRNGs;
1594 
1595 private:
1597  std::vector< MSMoveReminder* > myMoveReminders;
1598 
1608 
1614  public:
1616  explicit vehicle_position_sorter(const MSLane* lane) :
1617  myLane(lane) {
1618  }
1619 
1620 
1626  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1627 
1628  const MSLane* myLane;
1629 
1630  };
1631 
1637  public:
1639  explicit vehicle_natural_position_sorter(const MSLane* lane) :
1640  myLane(lane) {
1641  }
1642 
1643 
1649  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1650 
1651  const MSLane* myLane;
1652 
1653  };
1654 
1660  public:
1662  explicit by_connections_to_sorter(const MSEdge* const e);
1663 
1665  int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1666 
1667  private:
1668  const MSEdge* const myEdge;
1669  double myLaneDir;
1670  };
1671 
1672 
1673 
1679  public:
1681  explicit incoming_lane_priority_sorter(const MSLane* targetLane);
1682 
1684  int operator()(const IncomingLaneInfo& lane1, const IncomingLaneInfo& lane2) const;
1685 
1686  private:
1687  const MSLane* const myLane;
1688  double myLaneDir;
1689  };
1690 
1691 
1697  public:
1699  explicit outgoing_lane_priority_sorter(const MSLane* sourceLane);
1700 
1702  int operator()(const MSLink* link1, const MSLink* link2) const;
1703 
1704  private:
1705  double myLaneDir;
1706  };
1707 
1711  class edge_finder {
1712  public:
1714  bool operator()(const IncomingLaneInfo& ili) const {
1715  return &(ili.lane->getEdge()) == myEdge;
1716  }
1717  private:
1718  const MSEdge* const myEdge;
1719  };
1720 
1721 #ifdef HAVE_FOX
1723  typedef void(MSLane::*Operation)(const SUMOTime);
1724 
1729  class SimulationTask : public MFXWorkerThread::Task {
1730  public:
1731  SimulationTask(MSLane& l, const SUMOTime time)
1732  : myLane(l), myTime(time) {}
1733  void init(Operation operation, const SUMOTime time) {
1734  myOperation = operation;
1735  myTime = time;
1736  }
1737  void run(MFXWorkerThread* /*context*/) {
1738  try {
1739  (myLane.*(myOperation))(myTime);
1740  } catch (ProcessError& e) {
1741  WRITE_ERROR(e.what());
1742  }
1743  }
1744  private:
1745  Operation myOperation = nullptr;
1746  MSLane& myLane;
1747  SUMOTime myTime;
1748  private:
1750  SimulationTask& operator=(const SimulationTask&) = delete;
1751  };
1752 
1753  SimulationTask mySimulationTask;
1755  mutable FXMutex myLeaderInfoMutex;
1757  mutable FXMutex myFollowerInfoMutex;
1759  mutable FXMutex myPartialOccupatorMutex;
1760 #endif
1761  std::vector<StopWatch<std::chrono::nanoseconds> > myStopWatch;
1762 
1763 private:
1765  MSLane(const MSLane&) = delete;
1766 
1768  MSLane& operator=(const MSLane&) = delete;
1769 
1770 
1771 };
1772 
1773 // specialized implementation for speedup and avoiding warnings
1774 #define LANE_RTREE_QUAL RTree<MSLane*, MSLane, float, 2, MSLane::StoringVisitor>
1775 
1776 template<>
1777 inline float LANE_RTREE_QUAL::RectSphericalVolume(Rect* a_rect) {
1778  ASSERT(a_rect);
1779  const float extent0 = a_rect->m_max[0] - a_rect->m_min[0];
1780  const float extent1 = a_rect->m_max[1] - a_rect->m_min[1];
1781  return .78539816f * (extent0 * extent0 + extent1 * extent1);
1782 }
1783 
1784 template<>
1785 inline LANE_RTREE_QUAL::Rect LANE_RTREE_QUAL::CombineRect(Rect* a_rectA, Rect* a_rectB) {
1786  ASSERT(a_rectA && a_rectB);
1787  Rect newRect;
1788  newRect.m_min[0] = rtree_min(a_rectA->m_min[0], a_rectB->m_min[0]);
1789  newRect.m_max[0] = rtree_max(a_rectA->m_max[0], a_rectB->m_max[0]);
1790  newRect.m_min[1] = rtree_min(a_rectA->m_min[1], a_rectB->m_min[1]);
1791  newRect.m_max[1] = rtree_max(a_rectA->m_max[1], a_rectB->m_max[1]);
1792  return newRect;
1793 }
long long int SUMOTime
Definition: GUI.h:35
std::map< const MSLane *, std::pair< double, double > > LaneCoverageInfo
Coverage info.
Definition: MSLane.h:65
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:304
#define rtree_min(a, b)
Definition: RTree.h:20
#define rtree_max(a, b)
Definition: RTree.h:21
#define ASSERT
Definition: RTree.h:12
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
InsertionCheck
different checking levels for vehicle insertion
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
T MIN2(T a, T b)
Definition: StdDefs.h:76
size_t size() const
Definition: MFXSynchQue.h:156
Abstract superclass of a task to be run with an index to keep track of pending tasks.
A thread repeatingly calculating incoming tasks.
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:55
A road/street connecting two junctions.
Definition: MSEdge.h:77
static int gNumSimThreads
how many threads to use for simulation
Definition: MSGlobals.h:143
The base class for an intersection.
Definition: MSJunction.h:58
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
Definition: MSLane.h:129
bool operator!=(AnyVehicleIterator const &other) const
Definition: MSLane.h:160
int myI2End
end index for myPartialVehicles
Definition: MSLane.h:186
int myI2
index for myPartialVehicles
Definition: MSLane.h:180
bool myDownstream
iteration direction
Definition: MSLane.h:190
bool nextIsMyVehicles() const
Definition: MSLane.cpp:200
int myI3
index for myTmpVehicles
Definition: MSLane.h:182
int myDirection
index delta
Definition: MSLane.h:192
AnyVehicleIterator & operator++()
Definition: MSLane.cpp:166
const MSLane * myLane
the lane that is being iterated
Definition: MSLane.h:176
bool operator==(AnyVehicleIterator const &other) const
Definition: MSLane.h:151
const MSVehicle * operator*()
Definition: MSLane.cpp:183
int myI3End
end index for myTmpVehicles
Definition: MSLane.h:188
AnyVehicleIterator(const MSLane *lane, int i1, int i2, int i3, const int i1End, const int i2End, const int i3End, bool downstream=true)
Definition: MSLane.h:131
int myI1End
end index for myVehicles
Definition: MSLane.h:184
int myI1
index for myVehicles
Definition: MSLane.h:178
const MSVehicle * operator->()
Definition: MSLane.h:164
StoringVisitor(const StoringVisitor &src)
invalidated copy constructor
void add(const MSLane *const l) const
Adds the given object to the container.
Definition: MSLane.cpp:119
StoringVisitor(std::set< const Named * > &objects, const PositionVector &shape, const double range, const int domain)
Constructor.
Definition: MSLane.h:89
const int myDomain
Definition: MSLane.h:101
std::set< const Named * > & myObjects
The container.
Definition: MSLane.h:98
StoringVisitor & operator=(const StoringVisitor &src)
invalidated assignment operator
const double myRange
Definition: MSLane.h:100
const PositionVector & myShape
Definition: MSLane.h:99
Sorts edges by their angle relative to the given edge (straight comes first)
Definition: MSLane.h:1659
by_connections_to_sorter(const MSEdge *const e)
constructor
Definition: MSLane.cpp:3374
const MSEdge *const myEdge
Definition: MSLane.h:1668
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Definition: MSLane.cpp:3381
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1714
edge_finder(MSEdge *e)
Definition: MSLane.h:1713
const MSEdge *const myEdge
Definition: MSLane.h:1718
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
Definition: MSLane.h:1678
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
Definition: MSLane.cpp:3415
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
Definition: MSLane.cpp:3420
Sorts lanes (their origin link) by the priority of their noninternal target edges or,...
Definition: MSLane.h:1696
outgoing_lane_priority_sorter(const MSLane *sourceLane)
constructor
Definition: MSLane.cpp:3493
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
Definition: MSLane.cpp:3497
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1639
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:3363
Sorts vehicles by their position (descending)
Definition: MSLane.h:1613
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:3351
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1616
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:45
Performs lane changing of vehicles.
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:2730
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
detect whether there is a collision between the two vehicles
Definition: MSLane.cpp:1855
static SUMOTime myIntermodalCollisionStopTime
Definition: MSLane.h:1605
MFXSynchQue< MSVehicle *, std::vector< MSVehicle * > > myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
Definition: MSLane.h:1464
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1505
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1521
static void initCollisionAction(const OptionsCont &oc, const std::string &option, CollisionAction &myAction)
Definition: MSLane.cpp:4339
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned.
Definition: MSLane.cpp:1520
std::set< const MSBaseVehicle * > myParkingVehicles
Definition: MSLane.h:1477
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.h:712
bool checkForPedestrians(const MSVehicle *aVehicle, double &speed, double &dist, double pos, bool patchSpeed) const
check whether pedestrians on this lane interfere with vehicle insertion
Definition: MSLane.cpp:4426
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, MinorLinkMode mLinkMode) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane)
Definition: MSLane.cpp:4246
std::pair< const MSPerson *, double > nextBlocking(double minPos, double minRight, double maxLeft, double stopTime=0, bool bidi=false) const
This is just a wrapper around MSPModel::nextBlocking. You should always check using hasPedestrians be...
Definition: MSLane.cpp:4420
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition: MSLane.cpp:2714
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1568
const StopOffset & getLaneStopOffsets() const
Returns vehicle class specific stopOffsets.
Definition: MSLane.cpp:3643
virtual void removeParking(MSBaseVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
Definition: MSLane.cpp:3538
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:293
static CollisionAction getIntermodalCollisionAction()
Definition: MSLane.h:1347
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:652
const MSLeaderInfo getFirstVehicleInformation(const MSVehicle *ego, double latOffset, bool onlyFrontOnLane, double maxPos=std::numeric_limits< double >::max(), bool allowCached=true) const
analogue to getLastVehicleInformation but in the upstream direction
Definition: MSLane.cpp:1425
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:2432
double myLength
Lane length [m].
Definition: MSLane.h:1480
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.h:942
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
Definition: MSLane.cpp:3260
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:2696
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1
Definition: MSLane.cpp:3215
SumoRNG * getRNG() const
return the associated RNG
Definition: MSLane.h:246
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1425
PositionVector * myOutlineShape
the outline of the lane (optional)
Definition: MSLane.h:1428
std::map< long long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1582
int getRNGIndex() const
returns the associated RNG index
Definition: MSLane.h:241
double getFrictionCoefficient() const
Returns the lane's friction coefficient.
Definition: MSLane.h:591
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1515
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
Definition: MSLane.cpp:429
void initRestrictions()
initialized vClass-specific speed limits
Definition: MSLane.cpp:302
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
Definition: MSLane.h:1597
bool hasApproaching() const
Definition: MSLane.cpp:3543
SVCPermissions getChangeRight() const
Returns the vehicle class permissions for changing to the right neighbour lane.
Definition: MSLane.h:620
void addParking(MSBaseVehicle *veh)
add parking vehicle. This should only used during state loading
Definition: MSLane.cpp:3532
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Definition: MSLane.h:1460
MSLane(const std::string &id, double maxSpeed, double friction, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, SVCPermissions changeLeft, SVCPermissions changeRight, int index, bool isRampAccel, const std::string &type, const PositionVector &outlineShape)
Constructor.
Definition: MSLane.cpp:244
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:575
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1551
const MSLane * getNormalSuccessorLane() const
get normal lane following this internal lane, for normal lanes, the lane itself is returned
Definition: MSLane.cpp:3100
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:448
static SUMOTime myCollisionStopTime
Definition: MSLane.h:1604
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1600
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Definition: MSLane.h:1527
SVCPermissions myChangeLeft
The vClass permissions for changing from this lane.
Definition: MSLane.h:1508
void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle *ego, const std::vector< MSLane * > &bestLaneConts, MSLeaderDistanceInfo &result, bool oppositeDirection=false) const
Returns the immediate leaders and the distance to them (as getLeaderOnConsecutive but for the sublane...
Definition: MSLane.cpp:3883
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
Definition: MSLane.h:1518
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
Definition: MSLane.h:487
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:2387
const std::string & getLaneType() const
return the type of this lane
Definition: MSLane.h:540
bool hadPermissionChanges() const
Definition: MSLane.cpp:4395
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:2459
double myFrictionCoefficient
Lane-wide friction coefficient [0..1].
Definition: MSLane.h:1496
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2546
MSLane(const MSLane &)=delete
invalidated copy constructor
const MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else nullptr.
Definition: MSLane.cpp:2632
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition: MSLane.h:456
static bool myCheckJunctionCollisions
Definition: MSLane.h:1602
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:2378
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:1144
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
Definition: MSLane.cpp:411
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition: MSLane.h:1512
MSEdge *const myEdge
The lane's edge, for routing only.
Definition: MSLane.h:1491
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1533
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:727
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition: MSLane.h:923
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:2560
void detectPedestrianJunctionCollision(const MSVehicle *collider, const PositionVector &colliderBoundary, const MSLane *foeLane, SUMOTime timestep, const std::string &stage, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport)
detect whether a vehicle collids with pedestrians on the junction
Definition: MSLane.cpp:1814
double getMissingRearGap(const MSVehicle *leader, double backOffset, double leaderSpeed) const
return by how much further the leader must be inserted to avoid rear end collisions
Definition: MSLane.cpp:2755
double myMaxSpeed
Lane-wide speed limit [m/s].
Definition: MSLane.h:1494
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:3553
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:475
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
Definition: MSLane.cpp:2609
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1570
void setChangeRight(SVCPermissions permissions)
Sets the permissions for changing to the right neighbour lane.
Definition: MSLane.cpp:4407
const bool myIsRampAccel
whether this lane is an acceleration lane
Definition: MSLane.h:1562
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step....
Definition: MSLane.cpp:1480
virtual double getLengthGeometryFactor(bool) const
Definition: MSLane.h:290
static void saveRNGStates(OutputDevice &out)
save random number generator states to the given output device
Definition: MSLane.cpp:4475
void visit(const MSLane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:1320
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1556
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1549
bool isInsertionSuccess(MSVehicle *vehicle, double speed, double pos, double posLat, bool recheckNextLanes, MSMoveReminder::Notification notification)
Tries to insert the given vehicle with the given state (speed and pos)
Definition: MSLane.cpp:811
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:1316
double getVehicleStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
Definition: MSLane.cpp:3630
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:4355
int myNumericalID
Unique numerical ID (set on reading by netload)
Definition: MSLane.h:1422
bool isAccelLane() const
return whether this lane is an acceleration lane
Definition: MSLane.h:535
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1444
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:584
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
Definition: MSLane.cpp:4083
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:119
bool checkFailure(const MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg, InsertionCheck check) const
Definition: MSLane.cpp:779
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSLane.h:1591
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:2395
double safeInsertionSpeed(const MSVehicle *veh, double seen, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
Definition: MSLane.cpp:1327
MSLane * myBidiLane
Definition: MSLane.h:1579
std::vector< StopWatch< std::chrono::nanoseconds > > & getStopWatch()
Definition: MSLane.h:1271
std::vector< const MSJunction * > getUpcomingJunctions(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming junctions within given range along the given (non-internal) continuation lanes m...
Definition: MSLane.cpp:4170
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:2720
bool isWalkingArea() const
Definition: MSLane.cpp:2503
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:2331
SVCPermissions getChangeLeft() const
Returns the vehicle class permissions for changing to the left neighbour lane.
Definition: MSLane.h:613
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:321
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
Definition: MSLane.cpp:4150
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:3208
double getDepartPosLat(const MSVehicle &veh)
Definition: MSLane.cpp:626
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir, MinorLinkMode mLinkMode=MinorLinkMode::FOLLOW_NEVER) const
Definition: MSLane.cpp:4269
int getThreadIndex() const
returns the associated thread index
Definition: MSLane.h:236
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:606
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:3166
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
Definition: MSLane.cpp:2311
static const long CHANGE_PERMISSIONS_PERMANENT
Definition: MSLane.h:1351
MSLane * getCanonicalPredecessorLane() const
Definition: MSLane.cpp:3121
void resetPermissions(long long transientID)
Definition: MSLane.cpp:4380
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:2509
static void loadRNGState(int index, const std::string &state)
load random number generator state for the given rng index
Definition: MSLane.cpp:4485
const std::string myLaneType
the type of this lane
Definition: MSLane.h:1565
const std::set< const MSBaseVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
Definition: MSLane.h:1239
int myRNGIndex
Definition: MSLane.h:1585
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step....
Definition: MSLane.h:1472
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
Definition: MSLane.cpp:3994
bool needsCollisionCheck() const
short-circut collision check if nothing changed since the last check
Definition: MSLane.h:693
static double myCheckJunctionCollisionMinGap
Definition: MSLane.h:1603
double getLength() const
Returns the lane's length.
Definition: MSLane.h:598
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1530
void setChangeLeft(SVCPermissions permissions)
Sets the permissions for changing to the left neighbour lane.
Definition: MSLane.cpp:4401
std::vector< const MSLink * > getUpcomingLinks(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming links within given range along the given (non-internal) continuation lanes measu...
Definition: MSLane.cpp:4181
const MSLane * getFirstInternalInConnection(double &offset) const
Returns 0 if the lane is not internal. Otherwise the first part of the connection (sequence of intern...
Definition: MSLane.cpp:2337
static int getNumRNGs()
return the number of RNGs
Definition: MSLane.h:251
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
take action upon collision
Definition: MSLane.cpp:1962
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:2771
static CollisionAction myIntermodalCollisionAction
Definition: MSLane.h:1601
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
Definition: MSLane.cpp:2621
bool isLinkEnd(std::vector< MSLink * >::iterator &i)
Definition: MSLane.h:847
static std::vector< SumoRNG > myRNGs
Definition: MSLane.h:1593
bool allowsChangingLeft(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition: MSLane.h:918
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:2679
std::pair< MSVehicle *const, double > getCriticalLeader(double dist, double seen, double speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
Definition: MSLane.cpp:2981
StopOffset myLaneStopOffset
Definition: MSLane.h:1488
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
Definition: MSLane.cpp:1369
static void initRNGs(const OptionsCont &oc)
initialize rngs
Definition: MSLane.cpp:4462
std::set< MSVehicle * > getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr< LaneCoverageInfo > checkedLanes) const
Returns all vehicles closer than downstreamDist along the road network starting on the given position...
Definition: MSLane.cpp:4098
const PositionVector * getOutlineShape() const
Definition: MSLane.h:1336
void clearState()
Remove all vehicles before quick-loading state.
Definition: MSLane.cpp:3595
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
Definition: MSLane.h:1524
bool myNeedsCollisionCheck
whether a collision check is currently needed
Definition: MSLane.h:1573
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
Definition: MSLane.h:841
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:913
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:358
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:566
void setBidiLane(MSLane *bidyLane)
Adds the (overlapping) reverse direction lane to this lane.
Definition: MSLane.cpp:335
double getRightSideOnEdge() const
Definition: MSLane.h:1180
void checkBufferType()
Definition: MSLane.cpp:309
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
Definition: MSLane.cpp:4297
bool mySpeedByTraCI
Whether the current speed limit has been set through TraCI.
Definition: MSLane.h:1502
bool hasPedestrians() const
whether the lane has pedestrians on it
Definition: MSLane.cpp:4413
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:3177
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:4060
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:634
void setLaneStopOffset(const StopOffset &stopOffset)
Set vehicle class specific stopOffsets.
Definition: MSLane.cpp:3649
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition: MSLane.h:1536
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:3201
MSLane * getCanonicalSuccessorLane() const
Definition: MSLane.cpp:3145
void requireCollisionCheck()
require another collision check due to relevant changes in the simulation
Definition: MSLane.h:698
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:936
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
Definition: MSLane.h:1761
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
Definition: MSLane.cpp:4368
const double myWidth
Lane width [m].
Definition: MSLane.h:1483
bool lastInsertion(MSVehicle &veh, double mspeed, double posLat, bool patchSpeed)
inserts vehicle as close as possible to the last vehicle on this lane (or at the end of the lane if t...
Definition: MSLane.cpp:454
virtual void addSecondaryShape(const PositionVector &)
Definition: MSLane.h:288
void changeLanes(const SUMOTime time)
Definition: MSLane.cpp:2325
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:4241
SVCPermissions myChangeRight
Definition: MSLane.h:1509
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1559
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:2172
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:3065
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:3245
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
Definition: MSLane.h:499
int myIndex
The lane index.
Definition: MSLane.h:1431
double getCenterOnEdge() const
Definition: MSLane.h:1188
bool isNormal() const
Definition: MSLane.cpp:2492
bool isCrossing() const
Definition: MSLane.cpp:2498
double getMeanSpeedBike() const
get the mean speed of all bicycles on this lane
Definition: MSLane.cpp:3309
void updateLeaderInfo(const MSVehicle *veh, VehCont::reverse_iterator &vehPart, VehCont::reverse_iterator &vehRes, MSLeaderInfo &ahead) const
This updates the MSLeaderInfo argument with respect to the given MSVehicle. All leader-vehicles on th...
Definition: MSLane.cpp:1528
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:3275
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:2355
virtual bool isSelected() const
whether this lane is selected in the GUI
Definition: MSLane.h:1244
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1581
std::vector< MSLink * > myLinks
Definition: MSLane.h:1543
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:2527
bool isInternal() const
Definition: MSLane.cpp:2486
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1352
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1456
void sortManeuverReservations()
sorts myManeuverReservations
Definition: MSLane.cpp:2467
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:752
MinorLinkMode
determine whether/how getFollowers looks upstream beyond minor links
Definition: MSLane.h:959
@ FOLLOW_ONCOMING
Definition: MSLane.h:962
@ FOLLOW_ALWAYS
Definition: MSLane.h:961
@ FOLLOW_NEVER
Definition: MSLane.h:960
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:525
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible)
Definition: MSLane.h:464
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:558
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
Definition: MSLane.h:493
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
Definition: MSLane.cpp:3187
bool mySpeedByVSS
Whether the current speed limit is set by a variable speed sign (VSS)
Definition: MSLane.h:1499
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:377
void setOpposite(MSLane *oppositeLane)
Adds a neighbor to this lane.
Definition: MSLane.cpp:327
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:803
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
Definition: MSLane.h:481
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:3334
std::pair< MSVehicle *const, double > getLeader(const MSVehicle *veh, const double vehPos, const std::vector< MSLane * > &bestLaneConts, double dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
Definition: MSLane.cpp:2783
void handleIntermodalCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSTransportable *victim, double gap, const std::string &collisionType, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
Definition: MSLane.cpp:2095
static bool myExtrapolateSubstepDepart
Definition: MSLane.h:1607
MSLane * getOpposite() const
return the neighboring opposite direction lane for lane changing or nullptr
Definition: MSLane.cpp:4229
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Definition: MSLane.cpp:2672
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
Definition: MSLane.h:1546
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:505
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
Definition: MSLane.cpp:4500
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:546
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
Definition: MSLane.cpp:400
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
Definition: MSLane.cpp:4494
static double myCollisionMinGapFactor
Definition: MSLane.h:1606
MSLane & operator=(const MSLane &)=delete
invalidated assignment operator
bool isEmpty() const
Definition: MSLane.h:853
std::pair< MSVehicle *const, double > getLeaderOnConsecutive(double dist, double seen, double speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts) const
Returns the immediate leader and the distance to him.
Definition: MSLane.cpp:2855
bool hasApproaching(const std::vector< MSLink * > &links) const
check whether any of the outgoing links are being approached
double getLengthGeometryFactor() const
return shape.length() / myLength
Definition: MSLane.h:530
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1554
MSLane * myOpposite
Definition: MSLane.h:1576
CollisionAction
Definition: MSLane.h:201
@ COLLISION_ACTION_NONE
Definition: MSLane.h:202
@ COLLISION_ACTION_WARN
Definition: MSLane.h:203
@ COLLISION_ACTION_TELEPORT
Definition: MSLane.h:204
@ COLLISION_ACTION_REMOVE
Definition: MSLane.h:205
MSLane * getParallelOpposite() const
return the opposite direction lane of this lanes edge or nullptr
Definition: MSLane.cpp:4235
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
Definition: MSLane.h:1588
double getFractionalVehicleLength(bool brutto) const
return length of fractional vehicles on this lane
Definition: MSLane.cpp:3226
double getSpaceTillLastStanding(const MSVehicle *ego, bool &foundStopped) const
return the empty space up to the last standing vehicle or the empty space on the whole lane if no veh...
Definition: MSLane.cpp:4509
double getEmissions() const
Returns the sum of last step emissions The value is always per 1s, so multiply by step length if nece...
Definition: MSLane.h:1154
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
Definition: MSLane.cpp:3090
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition: MSLane.h:315
int getNumericalID() const
Returns this lane's numerical id.
Definition: MSLane.h:517
void setRightSideOnEdge(double value, int rightmostSublane)
Definition: MSLane.h:1170
virtual bool appropriate(const MSVehicle *veh) const
Definition: MSLane.cpp:2411
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, MinorLinkMode mLinkMode=FOLLOW_ALWAYS) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
Definition: MSLane.cpp:3655
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:627
bool freeInsertion(MSVehicle &veh, double speed, double posLat, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
Definition: MSLane.cpp:489
void setMaxSpeed(double val, bool byVSS=false, bool byTraCI=false, double jamThreshold=-1)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:2649
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
Definition: MSLane.cpp:348
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:2518
int getRightmostSublane() const
Definition: MSLane.h:1184
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:3288
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
Definition: MSLane.h:1539
friend class AnyVehicleIterator
Definition: MSLane.h:116
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:3612
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:552
void setFrictionCoefficient(double val)
Sets a new friction coefficient for the lane [to be later (used by TraCI and MSCalibrator)].
Definition: MSLane.cpp:2665
virtual const PositionVector & getShape(bool) const
Definition: MSLane.h:294
static CollisionAction getCollisionAction()
Definition: MSLane.h:1343
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:144
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
Export the queueing length in front of a junction (very experimental!)
Definition: MSQueueExport.h:47
The class responsible for building and deletion of vehicles.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
Base class for objects which have an id.
Definition: Named.h:54
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Representation of a vehicle, person, or container.
virtual double getChosenSpeedFactor() const =0
virtual double getMaxSpeed() const =0
Returns the object's maximum speed (minimum of technical and desired maximum speed)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
stop offset