SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-2016 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*, SUMOReal, bool > {
97  bool operator()(const MSVehicle* cmp, SUMOReal 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 
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 
182  MSLane(const std::string& id, SUMOReal maxSpeed, SUMOReal length, MSEdge* const edge,
183  int numericalID, const PositionVector& shape, SUMOReal width,
184  SVCPermissions permissions, int index);
185 
186 
188  virtual ~MSLane();
189 
190 
191 
194 
202  void addLink(MSLink* link);
203 
208  void addNeigh(const std::string& id);
210 
211 
212 
215 
222  virtual void addMoveReminder(MSMoveReminder* rem);
223 
224 
228  inline const std::vector< MSMoveReminder* >& getMoveReminders() const {
229  return myMoveReminders;
230  }
232 
233 
234 
237 
253  bool insertVehicle(MSVehicle& v);
254 
255 
274  bool isInsertionSuccess(MSVehicle* vehicle, SUMOReal speed, SUMOReal pos, SUMOReal posLat,
275  bool recheckNextLanes,
276  MSMoveReminder::Notification notification);
277 
278  // XXX: Documentation?
279  bool checkFailure(MSVehicle* aVehicle, SUMOReal& speed, SUMOReal& dist, const SUMOReal nspeed, const bool patchSpeed, const std::string errorMsg) const;
280 
284  bool lastInsertion(MSVehicle& veh, SUMOReal mspeed);
285 
293  bool freeInsertion(MSVehicle& veh, SUMOReal speed,
295 
296 
306  void forceVehicleInsertion(MSVehicle* veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat = 0);
308 
309 
310 
313 
321 
325  virtual void resetPartialOccupation(MSVehicle* v);
326 
337  const MSLeaderInfo& getLastVehicleInformation(const MSVehicle* ego, SUMOReal latOffset, SUMOReal minPos = 0, bool allowCached = true) const;
338 
340  const MSLeaderInfo& getFirstVehicleInformation(const MSVehicle* ego, SUMOReal latOffset, bool onlyFrontOnLane, SUMOReal maxPos = std::numeric_limits<SUMOReal>::max(), bool allowCached = true) const;
341 
343 
344 
345 
348 
353  int getVehicleNumber() const {
354  return (int)myVehicles.size();
355  }
356 
362  return (int)myVehicles.size() + (int)myPartialVehicles.size();
363  }
364 
370  return (int)myPartialVehicles.size();
371  }
372 
373 
380  virtual const VehCont& getVehiclesSecure() const {
381  return myVehicles;
382  }
383 
384 
387  return AnyVehicleIterator(this, 0, 0, (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
388  }
389 
392  return AnyVehicleIterator(this, (int)myVehicles.size(), (int)myPartialVehicles.size(), (int)myVehicles.size(), (int)myPartialVehicles.size(), true);
393  }
394 
397  return AnyVehicleIterator(this, (int)myVehicles.size() - 1, (int)myPartialVehicles.size() - 1, -1, -1, false);
398  }
399 
402  return AnyVehicleIterator(this, -1, -1, -1, -1, false);
403  }
404 
407  virtual void releaseVehicles() const { }
409 
410 
411 
414 
415 
419  inline int getNumericalID() const {
420  return myNumericalID;
421  }
422 
423 
427  inline const PositionVector& getShape() const {
428  return myShape;
429  }
430 
433  return myLengthGeometryFactor;
434  }
435 
436  /* @brief fit the given lane position to a visibly suitable geometry position
437  * (lane length might differ from geometry length) */
439  return lanePos * myLengthGeometryFactor;
440  }
441 
442  /* @brief fit the given lane position to a visibly suitable geometry position
443  * and return the coordinates */
444  inline const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset = 0) const {
445  return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);
446  }
447 
448  /* @brief fit the given geomtry position to a valid lane position
449  * (lane length might differ from geometry length) */
451  return geometryPos / myLengthGeometryFactor;
452  }
453 
458  inline SUMOReal getVehicleMaxSpeed(const SUMOVehicle* const veh) const {
459  if (myRestrictions != 0) {
460  std::map<SUMOVehicleClass, SUMOReal>::const_iterator r = myRestrictions->find(veh->getVClass());
461  if (r != myRestrictions->end()) {
462  return MIN2(veh->getMaxSpeed(), r->second * veh->getChosenSpeedFactor());
463  }
464  }
465  return MIN2(veh->getMaxSpeed(), myMaxSpeed * veh->getChosenSpeedFactor());
466  }
467 
468 
472  inline SUMOReal getSpeedLimit() const {
473  return myMaxSpeed;
474  }
475 
476 
480  inline SUMOReal getLength() const {
481  return myLength;
482  }
483 
484 
489  return myPermissions;
490  }
491 
492 
496  SUMOReal getWidth() const {
497  return myWidth;
498  }
499 
503  int getIndex() const {
504  return myIndex;
505  }
507 
509  int getCrossingIndex() const;
510 
511 
514 
522  virtual void planMovements(const SUMOTime t);
523 
532  virtual bool executeMovements(SUMOTime t, std::vector<MSLane*>& lanesWithVehiclesToIntegrate);
533 
535  virtual bool integrateNewVehicle(SUMOTime t);
537 
538 
539 
541  virtual void detectCollisions(SUMOTime timestep, const std::string& stage);
542 
543 
546  virtual bool appropriate(const MSVehicle* veh);
547 
548 
550  const MSLinkCont& getLinkCont() const;
551 
553  bool empty() const {
554  assert(myVehBuffer.size() == 0);
555  return myVehicles.empty();
556  }
557 
561  void setMaxSpeed(SUMOReal val);
562 
566  void setLength(SUMOReal val);
567 
571  MSEdge& getEdge() const {
572  return *myEdge;
573  }
574 
575 
579  const MSEdge* getInternalFollower() const;
580 
581 
584 
595  static bool dictionary(const std::string& id, MSLane* lane);
596 
597 
604  static MSLane* dictionary(const std::string& id);
605 
606 
608  static void clear();
609 
610 
614  static int dictSize() {
615  return (int)myDict.size();
616  }
617 
618 
622  static void insertIDs(std::vector<std::string>& into);
623 
624 
629  template<class RTREE>
630  static void fill(RTREE& into);
632 
633 
634 
635  // XXX: succLink does not exist... Documentation?
640  static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle& veh,
641  int nRouteSuccs,
642  const MSLane& succLinkSource,
643  const std::vector<MSLane*>& conts);
644 
645 
648  bool isLinkEnd(MSLinkCont::const_iterator& i) const;
649 
652  bool isLinkEnd(MSLinkCont::iterator& i);
653 
656  bool isEmpty() const;
657 
659  bool isInternal() const;
660 
662  MSVehicle* getLastFullVehicle() const;
663 
666 
668  MSVehicle* getLastAnyVehicle() const;
669 
671  MSVehicle* getFirstAnyVehicle() const;
672 
673  /* @brief remove the vehicle from this lane
674  * @param[notify] whether moveReminders of the vehicle shall be triggered
675  */
676  virtual MSVehicle* removeVehicle(MSVehicle* remVehicle, MSMoveReminder::Notification notification, bool notify = true);
677 
678  void leftByLaneChange(MSVehicle* v);
680 
684  MSLane* getParallelLane(int offset) const;
685 
686 
691  void setPermissions(SVCPermissions permissions, long transientID);
692  void resetPermissions(long transientID);
693 
694 
695  inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {
696  return (myPermissions & vclass) == vclass;
697  }
698 
699  void addIncomingLane(MSLane* lane, MSLink* viaLink);
700 
701 
706  };
707 
708  const std::vector<IncomingLaneInfo>& getIncomingLanes() const {
709  return myIncomingLanes;
710  }
711 
712 
713  void addApproachingLane(MSLane* lane, bool warnMultiCon);
714  bool isApproachedFrom(MSEdge* const edge);
715  bool isApproachedFrom(MSEdge* const edge, MSLane* const lane);
716 
717 
718 
720  std::pair<MSVehicle* const, SUMOReal> getFollowerOnConsecutive(
721  SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel, SUMOReal dist = -1) const;
722 
724  MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle* ego, bool allSublanes) const;
725 
727  SUMOReal getMissingRearGap(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel) const;
728 
741  std::pair<MSVehicle* const, SUMOReal> getLeader(const MSVehicle* veh, const SUMOReal vehPos, const std::vector<MSLane*>& bestLaneConts, SUMOReal dist = -1, bool checkTmpVehicles = false) const;
742 
765  std::pair<MSVehicle* const, SUMOReal> getLeaderOnConsecutive(SUMOReal dist, SUMOReal seen,
766  SUMOReal speed, const MSVehicle& veh, const std::vector<MSLane*>& bestLaneConts) const;
767 
769  void getLeadersOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle* ego,
770  const std::vector<MSLane*>& bestLaneConts, MSLeaderDistanceInfo& result) const;
771 
789  std::pair<MSVehicle* const, SUMOReal> getCriticalLeader(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle& veh) const;
790 
791  /* @brief return the partial vehicle closest behind ego or 0
792  * if no such vehicle exists */
793  MSVehicle* getPartialBehind(const MSVehicle* ego) const;
794 
799 
802  MSLane* getLogicalPredecessorLane(const MSEdge& fromEdge) const;
803 
806 
808  std::vector<const MSLane*> getOutgoingLanes() const;
809 
811 
812 
816  SUMOReal getMeanSpeed() const;
817 
821  SUMOReal getWaitingSeconds() const;
822 
823 
828 
829 
833  SUMOReal getNettoOccupancy() const;
834 
835 
839  inline SUMOReal getBruttoVehLenSum() const {
841  }
842 
843 
847  SUMOReal getCO2Emissions() const;
848 
849 
853  SUMOReal getCOEmissions() const;
854 
855 
859  SUMOReal getPMxEmissions() const;
860 
861 
865  SUMOReal getNOxEmissions() const;
866 
867 
871  SUMOReal getHCEmissions() const;
872 
873 
878 
879 
884 
885 
891 
892  void setRightSideOnEdge(SUMOReal value, int rightmostSublane) {
893  myRightSideOnEdge = value;
894  myRightmostSublane = rightmostSublane;
895  }
896 
898  return myRightSideOnEdge;
899  }
900 
901  int getRightmostSublane() const {
902  return myRightmostSublane;
903  }
904 
906  return myRightSideOnEdge + 0.5 * myWidth;
907  }
908 
910  void sortPartialVehicles();
911 
913  MSLane* getOpposite() const;
914 
916  SUMOReal getOppositePos(SUMOReal pos) const;
917 
918  std::pair<MSVehicle* const, SUMOReal> getOppositeLeader(const MSVehicle* ego, SUMOReal dist) const;
919 
920  std::pair<MSVehicle* const, SUMOReal> getOppositeFollower(const MSVehicle* ego) const;
921 
922 
929  std::pair<MSVehicle* const, SUMOReal> getFollower(const MSVehicle* ego, SUMOReal egoPos, SUMOReal dist) const;
930 
933 
941  void saveState(OutputDevice& out);
942 
954  void loadState(std::vector<std::string>& vehIDs, MSVehicleControl& vc);
956 
957 
958 #ifndef NO_TRACI
959 
966  void visit(const TraCIServerAPI_Lane::StoringVisitor& cont) const {
967  cont.add(this);
968  }
969 #endif
970 
971  static void initCollisionOptions(const OptionsCont& oc);
972 
973  static bool teleportOnCollision() {
975  }
976 
977  static const long CHANGE_PERMISSIONS_PERMANENT = 0;
978  static const long CHANGE_PERMISSIONS_GUI = 1;
979 
980 protected:
982  virtual void swapAfterLaneChange(SUMOTime t);
983 
995  virtual void incorporateVehicle(MSVehicle* veh, SUMOReal pos, SUMOReal speed, SUMOReal posLat,
996  const MSLane::VehCont::iterator& at,
998 
999 
1001  bool detectCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
1002  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1003  std::set<const MSVehicle*>& toTeleport) const;
1004 
1006  void handleCollisionBetween(SUMOTime timestep, const std::string& stage, const MSVehicle* collider, const MSVehicle* victim,
1007  SUMOReal gap, SUMOReal latGap,
1008  std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1009  std::set<const MSVehicle*>& toTeleport) const;
1010 
1012  SUMOReal getMaximumBrakeDist() const;
1013 
1014  /* @brief determine depart speed and whether it may be patched
1015  * @param[in] veh The departing vehicle
1016  * @param[out] whether the speed may be patched to account for safety
1017  * @return the depart speed
1018  */
1019  SUMOReal getDepartSpeed(const MSVehicle& veh, bool& patchSpeed);
1020 
1023  SUMOReal safeInsertionSpeed(const MSVehicle* veh, const MSLeaderInfo& leaders, SUMOReal speed);
1024 
1026  SUMOReal basePos(const MSVehicle& veh) const;
1027 
1030 
1033 
1035  int myIndex;
1036 
1048  VehCont myVehicles;
1049 
1061 
1064  VehCont myTmpVehicles;
1065 
1068  VehCont myVehBuffer;
1069 
1070 
1073 
1076 
1078  MSEdge* const myEdge;
1079 
1082 
1085 
1088 
1090  const std::map<SUMOVehicleClass, SUMOReal>* myRestrictions;
1091 
1092  std::vector<IncomingLaneInfo> myIncomingLanes;
1094 
1095 
1098 
1101 
1105 
1106  std::map<MSEdge*, std::vector<MSLane*> > myApproachingLanes;
1107 
1112 
1114 
1119 
1122 
1127 
1128  // @brief the ids of neighboring lanes
1129  std::vector<std::string> myNeighs;
1130 
1131  // @brief transient changes in permissions
1132  std::map<long, SVCPermissions> myPermissionChanges;
1133 
1135  typedef std::map< std::string, MSLane* > DictType;
1136 
1138  static DictType myDict;
1139 
1140 private:
1142  std::vector< MSMoveReminder* > myMoveReminders;
1143 
1147 
1153  public:
1155  explicit vehicle_position_sorter(const MSLane* lane) :
1156  myLane(lane) {
1157  }
1158 
1159 
1165  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1166 
1167  const MSLane* myLane;
1168 
1169  };
1170 
1176  public:
1178  explicit vehicle_natural_position_sorter(const MSLane* lane) :
1179  myLane(lane) {
1180  }
1181 
1182 
1188  int operator()(MSVehicle* v1, MSVehicle* v2) const;
1189 
1190  const MSLane* myLane;
1191 
1192  };
1193 
1199  public:
1201  explicit by_connections_to_sorter(const MSEdge* const e);
1202 
1204  int operator()(const MSEdge* const e1, const MSEdge* const e2) const;
1205 
1206  private:
1207  by_connections_to_sorter& operator=(const by_connections_to_sorter&); // just to avoid a compiler warning
1208  private:
1209  const MSEdge* const myEdge;
1211  };
1212 
1216  class edge_finder {
1217  public:
1218  edge_finder(MSEdge* e) : myEdge(e) {}
1219  bool operator()(const IncomingLaneInfo& ili) const {
1220  return &(ili.lane->getEdge()) == myEdge;
1221  }
1222  private:
1223  edge_finder& operator=(const edge_finder&); // just to avoid a compiler warning
1224  private:
1225  const MSEdge* const myEdge;
1226  };
1227 
1228 private:
1230  MSLane(const MSLane&);
1231 
1233  MSLane& operator=(const MSLane&);
1234 
1235 
1236 };
1237 
1238 
1239 #endif
1240 
1241 /****************************************************************************/
1242 
int getRightmostSublane() const
Definition: MSLane.h:901
int getNumericalID() const
Returns this lane's numerical id.
Definition: MSLane.h:419
const std::map< SUMOVehicleClass, SUMOReal > * myRestrictions
The vClass speed restrictions for this lane.
Definition: MSLane.h:1090
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
Definition: MSLane.cpp:2256
SVCPermissions myPermissions
The vClass permissions for this lane.
Definition: MSLane.h:1084
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
Definition: MSLane.h:1048
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:127
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:571
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible) ...
Definition: MSLane.h:369
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:82
bool isLinkEnd(MSLinkCont::const_iterator &i) const
Definition: MSLane.cpp:1394
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1433
long long int SUMOTime
Definition: SUMOTime.h:43
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition: MSLane.cpp:1461
void resetPermissions(long transientID)
Definition: MSLane.cpp:2615
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
Definition: MSLane.h:353
SUMOReal getWaitingSeconds() const
Returns the overall waiting time on this lane.
Definition: MSLane.cpp:2071
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
Definition: MSLane.cpp:1318
const MSEdge * getInternalFollower() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
Definition: MSLane.cpp:1275
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
Definition: MSLane.cpp:1447
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition: MSLane.h:407
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:2207
static bool teleportOnCollision()
Definition: MSLane.h:973
static const long CHANGE_PERMISSIONS_GUI
Definition: MSLane.h:978
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
int myI2
index for myPartialVehicles
Definition: MSLane.h:145
std::pair< MSVehicle *const, SUMOReal > getOppositeFollower(const MSVehicle *ego) const
Definition: MSLane.cpp:2561
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
Definition: MSLane.cpp:2500
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:1326
SUMOReal getLength() const
Returns the lane's length.
Definition: MSLane.h:480
std::vector< IncomingLaneInfo > myIncomingLanes
Definition: MSLane.h:1092
int SVCPermissions
int myI2End
end index for myPartialVehicles
Definition: MSLane.h:149
void setLength(SUMOReal val)
Sets a new length for the lane (used by TraCI only)
Definition: MSLane.cpp:1525
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:190
int myIndex
The lane index.
Definition: MSLane.h:1035
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
Definition: MSLane.cpp:1362
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
Definition: MSLane.h:1116
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1424
Notification
Definition of a vehicle state.
SUMOReal getFuelConsumption() const
Returns the sum of last step fuel consumption.
Definition: MSLane.cpp:2160
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition: MSLane.cpp:1543
bool operator==(AnyVehicleIterator const &other) const
Definition: MSLane.h:118
const MSEdge *const myEdge
Definition: MSLane.h:1209
SUMOReal getWidth() const
Returns the lane's width.
Definition: MSLane.h:496
SUMOReal getMaximumBrakeDist() const
compute maximum braking distance on this lane
Definition: MSLane.cpp:1631
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1567
SUMOReal getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
Definition: MSLane.cpp:2056
by_connections_to_sorter(const MSEdge *const e)
constructor
Definition: MSLane.cpp:2222
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:2585
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:203
SUMOReal getCenterOnEdge() const
Definition: MSLane.h:905
void leftByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2016
void getLeadersOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal 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:2385
SUMOReal getElectricityConsumption() const
Returns the sum of last step electricity consumption.
Definition: MSLane.cpp:2172
std::map< long, SVCPermissions > myPermissionChanges
Definition: MSLane.h:1132
virtual SUMOReal getMaxSpeed() const =0
Returns the vehicle's maximum speed.
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
Definition: MSLane.cpp:196
bool isInternal() const
Definition: MSLane.cpp:1410
bool operator()(const IncomingLaneInfo &ili) const
Definition: MSLane.h:1219
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Definition: MSLane.cpp:2229
std::pair< MSVehicle *const, SUMOReal > getCriticalLeader(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
Definition: MSLane.cpp:1885
const SUMOReal myWidth
Lane width [m].
Definition: MSLane.h:1075
by_connections_to_sorter & operator=(const by_connections_to_sorter &)
bool freeInsertion(MSVehicle &veh, SUMOReal speed, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
Definition: MSLane.cpp:284
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
Definition: MSLane.h:1060
static bool myCheckJunctionCollisions
Definition: MSLane.h:1146
const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset=0) const
Definition: MSLane.h:444
SUMOReal myMaxSpeed
Lane-wide speedlimit [m/s].
Definition: MSLane.h:1081
SUMOReal getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
Definition: MSLane.h:839
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:1032
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, bool allSublanes) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
Definition: MSLane.cpp:2268
bool myDownstream
iteration direction
Definition: MSLane.h:151
SUMOReal getHCEmissions() const
Returns the sum of last step HC emissions.
Definition: MSLane.cpp:2148
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition: MSLane.h:380
Performs lane changing of vehicles.
std::vector< std::string > myNeighs
Definition: MSLane.h:1129
void setMaxSpeed(SUMOReal val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
Definition: MSLane.cpp:1518
static CollisionAction myCollisionAction
the action to take on collisions
Definition: MSLane.h:1145
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
Definition: MSLane.h:1135
bool lastInsertion(MSVehicle &veh, SUMOReal mspeed)
Definition: MSLane.cpp:265
virtual void incorporateVehicle(MSVehicle *veh, SUMOReal pos, SUMOReal speed, SUMOReal 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:245
MSLinkCont myLinks
Definition: MSLane.h:1104
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
Definition: MSLane.cpp:979
static DictType myDict
Static dictionary to associate string-ids with objects.
Definition: MSLane.h:1138
virtual SUMOReal getChosenSpeedFactor() const =0
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:1577
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:55
A road/street connecting two junctions.
Definition: MSEdge.h:80
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Definition: MSLane.cpp:2212
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
Definition: MSLane.cpp:399
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle's access class.
SUMOReal myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
Definition: MSLane.h:1124
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
Definition: MSLane.cpp:1954
#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:1064
Allows to store the object; used as context while traveling the rtree in TraCI.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: MSLane.h:695
std::pair< MSVehicle *const, SUMOReal > getLeaderOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts) const
Returns the immediate leader and the distance to him.
Definition: MSLane.cpp:1793
const MSVehicle * operator*()
Definition: MSLane.cpp:112
static int dictSize()
Returns the number of stored lanes.
Definition: MSLane.h:614
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:225
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
Definition: MSLane.cpp:1994
SUMOReal getMissingRearGap(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel) const
return by how much further the leader must be inserted to avoid rear end collisions ...
Definition: MSLane.cpp:1615
SUMOReal basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
Definition: MSLane.cpp:483
const MSEdge *const myEdge
Definition: MSLane.h:1225
Representation of a vehicle.
Definition: SUMOVehicle.h:66
void add(const MSLane *const l) const
Adds the given object to the container.
friend class AnyVehicleIterator
Definition: MSLane.h:88
SUMOReal getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Definition: MSLane.cpp:372
Sorts vehicles by their position (descending)
Definition: MSLane.h:1152
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
Definition: MSLane.h:1087
A list of positions.
void enteredByLaneChange(MSVehicle *v)
Definition: MSLane.cpp:2023
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:1561
SUMOReal getMeanSpeed() const
Returns the mean speed on this lane.
Definition: MSLane.cpp:2084
const MSLeaderInfo & getLastVehicleInformation(const MSVehicle *ego, SUMOReal latOffset, SUMOReal minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
Definition: MSLane.cpp:834
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
Definition: MSLane.h:361
edge_finder & operator=(const edge_finder &)
T MIN2(T a, T b)
Definition: StdDefs.h:69
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition: MSLane.h:472
CollisionAction
Definition: MSLane.h:162
MSLane(const std::string &id, SUMOReal maxSpeed, SUMOReal length, MSEdge *const edge, int numericalID, const PositionVector &shape, SUMOReal width, SVCPermissions permissions, int index)
Constructor.
Definition: MSLane.cpp:160
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
Definition: MSLane.h:1126
MSLane * myLogicalPredecessorLane
Definition: MSLane.h:1093
Something on a lane to be noticed about vehicle movement.
SUMOReal myLength
Lane length [m].
Definition: MSLane.h:1072
bool empty() const
Returns true if there is not a single vehicle on the lane.
Definition: MSLane.h:553
bool operator!=(AnyVehicleIterator const &other) const
Definition: MSLane.h:125
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
Definition: MSLane.h:488
virtual SUMOReal setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
Definition: MSLane.cpp:212
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
Definition: MSLane.cpp:1532
SUMOReal getLengthGeometryFactor() const
return shape.length() / myLength
Definition: MSLane.h:432
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:503
An upper class for objects with additional parameters.
Definition: Parameterised.h:47
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSVehicle *victim, SUMOReal gap, SUMOReal latGap, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle * > &toTeleport) const
take action upon collision
Definition: MSLane.cpp:1132
void setRightSideOnEdge(SUMOReal value, int rightmostSublane)
Definition: MSLane.h:892
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
Definition: MSLane.h:1106
std::vector< MSVehicle * > VehCont
Container for vehicles.
Definition: MSLane.h:91
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:1029
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
Definition: MSLane.h:1142
SUMOReal safeInsertionSpeed(const MSVehicle *veh, const MSLeaderInfo &leaders, SUMOReal speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
Definition: MSLane.cpp:815
const SUMOReal myLengthGeometryFactor
precomputed myShape.length / myLength
Definition: MSLane.h:1121
AnyVehicleIterator & operator++()
Definition: MSLane.cpp:97
void forceVehicleInsertion(MSVehicle *veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat=0)
Inserts the given vehicle at the given position.
Definition: MSLane.cpp:806
void sortPartialVehicles()
sorts myPartialVehicles
Definition: MSLane.cpp:1387
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:2603
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
Definition: MSLane.cpp:2005
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1286
SUMOReal getNOxEmissions() const
Returns the sum of last step NOx emissions.
Definition: MSLane.cpp:2136
SUMOReal getPMxEmissions() const
Returns the sum of last step PMx emissions.
Definition: MSLane.cpp:2124
The vehicle has departed (was inserted into the network)
int myI1
index for myVehicles
Definition: MSLane.h:143
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const 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:1086
bool operator()(const MSVehicle *cmp, SUMOReal pos) const
compares vehicle position to the detector position
Definition: MSLane.cpp:2201
std::pair< MSVehicle *const, SUMOReal > getOppositeLeader(const MSVehicle *ego, SUMOReal dist) const
Definition: MSLane.cpp:2540
SUMOReal myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
Definition: MSLane.h:1097
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1309
bool isEmpty() const
Definition: MSLane.cpp:1405
SUMOReal interpolateLanePosToGeometryPos(SUMOReal lanePos) const
Definition: MSLane.h:438
SUMOReal getCO2Emissions() const
Returns the sum of last step CO2 emissions.
Definition: MSLane.cpp:2100
MSEdge *const myEdge
The lane's edge, for routing only.
Definition: MSLane.h:1078
const MSVehicle * operator->()
Definition: MSLane.h:129
SUMOReal getCOEmissions() const
Returns the sum of last step CO emissions.
Definition: MSLane.cpp:2112
const MSLane * myLane
the lane that is being iterated
Definition: MSLane.h:141
bool checkFailure(MSVehicle *aVehicle, SUMOReal &speed, SUMOReal &dist, const SUMOReal nspeed, const bool patchSpeed, const std::string errorMsg) const
Definition: MSLane.cpp:488
MSVehicle * getPartialBehind(const MSVehicle *ego) const
Definition: MSLane.cpp:2476
A storage for options typed value containers)
Definition: OptionsCont.h:99
bool isApproachedFrom(MSEdge *const edge)
Definition: MSLane.cpp:1591
const MSLeaderInfo & getFirstVehicleInformation(const MSVehicle *ego, SUMOReal latOffset, bool onlyFrontOnLane, SUMOReal maxPos=std::numeric_limits< SUMOReal >::max(), bool allowCached=true) const
analogue to getLastVehicleInformation but in the upstream direction
Definition: MSLane.cpp:885
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:391
MSLane & operator=(const MSLane &)
invalidated assignment operator
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
Definition: MSLane.cpp:2245
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
Definition: MSLane.h:1109
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:427
SUMOReal getOppositePos(SUMOReal pos) const
return the corresponding position on the opposite lane
Definition: MSLane.cpp:2509
void visit(const TraCIServerAPI_Lane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition: MSLane.h:966
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool nextIsMyVehicles() const
Definition: MSLane.cpp:126
#define SUMOReal
Definition: config.h:214
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
Definition: MSLane.h:1111
virtual ~MSLane()
Destructor.
Definition: MSLane.cpp:182
SUMOReal myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
Definition: MSLane.h:1100
bool isInsertionSuccess(MSVehicle *vehicle, SUMOReal speed, SUMOReal pos, SUMOReal posLat, bool recheckNextLanes, MSMoveReminder::Notification notification)
Tries to insert the given vehicle with the given state (speed and pos)
Definition: MSLane.cpp:506
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1512
The class responsible for building and deletion of vehicles.
std::pair< MSVehicle *const, SUMOReal > getFollower(const MSVehicle *ego, SUMOReal egoPos, SUMOReal dist) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane) ...
Definition: MSLane.cpp:2521
MSLeaderInfo myLeaderInfoTmp
Definition: MSLane.h:1113
VehCont myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
Definition: MSLane.h:1068
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: MSLane.h:458
SUMOReal getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
Definition: MSLane.cpp:2184
static const long CHANGE_PERMISSIONS_PERMANENT
Definition: MSLane.h:977
AnyVehicleIterator(const MSLane *lane, int i1, int i2, const int i1End, const int i2End, bool downstream=true)
Definition: MSLane.h:102
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:708
SUMOReal interpolateGeometryPosToLanePos(SUMOReal geometryPos) const
Definition: MSLane.h:450
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
Definition: MSLane.cpp:2041
virtual bool executeMovements(SUMOTime t, std::vector< MSLane * > &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSLane.cpp:1187
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
Definition: MSLane.h:1118
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
Definition: MSLane.cpp:1415
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
Definition: MSLane.h:228
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
Definition: MSLane.h:386
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:401
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
Definition: MSLane.cpp:2030
std::pair< MSVehicle *const, SUMOReal > getFollowerOnConsecutive(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel, SUMOReal dist=-1) const
return the follower with the largest missing rear gap among all predecessor lanes (within dist) ...
Definition: MSLane.cpp:1640
std::pair< MSVehicle *const, SUMOReal > getLeader(const MSVehicle *veh, const SUMOReal vehPos, const std::vector< MSLane * > &bestLaneConts, SUMOReal dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
Definition: MSLane.cpp:1735
edge_finder(MSEdge *e)
Definition: MSLane.h:1218
virtual bool appropriate(const MSVehicle *veh)
Definition: MSLane.cpp:1344
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:937
SUMOReal getRightSideOnEdge() const
Definition: MSLane.h:897
vehicle_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1155
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
Definition: MSLane.h:396
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
Definition: MSLane.h:1178