54#define BEST_LANE_LOOKAHEAD 3000.0
71 const std::string& streetName,
72 const std::string& edgeType,
73 const std::string& routingType,
76 Named(id), myNumericalID(numericalID), myLanes(nullptr),
77 myLaneChanger(nullptr), myFunction(function), myVaporizationRequests(0),
78 myLastFailedInsertionTime(-1),
79 myFromJunction(nullptr), myToJunction(nullptr),
80 myHaveTransientPermissions(false),
81 myOtherTazConnector(nullptr),
82 myStreetName(streetName),
84 myRoutingType(routingType),
89 myEmptyTraveltime(0.),
92 myAmRoundabout(false),
108 myLanes = std::shared_ptr<const std::vector<MSLane*> >(lanes);
112 for (
MSLane*
const lane : *lanes) {
137 if (haveTLSPenalty || minorPenalty > 0) {
141 for (
const MSLink*
const link : l->getLinkCont()) {
142 if (link->getLane()->isWalkingArea() && link->getLaneBefore()->isNormal()) {
145 SUMOTime linkPenalty = link->isTLSControlled() ? link->getMesoTLSPenalty() : (link->havePriority() ? 0 : minorPenalty);
146 if (minPenalty == -1) {
147 minPenalty = linkPenalty;
149 minPenalty =
MIN2(minPenalty, linkPenalty);
153 if (minPenalty > 0) {
160 for (
const auto& ili :
myLanes->front()->getIncomingLanes()) {
161 double penalty =
STEPS2TIME(ili.viaLink->getMesoTLSPenalty());
162 if (!ili.viaLink->haveOffPriority()) {
171 const MSLink* link =
myLanes->front()->getIncomingLanes()[0].viaLink;
190 if (!edge->isInternal()) {
194 auto it = std::find(succ.begin(), succ.end(),
this);
195 auto it2 = std::find(succVia.begin(), succVia.end(), std::make_pair(
const_cast<const MSEdge*
>(
this), (
const MSEdge*)
nullptr));
196 auto it3 = std::find(pred.begin(), pred.end(),
this);
197 if (it != succ.end()) {
201 if (it3 != pred.end()) {
211 for (
MSLink*
const link : lane->getLinkCont()) {
212 link->initParallelLinks();
213 MSLane*
const toL = link->getLane();
214 MSLane*
const viaL = link->getViaLane();
215 if (toL !=
nullptr) {
228 if (viaL !=
nullptr) {
235 lane->checkBufferType();
242 if (
myLanes->back()->getOpposite() !=
nullptr) {
285 const MSLink*
const link = lane->getLogicalPredecessorLane()->getLinkTo(lane);
286 assert(link !=
nullptr);
305 for (
auto& allowed : laneCont) {
307 allowed.first |= permissions;
311 laneCont.push_back(std::make_pair(permissions,
allowedLanes));
319 return (p | ignored) == ignored ? 0 : p;
335 bool lanesChangedPermission =
false;
343 lanesChangedPermission |= lane->hadPermissionChanges();
352 if (!onInit && (lanesChangedPermission
366 std::shared_ptr<std::vector<MSLane*> >
allowedLanes = std::make_shared<std::vector<MSLane*> >();
383 pred->myOrigAllowed = pred->myAllowed;
384 pred->myOrigAllowedTargets = pred->myAllowedTargets;
385 pred->myOrigClassesViaSuccessorMap = pred->myClassesViaSuccessorMap;
386 pred->myHaveTransientPermissions =
true;
388 pred->rebuildAllowedTargets(updateVehicles);
392 s->updatePermissions();
396 for (
MSLink* link : lane->getLinkCont()) {
397 link->updatePermissions();
399 for (
auto ili : lane->getIncomingLanes()) {
400 ili.viaLink->updatePermissions();
406 for (
MSLane*
const lane : *pred->myLanes) {
407 for (
MSLink* link : lane->getLinkCont()) {
408 if (&link->getLane()->getEdge() ==
this) {
409 link->updatePermissions();
422 bool universalMap =
true;
423 std::shared_ptr<std::vector<MSLane*> > allLanes = std::make_shared<std::vector<MSLane*> >();
427 for (
const MSLink*
const link : lane->getLinkCont()) {
428 if (&link->getLane()->getEdge() == target) {
429 allLanes->push_back(lane);
430 combinedTargetPermissions |= link->getLane()->getPermissions();
431 if (link->getViaLane() !=
nullptr &&
432 ((lane->getPermissions() & link->getLane()->getPermissions()) != link->getViaLane()->getPermissions())) {
434 universalMap =
false;
438 if (combinedTargetPermissions == 0 || (lane->getPermissions() & combinedTargetPermissions) != lane->getPermissions()) {
439 universalMap =
false;
456 std::shared_ptr<std::vector<MSLane*> >
allowedLanes = std::make_shared<std::vector<MSLane*> >();
459 for (
const MSLink*
const link : lane->getLinkCont()) {
460 if (link->getLane()->allowsVehicleClass((
SUMOVehicleClass)vclass) && &link->getLane()->getEdge() == target && (link->getViaLane() ==
nullptr || link->getViaLane()->allowsVehicleClass((
SUMOVehicleClass)vclass))) {
471 if (updateVehicles) {
475 veh->updateBestLanes(
true);
477 lane->releaseVehicles();
500 const int resultIndex = lane->
getIndex() + offset;
501 if (resultIndex >=
getNumLanes() && includeOpposite) {
507 }
else if (resultIndex >= (
int)
myLanes->size() || resultIndex < 0) {
510 return (*
myLanes)[resultIndex];
515const std::vector<MSLane*>*
518 AllowedLanesByTarget::const_iterator i = targets.find(&destination);
519 if (i != targets.end()) {
520 for (
const auto& allowed : i->second) {
521 if ((allowed.first & vclass) == vclass) {
522 return allowed.second.get();
530const std::vector<MSLane*>*
537 if ((allowed.first & vclass) == vclass) {
538 return allowed.second.get();
547const std::vector<MSLane*>*
550 if ((minP & vclass) == vclass) {
554 if ((comP & vclass) == vclass) {
556 for (
const auto& allowed : allowedCont) {
557 if ((allowed.first & vclass) == vclass) {
558 return allowed.second.get();
584 if (allowed ==
nullptr) {
588 if (allowed !=
nullptr) {
589 double largestGap = 0;
590 MSLane* resByGap =
nullptr;
591 double leastOccupancy = std::numeric_limits<double>::max();
592 for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
593 const double occupancy = (*i)->getBruttoOccupancy();
594 if (occupancy < leastOccupancy) {
596 leastOccupancy = occupancy;
598 const MSVehicle* last = (*i)->getLastFullVehicle();
600 if (lastGap > largestGap) {
601 largestGap = lastGap;
605 if (resByGap !=
nullptr) {
616 if (allowed ==
nullptr) {
620 if (allowed !=
nullptr) {
621 double largestGap = 0;
622 double largestSpeed = 0;
623 MSLane* resByGap =
nullptr;
624 double leastOccupancy = std::numeric_limits<double>::max();
626 for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i, aIndex++) {
627 const double occupancy = (*i)->getBruttoOccupancy();
628 if (occupancy < leastOccupancy) {
630 leastOccupancy = occupancy;
632 const MSVehicle* last = (*i)->getLastFullVehicle();
635 if (lastGap > largestGap && maxSpeed >= largestSpeed) {
636 largestGap = lastGap;
639 if (last !=
nullptr) {
643 if (resByGap !=
nullptr) {
676 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
677 MSVehicle* last = (*i)->getLastFullVehicle();
678 if (last !=
nullptr) {
739 const std::vector<MSVehicle::LaneQ>& bl = veh.
getBestLanes();
740 double bestLength = -1;
741 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
742 if ((*i).length > bestLength) {
743 bestLength = (*i).length;
749 double departPos = 0;
754 std::vector<MSLane*>* bestLanes =
new std::vector<MSLane*>();
755 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
756 if (((*i).length - departPos) >= bestLength) {
759 if (lane->getNormalSuccessorLane() == (*i).lane && lane->allowsVehicleClass(veh.
getVClass())) {
760 bestLanes->push_back(lane);
763 }
else if ((*i).lane->allowsVehicleClass(veh.
getVClass())) {
764 bestLanes->push_back((*i).lane);
792 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
793 if ((*i)->allowsVehicleClass(vClass, routingMode)) {
811 if (departLane !=
nullptr) {
815 vMax *= (1 + SPEED_EPS);
824 WRITE_WARNINGF(
TL(
"Choosing new speed factor % for vehicle '%' to match departure speed % (max %)."),
848 throw ProcessError(
TLF(
"Departure speed for vehicle '%' is too high for the departure edge '%', time=%.",
851 WRITE_WARNINGF(
TL(
"Departure speed for vehicle '%' is too high for the departure edge '%', time=%."),
868 WRITE_WARNINGF(
TL(
"Invalid departPos % given for vehicle '%', time=%. Inserting at lane end instead."),
885 while (segment !=
nullptr && !result) {
887 result = segment->
hasSpaceFor(veh, time, qIdx,
true) == time;
895 result = segment->
hasSpaceFor(veh, time, qIdx,
true) == time;
912 if (insertionLane ==
nullptr) {
913 WRITE_WARNINGF(
TL(
"Could not insert vehicle '%' on any lane of edge '%', time=%."),
922 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
923 const double occupancy = (*i)->getBruttoOccupancy();
933 if (insertionLane ==
nullptr) {
973 for (
const MSLink*
const link : l->getLinkCont()) {
974 if (&link->getLane()->getEdge() == followerAfterInternal) {
975 if (link->getViaLane() !=
nullptr) {
976 if (link->getViaLane()->allowsVehicleClass(vClass)) {
977 return &link->getViaLane()->getEdge();
993 assert(followerAfterInternal != 0);
998 while (edge !=
nullptr && edge->
isInternal()) {
1008 const MSEdge* result =
this;
1018 const MSEdge* result =
this;
1029 double totalNumVehs = 0;
1032 const int numVehs = segment->getCarNumber();
1035 totalNumVehs += numVehs;
1038 if (totalNumVehs == 0) {
1043 int numVehs = lane->getVehicleNumber();
1048 v += numVehs * lane->getMeanSpeed();
1049 totalNumVehs += numVehs;
1053 if (lane->getVehicleNumber() > 0) {
1059 if (totalNumVehs == 0) {
1063 return v / totalNumVehs;
1071 f += lane->getFrictionCoefficient();
1074 return f / (double)
myLanes->size();
1087 double totalNumVehs = 0;
1089 const int numVehs = lane->getVehicleNumber();
1090 v += numVehs * lane->getMeanSpeedBike();
1091 totalNumVehs += numVehs;
1093 if (totalNumVehs == 0) {
1096 return v / totalNumVehs;
1102 assert(minSpeed > 0);
1118 const DictType::iterator it =
myDict.lower_bound(
id);
1119 if (it ==
myDict.end() || it->first !=
id) {
1121 const auto it2 =
myDict.emplace_hint(it,
id, ptr);
1149 if (startIdx + 1 < (
int)
myEdges.size() &&
myEdges[startIdx + 1] !=
nullptr &&
myEdges[startIdx + 1]->getID() ==
id) {
1166 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1176 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1177 into.push_back((*i).first);
1184 const std::string& rid) {
1188 throw ProcessError(
"The edge '" + std::string(e.what()) +
"' within the route " + rid +
" is not known."
1189 +
"\n The route can not be build.");
1196 const std::string& rid) {
1197 for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
1200 if (edge ==
nullptr) {
1201 throw ProcessError(
"The edge '" + *i +
"' within the route " + rid +
" is not known."
1202 +
"\n The route can not be build.");
1204 into.push_back(edge);
1211 assert(
this != other);
1212 if (doBoundaryEstimate) {
1224 return getLanes()[0]->getShape()[-1].distanceTo2D(other->
getLanes()[0]->getShape()[0]);
1250 return myLanes->empty() ? 1 :
getLanes()[0]->getLengthGeometryFactor();
1265 lane->setMaxSpeed(val, modified, jamThreshold);
1283 auto it = tc.find(t);
1284 if (it != tc.end()) {
1289std::vector<MSTransportable*>
1292 if (includeRiding) {
1293 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
1295 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
1296 const std::vector<MSTransportable*>& persons = (*j)->getPersons();
1297 result.insert(result.end(), persons.begin(), persons.end());
1299 (*i)->releaseVehicles();
1307std::vector<MSTransportable*>
1356 if ((*it)->isTazConnector()) {
1357 i->second.push_back(*it);
1359 const std::vector<MSLane*>* allowed =
allowedLanes(**it, vClass);
1360 if (allowed !=
nullptr && allowed->size() > 0) {
1361 i->second.push_back(*it);
1380 auto i = viaMap.find(vClass);
1381 if (i == viaMap.end()) {
1386 if (viaPair.first->isTazConnector()) {
1387 result.push_back(viaPair);
1389 const std::vector<MSLane*>* allowed =
allowedLanes(*viaPair.first, vClass, ignoreTransientPermissions);
1390 if (allowed !=
nullptr && allowed->size() > 0) {
1391 result.push_back(viaPair);
1395 i = viaMap.find(vClass);
1414 return (!
myLanes->empty() &&
myLanes->back()->getOpposite() !=
nullptr &&
1424 if (!
myLanes->empty() &&
myLanes->back()->getOpposite() !=
nullptr) {
1425 return &(
myLanes->back()->getOpposite()->getEdge());
1435 for (
const MSLink*
const link : l->getLinkCont()) {
1436 if (!link->havePriority()) {
1450 if (l->getIndex() <= index && !l->allowsChangingRight(svc) && l->getIndex() > 0) {
1452 }
else if (l->getIndex() >= index && !l->allowsChangingLeft(svc) && l->getIndex() < (int)(
myLanes->size() - 1)) {
1474 for (ConstMSEdgeVector::const_iterator it = candidates.begin(); it != candidates.end(); it++) {
1497 int numBidiLanes = 0;
1500 if (l1->getShape().reverse().almostSame(l2->getShape(), POSITION_EPS * 2)) {
1501 l1->setBidiLane(l2);
1516 if (other ==
nullptr || other->
getLanes().size() !=
myLanes->size()) {
1519 std::vector<MSLane*>::const_iterator it1 =
myLanes->begin();
1520 std::vector<MSLane*>::const_reverse_iterator it2 = other->
getLanes().rbegin();
1522 if ((*it1)->getShape().reverse() != (*it2)->getShape()) {
1527 }
while (it1 !=
myLanes->end());
1547 std::vector<SUMOVehicle*>::iterator it = std::find(
myWaiting.begin(),
myWaiting.end(), vehicle);
1562 (!vehicle->hasDeparted() &&
1567 if (!vehicle->isLineStop(position) && vehicle->allowsBoarding(transportable)) {
1569 + transportable->
getID() +
"' at edge '" +
getID() +
"' position " +
toString(position) +
" cannot use waiting vehicle '"
1570 + vehicle->getID() +
"' at position " +
toString(vehicle->getPositionOnLane()) +
" because it is too far away.");
1577std::vector<const SUMOVehicle*>
1579 std::vector<const SUMOVehicle*> result;
1582 std::vector<const MEVehicle*> segmentVehs = segment->getVehicles();
1583 result.insert(result.end(), segmentVehs.begin(), segmentVehs.end());
1587 for (
auto veh : lane->getVehiclesSecure()) {
1588 result.push_back(veh);
1590 lane->releaseVehicles();
1607 if ((l->getPermissions() & filter) != 0) {
1625 if (segment->getCarNumber() > 0) {
1631 if (lane->getVehicleNumber() > 0) {
1645 wtime += segment->getWaitingSeconds();
1649 wtime += lane->getWaitingSeconds();
1671 sum += lane->getNettoOccupancy();
1673 return sum / (double)
myLanes->size();
1685 flow += (double) segment->getCarNumber() * segment->getMeanSpeed();
1687 return 3600 * flow / (*myLanes)[0]->getLength();
1698 occ += segment->getBruttoOccupancy();
1700 return occ / (*myLanes)[0]->getLength() / (double)(
myLanes->size());
1715 if (typeBefore !=
"") {
1717 if (typeBefore == typeAfter) {
1719 }
else if (typeAfter !=
"") {
1723 if (resBefore !=
nullptr && resAfter !=
nullptr) {
1727 for (
const auto& item : *resBefore) {
1729 const double speed = item.second;
1730 const auto it = (*resAfter).find(svc);
1731 if (it != (*resAfter).end()) {
1732 const double speed2 = it->second;
1734 ?
MAX2(speed, speed2) : (speed + speed2) / 2);
1759std::pair<double, SUMOTime>
1764 return std::make_pair(-1, -1);
1782const std::map<const MEVehicle*, std::pair<double, int> >&
1791 for (std::vector<MSLane*>::const_iterator msl =
myLanes->begin(); msl !=
myLanes->end(); ++msl, ++laneIndex) {
1793 double segmentOffset = 0;
1795 segment !=
nullptr; segment = segment->getNextSegment()) {
1796 const double segLength = segment->getLength();
1797 const double lanesCovered = segment->numQueues() == 1 ? std::round(segment->getCapacity() / segLength) : 1.;
1798 if (laneIndex < segment->numQueues()) {
1800 std::vector<MEVehicle*> queue = segment->getQueue(laneIndex);
1801 const int queueSize = (int)queue.size();
1802 SUMOTime earliestExitTime = segment->getQueueBlockTime(laneIndex);
1804 double prevPos = std::numeric_limits<double>::max();
1805 for (
int i = 0; i < queueSize; ++i) {
1806 const MEVehicle*
const veh = queue[queueSize - i - 1];
1809 double maxPos = segmentOffset + segLength;
1810 auto it = old.find(veh);
1811 const double oldPos = it != old.end() ? it->second.first : 0.;
1814 maxPos =
MIN2(maxPos, prevPos - vehLength / lanesCovered);
1817 assert(
STEPS2TIME(earliestExitTime) > entry);
1818 const double pos =
MAX2(
MIN2(segmentOffset + segLength * (now - entry) / (
STEPS2TIME(earliestExitTime) - entry), maxPos), oldPos);
1820 if (overlap == 0 && prevPos - pos < vehLength) {
1821 overlap = lanesCovered > 1. ? -3 : -1;
1829 segmentOffset += segLength;
1839 double result = std::numeric_limits<double>::max();
1841 result =
MIN2(result, l->getLength());
#define BEST_LANE_LOOKAHEAD
std::vector< const MSEdge * > ConstMSEdgeVector
std::vector< std::pair< const MSEdge *, const MSEdge * > > MSConstEdgePairVector
std::vector< MSEdge * > MSEdgeVector
#define WRITE_WARNINGF(...)
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const SVCPermissions SVCAll
all VClasses are allowed
const SUMOVehicleClass SUMOVehicleClass_MAX
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.
@ SVC_PRIVATE
private vehicles
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PEDESTRIAN
pedestrian
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ RANDOM
The lane is chosen randomly.
@ BEST_FREE
The least occupied lane from best lanes.
@ GIVEN
The lane is given.
@ ALLOWED_FREE
The least occupied lane from lanes which allow the continuation.
@ DEFAULT
No information given; use default.
@ FIRST_ALLOWED
The rightmost lane the vehicle may use.
@ FREE
The least occupied lane is used.
@ BEST_PROB
The lane most likely according the speedFactor (from best lanes)
@ RANDOM
A random position is chosen.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ FREE
A free position is chosen.
@ BASE
Back-at-zero position.
@ LAST
Insert behind the last vehicle as close as possible to still allow the specified departSpeed....
@ RANDOM_FREE
If a fixed number of random choices fails, a free position is chosen.
@ GIVEN
The speed is given.
const long long int VEHPARS_SPEEDFACTOR_SET
@ SPLIT
The departure is triggered by a train split.
@ CONTAINER_TRIGGERED
The departure is container triggered.
@ TRIGGERED
The departure is person triggered.
@ TURN
The link is a 180 degree turn.
@ STRAIGHT
The link is a straight direction.
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
@ LINKSTATE_STOP
This is an uncontrolled, minor link, has to stop.
@ LINKSTATE_EQUAL
This is an uncontrolled, right-before-left link.
@ LINKSTATE_DEADEND
This is a dead end link.
@ LINKSTATE_MINOR
This is an uncontrolled, minor link, has to brake.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
double getParameter(const int index) const
Returns the nth parameter of this distribution.
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
A single mesoscopic segment (cell)
bool initialise(MEVehicle *veh, SUMOTime time)
Inserts (emits) vehicle into the segment.
SUMOTime hasSpaceFor(const MEVehicle *const veh, const SUMOTime entryTime, int &qIdx, const bool init=false) const
Returns whether the given vehicle would still fit into the segment.
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
A vehicle from the mesoscopic point of view.
double getLastEntryTimeSeconds() const
Returns the entry time for the current segment.
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves its current segment.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getLength() const
Returns the vehicle's length.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
const MSRoute & getRoute() const
Returns the current route.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
Sorts edges by their ids.
Sorts transportables by their positions.
int operator()(const MSTransportable *const c1, const MSTransportable *const c2) const
comparing operator
A road/street connecting two junctions.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
SUMOVehicle * getWaitingVehicle(MSTransportable *transportable, const double position) const
void addToAllowed(const SVCPermissions permissions, std::shared_ptr< const std::vector< MSLane * > > allowedLanes, AllowedLanesCont &laneCont) const
void changeLanes(SUMOTime t) const
Performs lane changing on this edge.
double getBruttoOccupancy() const
SVCPermissions myCombinedPermissions
The union of lane permissions for this edge.
double getFlow() const
return flow based on meanSpeed
Boundary myBoundary
The bounding rectangle of end nodes incoming or outgoing edges for taz connectors or of my own start ...
double myWidth
Edge width [m].
AllowedLanesByTarget myAllowedTargets
From target edge to lanes allowed to be used to reach it.
bool isCrossing() const
return whether this edge is a pedestrian crossing
MSLane * getDepartLane(MSVehicle &veh) const
Finds a depart lane for the given vehicle parameters.
SUMOTime myLastFailedInsertionTime
The time of last insertion failure.
std::set< MSTransportable *, ComparatorNumericalIdLess > myContainers
Containers on the edge.
SUMOTime myLastCacheUpdate
time stamp of mesoscopic vehicle positions
void setMaxSpeed(const double val, const bool modified=true, const double jamThreshold=-1)
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
std::pair< double, SUMOTime > getLastBlocked(int index) const
retrieve properties of a blocked vehicle that wants to chane to the lane with the given index
static void clear()
Clears the dictionary.
void setJunctions(MSJunction *from, MSJunction *to)
double getMeanSpeedBike() const
get the mean speed of all bicycles on this edge
static MSEdgeVector myEdges
Static list of edges.
AllowedLanesCont myAllowed
Associative container from vehicle class to allowed-lanes.
double myEmptyTraveltime
the traveltime on the empty edge (cached value for speedup)
bool myAmFringe
whether this edge is at the network fringe
static double getTravelTimeAggregated(const MSEdge *const edge, const SUMOVehicle *const veh, double time)
MSJunction * myToJunction
void checkAndRegisterBiDirEdge(const std::string &bidiID="")
check and register the opposite superposable edge if any
virtual ~MSEdge()
Destructor.
double getDepartPosBound(const MSVehicle &veh, bool upper=true) const
return upper bound for the depart position on this edge
const double myDistance
the kilometrage/mileage at the start of the edge
void clearState()
Remove all transportables before quick-loading state.
MSLane * getDepartLaneMeso(SUMOVehicle &veh) const
consider given departLane parameter (only for validating speeds)
bool hasTransientPermissions() const
const MSEdge * myBidiEdge
the oppositing superposable edge
MSLane * leftLane(const MSLane *const lane) const
Returns the lane left to the one given, 0 if the given lane is leftmost.
std::string myEdgeType
the type of the edge (optionally used during network creation)
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
int getNumDrivingLanes() const
return the number of lanes that permit non-weak modes if the edge allows non weak modes and the numbe...
const MSEdge * getOppositeEdge() const
Returns the opposite direction edge if on exists else a nullptr.
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
double getLengthGeometryFactor() const
return shape.length() / myLength
void addSuccessor(MSEdge *edge, const MSEdge *via=nullptr)
Adds an edge to the list of edges which may be reached from this edge and to the incoming of the othe...
friend class MSLaneChangerSublane
std::vector< SUMOVehicle * > myWaiting
List of waiting vehicles.
const MSEdge * getNormalSuccessor() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Get the allowed lanes to reach the destination-edge.
double getInternalFollowingLengthTo(const MSEdge *followerAfterInternal, SUMOVehicleClass vClass) const
returns the length of all internal edges on the junction until reaching the non-internal edge followe...
bool isNormal() const
return whether this edge is an internal edge
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
void postLoadInitLaneChanger()
MSEdge(const std::string &id, int numericalID, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, const std::string &routingType, int priority, double distance)
Constructor.
bool isSuperposable(const MSEdge *other)
bool validateDepartSpeed(SUMOVehicle &v) const
check whether the given departSpeed is valid for this edge
double getDistanceTo(const MSEdge *other, const bool doBoundaryEstimate=false) const
optimistic air distance heuristic for use in routing
static MSEdge * dictionaryHint(const std::string &id, const int startIdx)
Returns the MSEdge associated to the key id giving a hint with a numerical id.
MSLaneChanger * myLaneChanger
This member will do the lane-change.
double getOccupancy() const
return mean occupancy on this edges lanes or segments
static int myDefaultDepartLane
const MSConstEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Returns the following edges with internal vias, restricted by vClass.
std::vector< MSTransportable * > getSortedContainers(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's containers sorted by pos.
const SumoXMLEdgeFunc myFunction
the purpose of the edge
MSLane * getProbableLane(const std::vector< MSLane * > *allowed, const SUMOVehicleClass vclass, double departPos, double maxSpeed) const
Finds the most probable lane allowing the vehicle class.
void recalcCache()
Recalculates the cached values.
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is returned; should pr...
SVCPermissions myOriginalCombinedPermissions
The original union of lane permissions for this edge (before temporary modifications)
bool myAmDelayed
whether this edge had a vehicle with less than max speed on it
SVCPermissions myOriginalMinimumPermissions
The original intersection of lane permissions for this edge (before temporary modifications)
std::map< SUMOVehicleClass, MSEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
MSEdgeVector myPredecessors
The preceeding edges.
bool hasChangeProhibitions(SUMOVehicleClass svc, int index) const
return whether this edge prohibits changing for the given vClass when starting on the given lane inde...
void rebuildAllowedTargets(const bool updateVehicles=true)
static SVCPermissions myMesoIgnoredVClasses
std::vector< std::pair< SVCPermissions, std::shared_ptr< const std::vector< MSLane * > > > > AllowedLanesCont
"Map" from vehicle class to allowed lanes
const MSJunction * getToJunction() const
double getLength() const
return the length of the edge
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
bool myHaveTransientPermissions
whether transient permission changes were applied to this edge or a predecessor
virtual void closeBuilding()
static SVCPermissions getMesoPermissions(SVCPermissions p, SVCPermissions ignoreIgnored=0)
bool canChangeToOpposite() const
whether this edge allows changing to the opposite direction edge
std::set< int > myFailedInsertionMemory
A cache for the rejected insertion attempts. Used to assure that no further insertion attempts are ma...
const MSJunction * getFromJunction() const
double getMeanSpeed() const
get the mean speed
static DictType myDict
Static dictionary to associate string-ids with objects.
std::set< MSTransportable *, ComparatorNumericalIdLess > myPersons
Persons on the edge for drawing and pushbutton.
bool isTazConnector() const
double getDistanceAt(double pos) const
Returns the kilometrage/mileage at the given offset along the edge.
const std::string & getRoutingType() const
Returns the type of the edge.
MSConstEdgePairVector myViaSuccessors
std::map< const MEVehicle *, std::pair< double, int > > myCachedMesoPos
Mesoscopic vehicle positions.
MSEdgeVector mySuccessors
The succeeding edges.
static DepartLaneDefinition myDefaultDepartLaneDefinition
static std::unordered_map< std::string_view, MSEdge * > myHashDict
bool isInternal() const
return whether this edge is an internal edge
MSLane * rightLane(const MSLane *const lane) const
Returns the lane right to the one given, 0 if the given lane is rightmost.
double getMinLength() const
return the minimum length of all lanes (only differs from getLength for curved internal lanes)
double getCurrentTravelTime(const double minSpeed=NUMERICAL_EPS) const
Computes and returns the current travel time for this edge.
std::map< SUMOVehicleClass, MSConstEdgePairVector > myOrigClassesViaSuccessorMap
AllowedLanesByTarget myOrigAllowedTargets
int getNumericalID() const
Returns the numerical id of the edge.
void resetTAZ(MSJunction *junction)
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false, const bool forceCheck=false) const
Tries to insert the given vehicle into the network.
static const Position getStopPosition(const SUMOVehicleParameter::Stop &stop)
return the coordinates of the center of the given stop
void addWaiting(SUMOVehicle *vehicle) const
Adds a vehicle to the list of waiting vehicles.
MSLane * parallelLane(const MSLane *const lane, int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to the given lane one or 0 if it does not exist.
ReversedEdge< MSEdge, SUMOVehicle > * myReversedRoutingEdge
a reversed version for backward routing
const std::string & getEdgeType() const
Returns the type of the edge.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
std::vector< const SUMOVehicle * > getVehicles() const
return vehicles on this edges lanes or segments
static void insertIDs(std::vector< std::string > &into)
Inserts IDs of all known edges into the given vector.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
MSJunction * myFromJunction
the junctions for this edge
double getMeanFriction() const
get the mean friction over the lanes
std::map< std::string, MSEdge * > DictType
definition of the static dictionary type
bool hasMinorLink() const
whether any lane has a minor link
double getPreference(const SUMOVTypeParameter &pars) const
std::map< SUMOVehicleClass, MSConstEdgePairVector > myClassesViaSuccessorMap
The successors available for a given vClass.
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
int getVehicleNumber() const
return total number of vehicles on this edges lanes or segments
const std::map< const MEVehicle *, std::pair< double, int > > & getMesoPositions() const
const MSEdgeVector & getPredecessors() const
virtual void removeTransportable(MSTransportable *t) const
SumoXMLEdgeFunc getFunction() const
Returns the edge type (SumoXMLEdgeFunc)
bool allowsLaneChanging() const
bool isEmpty() const
whether this edge has no vehicles
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal, SUMOVehicleClass vClass) const
void buildLaneChanger()
Has to be called after all successors and predecessors have been set (after closeBuilding())
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
virtual void lock() const
grant exclusive access to the mesoscopic state
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
MSLane * getFirstAllowed(SUMOVehicleClass vClass, bool defaultFirst=false, int routingMode=0) const
std::vector< double > mySublaneSides
the right side for each sublane on this edge
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
std::shared_ptr< const std::vector< MSLane * > > myLanes
Container for the edge's lane; should be sorted: (right-hand-traffic) the more left the lane,...
AllowedLanesCont myOrigAllowed
double getWaitingSeconds() const
return accumulated waiting time for all vehicles on this edges lanes or segments
int myVaporizationRequests
Vaporizer counter.
double myTimePenalty
flat penalty when computing traveltime
SVCPermissions myMinimumPermissions
The intersection of lane permissions for this edge.
MSLane * getFreeLane(const std::vector< MSLane * > *allowed, const SUMOVehicleClass vclass, double departPos) const
Finds the emptiest lane allowing the vehicle class.
void rebuildAllowedLanes(const bool onInit=false, bool updateVehicles=false)
virtual void addTransportable(MSTransportable *t) const
RailEdge< MSEdge, SUMOVehicle > * myRailwayRoutingEdge
double myLength
the length of the edge (cached value for speedup)
static double gStopTolerance
The tolerance to apply when matching waiting persons and vehicles.
static double gMinorPenalty
(minimum) time penalty for passing a minor link when routing
static double gTLSPenalty
scaled (minimum) time penalty for passing a tls link when routing
static double gTurnaroundPenalty
(minimum) time penalty for passing a turnaround link when routing
static MELoop * gMesoNet
mesoscopic simulation infrastructure
static double gLateralResolution
static int gNumSimThreads
how many threads to use for simulation
static SUMOTime gLaneChangeDuration
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
static int gNumThreads
how many threads to use
The base class for an intersection.
const ConstMSEdgeVector & getOutgoing() const
const Position & getPosition(bool secondaryShape=false) const
const ConstMSEdgeVector & getIncoming() const
Performs lane changing of vehicles.
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge'e lanes.
std::pair< double, SUMOTime > getLastBlocked(int index) const
retrieve properties of a blocked vehicle that wants to chane to the lane with the given index
Representation of a lane in the micro simulation.
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
bool empty() const
Returns true if there is not a single vehicle on the lane.
std::vector< MSVehicle * > VehCont
Container for vehicles.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
int getIndex() const
Returns the lane's index.
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
MSLane * getOpposite() const
return the neighboring opposite direction lane for lane changing or nullptr
MSEdge & getEdge() const
Returns the lane's edge.
double getWidth() const
Returns the lane's width.
LinkState getState() const
Returns the current state of the link.
bool isTLSControlled() const
bool havePriority() const
Returns whether this link is a major link.
bool isTurnaround() const
The simulated network and simulation perfomer.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getPreference(const std::string &routingType, const SUMOVTypeParameter &pars) const
retriefe edge type specific routing preference
bool hasJunctionHigherSpeeds() const
return whether the network was built with higher junction speeds
const std::map< SUMOVehicleClass, double > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
const MESegment::MesoEdgeType & getMesoType(const std::string &typeID)
Returns edge type specific meso parameters if no type specific parameters have been loaded,...
int size() const
Returns the number of edges to pass.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
static void invalidateCCHEdge(const MSEdge *e)
a runtime permission change (closure / re-opening) hit this edge: invalidate the graph's primed conne...
static double getAssumedSpeed(const MSEdge *edge, const SUMOVehicle *veh)
return current travel speed assumption
virtual double getEdgePos(SUMOTime now) const
MSStage * getCurrentStage() const
Return the current stage.
bool isPerson() const override
Whether it is a person.
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle in the current step.
Representation of a vehicle in the micro simulation.
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
double getPositionOnLane() const
Get the vehicle's position along the lane.
The car-following model and parameter.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getDesiredMaxSpeed() const
Returns the vehicles's desired maximum speed.
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
double getLength() const
Get vehicle's length [m].
double computeChosenSpeedDeviation(double speedFactorOverride, SumoRNG *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
Base class for objects which have an id.
const std::string & getID() const
Returns the id.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
A point in 2D or 3D with translation and scaling methods.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
static const T & getRandomFrom(const std::vector< T > &v, SumoRNG *rng=nullptr)
Returns a random element from the given vector.
Representation of a vehicle, person, or container.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual double getChosenSpeedFactor() const =0
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual double getMaxSpeed() const =0
Returns the object's maximum speed (minimum of technical and desired maximum speed)
Structure representing possible vehicle parameter.
Representation of a vehicle.
virtual int getRouteValidity(bool update=true, bool silent=false, std::string *msgReturn=nullptr)=0
computes validity attributes for the current route
virtual void setChosenSpeedFactor(const double factor)=0
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
double endPos
The stopping position end.
Structure representing possible vehicle parameter.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
double departSpeed
(optional) The initial speed of the vehicle
double speedFactor
individual speedFactor (overriding distribution from vType)
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
std::string id
The vehicle's id.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
A scoped lock which only triggers on condition.
static void tokenizeAndLookup(std::string_view input, std::vector< T * > &result)
edge type specific meso parameters