47 #define DEBUGCOND(PED) ((PED).myPerson->isSelected())
48 #define DEBUGCOND2(LANE) ((LANE)->isSelected())
52 for (
int i = 0; i < (int)obs.size(); ++i) {
54 <<
"(" << obs[i].description
55 <<
" x=(" << obs[i].xBack <<
"," << obs[i].xFwd
56 <<
") s=" << obs[i].speed
100 #define MINGAP_TO_VEHICLE 0.25
108 myNumActivePedestrians(0),
138 const MSLane* lane = getSidewalk<MSEdge, MSLane>(person->
getEdge());
139 if (lane ==
nullptr) {
140 std::string error =
"Person '" + person->
getID() +
"' could not find sidewalk on edge '" + person->
getEdge()->
getID() +
"', time="
166 const MSLane* lane =
dynamic_cast<PState*
>(state)->myLane;
168 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
170 pedestrians.erase(it);
179 double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
181 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
182 const PState& ped = **it_ped;
184 const double leaderBackDist = leaderFrontDist + ped.
getLength();
187 <<
" vehSide=" << vehSide
188 <<
" vehWidth=" << vehWidth
189 <<
" lBD=" << leaderBackDist
190 <<
" lFD=" << leaderFrontDist
193 if (leaderBackDist >= -vehWidth
194 && (leaderFrontDist < 0
199 if (collectBlockers ==
nullptr) {
202 collectBlockers->push_back(ped.
myPerson);
206 if (collectBlockers ==
nullptr) {
209 return collectBlockers->size() > 0;
233 double closest = std::numeric_limits<double>::max();
235 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
236 const PState& ped = **it_ped;
239 if (ped.
myRelX > minPos && (result.first == 0 || closest > relX2)) {
242 const bool overlap = (center + halfWidth > minRight && center - halfWidth < maxLeft);
244 std::cout <<
" nextBlocking lane=" << lane->
getID()
245 <<
" minPos=" << minPos <<
" minRight=" << minRight <<
" maxLeft=" << maxLeft
246 <<
" stopTime=" << stopTime
249 <<
" relX2=" << relX2
250 <<
" center=" << center
251 <<
" pedLeft=" << center + halfWidth
252 <<
" pedRight=" << center - halfWidth
253 <<
" overlap=" << overlap
296 if (from ==
nullptr || to ==
nullptr) {
318 for (
MSLink* link : lane->getLinkCont()) {
319 if (link->getWalkingAreaFoe() !=
nullptr) {
321 myWalkingAreaFoes[&link->getWalkingAreaFoe()->getEdge()].push_back(link->getLaneBefore());
324 if (link->getWalkingAreaFoeExit() !=
nullptr) {
326 myWalkingAreaFoes[&link->getWalkingAreaFoeExit()->getEdge()].push_back(link->getLaneBefore());
338 const MSLane* walkingArea = getSidewalk<MSEdge, MSLane>(edge);
342 std::vector<const MSLane*> lanes;
344 for (
int j = 0; j < (int)incoming.size(); ++j) {
345 lanes.push_back(getSidewalk<MSEdge, MSLane>(incoming[j]));
348 for (
int j = 0; j < (int)outgoing.size(); ++j) {
349 lanes.push_back(getSidewalk<MSEdge, MSLane>(outgoing[j]));
352 for (
int j = 0; j < (int)lanes.size(); ++j) {
353 for (
int k = 0; k < (int)lanes.size(); ++k) {
356 const MSLane* from = lanes[j];
357 const MSLane* to = lanes[k];
363 const double maxExtent = fromPos.
distanceTo2D(toPos) / 4;
364 const double extrapolateBy =
MIN2(maxExtent, walkingArea->
getWidth() / 2);
366 shape.push_back(fromPos);
376 if (shape.size() < 2) {
380 assert(shape.size() == 2);
400 std::vector<const MSLane*> lanes;
402 for (
int j = 0; j < (int)incoming.size(); ++j) {
403 lanes.push_back(getSidewalk<MSEdge, MSLane>(incoming[j]));
406 for (
int j = 0; j < (int)outgoing.size(); ++j) {
407 lanes.push_back(getSidewalk<MSEdge, MSLane>(outgoing[j]));
409 if (lanes.size() < 1) {
410 throw ProcessError(
"Invalid walkingarea '" + walkingArea->
getID() +
"' does not allow continuation.");
421 const MSLane* nextRouteLane = getSidewalk<MSEdge, MSLane>(nextRouteEdge);
423 const MSLane* nextLane = nextRouteLane;
427 if (nextRouteLane ==
nullptr && nextRouteEdge !=
nullptr) {
428 std::string error =
"Person '" + ped.
myPerson->
getID() +
"' could not find sidewalk on edge '" + nextRouteEdge->
getID() +
"', time="
432 nextRouteLane = nextRouteEdge->
getLanes().front();
438 if (nextRouteLane !=
nullptr) {
443 nextLane = currentLane->
getLinkCont()[0]->getViaLaneOrLane();
448 std::cout <<
" internal\n";
453 nextLane = currentLane->
getLinkCont()[0]->getLane();
458 std::cout <<
" crossing\n";
465 const double arrivalPos = (nextRouteEdge == ped.
myStage->
getRoute().back()
469 if (prevLane !=
nullptr) {
470 prohibited.push_back(&prevLane->
getEdge());
475 <<
" nre=" << nextRouteEdge->
getID()
476 <<
" nreDir=" << nextRouteEdgeDir
477 <<
" aPos=" << arrivalPos
478 <<
" crossingRoute=" <<
toString(crossingRoute)
481 if (crossingRoute.size() > 1) {
482 const MSEdge* nextEdge = crossingRoute[1];
483 nextLane = getSidewalk<MSEdge, MSLane>(crossingRoute[1]);
485 assert(nextLane != prevLane);
488 std::cout <<
" nextDir=" << nextDir <<
"\n";
504 <<
" no route from '" << (currentEdge ==
nullptr ?
"NULL" : currentEdge->
getID())
505 <<
"' to '" << (nextRouteEdge ==
nullptr ?
"NULL" : nextRouteEdge->
getID())
509 +
"' from walkingArea '" + currentEdge->
getID()
510 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
513 nextLane = nextRouteLane;
515 }
else if (currentEdge == nextRouteEdge) {
517 nextDir = -ped.
myDir;
522 if (nextLane !=
nullptr) {
525 std::cout <<
" next walkingArea " << (nextDir ==
FORWARD ?
"forward" :
"backward") <<
"\n";
534 if (link !=
nullptr) {
536 std::cout <<
" direct forward\n";
542 if (link !=
nullptr) {
544 std::cout <<
" direct backward\n";
547 if (nextLane !=
nullptr) {
549 while (nextLane->
getLinkCont()[0]->getViaLaneOrLane()->isInternal()) {
550 nextLane = nextLane->
getLinkCont()[0]->getViaLaneOrLane();
556 if (nextLane ==
nullptr) {
558 nextLane = nextRouteLane;
560 std::cout <<
SIMTIME <<
" no next lane found for " << currentLane->
getID() <<
" dir=" << ped.
myDir <<
"\n";
564 +
"' from edge '" + currentEdge->
getID()
565 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
580 nextLane = nextRouteLane;
589 <<
" l=" << currentLane->
getID()
590 <<
" nl=" << (nextLane ==
nullptr ?
"NULL" : nextLane->
getID())
591 <<
" nrl=" << (nextRouteLane ==
nullptr ?
"NULL" : nextRouteLane->
getID())
594 <<
" pedDir=" << ped.
myDir
597 assert(nextLane != 0 || nextRouteLane == 0);
606 for (MSLinkCont::const_iterator it = links.begin(); it != links.end(); ++it) {
607 if ((*it)->getLane()->getEdge().isWalkingArea()) {
613 const std::vector<MSLane::IncomingLaneInfo>& laneInfos = currentLane->
getIncomingLanes();
614 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = laneInfos.begin(); it != laneInfos.end(); ++it) {
615 if ((*it).lane->getEdge().isWalkingArea()) {
616 link = (*it).viaLink;
627 const PState& ego = *pedestrians[egoIndex];
629 std::vector<bool> haveBlocker(stripes,
false);
630 for (
int index = egoIndex + 1; index < (int)pedestrians.size(); index++) {
631 const PState& p = *pedestrians[index];
638 std::cout <<
" dist=" << ego.
distanceTo(o) << std::endl;
646 haveBlocker[p.
stripe()] =
true;
649 if (!haveBlocker[p.
stripe()]) {
667 int offset = (destStripes - origStripes) / 2;
669 offset += (destStripes - origStripes) % 2;
677 MSLane* lane,
const MSLane* nextLane,
int stripes,
int nextDir,
678 double currentLength,
int currentDir) {
679 if (nextLanesObs.count(nextLane) == 0) {
686 const int offset =
getStripeOffset(nextStripes, stripes, currentDir != nextDir && nextStripes > stripes);
697 if (nextStripes < stripes) {
699 for (
int ii = 0; ii < stripes; ++ii) {
700 if (ii < offset || ii >= nextStripes + offset) {
711 if ((stripes - nextStripes) % 2 != 0) {
714 nextDir = currentDir;
716 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
717 PState& p = *pedestrians[ii];
722 const double newY = relPos.
y() + lateral_offset;
733 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(nextDir));
734 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
735 const PState& p = *pedestrians[ii];
741 if (nextDir != currentDir) {
746 const int stripe = p.
stripe(newY);
747 if (stripe >= 0 && stripe < stripes) {
751 if (otherStripe >= 0 && otherStripe < stripes) {
752 obs[otherStripe] = pObs;
767 nextLanesObs[nextLane] = obs;
769 return nextLanesObs[nextLane];
774 for (
int ii = 0; ii < (int)obs.size(); ++ii) {
778 o.
xFwd += currentLength;
779 o.
xBack += currentLength;
781 const double tmp = o.
xFwd;
782 o.
xFwd = currentLength + nextLength - o.
xBack;
783 o.
xBack = currentLength + nextLength - tmp;
787 const double tmp = o.
xFwd;
791 o.
xFwd -= nextLength;
792 o.
xBack -= nextLength;
802 if ((dir ==
FORWARD && x - width / 2. < obs[stripe].xBack) || (dir ==
BACKWARD && x + width / 2. > obs[stripe].xFwd)) {
803 obs[stripe] =
Obstacle(x, 0, type,
id, width);
811 const MSLane* lane = it_lane->first;
813 if (pedestrians.size() == 0) {
824 std::set<const WalkingAreaPath*, walkingarea_path_sorter> paths;
825 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
828 if (p->
myDir == dir) {
832 std::cout <<
SIMTIME <<
" debugging WalkingAreaPath from=" << debugPath->
from->
getID() <<
" to=" << debugPath->
to->
getID() <<
"\n";
836 for (std::set<const WalkingAreaPath*, walkingarea_path_sorter>::iterator it = paths.begin(); it != paths.end(); ++it) {
840 transformedPeds.reserve(pedestrians.size());
841 for (Pedestrians::iterator it_p = pedestrians.begin(); it_p != pedestrians.end(); ++it_p) {
846 transformedPeds.push_back(p);
847 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (untransformed), vecCoord="
851 const double newY = relPos.
y() + lateral_offset;
859 toDelete.push_back(tp);
860 transformedPeds.push_back(tp);
861 if (path == debugPath) {
862 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (transformed), vecCoord=" << relPos <<
"\n";
865 if (path == debugPath) {
866 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (invalid), vecCoord=" << relPos <<
"\n";
876 for (
const MSLane* foeLane : itFoe->second) {
882 if (
addVehicleFoe(veh, lane, relPos, lateral_offset, minY, maxY, toDelete, transformedPeds)
883 &&
addVehicleFoe(veh, lane, relPos2, lateral_offset, minY, maxY, toDelete, transformedPeds)) {
887 const double relDist = dist / length;
888 Position between = (relPos * relDist) + (relPos2 * (1 - relDist));
889 addVehicleFoe(veh, lane, between, lateral_offset, minY, maxY, toDelete, transformedPeds);
898 for (Pedestrians::iterator it_p = toDelete.begin(); it_p != toDelete.end(); ++it_p) {
914 const double newY = relPos.
y() + lateral_offset;
915 if (newY >= minY && newY <= maxY) {
918 toDelete.push_back(tp);
919 transformedPeds.push_back(tp);
930 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
932 for (
int i = 0; i < (int)pedestrians.size(); i++) {
933 PState*
const p = pedestrians[i];
937 pedestrians.erase(pedestrians.begin() + i);
940 if (p->
myLane !=
nullptr) {
959 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
962 bool hasCrossingVehObs =
false;
965 hasCrossingVehObs =
addCrossingVehs(lane, stripes, 0, dir, crossingVehs,
true);
968 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
969 PState& p = *pedestrians[ii];
999 nextLanesObs, lane, nextLane, stripes,
1018 const double passingClearanceTime = 2;
1019 const double passingLength = p.
getLength() + passingClearanceTime * speed;
1025 <<
" opened=" << (link ==
nullptr ?
"NULL" :
toString(link->opened(currentTime -
DELTA_T, speed, speed, passingLength, p.
getImpatience(currentTime), speed, 0, 0,
nullptr, p.
ignoreRed(link)))) <<
"\n";
1061 if (hasCrossingVehObs) {
1070 p.
walk(currentObs, currentTime);
1077 for (
int coll = 0; coll < ii; ++coll) {
1078 PState& c = *pedestrians[coll];
1085 +
"', lane='" + lane->
getID() +
"', time=" +
time2string(currentTime) +
".");
1098 bool hasCrossingVehObs =
false;
1103 if (linkLeaders.size() > 0) {
1104 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1106 const MSVehicle* veh = (*it).vehAndGap.first;
1107 if (veh !=
nullptr) {
1119 const double bGap = (prio
1121 : veh->
getSpeed() * distToCrossBeforeVeh);
1125 if ((*it).fromLeft) {
1126 vehYmin = -(*it).vehAndGap.second + lateral_offset;
1130 vehYmax = crossing->
getWidth() + (*it).vehAndGap.second - lateral_offset;
1144 hasCrossingVehObs =
true;
1149 <<
" crossingVeh=" << veh->
getID()
1150 <<
" lane=" << crossing->
getID()
1152 <<
" latOffset=" << lateral_offset
1154 <<
" stripes=" << stripes
1155 <<
" dist=" << (*it).distToCrossing
1156 <<
" gap=" << (*it).vehAndGap.second
1157 <<
" brakeGap=" << bGap
1158 <<
" fromLeft=" << (*it).fromLeft
1159 <<
" distToCrossBefore=" << distToCrossBeforeVeh
1160 <<
" ymin=" << vehYmin
1161 <<
" ymax=" << vehYmax
1170 return hasCrossingVehObs;
1185 if (ped !=
nullptr) {
1205 const double vehNextSpeed =
MAX2(veh->
getSpeed(), 1.0);
1220 if (s == current && vehFront +
SAFETY_GAP < minX) {
1222 if (pRelY - pWidth < vehYmax &&
1223 pRelY + pWidth > vehYmin && dir ==
FORWARD) {
1225 std::cout <<
" ignoring vehicle '" << veh->
getID() <<
" on stripe " << s <<
" vehFrontSG=" << vehFront +
SAFETY_GAP <<
" minX=" << minX <<
"\n";
1236 std::cout <<
SIMTIME <<
" ped=" << pID <<
" veh=" << veh->
getID() <<
" obstacle on lane=" << lane->
getID()
1238 <<
" ymin=" << vehYmin
1239 <<
" ymax=" << vehYmax
1242 <<
" relY=" << pRelY
1243 <<
" current=" << current
1244 <<
" vo.xFwd=" << vo.
xFwd
1245 <<
" vo.xBack=" << vo.
xBack
1261 type(OBSTACLE_NONE),
1267 xFwd(ped.getMaxX()),
1268 xBack(ped.getMinX()),
1269 speed(ped.myDir * ped.mySpeed),
1271 description(ped.getID()) {
1285 myRelX(stage->getDepartPos()),
1286 myRelY(stage->getDepartPosLat()),
1289 myWaitingToEnter(true),
1291 myWalkingAreaPath(nullptr),
1294 myAngle(std::numeric_limits<double>::max()) {
1297 assert(!route.empty());
1298 if (route.size() == 1) {
1304 if (route.front()->isWalkingArea()) {
1311 std::cout <<
" initialize dir for " <<
myPerson->
getID() <<
" forward=" << mayStartForward <<
" backward=" << mayStartBackward <<
"\n";
1313 if (mayStartForward && mayStartBackward) {
1317 if (crossingRoute.size() > 1) {
1319 const MSEdge* nextEdge = crossingRoute[1];
1325 std::cout <<
" crossingRoute=" <<
toString(crossingRoute) <<
"\n";
1354 myWaitingToEnter(false),
1356 myWalkingAreaPath(nullptr),
1359 myAngle(std::numeric_limits<double>::max()) {
1367 return myRelX - getLength();
1369 return myRelX - (includeMinGap ? getMinGap() : 0.);
1377 return myRelX + (includeMinGap ? getMinGap() : 0.);
1379 return myRelX + getLength();
1385 return myPerson->getVehicleType().getLength();
1391 return myPerson->getVehicleType().getMinGap();
1403 const int s = stripe(relY);
1407 if (offset > threshold) {
1409 }
else if (offset < -threshold) {
1434 if (myStage->getNextRouteEdge() ==
nullptr) {
1435 return myDir * (myStage->getArrivalPos() - myRelX) -
POSITION_EPS;
1437 const double length = myWalkingAreaPath ==
nullptr ? myLane->getLength() : myWalkingAreaPath->length;
1438 return myDir ==
FORWARD ? length - myRelX : myRelX;
1445 double dist = distToLaneEnd();
1447 std::cout <<
SIMTIME <<
" ped=" << myPerson->getID() <<
" myRelX=" << myRelX <<
" dist=" << dist <<
"\n";
1455 const int oldDir = myDir;
1456 const MSLane* oldLane = myLane;
1457 myLane = myNLI.lane;
1459 const bool normalLane = (myLane ==
nullptr || myLane->getEdge().getFunction() ==
EDGEFUNC_NORMAL || &myLane->getEdge() == myStage->getNextRouteEdge());
1462 <<
" ped=" << myPerson->getID()
1463 <<
" moveToNextLane old=" << oldLane->
getID()
1464 <<
" new=" << (myLane ==
nullptr ?
"NULL" : myLane->getID())
1465 <<
" oldDir=" << oldDir
1466 <<
" newDir=" << myDir
1467 <<
" myRelX=" << myRelX
1471 if (myLane ==
nullptr) {
1472 myRelX = myStage->getArrivalPos();
1475 if (myStage->getRouteStep() == myStage->getRoute().end() - 1) {
1478 const bool arrived = myStage->moveToNextEdge(myPerson, currentTime, normalLane ?
nullptr : &myLane->getEdge());
1483 assert(myNLI.lane != oldLane);
1485 std::cout <<
" nextLane=" << (myNLI.lane ==
nullptr ?
"NULL" : myNLI.lane->getID()) <<
"\n";
1487 if (myLane->getEdge().isWalkingArea()) {
1490 assert(myWalkingAreaPath->from != 0);
1491 assert(myWalkingAreaPath->to != 0);
1492 assert(myWalkingAreaPath->shape.size() >= 2);
1494 std::cout <<
" mWAPath shape=" << myWalkingAreaPath->shape <<
" length=" << myWalkingAreaPath->length <<
"\n";
1500 const MSEdge* currRouteEdge = myStage->getRouteEdge();
1501 const MSEdge* nextRouteEdge = myStage->getNextRouteEdge();
1509 myStage->moveToNextEdge(myPerson, currentTime,
nullptr);
1510 myLane = myNLI.lane;
1511 assert(myLane != 0);
1514 myWalkingAreaPath =
nullptr;
1516 throw ProcessError(
"Disconnected walk for person '" + myPerson->getID() +
"'.");
1520 myWalkingAreaPath =
nullptr;
1525 const double newLength = (myWalkingAreaPath ==
nullptr ? myLane->getLength() : myWalkingAreaPath->length);
1526 if (-dist > newLength) {
1533 myRelX = newLength + dist;
1538 std::cout <<
SIMTIME <<
" update myRelX ped=" << myPerson->getID()
1539 <<
" newLength=" << newLength
1541 <<
" myRelX=" << myRelX
1545 if (myDir != oldDir) {
1552 std::cout <<
SIMTIME <<
" transformY ped=" << myPerson->getID()
1554 <<
" newY=" << myRelY
1556 <<
" od=" << oldDir <<
" nd=" << myDir
1557 <<
" offset=" << offset <<
"\n";
1569 myAngle = std::numeric_limits<double>::max();
1570 const int stripes = (int)obs.size();
1571 const int sMax = stripes - 1;
1573 const double vMax = myStage->getMaxSpeed(myPerson);
1575 const int current = stripe();
1576 const int other = otherStripe();
1578 std::vector<double> distance(stripes);
1579 for (
int i = 0; i < stripes; ++i) {
1580 distance[i] = distanceTo(obs[i], obs[i].type ==
OBSTACLE_PED);
1583 std::vector<double> utility(stripes, 0);
1585 for (
int i = 0; i < stripes; ++i) {
1587 if (i == current && (!myWaitingToEnter || stripe() != stripe(myRelY))) {
1591 for (
int j = 0; j <= i; ++j) {
1596 for (
int j = i; j < stripes; ++j) {
1605 const bool onJunction = myLane->getEdge().isWalkingArea() || myLane->getEdge().isCrossing();
1608 for (
int i = 0; i < reserved; ++i) {
1612 for (
int i = sMax; i > sMax - reserved; --i) {
1617 for (
int i = 0; i < stripes; ++i) {
1618 if (obs[i].speed * myDir < 0) {
1620 if (myDir ==
FORWARD && i > 0) {
1621 utility[i - 1] -= 0.5;
1622 }
else if (myDir ==
BACKWARD && i < sMax) {
1623 utility[i + 1] -= 0.5;
1627 const double walkDist =
MAX2(0., distance[i]);
1629 const double expectedDist =
MIN2(vMax *
LOOKAHEAD_SAMEDIR, walkDist + obs[i].speed * myDir * lookAhead);
1631 std::cout <<
" util=" << utility[i] <<
" exp=" << expectedDist <<
" dist=" << distance[i] <<
"\n";
1633 if (expectedDist >= 0) {
1634 utility[i] += expectedDist;
1641 if (myDir ==
FORWARD && obs[0].speed < 0) {
1643 }
else if (myDir ==
BACKWARD && obs[sMax].speed > 0) {
1647 if (distance[current] > 0 && myWaitingTime == 0) {
1648 for (
int i = 0; i < stripes; ++i) {
1654 int chosen = current;
1655 for (
int i = 0; i < stripes; ++i) {
1656 if (utility[chosen] < utility[i]) {
1661 const int next = (chosen == current ? current : (chosen < current ? current - 1 : current + 1));
1662 double xDist =
MIN3(distance[current], distance[other], distance[next]);
1663 if (next != chosen) {
1666 const int nextOther = chosen < current ? current - 2 : current + 2;
1667 xDist =
MIN2(xDist, distance[nextOther]);
1676 std::cout <<
" xSpeedPotential=" << xSpeed <<
"\n";
1683 (xDist == distance[current] && obs[current].type >=
OBSTACLE_END)
1684 || (xDist == distance[other] && obs[other].type >=
OBSTACLE_END)
1685 || (xDist == distance[next] && obs[next].type >=
OBSTACLE_END))
1695 +
"' is jammed on edge '" + myStage->getEdge()->getID()
1701 }
else if (stripe(myRelY) >= 0 && stripe(myRelY) <= sMax) {
1726 ySpeed = (yDist > 0 ?
1732 && stripe() == stripe(myRelY)
1734 && !myLane->getEdge().isCrossing()) {
1736 myRelY += myDir * vMax;
1741 <<
" ped=" << myPerson->getID()
1742 <<
" edge=" << myStage->getEdge()->getID()
1746 <<
" pvx=" << mySpeed
1747 <<
" cur=" << current
1748 <<
" cho=" << chosen
1752 <<
" dawdle=" << dawdle
1756 <<
" vMax=" << myStage->getMaxSpeed(myPerson)
1757 <<
" wTime=" << myStage->getWaitingTime(currentTime)
1758 <<
" jammed=" << myAmJammed
1759 <<
"\n distance=" <<
toString(distance)
1760 <<
"\n utility=" <<
toString(utility)
1768 myWaitingToEnter =
false;
1778 return MAX2(0.,
MIN2(1., myPerson->getVehicleType().getImpatience()
1792 return myRemoteXYPos;
1794 if (myLane ==
nullptr) {
1798 const double lateral_offset = myRelY + (
stripeWidth - myLane->getWidth()) * 0.5;
1799 if (myWalkingAreaPath ==
nullptr) {
1813 return myWalkingAreaPath->shape.positionAtOffset(myRelX, lateral_offset);
1820 if (myAngle != std::numeric_limits<double>::max()) {
1823 if (myLane ==
nullptr) {
1827 const PositionVector& shp = myWalkingAreaPath ==
nullptr ? myLane->getShape() : myWalkingAreaPath->shape;
1839 return myWaitingTime;
1851 return myNLI.lane ==
nullptr ? nullptr : &myNLI.lane->getEdge();
1856 double lanePosLat,
double angle,
int routeOffset,
1859 assert(p == myPerson);
1872 if (lane !=
nullptr &&
1875 const MSLane* sidewalk = getSidewalk<MSEdge, MSLane>(&lane->
getEdge());
1876 if (lane != sidewalk) {
1881 pm->
add(
this, lane);
1883 if (edges.empty()) {
1885 myStage->setRouteIndex(myPerson, routeOffset);
1887 myStage->moveToNextEdge(myPerson, t, &lane->
getEdge());
1894 myRelY = (myLane->getWidth() -
stripeWidth) * 0.5 - lanePosLat;
1898 myRemoteXYPos = pos;
1908 const double maxX = getMaxX(includeMinGap);
1909 const double minX = getMinX(includeMinGap);
1913 if ((obs.
xFwd >= maxX && obs.
xBack <= maxX) || (obs.
xFwd <= maxX && obs.
xFwd >= minX)) {
1927 for (
int i = 0; i < (int)into.size(); ++i) {
1929 std::cout <<
" i=" << i <<
" maxX=" << getMaxX(
true) <<
" minX=" << getMinX(
true)
1930 <<
" into=" << into[i].description <<
" iDist=" << distanceTo(into[i], into[i].type ==
OBSTACLE_PED)
1931 <<
" obs2=" << obs2[i].description <<
" oDist=" << distanceTo(obs2[i], obs2[i].type ==
OBSTACLE_PED) <<
"\n";
1933 const double dO = distanceTo(obs2[i], obs2[i].type ==
OBSTACLE_PED);
1934 const double dI = distanceTo(into[i], into[i].type ==
OBSTACLE_PED);
1949 for (
int i = 0; i < (int)into.size(); ++i) {
1950 int i2 = i + offset;
1951 if (i2 >= 0 && i2 < (
int)obs2.size()) {
1953 if (obs2[i2].xBack < into[i].xBack) {
1957 if (obs2[i2].xFwd > into[i].xFwd) {
1970 if (ignoreRedTime >= 0) {
1973 std::cout <<
SIMTIME <<
" ignoreRedTime=" << ignoreRedTime <<
" redDuration=" << redDuration <<
"\n";
1975 return ignoreRedTime > redDuration;
1986 return myPerson->getID();
1991 return myPerson->getVehicleType().getWidth();
2007 return myVehicle->getID();
2012 return myVehicle->getVehicleType().getWidth();
2017 return myRelX - myVehicle->getVehicleType().getWidth() / 2 -
SAFETY_GAP ;
2022 return myRelX + myVehicle->getVehicleType().getWidth() / 2 +
SAFETY_GAP;
2031 std::set<MSPerson*> changedLane;
2036 for (ActiveLanes::const_iterator it_lane =
myModel->getActiveLanes().begin(); it_lane !=
myModel->getActiveLanes().end(); ++it_lane) {
2037 const MSLane* lane = it_lane->first;
2039 if (pedestrians.size() == 0) {
2044 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
2045 const PState& p = *pedestrians[ii];