48 #define DEBUGCOND(PED) ((PED).myPerson->isSelected())
49 #define DEBUGCOND2(LANE) ((LANE)->isSelected())
53 for (
int i = 0; i < (int)obs.size(); ++i) {
55 <<
"(" << obs[i].description
56 <<
" x=(" << obs[i].xBack <<
"," << obs[i].xFwd
57 <<
") s=" << obs[i].speed
101 #define MINGAP_TO_VEHICLE 0.25
109 myNumActivePedestrians(0),
139 const MSLane* lane = getSidewalk<MSEdge, MSLane>(person->
getEdge());
140 if (lane ==
nullptr) {
141 std::string error =
"Person '" + person->
getID() +
"' could not find sidewalk on edge '" + person->
getEdge()->
getID() +
"', time="
159 PState* ped = dynamic_cast<PState*>(pState);
167 const MSLane* lane = dynamic_cast<PState*>(state)->myLane;
169 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
171 pedestrians.erase(it);
180 double oncomingGap, std::vector<const MSPerson*>* collectBlockers) {
182 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
183 const PState& ped = **it_ped;
185 const double leaderBackDist = leaderFrontDist + ped.
getLength();
188 <<
" vehSide=" << vehSide
189 <<
" vehWidth=" << vehWidth
190 <<
" lBD=" << leaderBackDist
191 <<
" lFD=" << leaderFrontDist
194 if (leaderBackDist >= -vehWidth
195 && (leaderFrontDist < 0
200 if (collectBlockers ==
nullptr) {
203 collectBlockers->push_back(ped.
myPerson);
207 if (collectBlockers ==
nullptr) {
210 return collectBlockers->size() > 0;
234 double closest = std::numeric_limits<double>::max();
236 for (Pedestrians::const_iterator it_ped = pedestrians.begin(); it_ped != pedestrians.end(); ++it_ped) {
237 const PState& ped = **it_ped;
240 if (ped.
myRelX > minPos && (result.first == 0 || closest > relX2)) {
243 const bool overlap = (center + halfWidth > minRight && center - halfWidth < maxLeft);
245 std::cout <<
" nextBlocking lane=" << lane->
getID()
246 <<
" minPos=" << minPos <<
" minRight=" << minRight <<
" maxLeft=" << maxLeft
247 <<
" stopTime=" << stopTime
250 <<
" relX2=" << relX2
251 <<
" center=" << center
252 <<
" pedLeft=" << center + halfWidth
253 <<
" pedRight=" << center - halfWidth
254 <<
" overlap=" << overlap
297 if (from ==
nullptr || to ==
nullptr) {
319 for (
MSLink* link : lane->getLinkCont()) {
320 if (link->getWalkingAreaFoe() !=
nullptr) {
322 myWalkingAreaFoes[&link->getWalkingAreaFoe()->getEdge()].push_back(link->getLaneBefore());
325 if (link->getWalkingAreaFoeExit() !=
nullptr) {
327 myWalkingAreaFoes[&link->getWalkingAreaFoeExit()->getEdge()].push_back(link->getLaneBefore());
339 const MSLane* walkingArea = getSidewalk<MSEdge, MSLane>(edge);
343 std::vector<const MSLane*> lanes;
345 for (
int j = 0; j < (int)incoming.size(); ++j) {
346 lanes.push_back(getSidewalk<MSEdge, MSLane>(incoming[j]));
349 for (
int j = 0; j < (int)outgoing.size(); ++j) {
350 lanes.push_back(getSidewalk<MSEdge, MSLane>(outgoing[j]));
353 for (
int j = 0; j < (int)lanes.size(); ++j) {
354 for (
int k = 0; k < (int)lanes.size(); ++k) {
357 const MSLane* from = lanes[j];
358 const MSLane* to = lanes[k];
364 const double maxExtent = fromPos.
distanceTo2D(toPos) / 4;
365 const double extrapolateBy =
MIN2(maxExtent, walkingArea->
getWidth() / 2);
367 shape.push_back(fromPos);
377 if (shape.size() < 2) {
381 assert(shape.size() == 2);
401 std::vector<const MSLane*> lanes;
403 for (
int j = 0; j < (int)incoming.size(); ++j) {
404 lanes.push_back(getSidewalk<MSEdge, MSLane>(incoming[j]));
407 for (
int j = 0; j < (int)outgoing.size(); ++j) {
408 lanes.push_back(getSidewalk<MSEdge, MSLane>(outgoing[j]));
410 if (lanes.size() < 1) {
411 throw ProcessError(
"Invalid walkingarea '" + walkingArea->
getID() +
"' does not allow continuation.");
422 const MSLane* nextRouteLane = getSidewalk<MSEdge, MSLane>(nextRouteEdge);
424 const MSLane* nextLane = nextRouteLane;
428 if (nextRouteLane ==
nullptr && nextRouteEdge !=
nullptr) {
429 std::string error =
"Person '" + ped.
myPerson->
getID() +
"' could not find sidewalk on edge '" + nextRouteEdge->
getID() +
"', time="
433 nextRouteLane = nextRouteEdge->
getLanes().front();
439 if (nextRouteLane !=
nullptr) {
444 nextLane = currentLane->
getLinkCont()[0]->getViaLaneOrLane();
449 std::cout <<
" internal\n";
454 nextLane = currentLane->
getLinkCont()[0]->getLane();
459 std::cout <<
" crossing\n";
466 const double arrivalPos = (nextRouteEdge == ped.
myStage->
getRoute().back()
470 if (prevLane !=
nullptr) {
471 prohibited.push_back(&prevLane->
getEdge());
476 <<
" nre=" << nextRouteEdge->
getID()
477 <<
" nreDir=" << nextRouteEdgeDir
478 <<
" aPos=" << arrivalPos
479 <<
" crossingRoute=" <<
toString(crossingRoute)
482 if (crossingRoute.size() > 1) {
483 const MSEdge* nextEdge = crossingRoute[1];
484 nextLane = getSidewalk<MSEdge, MSLane>(crossingRoute[1]);
486 assert(nextLane != prevLane);
489 std::cout <<
" nextDir=" << nextDir <<
"\n";
505 <<
" no route from '" << (currentEdge ==
nullptr ?
"NULL" : currentEdge->
getID())
506 <<
"' to '" << (nextRouteEdge ==
nullptr ?
"NULL" : nextRouteEdge->
getID())
510 +
"' from walkingArea '" + currentEdge->
getID()
511 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
514 nextLane = nextRouteLane;
516 }
else if (currentEdge == nextRouteEdge) {
518 nextDir = -ped.
myDir;
523 if (nextLane !=
nullptr) {
526 std::cout <<
" next walkingArea " << (nextDir ==
FORWARD ?
"forward" :
"backward") <<
"\n";
535 if (link !=
nullptr) {
537 std::cout <<
" direct forward\n";
543 if (link !=
nullptr) {
545 std::cout <<
" direct backward\n";
548 if (nextLane !=
nullptr) {
550 while (nextLane->
getLinkCont()[0]->getViaLaneOrLane()->isInternal()) {
551 nextLane = nextLane->
getLinkCont()[0]->getViaLaneOrLane();
557 if (nextLane ==
nullptr) {
559 nextLane = nextRouteLane;
561 std::cout <<
SIMTIME <<
" no next lane found for " << currentLane->
getID() <<
" dir=" << ped.
myDir <<
"\n";
565 +
"' from edge '" + currentEdge->
getID()
566 +
"' to edge '" + nextRouteEdge->
getID() +
"', time=" +
581 nextLane = nextRouteLane;
590 <<
" l=" << currentLane->
getID()
591 <<
" nl=" << (nextLane ==
nullptr ?
"NULL" : nextLane->
getID())
592 <<
" nrl=" << (nextRouteLane ==
nullptr ?
"NULL" : nextRouteLane->
getID())
595 <<
" pedDir=" << ped.
myDir
598 assert(nextLane != 0 || nextRouteLane == 0);
607 for (MSLinkCont::const_iterator it = links.begin(); it != links.end(); ++it) {
608 if ((*it)->getLane()->getEdge().isWalkingArea()) {
614 const std::vector<MSLane::IncomingLaneInfo>& laneInfos = currentLane->
getIncomingLanes();
615 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = laneInfos.begin(); it != laneInfos.end(); ++it) {
616 if ((*it).lane->getEdge().isWalkingArea()) {
617 link = (*it).viaLink;
628 const PState& ego = *pedestrians[egoIndex];
630 std::vector<bool> haveBlocker(stripes,
false);
631 for (
int index = egoIndex + 1; index < (int)pedestrians.size(); index++) {
632 const PState& p = *pedestrians[index];
639 std::cout <<
" dist=" << ego.
distanceTo(o) << std::endl;
647 haveBlocker[p.
stripe()] =
true;
650 if (!haveBlocker[p.
stripe()]) {
668 int offset = (destStripes - origStripes) / 2;
670 offset += (destStripes - origStripes) % 2;
678 MSLane* lane,
const MSLane* nextLane,
int stripes,
int nextDir,
679 double currentLength,
int currentDir) {
680 if (nextLanesObs.count(nextLane) == 0) {
687 const int offset =
getStripeOffset(nextStripes, stripes, currentDir != nextDir && nextStripes > stripes);
698 if (nextStripes < stripes) {
700 for (
int ii = 0; ii < stripes; ++ii) {
701 if (ii < offset || ii >= nextStripes + offset) {
712 if ((stripes - nextStripes) % 2 != 0) {
715 nextDir = currentDir;
717 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
718 PState& p = *pedestrians[ii];
723 const double newY = relPos.
y() + lateral_offset;
734 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(nextDir));
735 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
736 const PState& p = *pedestrians[ii];
742 if (nextDir != currentDir) {
747 const int stripe = p.
stripe(newY);
748 if (stripe >= 0 && stripe < stripes) {
752 if (otherStripe >= 0 && otherStripe < stripes) {
753 obs[otherStripe] = pObs;
768 nextLanesObs[nextLane] = obs;
770 return nextLanesObs[nextLane];
775 for (
int ii = 0; ii < (int)obs.size(); ++ii) {
779 o.
xFwd += currentLength;
780 o.
xBack += currentLength;
782 const double tmp = o.
xFwd;
783 o.
xFwd = currentLength + nextLength - o.
xBack;
784 o.
xBack = currentLength + nextLength - tmp;
788 const double tmp = o.
xFwd;
792 o.
xFwd -= nextLength;
793 o.
xBack -= nextLength;
803 if ((dir ==
FORWARD && x - width / 2. < obs[stripe].xBack) || (dir ==
BACKWARD && x + width / 2. > obs[stripe].xFwd)) {
804 obs[stripe] =
Obstacle(x, 0, type,
id, width);
812 const MSLane* lane = it_lane->first;
814 if (pedestrians.size() == 0) {
825 std::set<const WalkingAreaPath*, walkingarea_path_sorter> paths;
826 for (Pedestrians::iterator it = pedestrians.begin(); it != pedestrians.end(); ++it) {
829 if (p->
myDir == dir) {
833 std::cout <<
SIMTIME <<
" debugging WalkingAreaPath from=" << debugPath->
from->
getID() <<
" to=" << debugPath->
to->
getID() <<
"\n";
837 for (std::set<const WalkingAreaPath*, walkingarea_path_sorter>::iterator it = paths.begin(); it != paths.end(); ++it) {
841 transformedPeds.reserve(pedestrians.size());
842 for (Pedestrians::iterator it_p = pedestrians.begin(); it_p != pedestrians.end(); ++it_p) {
847 transformedPeds.push_back(p);
848 if (path == debugPath) std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << p->
myRelX <<
" relY=" << p->
myRelY <<
" (untransformed), vecCoord="
852 const double newY = relPos.
y() + lateral_offset;
860 toDelete.push_back(tp);
861 transformedPeds.push_back(tp);
862 if (path == debugPath) {
863 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (transformed), vecCoord=" << relPos <<
"\n";
866 if (path == debugPath) {
867 std::cout <<
" ped=" << p->
myPerson->
getID() <<
" relX=" << relPos.
x() <<
" relY=" << newY <<
" (invalid), vecCoord=" << relPos <<
"\n";
877 for (
const MSLane* foeLane : itFoe->second) {
883 if (
addVehicleFoe(veh, lane, relPos, lateral_offset, minY, maxY, toDelete, transformedPeds)
884 &&
addVehicleFoe(veh, lane, relPos2, lateral_offset, minY, maxY, toDelete, transformedPeds)) {
888 const double relDist = dist / length;
889 Position between = (relPos * relDist) + (relPos2 * (1 - relDist));
890 addVehicleFoe(veh, lane, between, lateral_offset, minY, maxY, toDelete, transformedPeds);
899 for (Pedestrians::iterator it_p = toDelete.begin(); it_p != toDelete.end(); ++it_p) {
915 const double newY = relPos.
y() + lateral_offset;
916 if (newY >= minY && newY <= maxY) {
919 toDelete.push_back(tp);
920 transformedPeds.push_back(tp);
931 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
933 for (
int i = 0; i < (int)pedestrians.size(); i++) {
934 PState*
const p = pedestrians[i];
938 pedestrians.erase(pedestrians.begin() + i);
941 if (p->
myLane !=
nullptr) {
960 sort(pedestrians.begin(), pedestrians.end(),
by_xpos_sorter(dir));
963 bool hasCrossingVehObs =
false;
966 hasCrossingVehObs =
addCrossingVehs(lane, stripes, 0, dir, crossingVehs,
true);
969 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
970 PState& p = *pedestrians[ii];
1000 nextLanesObs, lane, nextLane, stripes,
1019 const double passingClearanceTime = 2;
1020 const double passingLength = p.
getLength() + passingClearanceTime * speed;
1026 <<
" opened=" << (link ==
nullptr ?
"NULL" :
toString(link->opened(currentTime -
DELTA_T, speed, speed, passingLength, p.
getImpatience(currentTime), speed, 0, 0,
nullptr, p.
ignoreRed(link)))) <<
"\n";
1062 if (hasCrossingVehObs) {
1071 p.
walk(currentObs, currentTime);
1078 for (
int coll = 0; coll < ii; ++coll) {
1079 PState& c = *pedestrians[coll];
1086 +
"', lane='" + lane->
getID() +
"', time=" +
time2string(currentTime) +
".");
1099 bool hasCrossingVehObs =
false;
1104 if (linkLeaders.size() > 0) {
1105 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1107 const MSVehicle* veh = (*it).vehAndGap.first;
1108 if (veh !=
nullptr) {
1119 const double distToCrossBeforeVeh = (dir ==
FORWARD ? vo.xFwd : crossing->
getLength() - vo.xBack);
1120 const double bGap = (prio
1122 : veh->
getSpeed() * distToCrossBeforeVeh);
1126 if ((*it).fromLeft) {
1127 vehYmin = -(*it).vehAndGap.second + lateral_offset;
1131 vehYmax = crossing->
getWidth() + (*it).vehAndGap.second - lateral_offset;
1137 if ((dir ==
FORWARD && obs[s].xBack > vo.xBack)
1138 || (dir ==
BACKWARD && obs[s].xFwd < vo.xFwd)) {
1145 hasCrossingVehObs =
true;
1150 <<
" crossingVeh=" << veh->
getID()
1151 <<
" lane=" << crossing->
getID()
1153 <<
" latOffset=" << lateral_offset
1155 <<
" stripes=" << stripes
1156 <<
" dist=" << (*it).distToCrossing
1157 <<
" gap=" << (*it).vehAndGap.second
1158 <<
" brakeGap=" << bGap
1159 <<
" fromLeft=" << (*it).fromLeft
1160 <<
" distToCrossBefore=" << distToCrossBeforeVeh
1161 <<
" ymin=" << vehYmin
1162 <<
" ymax=" << vehYmax
1171 return hasCrossingVehObs;
1186 if (ped !=
nullptr) {
1206 const double vehNextSpeed =
MAX2(veh->
getSpeed(), 1.0);
1221 if (s == current && vehFront +
SAFETY_GAP < minX) {
1223 if (pRelY - pWidth < vehYmax &&
1224 pRelY + pWidth > vehYmin && dir ==
FORWARD) {
1226 std::cout <<
" ignoring vehicle '" << veh->
getID() <<
" on stripe " << s <<
" vehFrontSG=" << vehFront +
SAFETY_GAP <<
" minX=" << minX <<
"\n";
1237 std::cout <<
SIMTIME <<
" ped=" << pID <<
" veh=" << veh->
getID() <<
" obstacle on lane=" << lane->
getID()
1239 <<
" ymin=" << vehYmin
1240 <<
" ymax=" << vehYmax
1243 <<
" relY=" << pRelY
1244 <<
" current=" << current
1245 <<
" vo.xFwd=" << vo.xFwd
1246 <<
" vo.xBack=" << vo.xBack
1262 type(OBSTACLE_NONE),
1268 xFwd(ped.getMaxX()),
1269 xBack(ped.getMinX()),
1270 speed(ped.myDir * ped.mySpeed),
1272 description(ped.getID()) {
1286 myRelX(stage->getDepartPos()),
1287 myRelY(stage->getDepartPosLat()),
1290 myWaitingToEnter(true),
1292 myWalkingAreaPath(nullptr),
1295 myAngle(std::numeric_limits<double>::max()) {
1298 assert(!route.empty());
1299 if (route.size() == 1) {
1305 if (route.front()->isWalkingArea()) {
1312 std::cout <<
" initialize dir for " <<
myPerson->
getID() <<
" forward=" << mayStartForward <<
" backward=" << mayStartBackward <<
"\n";
1314 if (mayStartForward && mayStartBackward) {
1318 if (crossingRoute.size() > 1) {
1320 const MSEdge* nextEdge = crossingRoute[1];
1326 std::cout <<
" crossingRoute=" <<
toString(crossingRoute) <<
"\n";
1355 myWaitingToEnter(false),
1357 myWalkingAreaPath(nullptr),
1360 myAngle(std::numeric_limits<double>::max()) {
1368 return myRelX - getLength();
1370 return myRelX - (includeMinGap ? getMinGap() : 0.);
1378 return myRelX + (includeMinGap ? getMinGap() : 0.);
1380 return myRelX + getLength();
1386 return myPerson->getVehicleType().getLength();
1392 return myPerson->getVehicleType().getMinGap();
1404 const int s = stripe(relY);
1408 if (offset > threshold) {
1410 }
else if (offset < -threshold) {
1435 if (myStage->getNextRouteEdge() ==
nullptr) {
1436 return myDir * (myStage->getArrivalPos() - myRelX) -
POSITION_EPS;
1438 const double length = myWalkingAreaPath ==
nullptr ? myLane->getLength() : myWalkingAreaPath->length;
1439 return myDir ==
FORWARD ? length - myRelX : myRelX;
1446 double dist = distToLaneEnd();
1448 std::cout <<
SIMTIME <<
" ped=" << myPerson->getID() <<
" myRelX=" << myRelX <<
" dist=" << dist <<
"\n";
1456 const int oldDir = myDir;
1457 const MSLane* oldLane = myLane;
1458 myLane = myNLI.lane;
1460 const bool normalLane = (myLane ==
nullptr || myLane->getEdge().getFunction() ==
EDGEFUNC_NORMAL || &myLane->getEdge() == myStage->getNextRouteEdge());
1463 <<
" ped=" << myPerson->getID()
1464 <<
" moveToNextLane old=" << oldLane->
getID()
1465 <<
" new=" << (myLane ==
nullptr ?
"NULL" : myLane->getID())
1466 <<
" oldDir=" << oldDir
1467 <<
" newDir=" << myDir
1468 <<
" myRelX=" << myRelX
1472 if (myLane ==
nullptr) {
1473 myRelX = myStage->getArrivalPos();
1476 if (myStage->getRouteStep() == myStage->getRoute().end() - 1) {
1479 const bool arrived = myStage->moveToNextEdge(myPerson, currentTime, normalLane ?
nullptr : &myLane->getEdge());
1484 assert(myNLI.lane != oldLane);
1486 std::cout <<
" nextLane=" << (myNLI.lane ==
nullptr ?
"NULL" : myNLI.lane->getID()) <<
"\n";
1488 if (myLane->getEdge().isWalkingArea()) {
1491 assert(myWalkingAreaPath->from != 0);
1492 assert(myWalkingAreaPath->to != 0);
1493 assert(myWalkingAreaPath->shape.size() >= 2);
1495 std::cout <<
" mWAPath shape=" << myWalkingAreaPath->shape <<
" length=" << myWalkingAreaPath->length <<
"\n";
1501 const MSEdge* currRouteEdge = myStage->getRouteEdge();
1502 const MSEdge* nextRouteEdge = myStage->getNextRouteEdge();
1510 myStage->moveToNextEdge(myPerson, currentTime,
nullptr);
1511 myLane = myNLI.lane;
1512 assert(myLane != 0);
1515 myWalkingAreaPath =
nullptr;
1517 throw ProcessError(
"Disconnected walk for person '" + myPerson->getID() +
"'.");
1521 myWalkingAreaPath =
nullptr;
1526 const double newLength = (myWalkingAreaPath ==
nullptr ? myLane->getLength() : myWalkingAreaPath->length);
1527 if (-dist > newLength) {
1534 myRelX = newLength + dist;
1539 std::cout <<
SIMTIME <<
" update myRelX ped=" << myPerson->getID()
1540 <<
" newLength=" << newLength
1542 <<
" myRelX=" << myRelX
1546 if (myDir != oldDir) {
1553 std::cout <<
SIMTIME <<
" transformY ped=" << myPerson->getID()
1555 <<
" newY=" << myRelY
1557 <<
" od=" << oldDir <<
" nd=" << myDir
1558 <<
" offset=" << offset <<
"\n";
1570 myAngle = std::numeric_limits<double>::max();
1571 const int stripes = (int)obs.size();
1572 const int sMax = stripes - 1;
1574 const double vMax = myStage->getMaxSpeed(myPerson);
1576 const int current = stripe();
1577 const int other = otherStripe();
1579 std::vector<double> distance(stripes);
1580 for (
int i = 0; i < stripes; ++i) {
1581 distance[i] = distanceTo(obs[i], obs[i].type ==
OBSTACLE_PED);
1584 std::vector<double> utility(stripes, 0);
1586 for (
int i = 0; i < stripes; ++i) {
1588 if (i == current && (!myWaitingToEnter || stripe() != stripe(myRelY))) {
1592 for (
int j = 0; j <= i; ++j) {
1597 for (
int j = i; j < stripes; ++j) {
1606 const bool onJunction = myLane->getEdge().isWalkingArea() || myLane->getEdge().isCrossing();
1609 for (
int i = 0; i < reserved; ++i) {
1613 for (
int i = sMax; i > sMax - reserved; --i) {
1618 for (
int i = 0; i < stripes; ++i) {
1619 if (obs[i].speed * myDir < 0) {
1621 if (myDir ==
FORWARD && i > 0) {
1622 utility[i - 1] -= 0.5;
1623 }
else if (myDir ==
BACKWARD && i < sMax) {
1624 utility[i + 1] -= 0.5;
1628 const double walkDist =
MAX2(0., distance[i]);
1630 const double expectedDist =
MIN2(vMax *
LOOKAHEAD_SAMEDIR, walkDist + obs[i].speed * myDir * lookAhead);
1632 std::cout <<
" util=" << utility[i] <<
" exp=" << expectedDist <<
" dist=" << distance[i] <<
"\n";
1634 if (expectedDist >= 0) {
1635 utility[i] += expectedDist;
1642 if (myDir ==
FORWARD && obs[0].speed < 0) {
1644 }
else if (myDir ==
BACKWARD && obs[sMax].speed > 0) {
1648 if (distance[current] > 0 && myWaitingTime == 0) {
1649 for (
int i = 0; i < stripes; ++i) {
1655 int chosen = current;
1656 for (
int i = 0; i < stripes; ++i) {
1657 if (utility[chosen] < utility[i]) {
1662 const int next = (chosen == current ? current : (chosen < current ? current - 1 : current + 1));
1663 double xDist =
MIN3(distance[current], distance[other], distance[next]);
1664 if (next != chosen) {
1667 const int nextOther = chosen < current ? current - 2 : current + 2;
1668 xDist =
MIN2(xDist, distance[nextOther]);
1677 std::cout <<
" xSpeedPotential=" << xSpeed <<
"\n";
1684 (xDist == distance[current] && obs[current].type >=
OBSTACLE_END)
1685 || (xDist == distance[other] && obs[other].type >=
OBSTACLE_END)
1686 || (xDist == distance[next] && obs[next].type >=
OBSTACLE_END))
1696 +
"' is jammed on edge '" + myStage->getEdge()->getID()
1702 }
else if (stripe(myRelY) >= 0 && stripe(myRelY) <= sMax) {
1727 ySpeed = (yDist > 0 ?
1733 && stripe() == stripe(myRelY)
1735 && !myLane->getEdge().isCrossing()) {
1737 myRelY += myDir * vMax;
1742 <<
" ped=" << myPerson->getID()
1743 <<
" edge=" << myStage->getEdge()->getID()
1747 <<
" pvx=" << mySpeed
1748 <<
" cur=" << current
1749 <<
" cho=" << chosen
1753 <<
" dawdle=" << dawdle
1757 <<
" vMax=" << myStage->getMaxSpeed(myPerson)
1758 <<
" wTime=" << myStage->getWaitingTime(currentTime)
1759 <<
" jammed=" << myAmJammed
1760 <<
"\n distance=" <<
toString(distance)
1761 <<
"\n utility=" <<
toString(utility)
1769 myWaitingToEnter =
false;
1779 return MAX2(0.,
MIN2(1., myPerson->getVehicleType().getImpatience()
1792 if (myLane ==
nullptr) {
1796 const double lateral_offset = myRelY + (
stripeWidth - myLane->getWidth()) * 0.5;
1797 if (myWalkingAreaPath ==
nullptr) {
1811 return myWalkingAreaPath->shape.positionAtOffset(myRelX, lateral_offset);
1818 if (myAngle != std::numeric_limits<double>::max()) {
1821 if (myLane ==
nullptr) {
1825 const PositionVector& shp = myWalkingAreaPath ==
nullptr ? myLane->getShape() : myWalkingAreaPath->shape;
1837 return myWaitingTime;
1849 return myNLI.lane ==
nullptr ? nullptr : &myNLI.lane->getEdge();
1854 double lanePosLat,
double angle,
int routeOffset,
1857 assert(p == myPerson);
1871 if (lane !=
nullptr) {
1873 const MSLane* sidewalk = getSidewalk<MSEdge, MSLane>(&lane->
getEdge());
1874 if (lane != sidewalk) {
1879 pm->
add(
this, lane);
1881 if (edges.empty()) {
1883 myStage->setRouteIndex(myPerson, routeOffset);
1885 myStage->moveToNextEdge(myPerson, t, &lane->
getEdge());
1892 myRelY = (myLane->getWidth() -
stripeWidth) * 0.5 - lanePosLat;
1895 myRemoteXYPos = pos;
1905 const double maxX = getMaxX(includeMinGap);
1906 const double minX = getMinX(includeMinGap);
1910 if ((obs.
xFwd >= maxX && obs.
xBack <= maxX) || (obs.
xFwd <= maxX && obs.
xFwd >= minX)) {
1924 for (
int i = 0; i < (int)into.size(); ++i) {
1926 std::cout <<
" i=" << i <<
" maxX=" << getMaxX(
true) <<
" minX=" << getMinX(
true)
1927 <<
" into=" << into[i].description <<
" iDist=" << distanceTo(into[i], into[i].type ==
OBSTACLE_PED)
1928 <<
" obs2=" << obs2[i].description <<
" oDist=" << distanceTo(obs2[i], obs2[i].type ==
OBSTACLE_PED) <<
"\n";
1930 const double dO = distanceTo(obs2[i], obs2[i].type ==
OBSTACLE_PED);
1931 const double dI = distanceTo(into[i], into[i].type ==
OBSTACLE_PED);
1946 for (
int i = 0; i < (int)into.size(); ++i) {
1947 int i2 = i + offset;
1948 if (i2 >= 0 && i2 < (
int)obs2.size()) {
1950 if (obs2[i2].xBack < into[i].xBack) {
1954 if (obs2[i2].xFwd > into[i].xFwd) {
1967 if (ignoreRedTime >= 0) {
1970 std::cout <<
SIMTIME <<
" ignoreRedTime=" << ignoreRedTime <<
" redDuration=" << redDuration <<
"\n";
1972 return ignoreRedTime > redDuration;
1983 return myPerson->getID();
1988 return myPerson->getVehicleType().getWidth();
2004 return myVehicle->getID();
2009 return myVehicle->getVehicleType().getWidth();
2014 return myRelX - myVehicle->getVehicleType().getWidth() / 2 -
SAFETY_GAP ;
2019 return myRelX + myVehicle->getVehicleType().getWidth() / 2 +
SAFETY_GAP;
2028 std::set<MSPerson*> changedLane;
2033 for (ActiveLanes::const_iterator it_lane =
myModel->getActiveLanes().begin(); it_lane !=
myModel->getActiveLanes().end(); ++it_lane) {
2034 const MSLane* lane = it_lane->first;
2036 if (pedestrians.size() == 0) {
2041 for (
int ii = 0; ii < (int)pedestrians.size(); ++ii) {
2042 const PState& p = *pedestrians[ii];