SUMO - Simulation of Urban MObility
MSLane.h
Go to the documentation of this file.
1 /****************************************************************************/
13 // Representation of a lane in the micro simulation
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 #ifndef MSLane_h
27 #define MSLane_h
28 
29 
30 // ===========================================================================
31 // included modules
32 // ===========================================================================
33 #ifdef _MSC_VER
34 #include <windows_config.h>
35 #else
36 #include <config.h>
37 #endif
38 
39 #include <vector>
40 #include <deque>
41 #include <cassert>
42 #include <utils/common/Named.h>
48 #include "MSLinkCont.h"
49 #include "MSLeaderInfo.h"
50 #include "MSMoveReminder.h"
51 #ifndef NO_TRACI
53 #endif
54 
55 
56 // ===========================================================================
57 // class declarations
58 // ===========================================================================
59 class MSEdge;
60 class MSVehicle;
61 class MSLaneChanger;
62 class MSLink;
63 class MSVehicleTransfer;
64 class MSVehicleControl;
65 class OutputDevice;
66 class MSLeaderInfo;
67 
68 
69 // ===========================================================================
70 // class definitions
71 // ===========================================================================
79 class MSLane : public Named, public Parameterised {
80 public:
82  friend class MSLaneChanger;
83  friend class MSLaneChangerSublane;
84 
85  friend class MSXMLRawOut;
86 
87  friend class MSQueueExport;
88  friend class AnyVehicleIterator;
89 
91  typedef std::vector<MSVehicle*> VehCont;
92 
95  struct VehPosition : public std::binary_function < const MSVehicle*, double, bool > {
97  bool operator()(const MSVehicle* cmp, double pos) const;
98  };
99 
101  public:
103  const MSLane* lane,
104  int i1,
105  int i2,
106  const int i1End,
107  const int i2End,
108  bool downstream = true) :
109  myLane(lane),
110  myI1(i1),
111  myI2(i2),
112  myI1End(i1End),
113  myI2End(i2End),
114  myDownstream(downstream),
115  myDirection(downstream ? 1 : -1) {
116  }
117 
118  bool operator== (AnyVehicleIterator const& other) const {
119  return (myI1 == other.myI1
120  && myI2 == other.myI2
121  && myI1End == other.myI1End
122  && myI2End == other.myI2End);
123  }
124 
125  bool operator!= (AnyVehicleIterator const& other) const {
126  return !(*this == other);
127  }
128 
130  return **this;
131  }
132 
133  const MSVehicle* operator*();
134 
135  AnyVehicleIterator& operator++();
136 
137  private:
138  bool nextIsMyVehicles() const;
139 
141  const MSLane* myLane;
143  int myI1;
145  int myI2;
147  int myI1End;
149  int myI2End;
154 
155  };
156 
157 
158 public:
167  };
168 
183  MSLane(const std::string& id, double maxSpeed, double length, MSEdge* const edge,
184  int numericalID, const PositionVector& shape, double width,
185  SVCPermissions permissions, int index, bool isRampAccel);
186 
187 
189  virtual ~MSLane();
190 
191 
192 
195 
203  void addLink(MSLink* link);
204 
209  void addNeigh(const std::string& id);
211 
212 
213 
216 
223  virtual void addMoveReminder(MSMoveReminder* rem);
224 
225 
229  inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
230  return myMoveReminders;
231  }
233 
234 
235 
238 
254  bool insertVehicle(MSVehicle& v);
255 
256 
275  bool isInsertionSuccess(MSVehicle* vehicle, double speed, double pos, double posLat,
276  bool recheckNextLanes,
277  MSMoveReminder::Notification notification);
278 
279  // XXX: Documentation?
280  bool checkFailure(MSVehicle* aVehicle, double& speed, double& dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const;
281 
285  bool lastInsertion(MSVehicle& veh, double mspeed, bool patchSpeed);
286 
294  bool freeInsertion(MSVehicle& veh, double speed,
296 
297 
307  void forceVehicleInsertion(MSVehicle* veh, double pos, MSMoveReminder::Notification notification, double posLat = 0);
309 
310 
311 
314 
321  virtual double setPartialOccupation(MSVehicle* v);
322 
326  virtual void resetPartialOccupation(MSVehicle* v);
327 
338  const MSLeaderInfo& getLastVehicleInformation(const MSVehicle* ego, double latOffset, double minPos = 0, bool allowCached = true) const;
339 
341  const MSLeaderInfo& getFirstVehicleInformation(const MSVehicle* ego, double latOffset, bool onlyFrontOnLane, double maxPos = std::numeric_limits<double>::max(), bool allowCached = true) const;
342 
344 
347 
352  int getVehicleNumber() const {
353  return (int)myVehicles.size();
354  }
355 
361  return (int)myVehicles.size() + (int)myPartialVehicles.size();
362  }
363 
369  return (int)myPartialVehicles.size();
370  }
371 
372 
379  virtual const VehCont& getVehiclesSecure() const {
380  return myVehicles;
381  }
382 
383 
386  return AnyVehicleIterator(this, 0, 0, (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
387  }
388 
391  return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
392  }
393 
396  return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, -1, -1, false);
397  }
398 
401  return AnyVehicleIterator(this, -1, -1, -1, -1, false);
402  }
403 
406  virtual void releaseVehicles() const { }
408 
409 
410 
413 
414 
418  inline int getNumericalID() const {
419  return myNumericalID;
420  }
421 
422 
426  inline const PositionVector& getShape() const {
427  return myShape;
428  }
429 
431  inline double getLengthGeometryFactor() const {
432  return myLengthGeometryFactor;
433  }
434 
436  inline bool isAccelLane() const {
437  return myIsRampAccel;
438  }
439 
440  /* @brief fit the given lane position to a visibly suitable geometry position
441  * (lane length might differ from geometry length) */
442  inline double interpolateLanePosToGeometryPos(double lanePos) const {
443  return lanePos * myLengthGeometryFactor;
444  }
445 
446  /* @brief fit the given lane position to a visibly suitable geometry position
447  * and return the coordinates */
448  inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {
449  return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
450  }
451 
452  /* @brief fit the given geomtry position to a valid lane position
453  * (lane length might differ from geometry length) */
454  inline double interpolateGeometryPosToLanePos(double geometryPos) const {
455  return geometryPos / myLengthGeometryFactor;
456  }
457 
462  inline double getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
463  if (myRestrictions != 0) {
464  std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(veh->getVClass());
465  if (r != myRestrictions->end()) {
466  return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
467  }
468  }
469  return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
470  }
471 
472 
476  inline double getSpeedLimit() const {
477  return myMaxSpeed;
478  }
479 
480 
484  inline double getLength() const {
485  return myLength;
486  }
487 
488 
493  return myPermissions;
494  }
495 
496 
500  double getWidth() const {
501  return myWidth;
502  }
503 
507  int getIndex() const {
508  return myIndex;
509  }
511 
513  int getCrossingIndex() const;
514 
515 
518 
526  virtual void planMovements(const SUMOTime t);
527 
536  virtual bool executeMovements(SUMOTime t, std::vector<MSLane*>& lanesWithVehiclesToIntegrate);
537 
539  virtual bool integrateNewVehicle(SUMOTime t);
541 
542 
543 
545  virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
546 
547 
550  virtual bool appropriate(const MSVehicle* veh);
551 
552 
554  const MSLinkCont& getLinkCont() const;
555 
557  MSLink* getLinkTo(const MSLane*) const;
558 
560  MSLink* getEntryLink() const;
561 
562 
564  bool empty() const {
565  assert(myVehBuffer.size() == 0);
566  return myVehicles.empty();
567  }
568 
572  void setMaxSpeed(double val);
573 
577  void setLength(double val);
578 
582  MSEdge& getEdge() const {
583  return *myEdge;
584  }
585 
586 
590  const MSEdge* getNextNormal() const;
591 
592 
595 
606  static bool dictionary(const std::string& id, MSLane* lane);
607 
608 
615  static MSLane* dictionary(const std::string& id);
616 
617 
619  static void clear();
620 
621 
625  static int dictSize() {
626  return (int)myDict.size();
627  }
628 
629 
633  static void insertIDs(std::vector<std::string>& into);
634 
635 
640  template<class RTREE>
641  static void fill(RTREE& into);
643 
644 
645 
646  // XXX: succLink does not exist... Documentation?
651  static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle& veh,
652  int nRouteSuccs,
653  const MSLane& succLinkSource,
654  const std::vector<MSLane*>& conts);
655 
656 
659  bool isLinkEnd(MSLinkCont::const_iterator& i) const;
660 
663  bool isLinkEnd(MSLinkCont::iterator& i);
664 
667  bool isEmpty() const;
668 
670  bool isInternal() const;
671 
673  MSVehicle* getLastFullVehicle() const;
674 
677 
679  MSVehicle* getLastAnyVehicle() const;
680 
682  MSVehicle* getFirstAnyVehicle() const;
683 
684  /* @brief remove the vehicle from this lane
685  * @param[notify] whether moveReminders of the vehicle shall be triggered
686  */
687  virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
688 
689  void leftByLaneChange(MSVehicle* v);
691 
695  MSLane* getParallelLane(int offset) const;
696 
697 
702  void setPermissions(SVCPermissions permissions, long transientID);
703  void resetPermissions(long transientID);
704 
705 
706  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
707  return (myPermissions & vclass) == vclass;
708  }
709 
710  void addIncomingLane(MSLane* lane, MSLink* viaLink);
711 
712 
715  double length;
717  };
718 
719  const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
720  return myIncomingLanes;
721  }
722 
723 
724  void addApproachingLane(MSLane* lane, bool warnMultiCon);
725  bool isApproachedFrom(MSEdge* const edge);
726  bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
727 
728 
729 
731  MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, double backOffset,
732  bool allSublanes, double searchDist = -1, bool ignoreMinorLinks = false) const;
733 
735  double getMissingRearGap(const MSVehicle* leader, double backOffset, double leaderSpeed) const;
736 
749  std::pair<MSVehicle* const, double> getLeader(const MSVehicle* veh, const double vehPos, const std::vector<MSLane*>& bestLaneConts, double dist = -1, bool checkTmpVehicles = false) const;
750 
773  std::pair<MSVehicle* const, double> getLeaderOnConsecutive(double dist, double seen,
774  double speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
775 
777  void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle* ego,
778  const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result) const;
779 
797  std::pair<MSVehicle* const, double> getCriticalLeader(double dist, double seen, double speed, const MSVehicle& veh) const;
798 
799  /* @brief return the partial vehicle closest behind ego or 0
800  * if no such vehicle exists */
801  MSVehicle* getPartialBehind(const MSVehicle* ego) const;
802 
807 
810  MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
811 
812 
819 
820 
827 
830 
832  std::vector<const MSLane*> getOutgoingLanes() const;
833 
835 
836 
840  double getMeanSpeed() const;
841 
845  double getWaitingSeconds() const;
846 
847 
851  double getBruttoOccupancy() const;
852 
853 
857  double getNettoOccupancy() const;
858 
859 
863  inline double getBruttoVehLenSum() const {
865  }
866 
867 
871  double getCO2Emissions() const;
872 
873 
877  double getCOEmissions() const;
878 
879 
883  double getPMxEmissions() const;
884 
885 
889  double getNOxEmissions() const;
890 
891 
895  double getHCEmissions() const;
896 
897 
901  double getFuelConsumption() const;
902 
903 
907  double getElectricityConsumption() const;
908 
909 
913  double getHarmonoise_NoiseEmissions() const;
915 
916  void setRightSideOnEdge(double value, int rightmostSublane) {
917  myRightSideOnEdge = value;
918  myRightmostSublane = rightmostSublane;
919  }
920 
922  void initRestrictions();
923 
924  double getRightSideOnEdge() const {
925  return myRightSideOnEdge;
926  }
927 
928  int getRightmostSublane() const {
929  return myRightmostSublane;
930  }
931 
932  double getCenterOnEdge() const {
933  return myRightSideOnEdge + 0.5 * myWidth;
934  }
935 
937  void sortPartialVehicles();
938 
940  MSLane* getOpposite() const;
941 
943  double getOppositePos(double pos) const;
944 
945  /* @brief find leader for a vehicle depending the relative driving direction
946  * @param[in] ego The ego vehicle
947  * @param[in] dist The look-ahead distance when looking at consecutive lanes
948  * @param[in] oppositeDir Whether the lane has the opposite driving direction of ego
949  * @return the leader vehicle and it's gap to ego
950  */
951  std::pair<MSVehicle* const, double> getOppositeLeader(const MSVehicle* ego, double dist, bool oppositeDir) const;
952 
953  /* @brief find follower for a vehicle that is located on the opposite of this lane
954  * @param[in] ego The ego vehicle
955  * @return the follower vehicle and it's gap to ego
956  */
957  std::pair<MSVehicle* const, double> getOppositeFollower(const MSVehicle* ego) const;
958 
959 
967  std::pair<MSVehicle* const, double> getFollower(const MSVehicle* ego, double egoPos, double dist, bool ignoreMinorLinks) const;
968 
971 
979  void saveState(OutputDevice& out);
980 
992  void loadState(std::vector<std::string>& vehIDs, MSVehicleControl& vc);
994 
995 
996 #ifndef NO_TRACI
997 
1004  void visit(const TraCIServerAPI_Lane::StoringVisitor& cont) const {
1005  cont.add(this);
1006  }
1007 #endif
1008 
1009  static void initCollisionOptions(const OptionsCont& oc);
1010 
1011  static bool teleportOnCollision() {
1013  }
1014 
1016  return myCollisionAction;
1017  }
1018 
1019  static const long CHANGE_PERMISSIONS_PERMANENT = 0;
1020  static const long CHANGE_PERMISSIONS_GUI = 1;
1021 
1022 protected:
1024  virtual void swapAfterLaneChange(SUMOTime t);
1025 
1037  virtual void incorporateVehicle(MSVehicle* veh, double pos, double speed, double posLat,
1038  const MSLane::VehCont::iterator& at,
1040 
1041 
1043  bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1044  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1045  std::set<const MSVehicle*>& toTeleport) const;
1046 
1048  void handleCollisionBetween(SUMOTime timestep, const std::string& stage, MSVehicle* collider, MSVehicle* victim,
1049  double gap, double latGap,
1050  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1051  std::set<const MSVehicle*>& toTeleport) const;
1052 
1054  double getMaximumBrakeDist() const;
1055 
1056  /* @brief determine depart speed and whether it may be patched
1057  * @param[in] veh The departing vehicle
1058  * @param[out] whether the speed may be patched to account for safety
1059  * @return the depart speed
1060  */
1061  double getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1062 
1065  double safeInsertionSpeed(const MSVehicle* veh, const MSLeaderInfo& leaders, double speed);
1066 
1068  double basePos(const MSVehicle& veh) const;
1069 
1072 
1075 
1077  int myIndex;
1078 
1090  VehCont myVehicles;
1091 
1103 
1106  VehCont myTmpVehicles;
1107 
1110  VehCont myVehBuffer;
1111 
1112 
1114  double myLength;
1115 
1117  const double myWidth;
1118 
1120  MSEdge* const myEdge;
1121 
1123  double myMaxSpeed;
1124 
1127 
1130 
1132  const std::map<SUMOVehicleClass, double>* myRestrictions;
1133 
1135  std::vector<IncomingLaneInfo> myIncomingLanes;
1136 
1139 
1142 
1145 
1148 
1151 
1155 
1157  std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1158 
1163 
1165 
1170 
1173 
1175  const bool myIsRampAccel;
1176 
1181 
1182  // @brief the ids of neighboring lanes
1183  std::vector<std::string> myNeighs;
1184 
1185  // @brief transient changes in permissions
1186  std::map<long, SVCPermissions> myPermissionChanges;
1187 
1189  typedef std::map< std::string, MSLane* > DictType;
1190 
1192  static DictType myDict;
1193 
1194 private:
1196  std::vector< MSMoveReminder* > myMoveReminders;
1197 
1202 
1208  public:
1210  explicit vehicle_position_sorter(const MSLane* lane) :
1211  myLane(lane) {
1212  }
1213 
1214 
1220  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1221 
1222  const MSLane* myLane;
1223 
1224  };
1225 
1231  public:
1233  explicit vehicle_natural_position_sorter(const MSLane* lane) :
1234  myLane(lane) {
1235  }
1236 
1237 
1243  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1244 
1245  const MSLane* myLane;
1246 
1247  };
1248 
1254  public:
1256  explicit by_connections_to_sorter(const MSEdge* const e);
1257 
1259  int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1260 
1261  private:
1262  by_connections_to_sorter& operator=(const by_connections_to_sorter&); // just to avoid a compiler warning
1263  private:
1264  const MSEdge* const myEdge;
1265  double myLaneDir;
1266  };
1267 
1268 
1269 
1275  public:
1277  explicit incoming_lane_priority_sorter(const MSLane* targetLane);
1278 
1280  int operator()(const IncomingLaneInfo& lane1, const IncomingLaneInfo& lane2) const;
1281 
1282  private:
1283  incoming_lane_priority_sorter& operator=(const incoming_lane_priority_sorter&); // just to avoid a compiler warning
1284  private:
1285  const MSLane* const myLane;
1286  double myLaneDir;
1287  };
1288 
1289 
1295  public:
1297  explicit outgoing_lane_priority_sorter(const MSLane* sourceLane);
1298 
1300  int operator()(const MSLink* link1, const MSLink* link2) const;
1301 
1302  private:
1303  outgoing_lane_priority_sorter& operator=(const outgoing_lane_priority_sorter&); // just to avoid a compiler warning
1304  private:
1305  const MSLane* const myLane;
1306  double myLaneDir;
1307  };
1308 
1312  class edge_finder {
1313  public:
1314  edge_finder(MSEdge* e) : myEdge(e) {}
1315  bool operator()(const IncomingLaneInfo& ili) const {
1316  return &(ili.lane->getEdge()) == myEdge;
1317  }
1318  private:
1319  edge_finder& operator=(const edge_finder&); // just to avoid a compiler warning
1320  private:
1321  const MSEdge* const myEdge;
1322  };
1323 
1324 private:
1326  MSLane(const MSLane&);
1327 
1329  MSLane& operator=(const MSLane&);
1330 
1331 
1332 };
1333 
1334 
1335 #endif
1336 
1337 /****************************************************************************/
1338 
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:719
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, bool ignoreMinorLinks) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane) ...
Definition: MSLane.cpp:2725
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2106
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:2458
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1126
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:1979
VehCont myVehicles
The lane&#39;s vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1090
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:462
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:136
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2201
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:582
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1511
void resetPermissions(long transientID)
Definition: MSLane.cpp:2822
MSLane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, int index, bool isRampAccel)
Constructor.
Definition: MSLane.cpp:161
const MSEdge * getNextNormal() const
Returns the lane&#39;s follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:1360
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:1403
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn&#39;t apply, wrt. the angle differenc...
Definition: MSLane.h:1274
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
Definition: MSLane.cpp:2744
static bool teleportOnCollision()
Definition: MSLane.h:1011
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:1020
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
int myI2
index for myPartialVehicles
Definition: MSLane.h:145
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2225
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:535
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:1411
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:1755
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:1642
bool freeInsertion(MSVehicle &veh, double speed, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
Definition: MSLane.cpp:313
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
Definition: MSLane.h:1135
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
int myI2End
end index for myPartialVehicles
Definition: MSLane.h:149
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:201
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
Definition: MSLane.h:1141
int myIndex
The lane index.
Definition: MSLane.h:1077
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1447
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1167
bool operator()(const MSVehicle *cmp, double pos) const
compares vehicle position to the detector position
Definition: MSLane.cpp:2266
static SUMOTime myCollisionStopTime
Definition: MSLane.h:1201
Notification
Definition of a vehicle state.
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:2070
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
take action upon collision
Definition: MSLane.cpp:1173
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1667
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
detect whether there is a collision between the two vehicles
Definition: MSLane.cpp:1116
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1147
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1534
const MSEdge *const myEdge
Definition: MSLane.h:1264
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1691
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2189
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:484
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:379
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:426
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:1481
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:2791
Realises dumping the complete network state.
Definition: MSXMLRawOut.h:62
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
Definition: MSLane.cpp:214
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
Definition: MSLane.cpp:1604
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2081
MSLane * getCanonicalPredecessorLane() const
Definition: MSLane.cpp:2018
std::map< long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1186
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
Definition: MSLane.cpp:207
const std::vector< MSMoveReminder *> & getMoveReminders() const
Return the list of this lane&#39;s move reminders.
Definition: MSLane.h:229
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:223
VehCont myPartialVehicles
The lane&#39;s partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1102
static bool myCheckJunctionCollisions
Definition: MSLane.h:1200
double getWidth() const
Returns the lane&#39;s width.
Definition: MSLane.h:500
int myI1End
end index for myVehicles
Definition: MSLane.h:147
int myDirection
index delta
Definition: MSLane.h:153
PositionVector myShape
The shape of the lane.
Definition: MSLane.h:1074
MSLane * getCanonicalSuccessorLane() const
Definition: MSLane.cpp:2038
void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle *ego, const std::vector< MSLane *> &bestLaneConts, MSLeaderDistanceInfo &result) const
Returns the immediate leaders and the distance to them (as getLeaderOnConsecutive but for the sublane...
Definition: MSLane.cpp:2595
bool myDownstream
iteration direction
Definition: MSLane.h:151
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition: MSLane.h:360
Performs lane changing of vehicles.
std::vector< std::string > myNeighs
Definition: MSLane.h:1183
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1199
int getNumericalID() const
Returns this lane&#39;s numerical id.
Definition: MSLane.h:418
std::map< std::string, MSLane *> DictType
definition of the static dictionary type
Definition: MSLane.h:1189
static CollisionAction getCollisionAction()
Definition: MSLane.h:1015
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible) ...
Definition: MSLane.h:368
MSLinkCont myLinks
Definition: MSLane.h:1154
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:1004
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSLane.h:1192
Sorts lanes (their origin link) by the priority of their noninternal target edges or...
Definition: MSLane.h:1294
bool isInternal() const
Definition: MSLane.cpp:1497
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:1701
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:55
A road/street connecting two junctions.
Definition: MSEdge.h:80
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:428
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle&#39;s access class.
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:863
bool checkFailure(MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
Definition: MSLane.cpp:517
double myLength
Lane length [m].
Definition: MSLane.h:1114
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:507
#define max(a, b)
Definition: polyfonts.c:65
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Definition: MSLane.h:1106
Allows to store the object; used as context while traveling the rtree in TraCI.
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
Definition: MSLane.cpp:1625
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:625
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
Definition: MSLane.cpp:2095
Export the queueing length in front of a junction (very experimental!)
Definition: MSQueueExport.h:57
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:236
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2165
const bool myIsRampAccel
whether this lane is an acceleration lane
Definition: MSLane.h:1175
const MSEdge *const myEdge
Definition: MSLane.h:1321
Representation of a vehicle.
Definition: SUMOVehicle.h:67
friend class AnyVehicleIterator
Definition: MSLane.h:88
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Definition: MSLane.cpp:1649
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition: MSLane.h:454
double basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
Definition: MSLane.cpp:512
Sorts vehicles by their position (descending)
Definition: MSLane.h:1207
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1178
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
double getCenterOnEdge() const
Definition: MSLane.h:932
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition: MSLane.h:1129
A list of positions.
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2088
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:859
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:352
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1132
bool isEmpty() const
Definition: MSLane.cpp:1492
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
Definition: MSLane.cpp:2767
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:492
double getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:476
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Sorts edges by their angle relative to the given edge (straight comes first)
Definition: MSLane.h:1253
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:831
T MIN2(T a, T b)
Definition: StdDefs.h:64
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:2680
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:390
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:385
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:2059
virtual bool executeMovements(SUMOTime t, std::vector< MSLane *> &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1262
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:1765
CollisionAction
Definition: MSLane.h:162
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1180
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1138
Something on a lane to be noticed about vehicle movement.
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
Definition: MSLane.cpp:2704
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:395
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:1656
An upper class for objects with additional parameters.
Definition: Parameterised.h:51
double getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2213
virtual double getChosenSpeedFactor() const =0
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
Definition: MSLane.h:1157
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:91
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
Definition: MSLane.cpp:1548
Base class for objects which have an id.
Definition: Named.h:46
int myNumericalID
Unique numerical ID (set on reading by netload)
Definition: MSLane.h:1071
std::vector< MSMoveReminder *> myMoveReminders
This lane&#39;s move reminder.
Definition: MSLane.h:1196
virtual double getMaxSpeed() const =0
Returns the vehicle&#39;s maximum speed.
double getRightSideOnEdge() const
Definition: MSLane.h:924
void initRestrictions()
initialized vClass-specific speed limits
Definition: MSLane.cpp:195
double getLengthGeometryFactor() const
return shape.length() / myLength
Definition: MSLane.h:431
int getRightmostSublane() const
Definition: MSLane.h:928
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1502
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:1474
void setPermissions(SVCPermissions permissions, long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
Definition: MSLane.cpp:2810
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2237
double safeInsertionSpeed(const MSVehicle *veh, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
Definition: MSLane.cpp:840
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1371
The vehicle has departed (was inserted into the network)
double getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2177
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:1830
int myI1
index for myVehicles
Definition: MSLane.h:143
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:2713
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1315
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1394
void visit(const TraCIServerAPI_Lane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:1004
MSEdge *const myEdge
The lane&#39;s edge, for routing only.
Definition: MSLane.h:1120
const MSVehicle * operator->()
Definition: MSLane.h:129
Point2D< point_type > operator*(mul_type val, const Point2D< point_type > pt)
Definition: points.h:180
const MSLane * myLane
the lane that is being iterated
Definition: MSLane.h:141
A storage for options typed value containers)
Definition: OptionsCont.h:99
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:442
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1520
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:448
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.cpp:1715
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2249
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:1916
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:400
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:910
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:706
MSLane & operator=(const MSLane &)
invalidated assignment operator
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:2447
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1160
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Definition: MSLane.h:1144
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
long long int SUMOTime
Definition: TraCIDefs.h:52
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1150
double getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2149
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1162
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:187
The class responsible for building and deletion of vehicles.
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:1739
const double myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1172
MSLeaderInfo myLeaderInfoTmp
Definition: MSLane.h:1164
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1597
VehCont myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
Definition: MSLane.h:1110
static const long CHANGE_PERMISSIONS_PERMANENT
Definition: MSLane.h:1019
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, bool ignoreMinorLinks=false) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
Definition: MSLane.cpp:2472
AnyVehicleIterator(const MSLane *lane, int i1, int i2, const int i1End, const int i2End, bool downstream=true)
Definition: MSLane.h:102
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:564
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1169
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:406
double myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1123
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:2121
void add(const MSLane *const l) const
Adds the given object to the container.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:2136
const double myWidth
Lane width [m].
Definition: MSLane.h:1117
edge_finder(MSEdge *e)
Definition: MSLane.h:1314
void setRightSideOnEdge(double value, int rightmostSublane)
Definition: MSLane.h:916
bool isAccelLane() const
return whether this lane is an acceleration lane
Definition: MSLane.h:436
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:256
bool lastInsertion(MSVehicle &veh, double mspeed, 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:276
virtual bool appropriate(const MSVehicle *veh)
Definition: MSLane.cpp:1429
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:962
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition: MSLane.cpp:1685
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1210
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1233
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:401