73 #ifdef CHECK_MEMORY_LEAKS 75 #endif // CHECK_MEMORY_LEAKS 81 #define DEBUG_COND (getID() == "disabled") 82 #define DEBUG_COND2(obj) ((obj != 0 && (obj)->getID() == "disabled")) 183 for (MSLinkCont::iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
206 (*veh)->addReminder(rem);
215 std::cout <<
SIMTIME <<
" setPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
228 std::cout <<
SIMTIME <<
" resetPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
268 const bool adaptSpeed =
false;
276 if (leaderBack >= frontGapNeeded) {
286 bool adaptableSpeed =
true;
295 if (missingRearGap > 0) {
296 if (minPos + missingRearGap <=
myLength) {
303 return isInsertionSuccess(&veh, mspeed, minPos + missingRearGap, 0, adaptableSpeed, notification);
317 if (leaderPos >= frontGapNeeded) {
327 MSLane::VehCont::iterator predIt =
myVehicles.begin();
339 if (adaptableSpeed && leader != 0) {
348 frontMax = leaderRearPos - frontGapNeeded;
356 if (frontMax > minPos && backMin +
POSITION_EPS < frontMax) {
402 bool patchSpeed =
true;
418 for (
int i = 0; i < 10; i++) {
452 for (
int i = 0; i < 10; i++) {
489 if (nspeed < speed) {
491 speed =
MIN2(nspeed, speed);
493 }
else if (speed > 0) {
494 if (errorMsg !=
"") {
495 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (" + errorMsg +
")!");
512 aVehicle->
getID() +
"'. Inserting at lane end instead.");
516 #ifdef DEBUG_INSERTION 517 if (
DEBUG_COND2(aVehicle)) std::cout <<
"\nIS_INSERTION_SUCCESS\n" 519 <<
" veh '" << aVehicle->
getID() <<
"'\n";
526 std::vector<MSLane*>::const_iterator ri = bestLaneConts.begin();
534 if (nextStop.
lane ==
this) {
535 std::stringstream msg;
536 msg <<
"scheduled stop on lane '" <<
myID <<
"' too close";
539 patchSpeed, msg.str())) {
549 MSLane* currentLane =
this;
552 while (seen < dist && ri != bestLaneConts.end()) {
554 MSLinkCont::const_iterator link =
succLinkSec(*aVehicle, nRouteSuccs, *currentLane, bestLaneConts);
560 patchSpeed,
"arrival speed too low")) {
568 patchSpeed,
"junction too close")) {
577 || !(*link)->havePriority()) {
579 std::string errorMsg =
"";
580 const LinkState state = (*link)->getState();
586 errorMsg =
"unpriorised junction too close";
589 patchSpeed, errorMsg)) {
593 #ifdef DEBUG_INSERTION 595 std::cout <<
"trying insertion before minor link: " 596 <<
"insertion speed = " << speed <<
" dist=" << dist
603 nextLane = (*link)->getViaLaneOrLane();
611 if (nextStop.
lane == nextLane) {
612 std::stringstream msg;
613 msg <<
"scheduled stop on lane '" << nextStop.
lane->
getID() <<
"' too close";
616 patchSpeed, msg.str())) {
628 #ifdef DEBUG_INSERTION 630 <<
"leader on lane '" << nextLane->
getID() <<
"': " << leader->
getID() <<
"\n";
639 if (
checkFailure(aVehicle, speed, dist, nspeed, patchSpeed,
"")) {
641 #ifdef DEBUG_INSERTION 643 <<
" isInsertionSuccess lane=" <<
getID()
644 <<
" veh=" << aVehicle->
getID()
646 <<
" posLat=" << posLat
647 <<
" patchSpeed=" << patchSpeed
648 <<
" speed=" << speed
649 <<
" nspeed=" << nspeed
650 <<
" nextLane=" << nextLane->
getID()
651 <<
" lead=" << leader->
getID()
653 <<
" failed (@641)!\n";
660 if (nspeed < speed) {
666 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (slow lane ahead)!");
675 if ((*link)->hasApproachingFoe(arrivalTime, leaveTime, speed, cfModel.
getMaxDecel())) {
683 currentLane = nextLane;
684 #ifdef HAVE_INTERNAL_LANES 685 if ((*link)->getViaLane() == 0) {
700 if (nspeed < 0 ||
checkFailure(aVehicle, speed, dist, nspeed, patchSpeed,
"")) {
705 #ifdef DEBUG_INSERTION 707 <<
" isInsertionSuccess lane=" <<
getID()
708 <<
" veh=" << aVehicle->
getID()
710 <<
" posLat=" << posLat
711 <<
" patchSpeed=" << patchSpeed
712 <<
" speed=" << speed
713 <<
" nspeed=" << nspeed
714 <<
" nextLane=" << nextLane->
getID()
715 <<
" leaders=" << leaders.
toString()
716 <<
" failed (@700)!\n";
720 #ifdef DEBUG_INSERTION 722 <<
" speed = " << speed
723 <<
" nspeed = " << nspeed
728 for (
int i = 0; i < followers.
numSublanes(); ++i) {
729 const MSVehicle* follower = followers[i].first;
732 if (followers[i].second < backGapNeeded) {
734 #ifdef DEBUG_INSERTION 736 <<
" isInsertionSuccess lane=" <<
getID()
737 <<
" veh=" << aVehicle->
getID()
739 <<
" posLat=" << posLat
740 <<
" patchSpeed=" << patchSpeed
741 <<
" speed=" << speed
742 <<
" nspeed=" << nspeed
743 <<
" follower=" << follower->
getID()
744 <<
" backGapNeeded=" << backGapNeeded
745 <<
" gap=" << followers[i].second
746 <<
" failure (@719)!\n";
756 if (missingRearGap > 0) {
758 #ifdef DEBUG_INSERTION 760 <<
" isInsertionSuccess lane=" <<
getID()
761 <<
" veh=" << aVehicle->
getID()
763 <<
" posLat=" << posLat
764 <<
" patchSpeed=" << patchSpeed
765 <<
" speed=" << speed
766 <<
" nspeed=" << nspeed
767 <<
" missingRearGap=" << missingRearGap
768 <<
" failure (@728)!\n";
775 #ifdef DEBUG_INSERTION 777 <<
" isInsertionSuccess lane=" <<
getID()
778 <<
" veh=" << aVehicle->
getID()
780 <<
" posLat=" << posLat
781 <<
" patchSpeed=" << patchSpeed
782 <<
" speed=" << speed
783 <<
" nspeed=" << nspeed
784 <<
" failed (@733)!\n";
790 #ifdef DEBUG_INSERTION 792 <<
" isInsertionSuccess lane=" <<
getID()
793 <<
" veh=" << aVehicle->
getID()
795 <<
" posLat=" << posLat
796 <<
" patchSpeed=" << patchSpeed
797 <<
" speed=" << speed
798 <<
" nspeed=" << nspeed
824 nspeed =
MIN2(nspeed,
838 int freeSublanes = 1;
843 while (freeSublanes > 0 && veh != 0) {
844 #ifdef DEBUG_PLAN_MOVE 846 std::cout <<
" getLastVehicleInformation lane=" <<
getID() <<
" minPos=" << minPos <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
"\n";
852 #ifdef DEBUG_PLAN_MOVE 860 if (ego == 0 && minPos == 0) {
865 #ifdef DEBUG_PLAN_MOVE 890 int freeSublanes = 1;
892 while (freeSublanes > 0 && veh != 0) {
893 #ifdef DEBUG_PLAN_MOVE 895 std::cout <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
" maxPos=" << maxPos <<
"\n";
902 #ifdef DEBUG_PLAN_MOVE 904 std::cout <<
" veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
"\n";
916 #ifdef DEBUG_PLAN_MOVE 942 VehCont::reverse_iterator veh =
myVehicles.rbegin();
944 #ifdef DEBUG_PLAN_MOVE 948 <<
" planMovements lane=" <<
getID()
956 && ((*vehPart)->getPositionOnLane(
this) > (*veh)->getPositionOnLane())) {
957 const SUMOReal latOffset = (*vehPart)->getLatOffset(
this);
958 #ifdef DEBUG_PLAN_MOVE 960 std::cout <<
" partial ahead: " << (*vehPart)->getID() <<
" latOffset=" << latOffset <<
"\n";
963 ahead.
addLeader(*vehPart,
false, latOffset);
966 #ifdef DEBUG_PLAN_MOVE 968 std::cout <<
" plan move for: " << (*veh)->getID() <<
" ahead=" << ahead.
toString() <<
"\n";
971 (*veh)->planMove(t, ahead, cumulatedVehLength);
972 cumulatedVehLength += (*veh)->getVehicleType().getLengthWithGap();
993 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess> toRemove;
994 std::set<const MSVehicle*> toTeleport;
997 VehCont::iterator lastVeh =
myVehicles.end() - 1;
998 for (VehCont::iterator veh =
myVehicles.begin(); veh != lastVeh; ++veh) {
999 VehCont::iterator pred = veh + 1;
1019 if (lead == follow) {
1037 if (lead != 0 && lead != follow && shadowLane->
detectCollisionBetween(timestep, stage, follow, lead, toRemove, toTeleport)) {
1048 const std::vector<const MSLane*>& foeLanes =
myLinks.front()->getFoeLanes();
1053 for (std::vector<const MSLane*>::const_iterator it = foeLanes.begin(); it != foeLanes.end(); ++it) {
1054 const MSLane* foeLane = *it;
1071 for (std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
1075 if (toTeleport.count(veh) > 0) {
1087 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1088 std::set<const MSVehicle*>& toTeleport)
const {
1120 && victim->
getLane() !=
this) {
1133 SUMOReal gap,
SUMOReal latGap, std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1134 std::set<const MSVehicle*>& toTeleport)
const {
1138 prefix =
"Vehicle '" + collider->
getID() +
"'; collision with vehicle '" + victim->
getID() ;
1141 prefix =
"Teleporting vehicle '" + collider->
getID() +
"'; collision with vehicle '" + victim->
getID() ;
1142 toRemove.insert(collider);
1143 toTeleport.insert(collider);
1146 prefix =
"Removing collision participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1147 bool removeCollider =
true;
1148 bool removeVictim =
true;
1153 toRemove.insert(victim);
1155 if (removeCollider) {
1156 toRemove.insert(collider);
1158 if (!removeVictim) {
1159 if (!removeCollider) {
1160 prefix =
"Keeping remote-controlled collision participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1162 prefix =
"Removing collision participant: vehicle '" + collider->
getID() +
"', keeping remote-controlled vehicle '" + victim->
getID();
1164 }
else if (!removeCollider) {
1165 prefix =
"Keeping remote-controlled collision participant: vehicle '" + collider->
getID() +
"', removing vehicle '" + victim->
getID();
1168 toRemove.insert(victim);
1169 toRemove.insert(collider);
1177 +
"', lane='" +
getID()
1179 + (latGap == 0 ?
"" :
"', latGap=" +
toString(latGap))
1181 +
" stage=" + stage +
".");
1205 }
else if (target != 0 && moved) {
1213 lanesWithVehiclesToIntegrate.push_back(target);
1222 WRITE_WARNING(
"Teleporting vehicle '" + veh->
getID() +
"'; beyond end of lane, target lane='" +
getID() +
"', time=" +
1233 i = VehCont::reverse_iterator(
myVehicles.erase(i.base()));
1244 const bool minorLink = !wrongLane && (link !=
myLinks.end()) && !((*link)->havePriority());
1245 const std::string reason = (wrongLane ?
" (wrong lane)" : (minorLink ?
" (yield)" :
" (jam)"));
1252 + (r2 ?
" (highway)" :
"")
1256 }
else if (minorLink) {
1268 lanesWithVehiclesToIntegrate.push_back(
this);
1287 DictType::iterator it =
myDict.find(
id);
1288 if (it ==
myDict.end()) {
1290 myDict.insert(DictType::value_type(
id, ptr));
1299 DictType::iterator it =
myDict.find(
id);
1300 if (it ==
myDict.end()) {
1310 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1319 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1320 into.push_back((*i).first);
1325 template<
class RTREE>
void 1327 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1331 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
1332 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
1333 into.Insert(cmin, cmax, l);
1337 template void MSLane::fill<NamedRTree>(
NamedRTree& into);
1357 return (link !=
myLinks.end());
1368 assert(veh->
getLane() ==
this);
1382 return wasInactive &&
myVehicles.size() != 0;
1460 MSLinkCont::const_iterator
1462 const MSLane& succLinkSource,
const std::vector<MSLane*>& conts) {
1465 if (nRouteEdge == 0) {
1467 return succLinkSource.
myLinks.end();
1471 assert(succLinkSource.
myLinks.size() == 1);
1474 return succLinkSource.
myLinks.begin();
1485 MSLinkCont::const_iterator link;
1486 if (nRouteSuccs < (
int)conts.size()) {
1488 for (link = succLinkSource.
myLinks.begin(); link != succLinkSource.
myLinks.end(); ++link) {
1489 if ((*link)->getLane() != 0 && (*link)->getLane()->myEdge == nRouteEdge && (*link)->getLane()->allowsVehicleClass(veh.
getVehicleType().
getVehicleClass())) {
1491 if ((*link)->getLane() == conts[nRouteSuccs]) {
1498 return succLinkSource.
myLinks.end();
1503 WRITE_WARNING(
"Could not find connection between lane " + succLinkSource.
getID() +
" and lane " + conts[nRouteSuccs]->getID() +
1506 return succLinkSource.
myLinks.end();
1544 assert(remVehicle->
getLane() ==
this);
1546 if (remVehicle == *it) {
1584 WRITE_WARNING(
"Lane '" +
getID() +
"' is approached multiple times from edge '" + approachingEdge->
getID() +
"'. This may cause collisions.");
1598 std::map<MSEdge*, std::vector<MSLane*> >::const_iterator i =
myApproachingLanes.find(edge);
1602 const std::vector<MSLane*>& lanes = (*i).second;
1603 return find(lanes.begin(), lanes.end(), lane) != lanes.end();
1609 inline int operator()(
const std::pair<const MSVehicle*, SUMOReal>& p1,
const std::pair<const MSVehicle*, SUMOReal>& p2)
const {
1610 return p1.second < p2.second;
1621 std::pair<MSVehicle* const, SUMOReal> followerInfo =
getFollowerOnConsecutive(backOffset, leaderSpeed, leaderMaxDecel);
1639 std::pair<MSVehicle* const, SUMOReal>
1649 #ifdef DEBUG_CONTEXT 1651 <<
" backOffset=" << backOffset
1652 <<
" leaderSpeed=" << leaderSpeed
1656 std::pair<MSVehicle*, SUMOReal> result(static_cast<MSVehicle*>(0), -1);
1658 std::set<MSLane*> visited;
1659 std::vector<MSLane::IncomingLaneInfo> newFound;
1661 while (toExamine.size() != 0) {
1662 for (std::vector<MSLane::IncomingLaneInfo>::iterator i = toExamine.begin(); i != toExamine.end(); ++i) {
1663 MSLane* next = (*i).lane;
1664 #ifdef DEBUG_CONTEXT 1666 std::cout <<
SIMTIME <<
" nextLane=" << next->
getID() <<
"\n";
1682 if (!v->isFrontOnLane(next)) {
1683 agap = (*i).length - next->
getLength() + backOffset
1685 - v->getVehicleType().getMinGap();
1691 agap = (*i).length - v->
getPositionOnLane() + backOffset - v->getVehicleType().getMinGap();
1695 agap = (*i).length - v->getPositionOnLane() + backOffset - v->getVehicleType().getMinGap();
1697 #ifdef DEBUG_CONTEXT 1706 const SUMOReal missingRearGap = v->getCarFollowModel().getSecureGap(v->getSpeed(), leaderSpeed, leaderMaxDecel) - agap;
1707 if (missingRearGap > missingRearGapMax) {
1708 missingRearGapMax = missingRearGap;
1710 result.second = agap;
1713 if ((*i).length < dist) {
1714 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
1715 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
1716 if (visited.find((*j).lane) == visited.end()) {
1717 visited.insert((*j).lane);
1719 ili.
lane = (*j).lane;
1720 ili.
length = (*j).length + (*i).length;
1722 newFound.push_back(ili);
1729 swap(newFound, toExamine);
1734 std::pair<MSVehicle* const, SUMOReal>
1738 #ifdef DEBUG_CONTEXT 1743 if (checkTmpVehicles) {
1747 #ifdef DEBUG_CONTEXT 1749 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
1760 #ifdef DEBUG_CONTEXT 1762 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
1771 if (bestLaneConts.size() > 0) {
1777 #ifdef DEBUG_CONTEXT 1779 std::cout <<
" getLeader lane=" <<
getID() <<
" seen=" << seen <<
" dist=" << dist <<
"\n";
1783 return std::pair<MSVehicle* const, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
1787 return std::make_pair(static_cast<MSVehicle*>(0), -1);
1792 std::pair<MSVehicle* const, SUMOReal>
1794 const std::vector<MSLane*>& bestLaneConts)
const {
1795 #ifdef DEBUG_CONTEXT 1797 std::cout <<
" getLeaderOnConsecutive lane=" <<
getID() <<
" ego=" << veh.
getID() <<
" seen=" << seen <<
" dist=" << dist <<
" conts=" <<
toString(bestLaneConts) <<
"\n";
1801 return std::make_pair(static_cast<MSVehicle*>(0), -1);
1808 #ifdef DEBUG_CONTEXT 1815 const MSLane* nextLane =
this;
1818 nextLane->getVehiclesSecure();
1820 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
1821 if (nextLane->isLinkEnd(link) || !(*link)->opened(arrivalTime, speed, speed, veh.
getVehicleType().
getLength(),
1823 #ifdef DEBUG_CONTEXT 1825 std::cout <<
" cannot continue after nextLane=" << nextLane->getID() <<
"\n";
1828 nextLane->releaseVehicles();
1831 #ifdef HAVE_INTERNAL_LANES 1834 nextLane->releaseVehicles();
1835 if (linkLeaders.size() > 0) {
1838 #ifdef DEBUG_CONTEXT 1840 std::cout <<
" found linkLeader after nextLane=" << nextLane->getID() <<
"\n";
1843 return linkLeaders[0].vehAndGap;
1845 bool nextInternal = (*link)->getViaLane() != 0;
1847 nextLane = (*link)->getViaLaneOrLane();
1848 if (nextLane == 0) {
1851 nextLane->getVehiclesSecure();
1852 MSVehicle* leader = nextLane->getLastAnyVehicle();
1854 #ifdef DEBUG_CONTEXT 1856 std::cout <<
" found leader " << leader->
getID() <<
" on nextLane=" << nextLane->getID() <<
"\n";
1860 nextLane->releaseVehicles();
1861 return std::make_pair(leader, dist);
1863 nextLane->releaseVehicles();
1864 if (nextLane->getVehicleMaxSpeed(&veh) < speed) {
1867 seen += nextLane->getLength();
1872 #ifdef HAVE_INTERNAL_LANES 1873 if (!nextInternal) {
1879 }
while (seen <= dist);
1880 return std::make_pair(static_cast<MSVehicle*>(0), -1);
1884 std::pair<MSVehicle* const, SUMOReal>
1887 std::pair<MSVehicle*, SUMOReal> result = std::make_pair(static_cast<MSVehicle*>(0), -1);
1893 const MSLane* nextLane =
this;
1897 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
1902 #ifdef HAVE_INTERNAL_LANES 1905 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1906 const MSVehicle* leader = (*it).vehAndGap.first;
1907 if (leader != 0 && leader != result.first) {
1912 if (tmpSpeed < safeSpeed) {
1913 safeSpeed = tmpSpeed;
1914 result = (*it).vehAndGap;
1918 bool nextInternal = (*link)->getViaLane() != 0;
1920 nextLane = (*link)->getViaLaneOrLane();
1921 if (nextLane == 0) {
1925 if (leader != 0 && leader != result.first) {
1928 if (tmpSpeed < safeSpeed) {
1929 safeSpeed = tmpSpeed;
1930 result = std::make_pair(leader, gap);
1941 #ifdef HAVE_INTERNAL_LANES 1942 if (!nextInternal) {
1948 }
while (seen <= dist);
1961 for (MSEdgeVector::iterator i = pred.begin(); i != pred.end();) {
1970 if (pred.size() != 0) {
1972 MSEdge* best = *pred.begin();
1984 MSLane* cand = (*i).lane;
1985 if (&(cand->
getEdge()) == &fromEdge) {
2004 std::vector<const MSLane*>
2006 std::vector<const MSLane*> result;
2007 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2008 assert((*i)->getLane() != 0);
2009 result.push_back((*i)->getLane());
2031 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2032 if ((*i)->getLane()->getEdge().isCrossing()) {
2033 return (
int)(i -
myLinks.begin());
2077 wtime += (*i)->getWaitingSeconds();
2090 for (VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2091 v += (*i)->getSpeed();
2103 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2104 ret += (*i)->getCO2Emissions();
2115 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2116 ret += (*i)->getCOEmissions();
2127 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2128 ret += (*i)->getPMxEmissions();
2139 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2140 ret += (*i)->getNOxEmissions();
2151 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2152 ret += (*i)->getHCEmissions();
2163 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2164 ret += (*i)->getFuelConsumption();
2175 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2176 ret += (*i)->getElectricityConsumption();
2187 if (vehs.size() == 0) {
2191 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2192 SUMOReal sv = (*i)->getHarmonoise_NoiseEmissions();
2193 ret += (
SUMOReal) pow(10., (sv / 10.));
2224 myLaneDir(e->getLanes()[0]->
getShape().angleAt2D(0)) {
2233 if (ae1 != 0 && ae1->size() != 0) {
2237 if (ae2 != 0 && ae2->size() != 0) {
2257 for (std::vector<std::string>::const_iterator it = vehIds.begin(); it != vehIds.end(); ++it) {
2270 #ifdef DEBUG_CONTEXT 2282 #ifdef DEBUG_CONTEXT 2292 #ifdef DEBUG_CONTEXT 2294 std::cout <<
" (1) added veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
" result=" << result.
toString() <<
"\n";
2299 #ifdef DEBUG_CONTEXT 2301 std::cout <<
" result.numFreeSublanes=" << result.
numFreeSublanes() <<
"\n";
2305 const SUMOReal backOffset = ego->getBackPositionOnLane(ego->getLane());
2312 std::set<MSLane*> visited;
2313 std::vector<MSLane::IncomingLaneInfo> newFound;
2315 while (toExamine.size() != 0) {
2316 for (std::vector<MSLane::IncomingLaneInfo>::iterator it = toExamine.begin(); it != toExamine.end(); ++it) {
2317 MSLane* next = (*it).lane;
2321 #ifdef DEBUG_CONTEXT 2323 std::cout <<
" next=" << next->
getID() <<
" first=" << first.toString() <<
" firstFront=" << firstFront.
toString() <<
"\n";
2326 for (
int i = 0; i < first.numSublanes(); ++i) {
2329 if (v != 0 && v != ego) {
2336 agap = (*it).length - next->
getLength() + backOffset
2343 if (v != 0 && v != ego) {
2353 #ifdef DEBUG_CONTEXT 2360 if ((*it).length < dist) {
2361 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
2362 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
2363 if (visited.find((*j).lane) == visited.end()) {
2364 visited.insert((*j).lane);
2366 ili.
lane = (*j).lane;
2367 ili.
length = (*j).length + (*it).length;
2369 newFound.push_back(ili);
2375 swap(newFound, toExamine);
2400 const MSLane* nextLane =
this;
2406 MSLinkCont::const_iterator link =
succLinkSec(*ego, view, *nextLane, bestLaneConts);
2411 #ifdef HAVE_INTERNAL_LANES 2414 if (linkLeaders.size() > 0) {
2425 bool nextInternal = (*link)->getViaLane() != 0;
2427 nextLane = (*link)->getViaLaneOrLane();
2428 if (nextLane == 0) {
2433 #ifdef DEBUG_CONTEXT 2435 std::cout <<
SIMTIME <<
" getLeadersOnConsecutive lane=" <<
getID() <<
" nextLane=" << nextLane->
getID() <<
" leaders=" << leaders.
toString() <<
"\n";
2440 for (
int i = 0; i < iMax; ++i) {
2443 #ifdef DEBUG_CONTEXT 2463 #ifdef HAVE_INTERNAL_LANES 2464 if (!nextInternal) {
2482 #ifdef DEBUG_CONTEXT 2484 std::cout <<
SIMTIME <<
" getPartialBehind lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" found=" << veh->
getID() <<
"\n";
2490 #ifdef DEBUG_CONTEXT 2511 if (opposite == 0) {
2513 throw ProcessError(
"Lane '" +
getID() +
"' cannot compute oppositePos as there is no opposite lane.");
2520 std::pair<MSVehicle* const, SUMOReal>
2525 #ifdef DEBUG_CONTEXT 2527 std::cout <<
" getFollower lane=" <<
getID() <<
" egoPos=" << egoPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
2539 std::pair<MSVehicle* const, SUMOReal>
2541 #ifdef DEBUG_OPPOSITE 2543 <<
" ego=" << ego->
getID()
2560 std::pair<MSVehicle* const, SUMOReal>
2562 #ifdef DEBUG_OPPOSITE 2564 <<
" ego=" << ego->
getID()
2574 if (result.second > 0) {
2576 return std::make_pair(static_cast<MSVehicle*>(0), -1);
2586 const std::string action = oc.
getString(
"collision.action");
2587 if (action ==
"none") {
2589 }
else if (action ==
"warn") {
2591 }
else if (action ==
"teleport") {
2593 }
else if (action ==
"remove") {
2596 throw ProcessError(
"Invalid collision.action '" + action +
"'.");
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
SUMOReal getOppositePos(SUMOReal pos) const
return the corresponding position on the opposite lane
SUMOReal getWidth() const
Returns the lane's width.
SUMOReal 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) ...
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
const std::map< SUMOVehicleClass, SUMOReal > * myRestrictions
The vClass speed restrictions for this lane.
bool overlapsWith(const AbstractPoly &poly, SUMOReal offset=0) const
Returns the information whether the given polygon overlaps with this.
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
SVCPermissions myPermissions
The vClass permissions for this lane.
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
SUMOReal getLength() const
Returns the lane's length.
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
saves leader/follower vehicles and their distances relative to an ego vehicle
std::pair< MSVehicle *const, SUMOReal > getLeaderOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh, const std::vector< MSLane *> &bestLaneConts) const
Returns the immediate leader and the distance to him.
MSEdge & getEdge() const
Returns the lane's edge.
A free lateral position is chosen.
Representation of a vehicle in the micro simulation.
const MSLeaderInfo & getFirstVehicleInformation(const MSVehicle *ego, SUMOReal latOffset, bool onlyFrontOnLane, SUMOReal maxPos=std::numeric_limits< SUMOReal >::max(), bool allowCached=true) const
analogue to getLastVehicleInformation but in the upstream direction
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
void resetPermissions(long transientID)
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
At the leftmost side of the lane.
SUMOReal getPMxEmissions() const
Returns the sum of last step PMx emissions.
std::pair< MSVehicle *, SUMOReal > vehAndGap
SUMOReal getMaxSpeedFactor() const
return the maximum speed factor for all vehicles that ever entered the network
PositionVector getBoundingPoly() const
get bounding polygon
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
bool checkFailure(MSVehicle *aVehicle, SUMOReal &speed, SUMOReal &dist, const SUMOReal nspeed, const bool patchSpeed, const std::string errorMsg) const
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
MSLane * parallelLane(const MSLane *const lane, int offset) const
Returns the lane with the given offset parallel to the given lane one or 0 if it does not exist...
bool operator()(const MSVehicle *cmp, SUMOReal pos) const
compares vehicle position to the detector position
bool hasDeparted() const
Returns whether this vehicle has already departed.
void setTentativeLaneAndPosition(MSLane *lane, SUMOReal pos, SUMOReal posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
virtual SUMOReal insertionFollowSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage...
SUMOReal getSafeFollowSpeed(const std::pair< const MSVehicle *, SUMOReal > leaderInfo, const SUMOReal seen, const MSLane *const lane, SUMOReal distToCrossing) const
compute safe speed for following the given leader
int myI2
index for myPartialVehicles
void enterLaneAtInsertion(MSLane *enteredLane, SUMOReal pos, SUMOReal speed, SUMOReal posLat, MSMoveReminder::Notification notification)
Update when the vehicle enters a new lane in the emit step.
MSLane * getLane() const
Returns the lane the vehicle is on.
void registerTeleportYield()
register one non-collision-related teleport
static void fill(RTREE &into)
Fills the given RTree with lane instances.
The vehicle arrived at a junction.
bool isVTDAffected(SUMOTime t) const
void recalcCache()
Recalculates the cached values.
This is an uncontrolled, minor link, has to stop.
SUMOReal departSpeed
(optional) The initial speed of the vehicle
std::vector< IncomingLaneInfo > myIncomingLanes
The car-following model abstraction.
int myI2End
end index for myPartialVehicles
void setLength(SUMOReal val)
Sets a new length for the lane (used by TraCI only)
void addLink(MSLink *link)
Delayed initialization.
int myIndex
The lane index.
SUMOReal getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane...
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
The lateral position is chosen randomly.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
SUMOReal arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
If a fixed number of random choices fails, a free lateral position is chosen.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
Notification
Definition of a vehicle state.
static SUMOReal rand()
Returns a random real number in [0, 1)
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSVehicle *victim, SUMOReal gap, SUMOReal latGap, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
take action upon collision
std::string time2string(SUMOTime t)
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
SUMOReal getLength() const
Get vehicle's length [m].
A RT-tree for efficient storing of SUMO's Named objects.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
SUMOReal ymin() const
Returns minimum y-coordinate.
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
const MSEdge *const myEdge
void addIncomingLane(MSLane *lane, MSLink *viaLink)
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
by_connections_to_sorter(const MSEdge *const e)
constructor
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
const PositionVector & getShape() const
Returns this lane's shape.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
The speed is chosen randomly.
PositionVector getBoundingBox() const
get bounding rectangle
bool isLinkEnd(MSLinkCont::const_iterator &i) const
static void initCollisionOptions(const OptionsCont &oc)
void getLeadersOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle *ego, const std::vector< MSLane *> &bestLaneConts, MSLeaderDistanceInfo &result) const
Returns the immediate leaders and the distance to them (as getLeaderOnConsecutive but for the sublane...
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
const MSRoute & getRoute() const
Returns the current route.
The vehicle got vaporized.
SUMOReal getMinDeceleration() const
return the minimum deceleration capability for all vehicles that ever entered the network ...
void leftByLaneChange(MSVehicle *v)
const MSEdge * getLastEdge() const
returns the destination edge
Definition of vehicle stop (position and duration)
This is an uncontrolled, right-before-left link.
std::map< long, SVCPermissions > myPermissionChanges
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
const MSEdgeVector & getIncomingEdges() const
Returns the list of edges from which this edge may be reached.
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
SUMOReal ymax() const
Returns maximum y-coordinate.
const std::string & getID() const
Returns the id.
const SVCPermissions SVCAll
std::pair< MSVehicle *const, SUMOReal > getOppositeLeader(const MSVehicle *ego, SUMOReal dist) const
void gotActive(MSLane *l)
Informs the control that the given lane got active.
const SUMOReal myWidth
Lane width [m].
static SUMOReal angleDiff(const SUMOReal angle1, const SUMOReal angle2)
Returns the difference of the second angle to the first angle in radiants.
bool freeInsertion(MSVehicle &veh, SUMOReal speed, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
The position is chosen randomly.
static bool myCheckJunctionCollisions
This is an uncontrolled, all-way stop link.
SUMOReal myMaxSpeed
Lane-wide speedlimit [m/s].
SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
int myI1End
end index for myVehicles
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge) ...
A class that stores a 2D geometrical boundary.
int myDirection
index delta
SUMOReal xmin() const
Returns minimum x-coordinate.
PositionVector myShape
The shape of the lane.
#define WRITE_WARNING(msg)
bool myDownstream
iteration direction
MSAbstractLaneChangeModel & getLaneChangeModel()
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
const MSEdge * getInternalFollower() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
std::pair< MSVehicle *const, SUMOReal > getLeader(const MSVehicle *veh, const SUMOReal vehPos, const std::vector< MSLane *> &bestLaneConts, SUMOReal dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
std::vector< std::string > myNeighs
LinkState getState() const
Returns the current state of the link.
void setMaxSpeed(SUMOReal val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
static CollisionAction myCollisionAction
the action to take on collisions
const std::string & getEdgeType() const
Returns the type of the edge.
std::map< std::string, MSLane *> DictType
definition of the static dictionary type
SUMOReal getMaximumBrakeDist() const
compute maximum braking distance on this lane
bool lastInsertion(MSVehicle &veh, SUMOReal mspeed)
virtual void incorporateVehicle(MSVehicle *veh, SUMOReal pos, SUMOReal speed, SUMOReal posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
static DictType myDict
Static dictionary to associate string-ids with objects.
void addApproachingLane(MSLane *lane, bool warnMultiCon)
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
A road/street connecting two junctions.
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
SUMOReal getWidth() const
Get the width which vehicles of this class shall have when being drawn.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
SUMOReal myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
SUMOReal getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
const MSVehicle * operator*()
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
SUMOReal getNOxEmissions() const
Returns the sum of last step NOx emissions.
SUMOReal getFuelConsumption() const
Returns the sum of last step fuel consumption.
Representation of a vehicle.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
virtual int addLeader(const MSVehicle *veh, bool beyond, SUMOReal latOffset=0)
This is an uncontrolled, minor link, has to brake.
SUMOReal getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
Sorts vehicles by their position (descending)
bool isVTDControlled() const
SUMOReal getHCEmissions() const
Returns the sum of last step HC emissions.
SUMOReal getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
virtual SUMOReal freeSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal seen, SUMOReal maxSpeed, const bool onInsertion=false) const
Computes the vehicle's safe speed without a leader.
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
void enteredByLaneChange(MSVehicle *v)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the subpart of best lanes that describes the vehicle's current lane and their successors...
std::pair< MSVehicle *const, SUMOReal > getCriticalLeader(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const MSLane * lane
The lane to stop at.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
ConstMSEdgeVector::const_iterator MSRouteIterator
SUMOReal getWaitingSeconds() const
Returns the overall waiting time on this lane.
The vehicle arrived at its destination (is deleted)
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
SUMOReal basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
The maximum speed is used.
std::string toString() const
print a debugging representation
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
SUMOReal getElectricityConsumption() const
Returns the sum of last step electricity consumption.
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
MSVehicle * getPartialBehind(const MSVehicle *ego) const
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
void add(const SUMOTime t, MSVehicle *veh)
Adds a vehicle to this transfer object.
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
std::vector< LinkLeader > LinkLeaders
std::pair< MSVehicle *const, SUMOReal > getFollowerOnConsecutive(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel, SUMOReal dist=-1) const
return the follower with the largest missing rear gap among all predecessor lanes (within dist) ...
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
No information given; use default.
virtual bool executeMovements(SUMOTime t, std::vector< MSLane *> &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
MSLane(const std::string &id, SUMOReal maxSpeed, SUMOReal length, MSEdge *const edge, int numericalID, const PositionVector &shape, SUMOReal width, SVCPermissions permissions, int index)
Constructor.
bool hasInfluencer() const
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
MSLane * myLogicalPredecessorLane
virtual int addLeader(const MSVehicle *veh, SUMOReal gap, SUMOReal latOffset=0, int sublane=-1)
Something on a lane to be noticed about vehicle movement.
SUMOReal myLength
Lane length [m].
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
virtual SUMOReal setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
bool isInternal() const
return whether this edge is an internal edge
void registerTeleportJam()
register one non-collision-related teleport
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
If a fixed number of random choices fails, a free position is chosen.
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
int addFollower(const MSVehicle *veh, const MSVehicle *ego, SUMOReal gap, SUMOReal latOffset=0, int sublane=-1)
std::vector< MSVehicle * > VehCont
Container for vehicles.
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSVehicle *victim, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
detect whether there is a collision between the two vehicles
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Base class for objects which have an id.
int myNumericalID
Unique numerical ID (set on reading by netload)
std::vector< MSMoveReminder *> myMoveReminders
This lane's move reminder.
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, bool allSublanes) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
SUMOReal safeInsertionSpeed(const MSVehicle *veh, const MSLeaderInfo &leaders, SUMOReal speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
SUMOReal getMissingRearGap(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel) const
return by how much further the leader must be inserted to avoid rear end collisions ...
const SUMOReal myLengthGeometryFactor
precomputed myShape.length / myLength
SUMOReal brakeGap(const SUMOReal speed) const
Returns the distance the vehicle needs to halt including driver's reaction time, assuming that during...
AnyVehicleIterator & operator++()
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void leaveLane(const MSMoveReminder::Notification reason)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
void forceVehicleInsertion(MSVehicle *veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat=0)
Inserts the given vehicle at the given position.
SUMOReal getMeanSpeed() const
Returns the mean speed on this lane.
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
void sortPartialVehicles()
sorts myPartialVehicles
void setPermissions(SVCPermissions permissions, long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
virtual std::string toString() const
print a debugging representation
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
static SUMOTime gTimeToGridlockHighways
SUMOReal getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
std::string myID
The name of the object.
The vehicle has departed (was inserted into the network)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
void scheduleVehicleRemoval(SUMOVehicle *veh)
Removes a vehicle after it has ended.
Structure representing possible vehicle parameter.
int myI1
index for myVehicles
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
SUMOReal getCO2Emissions() const
Returns the sum of last step CO2 emissions.
SUMOReal xmax() const
Returns maximum x-coordinate.
SUMOReal myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
MSInsertionControl & getInsertionControl()
Returns the insertion control.
static void clear()
Clears the dictionary.
int operator()(const std::pair< const MSVehicle *, SUMOReal > &p1, const std::pair< const MSVehicle *, SUMOReal > &p2) const
const MSLeaderInfo & getLastVehicleInformation(const MSVehicle *ego, SUMOReal latOffset, SUMOReal minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
bool nextIsMyVehicles() const
MSEdge *const myEdge
The lane's edge, for routing only.
At the rightmost side of the lane.
At the center of the lane.
const MSLane * myLane
the lane that is being iterated
SUMOReal getCOEmissions() const
Returns the sum of last step CO emissions.
A storage for options typed value containers)
static SUMOReal gLateralResolution
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
bool isApproachedFrom(MSEdge *const edge)
virtual SUMOReal stopSpeed(const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) ...
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
const MSEdgeVector & getSuccessors() const
Returns the following edges.
static SUMOReal sum(SUMOReal val)
Computes the resulting noise.
static SUMOTime gTimeToGridlock
SUMOReal departPos
(optional) The position the vehicle shall depart from
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
SUMOReal endPos
The stopping position end.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
void registerCollision()
registers one collision-related teleport
MSEdgeControl & getEdgeControl()
Returns the edge control.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
virtual ~MSLane()
Destructor.
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
SUMOReal myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
bool isInsertionSuccess(MSVehicle *vehicle, SUMOReal speed, SUMOReal pos, SUMOReal posLat, bool recheckNextLanes, MSMoveReminder::Notification notification)
Tries to insert the given vehicle with the given state (speed and pos)
int numFreeSublanes() const
bool isStopped() const
Returns whether the vehicle is at a stop.
No information given; use default.
A free position is chosen.
The class responsible for building and deletion of vehicles.
std::vector< MSEdge * > MSEdgeVector
MSLeaderInfo myLeaderInfoTmp
Insert behind the last vehicle as close as possible to still allow the specified departSpeed. Fallback to DEPART_POS_BASE if there is no vehicle on the departLane yet.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
VehCont myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
bool isParking() const
Returns whether the vehicle is parking.
static const long CHANGE_PERMISSIONS_PERMANENT
SUMOReal getImpatience() const
Returns this vehicles impatience.
The edge is an internal edge.
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
static SUMOTime gLaneChangeDuration
SUMOReal getRightSideOnEdge() const
const std::string & getID() const
Returns the name of the vehicle.
void registerTeleportWrongLane()
register one non-collision-related teleport
SUMOReal departPosLat
(optional) The lateral position the vehicle shall depart from
Representation of a lane in the micro simulation.
SUMOReal getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
std::pair< MSVehicle *const, SUMOReal > getFollower(const MSVehicle *ego, SUMOReal egoPos, SUMOReal dist) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane) ...
virtual const std::string & getID() const =0
Get the vehicle's ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::pair< MSVehicle *const, SUMOReal > getOppositeFollower(const MSVehicle *ego) const
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
virtual bool appropriate(const MSVehicle *veh)
The vehicle is being teleported.
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step...
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
const std::map< SUMOVehicleClass, SUMOReal > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
virtual SUMOReal insertionStopSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap) const
Computes the vehicle's safe speed for approaching an obstacle at insertion without constraints due to...
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.