87 #define DEBUG_COND (isSelected())
89 #define DEBUG_COND2(obj) ((obj != 0 && (obj)->isSelected()))
129 if (nextIsMyVehicles()) {
130 if (myI1 != myI1End) {
131 return myLane->myVehicles[myI1];
132 }
else if (myI3 != myI3End) {
133 return myLane->myTmpVehicles[myI3];
138 return myLane->myPartialVehicles[myI2];
149 if (myI1 == myI1End && myI3 == myI3End) {
150 if (myI2 != myI2End) {
156 if (myI2 == myI2End) {
159 MSVehicle* cand = myI1 == myI1End ? myLane->myTmpVehicles[myI3] : myLane->myVehicles[myI1];
167 if (cand->
getPositionOnLane() < myLane->myPartialVehicles[myI2]->getPositionOnLane(myLane)) {
170 return !myDownstream;
183 const std::string& type) :
206 mySimulationTask(*this, 0),
211 assert(
myRNGs.size() > 0);
265 veh->addReminder(rem);
277 std::cout <<
SIMTIME <<
" setPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
296 std::cout <<
SIMTIME <<
" resetPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
315 std::cout <<
SIMTIME <<
" setManeuverReservation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
326 std::cout <<
SIMTIME <<
" resetManeuverReservation(): lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
367 if (leader ==
nullptr) {
372 leader = leaderInfo.first;
378 if (leader ==
nullptr) {
384 if (leaderBack >= frontGapNeeded) {
385 pos =
MIN2(pos, leaderBack - frontGapNeeded);
399 bool adaptableSpeed =
true;
408 if (missingRearGap > 0) {
409 if (minPos + missingRearGap <=
myLength) {
416 return isInsertionSuccess(&veh, mspeed, minPos + missingRearGap, posLat, adaptableSpeed, notification);
421 return isInsertionSuccess(&veh, mspeed, minPos, posLat, adaptableSpeed, notification);
428 const double speed = adaptableSpeed ? leader->
getSpeed() : mspeed;
430 if (leaderPos >= frontGapNeeded) {
440 MSLane::VehCont::iterator predIt =
myVehicles.begin();
451 double speed = mspeed;
452 if (adaptableSpeed && leader !=
nullptr) {
458 if (leader !=
nullptr) {
461 frontMax = leaderRearPos - frontGapNeeded;
469 if (frontMax > minPos && backMin + POSITION_EPS < frontMax) {
471 if (
isInsertionSuccess(&veh, speed, backMin + POSITION_EPS, posLat, adaptableSpeed, notification)) {
546 bool patchSpeed =
true;
563 for (
int i = 0; i < 10; i++) {
595 for (
int i = 0; i < 10; i++) {
627 double dist = speed * relevantDelay / (double)
DELTA_T;
629 if (leaderInfo.first !=
nullptr) {
633 dist =
MIN2(dist, leaderInfo.second - frontGapNeeded);
642 MSLane::checkFailure(
const MSVehicle* aVehicle,
double& speed,
double& dist,
const double nspeed,
const bool patchSpeed,
const std::string errorMsg)
const {
643 if (nspeed < speed) {
645 speed =
MIN2(nspeed, speed);
647 }
else if (speed > 0) {
651 if (emergencyBrakeGap <= dist) {
654 WRITE_WARNING(
"Vehicle '" + aVehicle->
getID() +
"' is inserted in emergency situation.");
659 if (errorMsg !=
"") {
660 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (" + errorMsg +
")!");
672 double speed,
double pos,
double posLat,
bool patchSpeed,
677 aVehicle->
getID() +
"'. Inserting at lane end instead.");
681 #ifdef DEBUG_INSERTION
683 std::cout <<
"\nIS_INSERTION_SUCCESS\n"
685 <<
" veh '" << aVehicle->
getID() <<
"'\n";
693 std::vector<MSLane*>::const_iterator ri = bestLaneConts.begin();
700 bool hadRailSignal =
false;
707 if (nextStop.
lane ==
this) {
708 std::stringstream msg;
709 msg <<
"scheduled stop on lane '" <<
myID <<
"' too close";
710 const double distToStop = nextStop.
pars.
endPos - pos;
712 patchSpeed, msg.str())) {
722 MSLane* currentLane =
this;
725 while ((seen < dist || (isRail && !hadRailSignal)) && ri != bestLaneConts.end()) {
727 std::vector<MSLink*>::const_iterator link =
succLinkSec(*aVehicle, nRouteSuccs, *currentLane, bestLaneConts);
735 patchSpeed,
"arrival speed too low")) {
751 #ifdef DEBUG_INSERTION
753 std::cout <<
" insertion constraint at link " << (*link)->getDescription() <<
" not cleared \n";
758 hadRailSignal |= (*link)->getTLLogic() !=
nullptr;
761 || !(*link)->havePriority()) {
763 std::string errorMsg =
"";
764 const LinkState state = (*link)->getState();
770 errorMsg =
"unpriorised junction too close";
772 const double remaining = seen - currentLane->
getStopOffset(aVehicle);
774 patchSpeed, errorMsg)) {
778 #ifdef DEBUG_INSERTION
780 std::cout <<
"trying insertion before minor link: "
781 <<
"insertion speed = " << speed <<
" dist=" << dist
787 #ifdef DEBUG_INSERTION
789 std::cout <<
" oncoming rail traffic at link " << (*link)->getDescription() <<
"\n";
797 nextLane = (*link)->getViaLaneOrLane();
799 if (nextLane !=
nullptr) {
810 if (nextStop.
lane == nextLane) {
811 std::stringstream msg;
812 msg <<
"scheduled stop on lane '" << nextStop.
lane->
getID() <<
"' too close";
813 const double distToStop = seen + nextStop.
pars.
endPos;
815 patchSpeed, msg.str())) {
826 #ifdef DEBUG_INSERTION
828 <<
" leader on lane '" << nextLane->
getID() <<
"': " << leaders.
toString() <<
" nspeed=" << nspeed <<
"\n";
832 #ifdef DEBUG_INSERTION
834 <<
" isInsertionSuccess lane=" <<
getID()
835 <<
" veh=" << aVehicle->
getID()
837 <<
" posLat=" << posLat
838 <<
" patchSpeed=" << patchSpeed
839 <<
" speed=" << speed
840 <<
" nspeed=" << nspeed
841 <<
" nextLane=" << nextLane->
getID()
844 <<
" failed (@641)!\n";
854 if (nspeed < speed) {
860 WRITE_WARNING(
"Vehicle '" + aVehicle->
getID() +
"' is inserted too fast and will violate the speed limit on a lane '" + nextLane->
getID() +
"'.");
863 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (slow lane ahead)!");
873 if ((*link)->hasApproachingFoe(arrivalTime, leaveTime, speed, cfModel.
getMaxDecel())) {
881 currentLane = nextLane;
882 if ((*link)->getViaLane() ==
nullptr) {
896 #ifdef DEBUG_INSERTION
898 <<
" isInsertionSuccess lane=" <<
getID()
899 <<
" veh=" << aVehicle->
getID()
901 <<
" posLat=" << posLat
902 <<
" patchSpeed=" << patchSpeed
903 <<
" speed=" << speed
904 <<
" nspeed=" << nspeed
905 <<
" nextLane=" << nextLane->
getID()
906 <<
" leaders=" << leaders.
toString()
907 <<
" failed (@700)!\n";
911 #ifdef DEBUG_INSERTION
913 <<
" speed = " << speed
914 <<
" nspeed = " << nspeed
919 for (
int i = 0; i < followers.
numSublanes(); ++i) {
920 const MSVehicle* follower = followers[i].first;
921 if (follower !=
nullptr) {
923 if (followers[i].second < backGapNeeded) {
925 #ifdef DEBUG_INSERTION
927 <<
" isInsertionSuccess lane=" <<
getID()
928 <<
" veh=" << aVehicle->
getID()
930 <<
" posLat=" << posLat
931 <<
" patchSpeed=" << patchSpeed
932 <<
" speed=" << speed
933 <<
" nspeed=" << nspeed
934 <<
" follower=" << follower->
getID()
935 <<
" backGapNeeded=" << backGapNeeded
936 <<
" gap=" << followers[i].second
937 <<
" failure (@719)!\n";
949 #ifdef DEBUG_INSERTION
954 if (shadowLane !=
nullptr) {
956 for (
int i = 0; i < shadowFollowers.
numSublanes(); ++i) {
957 const MSVehicle* follower = shadowFollowers[i].first;
958 if (follower !=
nullptr) {
960 if (shadowFollowers[i].second < backGapNeeded) {
962 #ifdef DEBUG_INSERTION
964 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
965 <<
" veh=" << aVehicle->
getID()
967 <<
" posLat=" << posLat
968 <<
" patchSpeed=" << patchSpeed
969 <<
" speed=" << speed
970 <<
" nspeed=" << nspeed
971 <<
" follower=" << follower->
getID()
972 <<
" backGapNeeded=" << backGapNeeded
973 <<
" gap=" << shadowFollowers[i].second
974 <<
" failure (@812)!\n";
983 if (veh !=
nullptr) {
986 if (gap < gapNeeded) {
988 #ifdef DEBUG_INSERTION
990 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
991 <<
" veh=" << aVehicle->
getID()
993 <<
" posLat=" << posLat
994 <<
" patchSpeed=" << patchSpeed
995 <<
" speed=" << speed
996 <<
" nspeed=" << nspeed
997 <<
" leader=" << veh->
getID()
998 <<
" gapNeeded=" << gapNeeded
1000 <<
" failure (@842)!\n";
1011 if (missingRearGap > 0) {
1013 #ifdef DEBUG_INSERTION
1015 <<
" isInsertionSuccess lane=" <<
getID()
1016 <<
" veh=" << aVehicle->
getID()
1018 <<
" posLat=" << posLat
1019 <<
" patchSpeed=" << patchSpeed
1020 <<
" speed=" << speed
1021 <<
" nspeed=" << nspeed
1022 <<
" missingRearGap=" << missingRearGap
1023 <<
" failure (@728)!\n";
1030 #ifdef DEBUG_INSERTION
1032 <<
" isInsertionSuccess lane=" <<
getID()
1033 <<
" veh=" << aVehicle->
getID()
1035 <<
" posLat=" << posLat
1036 <<
" patchSpeed=" << patchSpeed
1037 <<
" speed=" << speed
1038 <<
" nspeed=" << nspeed
1039 <<
" failed (@733)!\n";
1045 return v->getPositionOnLane() >= pos;
1047 #ifdef DEBUG_INSERTION
1049 <<
" isInsertionSuccess lane=" <<
getID()
1050 <<
" veh=" << aVehicle->
getID()
1052 <<
" posLat=" << posLat
1053 <<
" patchSpeed=" << patchSpeed
1054 <<
" speed=" << speed
1055 <<
" nspeed=" << nspeed
1059 <<
"\n leaders=" << leaders.
toString()
1072 return v->getPositionOnLane() >= pos;
1079 double nspeed = speed;
1080 #ifdef DEBUG_INSERTION
1082 std::cout <<
SIMTIME <<
" safeInsertionSpeed veh=" << veh->
getID() <<
" speed=" << speed <<
"\n";
1087 if (leader !=
nullptr) {
1092 nspeed =
MIN2(nspeed,
1094 #ifdef DEBUG_INSERTION
1096 std::cout <<
" leader=" << leader->
getID() <<
" nspeed=" << nspeed <<
"\n";
1111 int freeSublanes = 1;
1116 while (freeSublanes > 0 && veh !=
nullptr) {
1117 #ifdef DEBUG_PLAN_MOVE
1120 std::cout <<
" getLastVehicleInformation lane=" <<
getID() <<
" minPos=" << minPos <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
"\n";
1125 freeSublanes = leaderTmp.
addLeader(veh,
true, vehLatOffset);
1126 #ifdef DEBUG_PLAN_MOVE
1128 std::cout <<
" latOffset=" << vehLatOffset <<
" newLeaders=" << leaderTmp.
toString() <<
"\n";
1134 if (ego ==
nullptr && minPos == 0) {
1142 #ifdef DEBUG_PLAN_MOVE
1171 int freeSublanes = 1;
1173 while (freeSublanes > 0 && veh !=
nullptr) {
1174 #ifdef DEBUG_PLAN_MOVE
1176 std::cout <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
" maxPos=" << maxPos <<
"\n";
1183 #ifdef DEBUG_PLAN_MOVE
1185 std::cout <<
" veh=" << veh->
getID() <<
" latOffset=" << vehLatOffset <<
"\n";
1188 freeSublanes = followerTmp.
addLeader(veh,
true, vehLatOffset);
1192 if (ego ==
nullptr && maxPos == std::numeric_limits<double>::max()) {
1197 #ifdef DEBUG_PLAN_MOVE
1220 double cumulatedVehLength = 0.;
1224 VehCont::reverse_iterator veh =
myVehicles.rbegin();
1227 #ifdef DEBUG_PLAN_MOVE
1231 <<
" planMovements() lane=" <<
getID()
1239 #ifdef DEBUG_PLAN_MOVE
1241 std::cout <<
" plan move for: " << (*veh)->getID();
1245 #ifdef DEBUG_PLAN_MOVE
1247 std::cout <<
" leaders=" << leaders.
toString() <<
"\n";
1250 (*veh)->planMove(t, leaders, cumulatedVehLength);
1251 cumulatedVehLength += (*veh)->getVehicleType().getLengthWithGap();
1260 veh->setApproachingForAllLinks(t);
1269 bool nextToConsiderIsPartial;
1272 while (moreReservationsAhead || morePartialVehsAhead) {
1273 if ((!moreReservationsAhead || (*vehRes)->getPositionOnLane(
this) <= veh->
getPositionOnLane())
1274 && (!morePartialVehsAhead || (*vehPart)->getPositionOnLane(
this) <= veh->
getPositionOnLane())) {
1280 if (moreReservationsAhead && !morePartialVehsAhead) {
1281 nextToConsiderIsPartial =
false;
1282 }
else if (morePartialVehsAhead && !moreReservationsAhead) {
1283 nextToConsiderIsPartial =
true;
1285 assert(morePartialVehsAhead && moreReservationsAhead);
1287 nextToConsiderIsPartial = (*vehPart)->getPositionOnLane(
this) > (*vehRes)->getPositionOnLane(
this);
1290 if (nextToConsiderIsPartial) {
1291 const double latOffset = (*vehPart)->getLatOffset(
this);
1292 #ifdef DEBUG_PLAN_MOVE
1294 std::cout <<
" partial ahead: " << (*vehPart)->getID() <<
" latOffset=" << latOffset <<
"\n";
1297 ahead.
addLeader(*vehPart,
false, latOffset);
1301 const double latOffset = (*vehRes)->getLatOffset(
this);
1302 #ifdef DEBUG_PLAN_MOVE
1304 std::cout <<
" reservation ahead: " << (*vehRes)->getID() <<
" latOffset=" << latOffset <<
"\n";
1307 ahead.
addLeader(*vehRes,
false, latOffset);
1318 #ifdef DEBUG_COLLISIONS
1320 std::vector<const MSVehicle*> all;
1322 all.push_back(*last);
1324 std::cout <<
SIMTIME <<
" detectCollisions stage=" << stage <<
" lane=" <<
getID() <<
":\n"
1327 <<
" all=" <<
toString(all) <<
"\n"
1336 std::set<const MSVehicle*, ComparatorNumericalIdLess> toRemove;
1337 std::set<const MSVehicle*, ComparatorNumericalIdLess> toTeleport;
1340 #ifdef DEBUG_JUNCTION_COLLISIONS
1342 std::cout <<
SIMTIME <<
" detect junction Collisions stage=" << stage <<
" lane=" <<
getID() <<
":\n"
1349 const std::vector<const MSLane*>& foeLanes =
myLinks.front()->getFoeLanes();
1354 for (std::vector<const MSLane*>::const_iterator it = foeLanes.begin(); it != foeLanes.end(); ++it) {
1355 const MSLane* foeLane = *it;
1356 #ifdef DEBUG_JUNCTION_COLLISIONS
1358 std::cout <<
" foeLane " << foeLane->
getID()
1366 if (victim == collider) {
1370 #ifdef DEBUG_JUNCTION_COLLISIONS
1373 <<
" bound=" << colliderBoundary <<
" foeBound=" << victim->
getBoundingBox()
1390 if (
myLinks.front()->getWalkingAreaFoe() !=
nullptr) {
1393 if (
myLinks.front()->getWalkingAreaFoeExit() !=
nullptr) {
1404 VehCont::reverse_iterator lastVeh =
myVehicles.rend() - 1;
1405 for (VehCont::reverse_iterator pred =
myVehicles.rbegin(); pred != lastVeh; ++pred) {
1406 VehCont::reverse_iterator veh = pred + 1;
1417 double high = (*veh)->getPositionOnLane(
this);
1418 double low = (*veh)->getBackPositionOnLane(
this);
1425 double low2 =
myLength - (*veh2)->getPositionOnLane(bidiLane);
1426 double high2 =
myLength - (*veh2)->getBackPositionOnLane(bidiLane);
1427 if (!(high < low2 || high2 < low)) {
1428 #ifdef DEBUG_COLLISIONS
1430 std::cout <<
SIMTIME <<
" bidi-collision veh=" << (*veh)->getID() <<
" bidiVeh=" << (*veh2)->getID()
1431 <<
" vehFurther=" <<
toString((*veh)->getFurtherLanes())
1432 <<
" high=" << high <<
" low=" << low <<
" high2=" << high2 <<
" low2=" << low2 <<
"\n";
1439 std::swap(victim, collider);
1461 if (lead == follow) {
1480 if (lead !=
nullptr && lead != follow && shadowLane->
detectCollisionBetween(timestep, stage, follow, lead, toRemove, toTeleport)) {
1490 #ifdef DEBUG_PEDESTRIAN_COLLISIONS
1492 std::cout <<
SIMTIME <<
" detect pedestrian collisions stage=" << stage <<
" lane=" <<
getID() <<
"\n";
1502 #ifdef DEBUG_PEDESTRIAN_COLLISIONS
1504 std::cout <<
SIMTIME <<
" back=" << back <<
" right=" << right <<
" person=" <<
Named::getIDSecure(leader.first) <<
" dist=" << leader.second <<
"\n";
1507 if (leader.first != 0 && leader.second < length) {
1509 "Vehicle '" + v->
getID()
1510 +
"' collision with person '" + leader.first->getID()
1511 +
"', lane='" +
getID()
1512 +
"', gap=" +
toString(leader.second - length)
1514 +
" stage=" + stage +
".");
1521 for (std::set<const MSVehicle*, ComparatorNumericalIdLess>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
1525 if (toTeleport.count(veh) > 0) {
1537 SUMOTime timestep,
const std::string& stage) {
1539 #ifdef DEBUG_PEDESTRIAN_COLLISIONS
1541 std::cout <<
SIMTIME <<
" detect pedestrian junction collisions stage=" << stage <<
" lane=" <<
getID() <<
" foeLane=" << foeLane->
getID() <<
"\n";
1545 for (std::vector<MSTransportable*>::const_iterator it_p = persons.begin(); it_p != persons.end(); ++it_p) {
1546 #ifdef DEBUG_PEDESTRIAN_COLLISIONS
1548 std::cout <<
" collider=" << collider->
getID()
1549 <<
" ped=" << (*it_p)->getID()
1550 <<
" colliderBoundary=" << colliderBoundary
1551 <<
" pedBoundary=" << (*it_p)->getBoundingBox()
1555 if (colliderBoundary.
overlapsWith((*it_p)->getBoundingBox())) {
1557 "Vehicle '" + collider->
getID()
1558 +
"' collision with person '" + (*it_p)->getID()
1559 +
"', lane='" +
getID()
1561 +
" stage=" + stage +
".");
1571 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1572 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport)
const {
1579 if (collider == victim) {
1586 std::swap(victim, collider);
1594 #ifdef DEBUG_COLLISIONS
1597 <<
" thisLane=" <<
getID()
1598 <<
" collider=" << collider->
getID()
1599 <<
" victim=" << victim->
getID()
1602 <<
" colliderPos=" << colliderPos
1607 <<
" minGapFactor=" << minGapFactor
1612 if (gap < -NUMERICAL_EPS) {
1617 if (latGap + NUMERICAL_EPS > 0) {
1624 && victim->
getLane() !=
this) {
1628 #ifdef DEBUG_COLLISIONS
1630 std::cout <<
SIMTIME <<
" detectedCollision gap=" << gap <<
" latGap=" << latGap <<
"\n";
1642 double gap,
double latGap, std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1643 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport)
const {
1649 ?
"frontal collision" :
"collision");
1652 std::swap(collider, victim);
1654 std::string prefix =
"Vehicle '" + collider->
getID() +
"'; " + collisionType +
" with vehicle '" + victim->
getID() ;
1659 std::string dummyError;
1665 double victimSpeed = victim->
getSpeed();
1666 double colliderSpeed = collider->
getSpeed();
1669 if (collisionAngle < 45) {
1671 colliderSpeed =
MIN2(colliderSpeed, victimSpeed);
1672 }
else if (collisionAngle < 135) {
1688 victim->
addStop(stop, dummyError, 0,
true);
1695 collider->
addStop(stop, dummyError, 0,
true);
1706 prefix =
"Teleporting vehicle '" + collider->
getID() +
"'; " + collisionType +
" with vehicle '" + victim->
getID() ;
1707 toRemove.insert(collider);
1708 toTeleport.insert(collider);
1711 prefix =
"Removing " + collisionType +
" participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1712 bool removeCollider =
true;
1713 bool removeVictim =
true;
1717 toRemove.insert(victim);
1719 if (removeCollider) {
1720 toRemove.insert(collider);
1722 if (!removeVictim) {
1723 if (!removeCollider) {
1724 prefix =
"Keeping remote-controlled " + collisionType +
" participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1726 prefix =
"Removing " + collisionType +
" participant: vehicle '" + collider->
getID() +
"', keeping remote-controlled vehicle '" + victim->
getID();
1728 }
else if (!removeCollider) {
1729 prefix =
"Keeping remote-controlled " + collisionType +
" participant: vehicle '" + collider->
getID() +
"', removing vehicle '" + victim->
getID();
1738 +
"', lane='" +
getID()
1742 +
" stage=" + stage +
".");
1743 #ifdef DEBUG_COLLISIONS
1745 toRemove.erase(collider);
1746 toTeleport.erase(collider);
1749 toRemove.erase(victim);
1750 toTeleport.erase(victim);
1773 #ifdef DEBUG_EXEC_MOVE
1775 std::cout <<
SIMTIME <<
" veh " << veh->
getID() <<
" has arrived." << std::endl;
1780 }
else if (target !=
nullptr && moved) {
1798 WRITE_WARNING(
"Teleporting vehicle '" + veh->
getID() +
"'; beyond end of lane, target lane='" +
getID() +
"', time=" +
1824 i = VehCont::reverse_iterator(
myVehicles.erase(i.base()));
1835 const bool minorLink = !wrongLane && (link !=
myLinks.end()) && !((*link)->havePriority());
1836 const std::string reason = (wrongLane ?
" (wrong lane)" : (minorLink ?
" (yield)" :
" (jam)"));
1842 + (r2 ?
" (highway)" :
"")
1846 }
else if (minorLink) {
1895 const MSLane* firstInternal =
this;
1897 while (pred !=
nullptr && pred->
isInternal()) {
1898 firstInternal = pred;
1902 return firstInternal;
1909 DictType::iterator it =
myDict.find(
id);
1910 if (it ==
myDict.end()) {
1912 myDict.insert(DictType::value_type(
id, ptr));
1921 DictType::iterator it =
myDict.find(
id);
1922 if (it ==
myDict.end()) {
1932 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1941 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1942 into.push_back((*i).first);
1947 template<
class RTREE>
void
1949 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1953 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
1954 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
1955 into.Insert(cmin, cmax, l);
1959 template void MSLane::fill<NamedRTree>(
NamedRTree& into);
1977 return (link !=
myLinks.end());
1987 assert(veh->getLane() ==
this);
2001 #ifdef DEBUG_VEHICLE_CONTAINER
2019 #ifdef DEBUG_CONTEXT
2021 std::cout <<
"sortManeuverReservations on lane " <<
getID()
2026 #ifdef DEBUG_CONTEXT
2078 std::vector<MSLink*>::const_iterator
2080 const MSLane& succLinkSource,
const std::vector<MSLane*>& conts) {
2083 if (nRouteEdge ==
nullptr) {
2085 return succLinkSource.
myLinks.end();
2089 assert(succLinkSource.
myLinks.size() == 1);
2092 return succLinkSource.
myLinks.begin();
2103 if (nRouteSuccs < (
int)conts.size()) {
2105 for (std::vector<MSLink*>::const_iterator link = succLinkSource.
myLinks.begin(); link != succLinkSource.
myLinks.end(); ++link) {
2106 if ((*link)->getLane() !=
nullptr && (*link)->getLane()->myEdge == nRouteEdge && (*link)->getLane()->allowsVehicleClass(veh.
getVehicleType().
getVehicleClass())) {
2108 if ((*link)->getLane() == conts[nRouteSuccs]) {
2115 return succLinkSource.
myLinks.end();
2118 #ifdef DEBUG_NO_CONNECTION
2120 WRITE_WARNING(
"Could not find connection between lane " + succLinkSource.
getID() +
" and lane " + conts[nRouteSuccs]->getID() +
2123 return succLinkSource.
myLinks.end();
2131 if ((
internal && l->getViaLane() == target) || (!
internal && l->getLane() == target)) {
2142 if (l->getLane() == target) {
2143 return l->getViaLane();
2155 const MSLane*
internal =
this;
2157 assert(lane !=
nullptr);
2161 assert(lane !=
nullptr);
2194 assert(remVehicle->
getLane() ==
this);
2196 if (remVehicle == *it) {
2231 }
else if (!approachingEdge->
isInternal() && warnMultiCon) {
2234 WRITE_WARNING(
"Lane '" +
getID() +
"' is approached multiple times from edge '" + approachingEdge->
getID() +
"'. This may cause collisions.");
2242 std::map<MSEdge*, std::vector<MSLane*> >::const_iterator i =
myApproachingLanes.find(edge);
2246 const std::vector<MSLane*>& lanes = (*i).second;
2247 return std::find(lanes.begin(), lanes.end(), lane) != lanes.end();
2258 const MSVehicle* v = followerInfo.first;
2277 std::pair<MSVehicle* const, double>
2278 MSLane::getLeader(
const MSVehicle* veh,
const double vehPos,
const std::vector<MSLane*>& bestLaneConts,
double dist,
bool checkTmpVehicles)
const {
2281 #ifdef DEBUG_CONTEXT
2286 if (checkTmpVehicles) {
2293 #ifdef DEBUG_CONTEXT
2295 std::cout << std::setprecision(
gPrecision) <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
2309 #ifdef DEBUG_CONTEXT
2311 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos
2321 if (bestLaneConts.size() > 0) {
2327 #ifdef DEBUG_CONTEXT
2329 std::cout <<
" getLeader lane=" <<
getID() <<
" seen=" << seen <<
" dist=" << dist <<
"\n";
2333 return std::pair<MSVehicle* const, double>(
static_cast<MSVehicle*
>(
nullptr), -1);
2337 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
2342 std::pair<MSVehicle* const, double>
2344 const std::vector<MSLane*>& bestLaneConts)
const {
2345 #ifdef DEBUG_CONTEXT
2347 std::cout <<
" getLeaderOnConsecutive lane=" <<
getID() <<
" ego=" << veh.
getID() <<
" seen=" << seen <<
" dist=" << dist <<
" conts=" <<
toString(bestLaneConts) <<
"\n";
2351 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
2359 #ifdef DEBUG_CONTEXT
2366 return std::pair<MSVehicle* const, double>(pred, gap);
2369 const MSLane* nextLane =
this;
2374 std::vector<MSLink*>::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
2377 #ifdef DEBUG_CONTEXT
2379 std::cout <<
" cannot continue after nextLane=" << nextLane->
getID() <<
"\n";
2386 #ifdef DEBUG_CONTEXT
2391 const bool laneChanging = veh.
getLane() !=
this;
2393 #ifdef DEBUG_CONTEXT
2397 if (linkLeaders.size() > 0) {
2398 std::pair<MSVehicle*, double> result;
2399 double shortestGap = std::numeric_limits<double>::max();
2400 for (
auto ll : linkLeaders) {
2401 double gap = ll.vehAndGap.second;
2403 if (lVeh !=
nullptr) {
2407 #ifdef DEBUG_CONTEXT
2410 <<
" isLeader=" << veh.
isLeader(*link, lVeh)
2411 <<
" gap=" << ll.vehAndGap.second
2412 <<
" gap+brakeing=" << gap
2417 if (lVeh !=
nullptr && !laneChanging && !veh.
isLeader(*link, lVeh)) {
2420 if (gap < shortestGap) {
2422 result = ll.vehAndGap;
2425 if (shortestGap != std::numeric_limits<double>::max()) {
2426 #ifdef DEBUG_CONTEXT
2428 std::cout <<
" found linkLeader after nextLane=" << nextLane->
getID() <<
"\n";
2434 bool nextInternal = (*link)->getViaLane() !=
nullptr;
2435 nextLane = (*link)->getViaLaneOrLane();
2436 if (nextLane ==
nullptr) {
2441 if (leader !=
nullptr) {
2442 #ifdef DEBUG_CONTEXT
2444 std::cout <<
" found leader " << leader->
getID() <<
" on nextLane=" << nextLane->
getID() <<
"\n";
2449 return std::make_pair(leader, leaderDist);
2460 if (!nextInternal) {
2463 }
while (seen <= dist || nextLane->
isInternal());
2464 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
2468 std::pair<MSVehicle* const, double>
2470 #ifdef DEBUG_CONTEXT
2472 std::cout <<
SIMTIME <<
" getCriticalLeader. lane=" <<
getID() <<
" veh=" << veh.
getID() <<
"\n";
2476 std::pair<MSVehicle*, double> result = std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
2477 double safeSpeed = std::numeric_limits<double>::max();
2482 const MSLane* nextLane =
this;
2486 std::vector<MSLink*>::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
2493 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
2494 const MSVehicle* leader = (*it).vehAndGap.first;
2495 if (leader !=
nullptr && leader != result.first) {
2499 const double tmpSpeed = veh.
getSafeFollowSpeed((*it).vehAndGap, seen, nextLane, (*it).distToCrossing);
2500 #ifdef DEBUG_CONTEXT
2502 std::cout <<
" linkLeader=" << leader->
getID() <<
" gap=" << result.second <<
" tmpSpeed=" << tmpSpeed <<
" safeSpeed=" << safeSpeed <<
"\n";
2505 if (tmpSpeed < safeSpeed) {
2506 safeSpeed = tmpSpeed;
2507 result = (*it).vehAndGap;
2511 bool nextInternal = (*link)->getViaLane() !=
nullptr;
2512 nextLane = (*link)->getViaLaneOrLane();
2513 if (nextLane ==
nullptr) {
2517 if (leader !=
nullptr && leader != result.first) {
2520 if (tmpSpeed < safeSpeed) {
2521 safeSpeed = tmpSpeed;
2522 result = std::make_pair(leader, gap);
2533 if (!nextInternal) {
2536 }
while (seen <= dist || nextLane->
isInternal());
2546 for (MSEdgeVector::iterator i = pred.begin(); i != pred.end();) {
2555 if (pred.size() != 0) {
2557 MSEdge* best = *pred.begin();
2579 if (&(cand.lane->getEdge()) == &fromEdge) {
2604 #ifdef DEBUG_LANE_SORTER
2620 std::vector<MSLink*> candidateLinks =
myLinks;
2623 MSLane* best = (*candidateLinks.begin())->getViaLaneOrLane();
2624 #ifdef DEBUG_LANE_SORTER
2625 std::cout <<
"\nBest successor lane for lane '" <<
myID <<
"': '" << best->
getID() <<
"'" << std::endl;
2635 if (pred ==
nullptr) {
2643 const std::vector<std::pair<const MSLane*, const MSEdge*> >
2645 std::vector<std::pair<const MSLane*, const MSEdge*> > result;
2647 assert(link->getLane() !=
nullptr);
2648 result.push_back(std::make_pair(link->getLane(), link->getViaLane() ==
nullptr ?
nullptr : &link->getViaLane()->getEdge()));
2653 std::vector<const MSLane*>
2655 std::vector<const MSLane*> result = {};
2657 for (std::vector<MSLane*>::const_iterator it_lane = (*it).second.begin(); it_lane != (*it).second.end(); ++it_lane) {
2658 if (!((*it_lane)->isInternal())) {
2659 result.push_back(*it_lane);
2683 for (std::vector<MSLink*>::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2684 if ((*i)->getLane()->getEdge().isCrossing()) {
2685 return (
int)(i -
myLinks.begin());
2729 wtime += (*i)->getWaitingSeconds();
2742 for (VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2743 v += (*i)->getSpeed();
2761 v += veh->getSpeed();
2780 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2781 ret += (*i)->getCO2Emissions();
2792 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2793 ret += (*i)->getCOEmissions();
2804 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2805 ret += (*i)->getPMxEmissions();
2816 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2817 ret += (*i)->getNOxEmissions();
2828 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2829 ret += (*i)->getHCEmissions();
2840 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2841 ret += (*i)->getFuelConsumption();
2852 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2853 ret += (*i)->getElectricityConsumption();
2864 if (vehs.size() == 0) {
2868 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2869 double sv = (*i)->getHarmonoise_NoiseEmissions();
2870 ret += (double) pow(10., (sv / 10.));
2903 myLaneDir(e->getLanes()[0]->
getShape().angleAt2D(0)) {
2914 if (ae1 !=
nullptr && ae1->size() != 0) {
2924 if (ae2 !=
nullptr && ae2->size() != 0) {
2944 myLaneDir(targetLane->
getShape().angleAt2D(0)) {}
2962 #ifdef DEBUG_LANE_SORTER
2963 std::cout <<
"\nincoming_lane_priority sorter()\n"
2964 <<
"noninternal predecessor for lane '" << laneInfo1.
lane->
getID()
2965 <<
"': '" << noninternal1->
getID() <<
"'\n"
2966 <<
"noninternal predecessor for lane '" << laneInfo2.
lane->
getID()
2967 <<
"': '" << noninternal2->
getID() <<
"'\n";
2975 bool priorized1 =
true;
2976 bool priorized2 =
true;
2978 #ifdef DEBUG_LANE_SORTER
2979 std::cout <<
"FoeLinks of '" << noninternal1->
getID() <<
"'" << std::endl;
2982 #ifdef DEBUG_LANE_SORTER
2983 std::cout << foeLink->getLaneBefore()->getID() << std::endl;
2985 if (foeLink == link2) {
2991 #ifdef DEBUG_LANE_SORTER
2992 std::cout <<
"FoeLinks of '" << noninternal2->
getID() <<
"'" << std::endl;
2995 #ifdef DEBUG_LANE_SORTER
2996 std::cout << foeLink->getLaneBefore()->getID() << std::endl;
2999 if (foeLink == link1) {
3005 assert(priorized1 || priorized2);
3006 if (priorized1 != priorized2) {
3021 myLaneDir(sourceLane->
getShape().angleAt2D(0)) {}
3027 if (target2 ==
nullptr) {
3030 if (target1 ==
nullptr) {
3034 #ifdef DEBUG_LANE_SORTER
3035 std::cout <<
"\noutgoing_lane_priority sorter()\n"
3036 <<
"noninternal successors for lane '" << myLane->
getID()
3037 <<
"': '" << target1->
getID() <<
"' and "
3038 <<
"'" << target2->
getID() <<
"'\n";
3045 if (priority1 != priority2) {
3046 return priority1 > priority2;
3072 if (link->getApproaching().size() > 0) {
3081 const bool toRailJunction =
myLinks.size() > 0 && (
3084 const bool hasVehicles =
myVehicles.size() > 0;
3093 if (toRailJunction) {
3095 if (link->getApproaching().size() > 0) {
3098 for (
auto item : link->getApproaching()) {
3138 for (
const std::string&
id : vehIds) {
3167 bool allSublanes,
double searchDist,
bool ignoreMinorLinks)
const {
3170 #ifdef DEBUG_CONTEXT
3172 std::cout <<
SIMTIME <<
" getFollowers lane=" <<
getID() <<
" ego=" << ego->
getID()
3173 <<
" backOffset=" << backOffset <<
" pos=" << egoPos
3174 <<
" allSub=" << allSublanes <<
" searchDist=" << searchDist <<
" ignoreMinor=" << ignoreMinorLinks
3184 #ifdef DEBUG_CONTEXT
3194 #ifdef DEBUG_CONTEXT
3196 std::cout <<
" (1) added veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
" result=" << result.
toString() <<
"\n";
3201 #ifdef DEBUG_CONTEXT
3203 std::cout <<
" result.numFreeSublanes=" << result.
numFreeSublanes() <<
"\n";
3211 if (searchDist == -1) {
3213 #ifdef DEBUG_CONTEXT
3215 std::cout <<
" computed searchDist=" << searchDist <<
"\n";
3219 std::set<const MSEdge*> egoFurther;
3221 egoFurther.insert(&further->getEdge());
3231 std::vector<MSLane::IncomingLaneInfo> newFound;
3233 while (toExamine.size() != 0) {
3234 for (std::vector<MSLane::IncomingLaneInfo>::iterator it = toExamine.begin(); it != toExamine.end(); ++it) {
3235 MSLane* next = (*it).lane;
3239 #ifdef DEBUG_CONTEXT
3241 std::cout <<
" next=" << next->
getID() <<
" seen=" << (*it).length <<
" first=" << first.
toString() <<
" firstFront=" << firstFront.
toString() <<
" backOffset=" << backOffset <<
"\n";
3245 if (backOffset + (*it).length - next->
getLength() < 0
3246 && egoFurther.count(&next->
getEdge()) != 0
3252 for (
const auto& ll : linkLeaders) {
3253 if (ll.vehAndGap.first !=
nullptr) {
3254 const bool egoIsLeader = ll.vehAndGap.first->isLeader((*it).viaLink, ego);
3257 const double gap = (egoIsLeader
3258 ? -ll.vehAndGap.second - ll.vehAndGap.first->getVehicleType().getLengthWithGap() - ego->
getVehicleType().
getMinGap()
3261 #ifdef DEBUG_CONTEXT
3263 std::cout <<
SIMTIME <<
" ego=" << ego->
getID() <<
" link=" << (*it).viaLink->getViaLaneOrLane()->getID()
3265 <<
" gap=" << ll.vehAndGap.second <<
" dtC=" << ll.distToCrossing
3266 <<
" egoIsLeader=" << egoIsLeader <<
" gap2=" << gap
3273 #ifdef DEBUG_CONTEXT
3286 if (v !=
nullptr && v != ego) {
3293 agap = (*it).length - next->
getLength() + backOffset
3296 #ifdef DEBUG_CONTEXT
3298 std::cout <<
" agap1=" << agap <<
"\n";
3305 if (v !=
nullptr && v != ego) {
3313 if (!(*it).viaLink->havePriority() && !ego->
onFurtherEdge(&(*it).lane->getEdge())
3317 agap =
MAX2(agap, 0.0);
3321 #ifdef DEBUG_CONTEXT
3328 if ((*it).length < searchDist) {
3329 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
3330 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
3331 if (visited.find((*j).lane) == visited.end() && ((*j).viaLink->havePriority() || !ignoreMinorLinks)) {
3332 visited.insert((*j).lane);
3334 ili.
lane = (*j).lane;
3335 ili.
length = (*j).length + (*it).length;
3337 newFound.push_back(ili);
3343 swap(newFound, toExamine);
3368 const MSLane* nextLane =
this;
3374 std::vector<MSLink*>::const_iterator link =
succLinkSec(*ego, view, *nextLane, bestLaneConts);
3381 if (linkLeaders.size() > 0) {
3387 #ifdef DEBUG_CONTEXT
3389 std::cout <<
" linkleader=" << veh->
getID() <<
" gap=" << ll.
vehAndGap.second <<
"\n";
3397 bool nextInternal = (*link)->getViaLane() !=
nullptr;
3398 nextLane = (*link)->getViaLaneOrLane();
3399 if (nextLane ==
nullptr) {
3404 #ifdef DEBUG_CONTEXT
3406 std::cout <<
SIMTIME <<
" getLeadersOnConsecutive lane=" <<
getID() <<
" nextLane=" << nextLane->
getID() <<
" leaders=" << leaders.
toString() <<
"\n";
3411 for (
int i = 0; i < iMax; ++i) {
3413 if (veh !=
nullptr) {
3414 #ifdef DEBUG_CONTEXT
3434 if (!nextInternal) {
3449 #ifdef DEBUG_CONTEXT
3451 std::cout <<
SIMTIME <<
" getPartialBehind lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" found=" << veh->
getID() <<
"\n";
3457 #ifdef DEBUG_CONTEXT
3480 std::set<MSVehicle*>
3482 assert(checkedLanes !=
nullptr);
3483 if (checkedLanes->find(
this) != checkedLanes->end()) {
3484 #ifdef DEBUG_SURROUNDING
3485 std::cout <<
"Skipping previously scanned lane: " <<
getID() << std::endl;
3487 return std::set<MSVehicle*>();
3490 (*checkedLanes)[
this] = std::make_pair(
MAX2(0.0, startPos - upstreamDist),
MIN2(startPos + downstreamDist,
getLength()));
3492 #ifdef DEBUG_SURROUNDING
3493 std::cout <<
"Scanning on lane " <<
myID <<
"(downstr. " << downstreamDist <<
", upstr. " << upstreamDist <<
", startPos " << startPos <<
"): " << std::endl;
3496 if (startPos < upstreamDist) {
3499 MSLane* incoming = incomingInfo.lane;
3500 #ifdef DEBUG_SURROUNDING
3501 std::cout <<
"Checking on incoming: " << incoming->
getID() << std::endl;
3502 if (checkedLanes->find(incoming) != checkedLanes->end()) {
3503 std::cout <<
"Skipping previous: " << incoming->
getID() << std::endl;
3507 foundVehicles.insert(newVehs.begin(), newVehs.end());
3511 if (
getLength() < startPos + downstreamDist) {
3515 #ifdef DEBUG_SURROUNDING
3516 std::cout <<
"Checking on outgoing: " << l->getViaLaneOrLane()->getID() << std::endl;
3518 std::set<MSVehicle*> newVehs = l->getViaLaneOrLane()->getSurroundingVehicles(0.0, downstreamDist - (
myLength - startPos), upstreamDist, checkedLanes);
3519 foundVehicles.insert(newVehs.begin(), newVehs.end());
3522 #ifdef DEBUG_SURROUNDING
3523 std::cout <<
"On lane (2) " <<
myID <<
": \nFound vehicles: " << std::endl;
3525 std::cout << v->getID() <<
" pos = " << v->getPositionOnLane() << std::endl;
3528 return foundVehicles;
3532 std::set<MSVehicle*>
3534 std::set<MSVehicle*> res;
3537 if (!vehs.empty()) {
3539 if (veh->getPositionOnLane() >= a) {
3540 if (veh->getBackPositionOnLane() > b) {
3552 std::vector<const MSJunction*>
3555 std::vector<const MSJunction*> junctions;
3557 junctions.insert(junctions.end(), l->getJunction());
3563 std::vector<const MSLink*>
3565 #ifdef DEBUG_SURROUNDING
3566 std::cout <<
"getUpcoming links on lane '" <<
getID() <<
"' with pos=" << pos
3567 <<
" range=" << range << std::endl;
3570 std::vector<const MSLink*> links;
3573 const MSLane* lane =
this;
3576 std::vector<MSLane*>::const_iterator contLanesIt = contLanes.begin();
3580 const MSLink* link =
nullptr;
3582 assert(*contLanesIt ==
nullptr);
3584 links.insert(links.end(), link);
3589 assert(*(contLanesIt + 1) == lane);
3591 while (++contLanesIt != contLanes.end()) {
3595 #ifdef DEBUG_SURROUNDING
3596 std::cout <<
"Distance until end of lane '" << lane->
getID() <<
"' is " << dist <<
"." << std::endl;
3602 if (link !=
nullptr) {
3603 links.insert(links.end(), link);
3605 lane = *contLanesIt;
3623 if (opposite ==
nullptr) {
3625 throw ProcessError(
"Lane '" +
getID() +
"' cannot compute oppositePos as there is no opposite lane.");
3632 std::pair<MSVehicle* const, double>
3637 #ifdef DEBUG_CONTEXT
3639 std::cout <<
" getFollower lane=" <<
getID() <<
" egoPos=" << egoPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane(
this) <<
"\n";
3647 if (dist > 0 && backOffset > dist) {
3648 return std::make_pair(
nullptr, -1);
3651 return std::make_pair(
const_cast<MSVehicle*
>(result.first), result.first ==
nullptr ? -1 : result.second);
3654 std::pair<MSVehicle* const, double>
3656 #ifdef DEBUG_OPPOSITE
3658 <<
" ego=" << ego->
getID()
3662 <<
" oppositeDir=" << oppositeDir
3670 std::pair<MSVehicle* const, double> result =
getFollower(ego, egoPos + egoLength, dist,
true);
3677 std::pair<MSVehicle* const, double>
3679 #ifdef DEBUG_OPPOSITE
3681 <<
" ego=" << ego->
getID()
3691 if (result.first !=
nullptr) {
3692 if (result.first->getLaneChangeModel().isOpposite()) {
3693 result.second -= result.first->getVehicleType().getLength();
3695 if (result.second > POSITION_EPS) {
3697 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
3708 const std::string action = oc.
getString(
"collision.action");
3709 if (action ==
"none") {
3711 }
else if (action ==
"warn") {
3713 }
else if (action ==
"teleport") {
3715 }
else if (action ==
"remove") {
3718 WRITE_ERROR(
"Invalid collision.action '" + action +
"'.");
3770 #ifdef DEBUG_INSERTION
3772 std::cout <<
SIMTIME <<
" check for pedestrians on lane=" <<
getID() <<
" pos=" << pos <<
"\n";
3777 if (leader.first != 0) {
3780 if (gap < 0 ||
checkFailure(aVehicle, speed, dist, stopSpeed, patchSpeed,
"")) {
3782 #ifdef DEBUG_INSERTION
3784 <<
" isInsertionSuccess lane=" <<
getID()
3785 <<
" veh=" << aVehicle->
getID()
3788 <<
" patchSpeed=" << patchSpeed
3789 <<
" speed=" << speed
3790 <<
" stopSpeed=" << stopSpeed
3791 <<
" pedestrianLeader=" << leader.first->getID()
3792 <<
" failed (@796)!\n";
3805 const int numRNGs = oc.
getInt(
"thread-rngs");
3806 const bool random = oc.
getBool(
"random");
3807 int seed = oc.
getInt(
"seed");
3809 for (
int i = 0; i < numRNGs; i++) {
3810 myRNGs.push_back(std::mt19937());
3828 throw ProcessError(
"State was saved with more than " +
toString(
getNumRNGs()) +
" threads. Change the number of threads or do not load RNG state");
3837 if (bidiEdge ==
nullptr) {
3841 assert(bidiEdge->
getLanes().size() == 1);
std::vector< MSEdge * > MSEdgeVector
std::pair< const MSVehicle *, double > CLeaderDist
std::pair< const MSPerson *, double > PersonDist
ConstMSEdgeVector::const_iterator MSRouteIterator
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
const SVCPermissions SVCAll
all VClasses are allowed
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
@ SVC_SHIP
is an arbitrary ship
@ SVC_BICYCLE
vehicle is a bicycle
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const int STOP_DURATION_SET
@ GIVEN
The speed is given.
@ RANDOM
The lateral position is chosen randomly.
@ RIGHT
At the rightmost side of the lane.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ LEFT
At the leftmost side of the lane.
@ FREE
A free lateral position is chosen.
@ CENTER
At the center of the lane.
@ RANDOM_FREE
If a fixed number of random choices fails, a free lateral position is chosen.
@ RANDOM
The position is chosen randomly.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ STOP
depart position is endPos of first stop
@ 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.
@ RANDOM
The speed is chosen randomly.
@ MAX
The maximum safe speed is used.
@ GIVEN
The speed is given.
@ LIMIT
The maximum lane speed is used (speedLimit)
@ DEFAULT
No information given; use default.
@ DESIRED
The maximum lane speed is used (speedLimit * speedFactor)
@ SUMO_TAG_LINK
Link information for state-saving.
@ SUMO_TAG_APPROACHING
Link-approaching vehicle information for state-saving.
@ SUMO_TAG_VIEWSETTINGS_VEHICLES
@ SUMO_TAG_LANE
begin/end of the description of a single lane
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.
@ SUMO_ATTR_ARRIVALSPEEDBRAKING
@ SUMO_ATTR_ARRIVALTIMEBRAKING
@ SUMO_ATTR_STATE
The state of a link.
int gPrecision
the precision for floating point outputs
bool gDebugFlag1
global utility flags for debugging
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
A scoped lock which only triggers on condition.
Container & getContainer()
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
static double sum(double val)
Computes the resulting noise.
static bool haveLateralDynamics()
whether any kind of lateral dynamics is active
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
double getImpatience() const
Returns this vehicles impatience.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
bool isParking() const
Returns whether the vehicle is parking.
bool hasDeparted() const
Returns whether this vehicle has already departed.
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=nullptr)
Adds a stop.
NumericalID getNumericalID() const
return the numerical ID which is only for internal usage
SUMOTime getDepartDelay() const
Returns the depart delay.
const MSRoute & getRoute() const
Returns the current route.
bool isStopped() const
Returns whether the vehicle is at a stop.
The car-following model abstraction.
virtual double getSecureGap(const MSVehicle *const, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
double getCollisionMinGapFactor() const
Get the factor of minGap that must be maintained to avoid a collision event.
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
virtual double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage....
virtual double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false) const
Computes the vehicle's safe speed without a leader.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
virtual double insertionStopSpeed(const MSVehicle *const veh, double speed, double gap) const
Computes the vehicle's safe speed for approaching an obstacle at insertion without constraints due to...
virtual double stopSpeed(const MSVehicle *const veh, const double speed, double gap) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
std::string toString() const
print a debugging representation
int addFollower(const MSVehicle *veh, const MSVehicle *ego, double gap, double latOffset=0, int sublane=-1)
void gotActive(MSLane *l)
Informs the control that the given lane got active.
void needsVehicleIntegration(MSLane *const l)
A road/street connecting two junctions.
void changeLanes(SUMOTime t) const
Performs lane changing on this edge.
int getPriority() const
Returns the priority of the edge.
const MSEdgeVector & getPredecessors() const
const MSEdge * getNormalSuccessor() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
void recalcCache()
Recalculates the cached values.
bool isInternal() const
return whether this edge is an internal edge
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
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.
const std::string & getEdgeType() const
Returns the type of the edge.
const MSJunction * getToJunction() const
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
static SUMOTime gTimeToGridlockHighways
static double gLateralResolution
static int gNumSimThreads
how many threads to use for simulation
static SUMOTime gLaneChangeDuration
static bool gUnitTests
whether unit tests are being run
static SUMOTime gTimeToGridlock
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
SumoXMLNodeType getType() const
return the type of this Junction
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
int myI2
index for myPartialVehicles
bool nextIsMyVehicles() const
int myI3
index for myTmpVehicles
int myDirection
index delta
AnyVehicleIterator & operator++()
const MSVehicle * operator*()
int myI3End
end index for myTmpVehicles
int myI1End
end index for myVehicles
int myI1
index for myVehicles
Sorts edges by their angle relative to the given edge (straight comes first)
by_connections_to_sorter(const MSEdge *const e)
constructor
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
Sorts lanes (their origin link) by the priority of their noninternal target edges or,...
outgoing_lane_priority_sorter(const MSLane *sourceLane)
constructor
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Sorts vehicles by their position (descending)
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Representation of a lane in the micro simulation.
void addApproachingLane(MSLane *lane, bool warnMultiCon)
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
detect whether there is a collision between the two vehicles
SVCPermissions myPermissions
The vClass permissions for this lane.
MSLane * myLogicalPredecessorLane
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned.
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
bool checkForPedestrians(const MSVehicle *aVehicle, double &speed, double &dist, double pos, bool patchSpeed) const
check whether pedestrians on this lane interfere with vehicle insertion
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
virtual ~MSLane()
Destructor.
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
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
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
double myLength
Lane length [m].
bool isApproachedFrom(MSEdge *const edge)
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1
PositionVector myShape
The shape of the lane.
std::map< long long, SVCPermissions > myPermissionChanges
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
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.
void initRestrictions()
initialized vClass-specific speed limits
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
bool hasApproaching() const
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
bool checkFailure(const MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
static SUMOTime myCollisionStopTime
static CollisionAction myCollisionAction
the action to take on collisions
MSLane * myCanonicalSuccessorLane
Main successor lane,.
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
void sortPartialVehicles()
sorts myPartialVehicles
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
take action upon collision
const MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else nullptr.
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
static bool myCheckJunctionCollisions
static void clear()
Clears the dictionary.
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
MSEdge *const myEdge
The lane's edge, for routing only.
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
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
std::vector< std::string > myNeighs
double myMaxSpeed
Lane-wide speedlimit [m/s].
std::pair< const MSPerson *, double > nextBlocking(double minPos, double minRight, double maxLeft, double stopTime=0) const
This is just a wrapper around MSPModel::nextBlocking. You should always check using hasPedestrians be...
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
static std::vector< std::mt19937 > myRNGs
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
const bool myIsRampAccel
whether this lane is an acceleration lane
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step....
static void saveRNGStates(OutputDevice &out)
save random number generator states to the given output device
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
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)
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
static void initCollisionOptions(const OptionsCont &oc)
int myNumericalID
Unique numerical ID (set on reading by netload)
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
std::vector< MSVehicle * > VehCont
Container for vehicles.
static DictType myDict
Static dictionary to associate string-ids with objects.
static void fill(RTREE &into)
Fills the given RTree with lane instances.
double safeInsertionSpeed(const MSVehicle *veh, double seen, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
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)
std::vector< const MSJunction * > getUpcomingJunctions(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming junctions within given range along the given (non-internal) continuation lanes m...
void addIncomingLane(MSLane *lane, MSLink *viaLink)
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
void addLink(MSLink *link)
Delayed initialization.
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
void enteredByLaneChange(MSVehicle *v)
double getDepartPosLat(const MSVehicle &veh)
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
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, const std::string &type)
Constructor.
static const long CHANGE_PERMISSIONS_PERMANENT
MSLane * getCanonicalPredecessorLane() const
std::set< const MSVehicle * > myParkingVehicles
void resetPermissions(long long transientID)
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
static void loadRNGState(int index, const std::string &state)
load random number generator state for the given rng index
const std::string myLaneType
the type of this lane
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step....
double getLength() const
Returns the lane's length.
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
std::vector< const MSLink * > getUpcomingLinks(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming links within given range along the given (non-internal) continuation lanes measu...
const MSLane * getFirstInternalInConnection(double &offset) const
Returns 0 if the lane is not internal. Otherwise the first part of the connection (sequence of intern...
static int getNumRNGs()
return the number of RNGs
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
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.
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
static void initRNGs(const OptionsCont &oc)
initialize rngs
std::set< MSVehicle * > getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr< LaneCoverageInfo > checkedLanes) const
Returns all vehicles closer than downstreamDist along the along the road network starting on the give...
double getStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
void clearState()
Remove all vehicles before quick-loading state.
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
bool myNeedsCollisionCheck
whether a collision check is currently needed
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double getRightSideOnEdge() const
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
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...
bool hasPedestrians() const
whether the lane has pedestrians on it
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
MSVehicle * getPartialBehind(const MSVehicle *ego) const
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
void leftByLaneChange(MSVehicle *v)
MSLane * getCanonicalSuccessorLane() const
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
const double myWidth
Lane width [m].
bool lastInsertion(MSVehicle &veh, double mspeed, double posLat, bool patchSpeed)
inserts vehicle as close as possible to the last vehicle on this lane (or at the end of the lane if t...
void changeLanes(const SUMOTime time)
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
const double myLengthGeometryFactor
precomputed myShape.length / myLength
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
int myIndex
The lane index.
double getMeanSpeedBike() const
get the mean speed of all bicycles on this lane
void updateLeaderInfo(const MSVehicle *veh, VehCont::reverse_iterator &vehPart, VehCont::reverse_iterator &vehRes, MSLeaderInfo &ahead) const
This updates the MSLeaderInfo argument with respect to the given MSVehicle. All leader-vehicles on th...
FXSynchQue< MSVehicle *, std::vector< MSVehicle * > > myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
void detectPedestrianJunctionCollision(const MSVehicle *collider, const PositionVector &colliderBoundary, const MSLane *foeLane, SUMOTime timestep, const std::string &stage)
detect whether a vehicle collids with pedestrians on the junction
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
std::vector< MSLink * > myLinks
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...
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
void sortManeuverReservations()
sorts myManeuverReservations
MSEdge & getEdge() const
Returns the lane's edge.
std::map< SVCPermissions, double > myStopOffsets
const PositionVector & getShape() const
Returns this lane's shape.
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
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.
static bool myExtrapolateSubstepDepart
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
void addParking(MSVehicle *veh)
add parking vehicle. This should only used during state loading
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
static double myCollisionMinGapFactor
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.
double getCOEmissions() const
Returns the sum of last step CO emissions.
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
@ COLLISION_ACTION_TELEPORT
@ COLLISION_ACTION_REMOVE
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
virtual bool appropriate(const MSVehicle *veh) const
double getWidth() const
Returns the lane's width.
bool freeInsertion(MSVehicle &veh, double speed, double posLat, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
double getMeanSpeed() const
Returns the mean speed on this lane.
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
double getHCEmissions() const
Returns the sum of last step HC emissions.
static CollisionAction getCollisionAction()
saves leader/follower vehicles and their distances relative to an ego vehicle
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0)
int numFreeSublanes() const
virtual std::string toString() const
print a debugging representation
LinkState getState() const
Returns the current state of the link.
MSLane * getLane() const
Returns the connected lane.
std::vector< LinkLeader > LinkLeaders
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
const std::vector< MSLink * > & getFoeLinks() const
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_VAPORIZED_VAPORIZER
The vehicle got vaporized with a vaporizer.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_VAPORIZED_COLLISION
The vehicle got removed by a collision.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
The simulated network and simulation perfomer.
@ VEHICLE_STATE_COLLISION
The vehicle is involved in a collision.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
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.
MSEdgeControl & getEdgeControl()
Returns the edge control.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
bool hasPersons() const
Returns whether persons are simulated.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
virtual PersonDist nextBlocking(const MSLane *lane, double minPos, double minRight, double maxLeft, double stopTime=0)
returns the next pedestrian beyond minPos that is laterally between minRight and maxLeft or 0
static bool hasInsertionConstraint(MSLink *link, const MSVehicle *veh)
static bool hasOncomingRailTraffic(MSLink *link)
const MSEdge * getLastEdge() const
returns the destination edge
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
const MSLane * lane
The lane to stop at (microsim only)
double getEndPos(const SUMOVehicle &veh) const
return halting position for upcoming stop;
const SUMOVehicleParameter::Stop pars
The stop parameter.
MSPModel * getMovementModel()
Returns the default movement model for this kind of transportables.
bool isRemoteAffected(SUMOTime t) const
The class responsible for building and deletion of vehicles.
void registerTeleportYield()
register one non-collision-related teleport
double getMinDeceleration() const
return the minimum deceleration capability for all vehicles that ever entered the network
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
void registerTeleportJam()
register one non-collision-related teleport
void registerCollision()
registers one collision-related teleport
double getMaxSpeedFactor() const
return the maximum speed factor for all vehicles that ever entered the network
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
void registerTeleportWrongLane()
register one non-collision-related teleport
Representation of a vehicle in the micro simulation.
double getRightSideOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
double getSafeFollowSpeed(const std::pair< const MSVehicle *, double > leaderInfo, const double seen, const MSLane *const lane, double distToCrossing) const
compute safe speed for following the given leader
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
const std::vector< MSLane * > & getFurtherLanes() const
void enterLaneAtInsertion(MSLane *enteredLane, double pos, double speed, double posLat, MSMoveReminder::Notification notification)
Update when the vehicle enters a new lane in the emit step.
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
MSAbstractLaneChangeModel & getLaneChangeModel()
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
bool ignoreCollision()
whether this vehicle is except from collision checks
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
PositionVector getBoundingPoly() const
get bounding polygon
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
PositionVector getBoundingBox() const
get bounding rectangle
bool resumeFromStopping()
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
void leaveLane(const MSMoveReminder::Notification reason, const MSLane *approachedLane=0)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
bool isLeader(const MSLink *link, const MSVehicle *veh) const
whether the given vehicle must be followed at the given junction
SUMOTime collisionStopTime() const
Returns the remaining time a vehicle needs to stop due to a collision. A negative value indicates tha...
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
Influencer & getInfluencer()
double getRightSideOnLane() const
Get the vehicle's lateral position on the lane:
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getSpeed() const
Returns the vehicle's current speed.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
double processNextStop(double currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
double getPositionOnLane() const
Get the vehicle's position along the lane.
const MSLane * getLane() const
Returns the lane the vehicle is on.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
bool onFurtherEdge(const MSEdge *edge) const
whether this vehicle has its back (and no its front) on the given edge
double getAngle() const
Returns the vehicle's direction in radians.
bool hasInfluencer() const
void executeFractionalMove(double dist)
move vehicle forward by the given distance during insertion
double getCenterOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void add(const SUMOTime t, MSVehicle *veh)
Adds a vehicle to this transfer object.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getMinGap() const
Get the free space in front of vehicles of this class.
double getLength() const
Get vehicle's length [m].
Base class for objects which have an id.
std::string myID
The name of the object.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
A RT-tree for efficient storing of SUMO's Named objects.
A storage for options typed value containers)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns the information whether the given polygon overlaps with this.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
double angleAt2D(int pos) const
get angle in certain position of position vector
static double rand(std::mt19937 *rng=nullptr)
Returns a random real number in [0, 1)
static std::string saveState(std::mt19937 *rng=0)
save rng state to string
static void loadState(const std::string &state, std::mt19937 *rng=0)
load rng state from string
static void initRand(std::mt19937 *which=nullptr, const bool random=false, const int seed=23423)
Initialises the random number generator with hardware randomness or seed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
Representation of a vehicle.
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
int parametersSet
Information for the output which parameter were set.
double endPos
The stopping position end.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::pair< MSVehicle *, double > vehAndGap