81 #define DEBUG_COND (getID() == "disabled") 82 #define DEBUG_COND2(obj) ((obj != 0 && (obj)->getID() == "disabled")) 188 for (MSLinkCont::iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
217 (*veh)->addReminder(rem);
226 std::cout <<
SIMTIME <<
" setPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
239 std::cout <<
SIMTIME <<
" resetPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
278 const double posLat = 0;
288 leader = leaderInfo.first;
300 if (leaderBack >= frontGapNeeded) {
301 pos =
MIN2(pos, leaderBack - frontGapNeeded);
315 bool adaptableSpeed =
true;
324 if (missingRearGap > 0) {
325 if (minPos + missingRearGap <=
myLength) {
332 return isInsertionSuccess(&veh, mspeed, minPos + missingRearGap, 0, adaptableSpeed, notification);
344 const double speed = adaptableSpeed ? leader->
getSpeed() : mspeed;
346 if (leaderPos >= frontGapNeeded) {
356 MSLane::VehCont::iterator predIt =
myVehicles.begin();
367 double speed = mspeed;
368 if (adaptableSpeed && leader != 0) {
377 frontMax = leaderRearPos - frontGapNeeded;
385 if (frontMax > minPos && backMin +
POSITION_EPS < frontMax) {
431 bool patchSpeed =
true;
447 for (
int i = 0; i < 10; i++) {
481 for (
int i = 0; i < 10; i++) {
518 if (nspeed < speed) {
520 speed =
MIN2(nspeed, speed);
522 }
else if (speed > 0) {
523 if (errorMsg !=
"") {
524 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (" + errorMsg +
")!");
536 double speed,
double pos,
double posLat,
bool patchSpeed,
541 aVehicle->
getID() +
"'. Inserting at lane end instead.");
545 #ifdef DEBUG_INSERTION 546 if (
DEBUG_COND2(aVehicle)) std::cout <<
"\nIS_INSERTION_SUCCESS\n" 548 <<
" veh '" << aVehicle->
getID() <<
"'\n";
555 std::vector<MSLane*>::const_iterator ri = bestLaneConts.begin();
563 if (nextStop.
lane ==
this) {
564 std::stringstream msg;
565 msg <<
"scheduled stop on lane '" <<
myID <<
"' too close";
566 const double distToStop = nextStop.
endPos - pos;
568 patchSpeed, msg.str())) {
578 MSLane* currentLane =
this;
581 while (seen < dist && ri != bestLaneConts.end()) {
583 MSLinkCont::const_iterator link =
succLinkSec(*aVehicle, nRouteSuccs, *currentLane, bestLaneConts);
589 patchSpeed,
"arrival speed too low")) {
597 patchSpeed,
"junction too close")) {
606 || !(*link)->havePriority()) {
608 std::string errorMsg =
"";
609 const LinkState state = (*link)->getState();
615 errorMsg =
"unpriorised junction too close";
618 patchSpeed, errorMsg)) {
622 #ifdef DEBUG_INSERTION 624 std::cout <<
"trying insertion before minor link: " 625 <<
"insertion speed = " << speed <<
" dist=" << dist
632 nextLane = (*link)->getViaLaneOrLane();
640 if (nextStop.
lane == nextLane) {
641 std::stringstream msg;
642 msg <<
"scheduled stop on lane '" << nextStop.
lane->
getID() <<
"' too close";
643 const double distToStop = seen + nextStop.
endPos;
645 patchSpeed, msg.str())) {
657 #ifdef DEBUG_INSERTION 659 <<
"leader on lane '" << nextLane->
getID() <<
"': " << leader->
getID() <<
"\n";
668 if (
checkFailure(aVehicle, speed, dist, nspeed, patchSpeed,
"")) {
670 #ifdef DEBUG_INSERTION 672 <<
" isInsertionSuccess lane=" <<
getID()
673 <<
" veh=" << aVehicle->
getID()
675 <<
" posLat=" << posLat
676 <<
" patchSpeed=" << patchSpeed
677 <<
" speed=" << speed
678 <<
" nspeed=" << nspeed
679 <<
" nextLane=" << nextLane->
getID()
680 <<
" lead=" << leader->
getID()
682 <<
" failed (@641)!\n";
689 if (nspeed < speed) {
695 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (slow lane ahead)!");
704 if ((*link)->hasApproachingFoe(arrivalTime, leaveTime, speed, cfModel.
getMaxDecel())) {
712 currentLane = nextLane;
713 if ((*link)->getViaLane() == 0) {
725 if (nspeed < 0 ||
checkFailure(aVehicle, speed, dist, nspeed, patchSpeed,
"")) {
730 #ifdef DEBUG_INSERTION 732 <<
" isInsertionSuccess lane=" <<
getID()
733 <<
" veh=" << aVehicle->
getID()
735 <<
" posLat=" << posLat
736 <<
" patchSpeed=" << patchSpeed
737 <<
" speed=" << speed
738 <<
" nspeed=" << nspeed
739 <<
" nextLane=" << nextLane->
getID()
740 <<
" leaders=" << leaders.
toString()
741 <<
" failed (@700)!\n";
745 #ifdef DEBUG_INSERTION 747 <<
" speed = " << speed
748 <<
" nspeed = " << nspeed
753 for (
int i = 0; i < followers.
numSublanes(); ++i) {
754 const MSVehicle* follower = followers[i].first;
757 if (followers[i].second < backGapNeeded) {
759 #ifdef DEBUG_INSERTION 761 <<
" isInsertionSuccess lane=" <<
getID()
762 <<
" veh=" << aVehicle->
getID()
764 <<
" posLat=" << posLat
765 <<
" patchSpeed=" << patchSpeed
766 <<
" speed=" << speed
767 <<
" nspeed=" << nspeed
768 <<
" follower=" << follower->
getID()
769 <<
" backGapNeeded=" << backGapNeeded
770 <<
" gap=" << followers[i].second
771 <<
" failure (@719)!\n";
781 if (missingRearGap > 0) {
783 #ifdef DEBUG_INSERTION 785 <<
" isInsertionSuccess lane=" <<
getID()
786 <<
" veh=" << aVehicle->
getID()
788 <<
" posLat=" << posLat
789 <<
" patchSpeed=" << patchSpeed
790 <<
" speed=" << speed
791 <<
" nspeed=" << nspeed
792 <<
" missingRearGap=" << missingRearGap
793 <<
" failure (@728)!\n";
800 #ifdef DEBUG_INSERTION 802 <<
" isInsertionSuccess lane=" <<
getID()
803 <<
" veh=" << aVehicle->
getID()
805 <<
" posLat=" << posLat
806 <<
" patchSpeed=" << patchSpeed
807 <<
" speed=" << speed
808 <<
" nspeed=" << nspeed
809 <<
" failed (@733)!\n";
815 #ifdef DEBUG_INSERTION 817 <<
" isInsertionSuccess lane=" <<
getID()
818 <<
" veh=" << aVehicle->
getID()
820 <<
" posLat=" << posLat
821 <<
" patchSpeed=" << patchSpeed
822 <<
" speed=" << speed
823 <<
" nspeed=" << nspeed
841 double nspeed = speed;
849 nspeed =
MIN2(nspeed,
863 int freeSublanes = 1;
868 while (freeSublanes > 0 && veh != 0) {
869 #ifdef DEBUG_PLAN_MOVE 871 std::cout <<
" getLastVehicleInformation lane=" <<
getID() <<
" minPos=" << minPos <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
"\n";
877 #ifdef DEBUG_PLAN_MOVE 885 if (ego == 0 && minPos == 0) {
890 #ifdef DEBUG_PLAN_MOVE 915 int freeSublanes = 1;
917 while (freeSublanes > 0 && veh != 0) {
918 #ifdef DEBUG_PLAN_MOVE 920 std::cout <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
" maxPos=" << maxPos <<
"\n";
927 #ifdef DEBUG_PLAN_MOVE 929 std::cout <<
" veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
"\n";
941 #ifdef DEBUG_PLAN_MOVE 964 double cumulatedVehLength = 0.;
967 VehCont::reverse_iterator veh =
myVehicles.rbegin();
969 #ifdef DEBUG_PLAN_MOVE 973 <<
" planMovements lane=" <<
getID()
981 && ((*vehPart)->getPositionOnLane(
this) > (*veh)->getPositionOnLane())) {
982 const double latOffset = (*vehPart)->getLatOffset(
this);
983 #ifdef DEBUG_PLAN_MOVE 985 std::cout <<
" partial ahead: " << (*vehPart)->getID() <<
" latOffset=" << latOffset <<
"\n";
988 ahead.
addLeader(*vehPart,
false, latOffset);
991 #ifdef DEBUG_PLAN_MOVE 993 std::cout <<
" plan move for: " << (*veh)->getID() <<
" ahead=" << ahead.
toString() <<
"\n";
996 (*veh)->planMove(t, ahead, cumulatedVehLength);
997 cumulatedVehLength += (*veh)->getVehicleType().getLengthWithGap();
1005 #ifdef DEBUG_COLLISIONS 1007 std::vector<const MSVehicle*> all;
1009 all.push_back(*last);
1011 std::cout <<
SIMTIME <<
" detectCollisions stage=" << stage <<
" lane=" <<
getID() <<
":\n" 1014 <<
" all=" <<
toString(all) <<
"\n" 1022 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess> toRemove;
1023 std::set<const MSVehicle*> toTeleport;
1026 VehCont::iterator lastVeh =
myVehicles.end() - 1;
1027 for (VehCont::iterator veh =
myVehicles.begin(); veh != lastVeh; ++veh) {
1028 VehCont::iterator pred = veh + 1;
1048 if (lead == follow) {
1067 if (lead != 0 && lead != follow && shadowLane->
detectCollisionBetween(timestep, stage, follow, lead, toRemove, toTeleport)) {
1078 const std::vector<const MSLane*>& foeLanes =
myLinks.front()->getFoeLanes();
1083 for (std::vector<const MSLane*>::const_iterator it = foeLanes.begin(); it != foeLanes.end(); ++it) {
1084 const MSLane* foeLane = *it;
1101 for (std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
1105 if (toTeleport.count(veh) > 0) {
1117 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1118 std::set<const MSVehicle*>& toTeleport)
const {
1128 std::swap(victim, collider);
1135 #ifdef DEBUG_COLLISIONS 1137 <<
" thisLane=" <<
getID()
1138 <<
" collider=" << collider->
getID()
1139 <<
" victim=" << victim->
getID()
1142 <<
" colliderPos=" << colliderPos
1161 && victim->
getLane() !=
this) {
1174 double gap,
double latGap, std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1175 std::set<const MSVehicle*>& toTeleport)
const {
1176 std::string prefix =
"Vehicle '" + collider->
getID() +
"'; collision with vehicle '" + victim->
getID() ;
1181 std::string dummyError;
1201 victim->
addStop(stop, dummyError, 0,
true);
1208 collider->
addStop(stop, dummyError, 0,
true);
1215 prefix =
"Teleporting vehicle '" + collider->
getID() +
"'; collision with vehicle '" + victim->
getID() ;
1216 toRemove.insert(collider);
1217 toTeleport.insert(collider);
1220 prefix =
"Removing collision participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1221 bool removeCollider =
true;
1222 bool removeVictim =
true;
1227 toRemove.insert(victim);
1229 if (removeCollider) {
1230 toRemove.insert(collider);
1232 if (!removeVictim) {
1233 if (!removeCollider) {
1234 prefix =
"Keeping remote-controlled collision participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1236 prefix =
"Removing collision participant: vehicle '" + collider->
getID() +
"', keeping remote-controlled vehicle '" + victim->
getID();
1238 }
else if (!removeCollider) {
1239 prefix =
"Keeping remote-controlled collision participant: vehicle '" + collider->
getID() +
"', removing vehicle '" + victim->
getID();
1242 toRemove.insert(victim);
1243 toRemove.insert(collider);
1252 +
"', lane='" +
getID()
1254 + (latGap == 0 ?
"" :
"', latGap=" +
toString(latGap))
1256 +
" stage=" + stage +
".");
1275 }
else if (target != 0 && moved) {
1283 lanesWithVehiclesToIntegrate.push_back(target);
1292 WRITE_WARNING(
"Teleporting vehicle '" + veh->
getID() +
"'; beyond end of lane, target lane='" +
getID() +
"', time=" +
1318 i = VehCont::reverse_iterator(
myVehicles.erase(i.base()));
1329 const bool minorLink = !wrongLane && (link !=
myLinks.end()) && !((*link)->havePriority());
1330 const std::string reason = (wrongLane ?
" (wrong lane)" : (minorLink ?
" (yield)" :
" (jam)"));
1337 + (r2 ?
" (highway)" :
"")
1341 }
else if (minorLink) {
1353 lanesWithVehiclesToIntegrate.push_back(
this);
1372 DictType::iterator it =
myDict.find(
id);
1373 if (it ==
myDict.end()) {
1375 myDict.insert(DictType::value_type(
id, ptr));
1384 DictType::iterator it =
myDict.find(
id);
1385 if (it ==
myDict.end()) {
1395 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1404 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1405 into.push_back((*i).first);
1410 template<
class RTREE>
void 1412 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1416 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
1417 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
1418 into.Insert(cmin, cmax, l);
1422 template void MSLane::fill<NamedRTree>(
NamedRTree& into);
1442 return (link !=
myLinks.end());
1452 assert(veh->
getLane() ==
this);
1465 #ifdef DEBUG_VEHICLE_CONTAINER 1469 return wasInactive &&
myVehicles.size() != 0;
1547 MSLinkCont::const_iterator
1549 const MSLane& succLinkSource,
const std::vector<MSLane*>& conts) {
1552 if (nRouteEdge == 0) {
1554 return succLinkSource.
myLinks.end();
1558 assert(succLinkSource.
myLinks.size() == 1);
1561 return succLinkSource.
myLinks.begin();
1572 MSLinkCont::const_iterator link;
1573 if (nRouteSuccs < (
int)conts.size()) {
1575 for (link = succLinkSource.
myLinks.begin(); link != succLinkSource.
myLinks.end(); ++link) {
1576 if ((*link)->getLane() != 0 && (*link)->getLane()->myEdge == nRouteEdge && (*link)->getLane()->allowsVehicleClass(veh.
getVehicleType().
getVehicleClass())) {
1578 if ((*link)->getLane() == conts[nRouteSuccs]) {
1585 return succLinkSource.
myLinks.end();
1590 WRITE_WARNING(
"Could not find connection between lane " + succLinkSource.
getID() +
" and lane " + conts[nRouteSuccs]->getID() +
1593 return succLinkSource.
myLinks.end();
1605 MSLinkCont::const_iterator l =
myLinks.begin();
1608 if ((*l)->getViaLane()->getID() == target->
getID()) {
1615 if ((*l)->getLane()->getID() == target->
getID()) {
1629 const MSLane*
internal =
this;
1668 assert(remVehicle->
getLane() ==
this);
1670 if (remVehicle == *it) {
1708 WRITE_WARNING(
"Lane '" +
getID() +
"' is approached multiple times from edge '" + approachingEdge->
getID() +
"'. This may cause collisions.");
1722 std::map<MSEdge*, std::vector<MSLane*> >::const_iterator i =
myApproachingLanes.find(edge);
1726 const std::vector<MSLane*>& lanes = (*i).second;
1727 return find(lanes.begin(), lanes.end(), lane) != lanes.end();
1733 inline int operator()(
const std::pair<const MSVehicle*, double>& p1,
const std::pair<const MSVehicle*, double>& p2)
const {
1734 return p1.second < p2.second;
1746 const MSVehicle* v = followerInfo.first;
1764 std::pair<MSVehicle* const, double>
1765 MSLane::getLeader(
const MSVehicle* veh,
const double vehPos,
const std::vector<MSLane*>& bestLaneConts,
double dist,
bool checkTmpVehicles)
const {
1768 #ifdef DEBUG_CONTEXT 1773 if (checkTmpVehicles) {
1780 #ifdef DEBUG_CONTEXT 1782 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
1796 #ifdef DEBUG_CONTEXT 1798 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos
1808 if (bestLaneConts.size() > 0) {
1814 #ifdef DEBUG_CONTEXT 1816 std::cout <<
" getLeader lane=" <<
getID() <<
" seen=" << seen <<
" dist=" << dist <<
"\n";
1820 return std::pair<MSVehicle* const, double>(
static_cast<MSVehicle*
>(0), -1);
1824 return std::make_pair(static_cast<MSVehicle*>(0), -1);
1829 std::pair<MSVehicle* const, double>
1831 const std::vector<MSLane*>& bestLaneConts)
const {
1832 #ifdef DEBUG_CONTEXT 1834 std::cout <<
" getLeaderOnConsecutive lane=" <<
getID() <<
" ego=" << veh.
getID() <<
" seen=" << seen <<
" dist=" << dist <<
" conts=" <<
toString(bestLaneConts) <<
"\n";
1838 return std::make_pair(static_cast<MSVehicle*>(0), -1);
1845 #ifdef DEBUG_CONTEXT 1852 const MSLane* nextLane =
this;
1855 nextLane->getVehiclesSecure();
1857 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
1858 if (nextLane->isLinkEnd(link) || !(*link)->opened(arrivalTime, speed, speed, veh.
getVehicleType().
getLength(),
1860 #ifdef DEBUG_CONTEXT 1862 std::cout <<
" cannot continue after nextLane=" << nextLane->getID() <<
"\n";
1865 nextLane->releaseVehicles();
1870 nextLane->releaseVehicles();
1871 if (linkLeaders.size() > 0) {
1874 #ifdef DEBUG_CONTEXT 1876 std::cout <<
" found linkLeader after nextLane=" << nextLane->getID() <<
"\n";
1879 return linkLeaders[0].vehAndGap;
1881 bool nextInternal = (*link)->getViaLane() != 0;
1882 nextLane = (*link)->getViaLaneOrLane();
1883 if (nextLane == 0) {
1886 nextLane->getVehiclesSecure();
1887 MSVehicle* leader = nextLane->getLastAnyVehicle();
1889 #ifdef DEBUG_CONTEXT 1891 std::cout <<
" found leader " << leader->
getID() <<
" on nextLane=" << nextLane->getID() <<
"\n";
1895 nextLane->releaseVehicles();
1896 return std::make_pair(leader, dist);
1898 nextLane->releaseVehicles();
1899 if (nextLane->getVehicleMaxSpeed(&veh) < speed) {
1902 seen += nextLane->getLength();
1907 if (!nextInternal) {
1910 }
while (seen <= dist);
1911 return std::make_pair(static_cast<MSVehicle*>(0), -1);
1915 std::pair<MSVehicle* const, double>
1918 std::pair<MSVehicle*, double> result = std::make_pair(static_cast<MSVehicle*>(0), -1);
1924 const MSLane* nextLane =
this;
1928 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
1935 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1936 const MSVehicle* leader = (*it).vehAndGap.first;
1937 if (leader != 0 && leader != result.first) {
1941 const double tmpSpeed = veh.
getSafeFollowSpeed((*it).vehAndGap, seen, nextLane, (*it).distToCrossing);
1942 if (tmpSpeed < safeSpeed) {
1943 safeSpeed = tmpSpeed;
1944 result = (*it).vehAndGap;
1948 bool nextInternal = (*link)->getViaLane() != 0;
1949 nextLane = (*link)->getViaLaneOrLane();
1950 if (nextLane == 0) {
1954 if (leader != 0 && leader != result.first) {
1957 if (tmpSpeed < safeSpeed) {
1958 safeSpeed = tmpSpeed;
1959 result = std::make_pair(leader, gap);
1970 if (!nextInternal) {
1973 }
while (seen <= dist);
1986 for (MSEdgeVector::iterator i = pred.begin(); i != pred.end();) {
1995 if (pred.size() != 0) {
1997 MSEdge* best = *pred.begin();
2009 MSLane* cand = (*i).lane;
2010 if (&(cand->
getEdge()) == &fromEdge) {
2030 #ifdef DEBUG_LANE_SORTER 2031 std::cout <<
"\nBest predecessor lane for lane '" <<
myID <<
"': '" << best.lane->getID() <<
"'" << std::endl;
2046 std::vector<MSLink*> candidateLinks =
myLinks;
2049 MSLane* best = (*candidateLinks.begin())->getViaLaneOrLane();
2050 #ifdef DEBUG_LANE_SORTER 2051 std::cout <<
"\nBest successor lane for lane '" <<
myID <<
"': '" << best->getID() <<
"'" << std::endl;
2069 std::vector<const MSLane*>
2071 std::vector<const MSLane*> result;
2072 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2073 assert((*i)->getLane() != 0);
2074 result.push_back((*i)->getLane());
2096 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2097 if ((*i)->getLane()->getEdge().isCrossing()) {
2098 return (
int)(i -
myLinks.begin());
2142 wtime += (*i)->getWaitingSeconds();
2155 for (VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2156 v += (*i)->getSpeed();
2168 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2169 ret += (*i)->getCO2Emissions();
2180 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2181 ret += (*i)->getCOEmissions();
2192 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2193 ret += (*i)->getPMxEmissions();
2204 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2205 ret += (*i)->getNOxEmissions();
2216 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2217 ret += (*i)->getHCEmissions();
2228 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2229 ret += (*i)->getFuelConsumption();
2240 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2241 ret += (*i)->getElectricityConsumption();
2252 if (vehs.size() == 0) {
2256 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2257 double sv = (*i)->getHarmonoise_NoiseEmissions();
2258 ret += (double) pow(10., (sv / 10.));
2289 myLaneDir(e->getLanes()[0]->
getShape().angleAt2D(0)) {
2300 if (ae1 != 0 && ae1->size() != 0) {
2310 if (ae2 != 0 && ae2->size() != 0) {
2348 #ifdef DEBUG_LANE_SORTER 2349 std::cout <<
"\nincoming_lane_priority sorter()\n" 2350 <<
"noninternal predecessor for lane '" << laneInfo1.
lane->
getID()
2351 <<
"': '" << noninternal1->
getID() <<
"'\n" 2352 <<
"noninternal predecessor for lane '" << laneInfo2.
lane->
getID()
2353 <<
"': '" << noninternal2->
getID() <<
"'\n";
2361 bool priorized1 =
true;
2362 bool priorized2 =
true;
2364 std::vector<MSLink*>::const_iterator j;
2365 #ifdef DEBUG_LANE_SORTER 2366 std::cout <<
"FoeLinks of '" << noninternal1->
getID() <<
"'" << std::endl;
2369 #ifdef DEBUG_LANE_SORTER 2370 std::cout << (*j)->getLaneBefore()->getID() << std::endl;
2378 #ifdef DEBUG_LANE_SORTER 2379 std::cout <<
"FoeLinks of '" << noninternal2->
getID() <<
"'" << std::endl;
2382 #ifdef DEBUG_LANE_SORTER 2383 std::cout << (*j)->getLaneBefore()->getID() << std::endl;
2392 assert(priorized1 || priorized2);
2393 if (priorized1 != priorized2) {
2421 #ifdef DEBUG_LANE_SORTER 2422 std::cout <<
"\noutgoing_lane_priority sorter()\n" 2423 <<
"noninternal successors for lane '" <<
myLane->
getID()
2424 <<
"': '" << target1->
getID() <<
"' and " 2425 <<
"'" << target2->
getID() <<
"'\n";
2432 if (priority1 != priority2) {
2433 return priority1 > priority2;
2459 for (std::vector<std::string>::const_iterator it = vehIds.begin(); it != vehIds.end(); ++it) {
2473 bool allSublanes,
double searchDist,
bool ignoreMinorLinks)
const {
2476 #ifdef DEBUG_CONTEXT 2478 std::cout <<
SIMTIME <<
" getFollowers lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" pos=" << egoPos <<
"\n";
2487 #ifdef DEBUG_CONTEXT 2497 #ifdef DEBUG_CONTEXT 2499 std::cout <<
" (1) added veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
" result=" << result.
toString() <<
"\n";
2504 #ifdef DEBUG_CONTEXT 2506 std::cout <<
" result.numFreeSublanes=" << result.
numFreeSublanes() <<
"\n";
2514 if (searchDist == -1) {
2518 std::set<MSLane*> visited;
2519 std::vector<MSLane::IncomingLaneInfo> newFound;
2521 while (toExamine.size() != 0) {
2522 for (std::vector<MSLane::IncomingLaneInfo>::iterator it = toExamine.begin(); it != toExamine.end(); ++it) {
2523 MSLane* next = (*it).lane;
2527 #ifdef DEBUG_CONTEXT 2529 std::cout <<
" next=" << next->
getID() <<
" first=" << first.toString() <<
" firstFront=" << firstFront.
toString() <<
"\n";
2532 for (
int i = 0; i < first.numSublanes(); ++i) {
2535 if (v != 0 && v != ego) {
2542 agap = (*it).length - next->
getLength() + backOffset
2549 if (v != 0 && v != ego) {
2557 if (!(*it).viaLink->havePriority() && !ego->onFurtherEdge(&(*it).lane->getEdge())) {
2559 agap =
MAX2(agap, 0.0);
2563 #ifdef DEBUG_CONTEXT 2570 if ((*it).length < searchDist) {
2571 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
2572 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
2573 if (visited.find((*j).lane) == visited.end() && ((*j).viaLink->havePriority() || !ignoreMinorLinks)) {
2574 visited.insert((*j).lane);
2576 ili.
lane = (*j).lane;
2577 ili.
length = (*j).length + (*it).length;
2579 newFound.push_back(ili);
2585 swap(newFound, toExamine);
2610 const MSLane* nextLane =
this;
2616 MSLinkCont::const_iterator link =
succLinkSec(*ego, view, *nextLane, bestLaneConts);
2623 if (linkLeaders.size() > 0) {
2634 bool nextInternal = (*link)->getViaLane() != 0;
2635 nextLane = (*link)->getViaLaneOrLane();
2636 if (nextLane == 0) {
2641 #ifdef DEBUG_CONTEXT 2643 std::cout <<
SIMTIME <<
" getLeadersOnConsecutive lane=" <<
getID() <<
" nextLane=" << nextLane->
getID() <<
" leaders=" << leaders.
toString() <<
"\n";
2648 for (
int i = 0; i < iMax; ++i) {
2651 #ifdef DEBUG_CONTEXT 2671 if (!nextInternal) {
2686 #ifdef DEBUG_CONTEXT 2688 std::cout <<
SIMTIME <<
" getPartialBehind lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" found=" << veh->
getID() <<
"\n";
2694 #ifdef DEBUG_CONTEXT 2715 if (opposite == 0) {
2717 throw ProcessError(
"Lane '" +
getID() +
"' cannot compute oppositePos as there is no opposite lane.");
2724 std::pair<MSVehicle* const, double>
2729 #ifdef DEBUG_CONTEXT 2731 std::cout <<
" getFollower lane=" <<
getID() <<
" egoPos=" << egoPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane(
this) <<
"\n";
2740 return std::make_pair(const_cast<MSVehicle*>(result.first), result.second);
2743 std::pair<MSVehicle* const, double>
2745 #ifdef DEBUG_OPPOSITE 2747 <<
" ego=" << ego->
getID()
2751 <<
" oppositeDir=" << oppositeDir
2759 std::pair<MSVehicle* const, double> result =
getFollower(ego, egoPos + egoLength, dist,
true);
2766 std::pair<MSVehicle* const, double>
2768 #ifdef DEBUG_OPPOSITE 2770 <<
" ego=" << ego->
getID()
2780 if (result.second > 0) {
2782 return std::make_pair(static_cast<MSVehicle*>(0), -1);
2792 const std::string action = oc.
getString(
"collision.action");
2793 if (action ==
"none") {
2795 }
else if (action ==
"warn") {
2797 }
else if (action ==
"teleport") {
2799 }
else if (action ==
"remove") {
2802 throw ProcessError(
"Invalid collision.action '" + action +
"'.");
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
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) ...
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
static double gLateralResolution
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 ...
double ymin() const
Returns minimum y-coordinate.
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time, assuming that during...
saves leader/follower vehicles and their distances relative to an ego vehicle
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 xmax() const
Returns maximum x-coordinate.
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
MSEdge & getEdge() const
Returns the lane's edge.
A free lateral position is chosen.
Representation of a vehicle in the micro simulation.
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.
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0)
MSLane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, int index, bool isRampAccel)
Constructor.
int getPriority() const
Returns the priority of the edge.
PositionVector getBoundingPoly() const
get bounding polygon
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
std::string containerstop
(Optional) container stop if one is assigned to the stop
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
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.
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
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...
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
bool parking
whether the vehicle is removed from the net while stopping
MSLane * getLane() const
Returns the connected lane.
double getMaxSpeedFactor() const
return the maximum speed factor for all vehicles that ever entered the network
begin/end of the description of a single lane
bool hasDeparted() const
Returns whether this vehicle has already departed.
int myI2
index for myPartialVehicles
bool resumeFromStopping()
MSLane * getLane() const
Returns the lane the vehicle is on.
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
SUMOTime duration
The stopping duration.
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 registerTeleportYield()
register one non-collision-related teleport
static void fill(RTREE &into)
Fills the given RTree with lane instances.
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
The vehicle arrived at a junction.
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
bool isVTDAffected(SUMOTime t) const
bool freeInsertion(MSVehicle &veh, double speed, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
void recalcCache()
Recalculates the cached values.
This is an uncontrolled, minor link, has to stop.
const MSEdgeVector & getPredecessors() const
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
The car-following model abstraction.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
int myI2End
end index for myPartialVehicles
double getPositionOnLane() const
Get the vehicle's position along the lane.
void addLink(MSLink *link)
Delayed initialization.
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
int myIndex
The lane index.
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)
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.
bool operator()(const MSVehicle *cmp, double pos) const
compares vehicle position to the detector position
static SUMOTime myCollisionStopTime
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
take action upon collision
A RT-tree for efficient storing of SUMO's Named objects.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
detect whether there is a collision between the two vehicles
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
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)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
by_connections_to_sorter(const MSEdge *const e)
constructor
double getLength() const
Returns the lane's length.
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)
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
const MSRoute & getRoute() const
Returns the current route.
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
The vehicle got vaporized.
void leftByLaneChange(MSVehicle *v)
SUMOTime until
The time at which the vehicle may continue its journey.
const MSEdge * getLastEdge() const
returns the destination edge
MSLane * getCanonicalPredecessorLane() const
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.
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 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.
const std::string & getID() const
Returns the id.
const SVCPermissions SVCAll
all VClasses are allowed
void gotActive(MSLane *l)
Informs the control that the given lane got active.
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 setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
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.
double getWidth() const
Returns the lane's width.
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.
virtual double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage...
int myDirection
index delta
std::string parkingarea
(Optional) parking area if one is assigned to the stop
PositionVector myShape
The shape of the lane.
#define WRITE_WARNING(msg)
MSLane * getCanonicalSuccessorLane() 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 myDownstream
iteration direction
MSAbstractLaneChangeModel & getLaneChangeModel()
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
std::vector< std::string > myNeighs
LinkState getState() const
Returns the current state of the link.
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
static CollisionAction getCollisionAction()
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.
Sorts lanes (their origin link) by the priority of their noninternal target edges or...
std::string busstop
(Optional) bus stop if one is assigned to the stop
void addApproachingLane(MSLane *lane, bool warnMultiCon)
double departSpeed
(optional) The initial speed of the vehicle
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.
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.
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane...
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
bool checkFailure(MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
double myLength
Lane length [m].
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...
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
const MSVehicle * operator*()
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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.
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
const bool myIsRampAccel
whether this lane is an acceleration lane
Representation of a vehicle.
double startPos
The stopping position start.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
int operator()(const std::pair< const MSVehicle *, double > &p1, const std::pair< const MSVehicle *, double > &p2) const
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
This is an uncontrolled, minor link, has to brake.
double basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
Sorts vehicles by their position (descending)
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
std::string chargingStation
(Optional) charging station if one is assigned to the stop
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
outgoing_lane_priority_sorter(const MSLane *sourceLane)
constructor
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 best sequence of lanes to continue the route starting at myLane.
const MSLeaderInfo & getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
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) ...
const MSLane * lane
The lane to stop at.
double getMinDeceleration() const
return the minimum deceleration capability for all vehicles that ever entered the network ...
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
bool triggered
whether an arriving person lets the vehicle continue
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
ConstMSEdgeVector::const_iterator MSRouteIterator
The vehicle arrived at its destination (is deleted)
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
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.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false)
Adds a stop.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
Sorts edges by their angle relative to the given edge (straight comes first)
The maximum speed is used.
std::string toString() const
print a debugging representation
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
SUMOTime string2time(const std::string &r)
static double rand()
Returns a random real number in [0, 1)
MSVehicle * getPartialBehind(const MSVehicle *ego) const
double xmin() const
Returns minimum x-coordinate.
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
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
double getImpatience() const
Returns this vehicles impatience.
No information given; use default.
virtual bool executeMovements(SUMOTime t, std::vector< MSLane *> &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
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.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
std::pair< MSVehicle *, double > vehAndGap
Boundary & grow(double by)
extends the boundary by the given amount
bool hasInfluencer() const
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
MSLane * myLogicalPredecessorLane
double endPos
The stopping position end.
double getMinGap() const
Get the free space in front of vehicles of this class.
SUMOTime collisionStopTime() const
Returns the remaining time a vehicle needs to stop due to a collision. A negative value indicates tha...
Something on a lane to be noticed about vehicle movement.
double getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns the information whether the given polygon overlaps with this.
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
bool isInternal() const
return whether this edge is an internal edge
void registerTeleportJam()
register one non-collision-related teleport
double getHCEmissions() const
Returns the sum of last step HC emissions.
If a fixed number of random choices fails, a free position is chosen.
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
std::vector< MSVehicle * > VehCont
Container for vehicles.
bool containerTriggered
whether an arriving container lets the vehicle continue
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.
const MSLane *const myLane
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getRightSideOnEdge() const
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
std::string lane
The lane to stop at.
void initRestrictions()
initialized vClass-specific speed limits
AnyVehicleIterator & operator++()
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
double departPosLat
(optional) The lateral position the vehicle shall depart from
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
void sortPartialVehicles()
sorts myPartialVehicles
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
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
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
double safeInsertionSpeed(const MSVehicle *veh, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
double departPos
(optional) The position the vehicle shall depart from
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
static SUMOTime gTimeToGridlockHighways
std::pair< const MSVehicle *, double > CLeaderDist
int addFollower(const MSVehicle *veh, const MSVehicle *ego, double gap, double latOffset=0, int sublane=-1)
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.
double getCOEmissions() const
Returns the sum of last step CO emissions.
Structure representing possible vehicle parameter.
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.
int myI1
index for myVehicles
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
double processNextStop(double currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
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...
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.
const std::vector< MSLink * > & getFoeLinks()
bool nextIsMyVehicles() const
MSEdge *const myEdge
The lane's edge, for routing only.
Definition of vehicle stop (position and duration)
At the rightmost side of the lane.
At the center of the lane.
const MSLane * myLane
the lane that is being iterated
A storage for options typed value containers)
double angleAt2D(int pos) const
get angle in certain position of position vector
int index
at which position in the stops list
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
bool isApproachedFrom(MSEdge *const edge)
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
const MSEdgeVector & getSuccessors() const
Returns the following edges.
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.
static SUMOTime gTimeToGridlock
double getLength() const
Get vehicle's length [m].
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
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
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
const MSLane *const myLane
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
MSLane * myCanonicalSuccessorLane
Main successor lane,.
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.
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
double getMeanSpeed() const
Returns the mean speed on this lane.
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
virtual ~MSLane()
Destructor.
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
int numFreeSublanes() const
bool isStopped() const
Returns whether the vehicle is at a stop.
double getSecureGap(const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
No information given; use default.
A free position is chosen.
The class responsible for building and deletion of vehicles.
double getMissingRearGap(const MSVehicle *leader, double backOffset, double leaderSpeed) const
return by how much further the leader must be inserted to avoid rear end collisions ...
const double myLengthGeometryFactor
precomputed myShape.length / myLength
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 ...
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
bool isParking() const
Returns whether the vehicle is parking.
double endPos
The stopping position end.
double getSpeed() const
Returns the vehicle's current speed.
static const long CHANGE_PERMISSIONS_PERMANENT
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...
double ymax() const
Returns maximum y-coordinate.
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
double myMaxSpeed
Lane-wide speedlimit [m/s].
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
static double sum(double val)
Computes the resulting noise.
const std::string & getID() const
Returns the name of the vehicle.
void registerTeleportWrongLane()
register one non-collision-related teleport
Representation of a lane in the micro simulation.
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
virtual const std::string & getID() const =0
Get the vehicle's ID.
const double myWidth
Lane width [m].
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
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) ...
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
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.
bool lastInsertion(MSVehicle &veh, double mspeed, bool patchSpeed)
inserts vehicle as close as possible to the last vehicle on this lane (or at the end of the lane if t...
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.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.