Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unncessary footpathIndex #302

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions connection_scan_algorithm/src/forward_calculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace TrRouting
short connectionMinWaitingTimeSeconds {-1};
//long long footpathsRangeStart {-1};
//long long footpathsRangeEnd {-1};
int footpathIndex {-1};
int footpathTravelTime {-1};
int footpathDistance {-1};
int tentativeEgressNodeArrivalTime {MAX_INT};
Expand Down Expand Up @@ -110,7 +109,6 @@ namespace TrRouting
tentativeEgressNodeArrivalTime = connectionArrivalTime;
}

footpathIndex = 0;
for (const NodeTimeDistance & transferableNode : nodeArrival.transferableNodes)
{
// Extract tentative time for current transferable node if found
Expand All @@ -119,18 +117,17 @@ namespace TrRouting
if (nodeArrival != transferableNode.node &&
currentTransferablenNodesTentativeTime < connectionArrivalTime)
{
footpathIndex++;
continue;
}

//TODO We should not do a direct == with float values
footpathTravelTime = parameters.getWalkingSpeedFactor() == 1.0 ? nodeArrival.transferableNodes[footpathIndex].time : (int)ceil((float)nodeArrival.transferableNodes[footpathIndex].time / parameters.getWalkingSpeedFactor());
footpathTravelTime = parameters.getWalkingSpeedFactor() == 1.0 ? transferableNode.time : (int)ceil((float)transferableNode.time / parameters.getWalkingSpeedFactor());

if (footpathTravelTime <= parameters.getMaxTransferWalkingTravelTimeSeconds())
{
if (footpathTravelTime + connectionArrivalTime < currentTransferablenNodesTentativeTime)
{
footpathDistance = nodeArrival.transferableNodes[footpathIndex].distance;
footpathDistance = transferableNode.distance;
nodesTentativeTime[transferableNode.node.uid] = footpathTravelTime + connectionArrivalTime;

//TODO DO we need a make_optional here??
Expand All @@ -148,11 +145,10 @@ namespace TrRouting
)
)
{
footpathDistance = nodeArrival.transferableNodes[footpathIndex].distance;
footpathDistance = transferableNode.distance;
forwardEgressJourneysSteps.insert_or_assign(transferableNode.node.uid, JourneyStep(currentTripQueryOverlay.enterConnection, *connection, std::cref(trip), footpathTravelTime, true, footpathDistance));
}
}
footpathIndex++;
}
}
reachableConnectionsCount++;
Expand Down Expand Up @@ -212,7 +208,6 @@ namespace TrRouting
short connectionMinWaitingTimeSeconds {-1};
//long long footpathsRangeStart {-1};
//long long footpathsRangeEnd {-1};
int footpathIndex {-1};
int footpathTravelTime {-1};
int footpathDistance {-1};
bool nodeWasAccessedFromOrigin {false};
Expand Down Expand Up @@ -286,7 +281,6 @@ namespace TrRouting
const Node &nodeArrival = (*connection).get().getArrivalNode();
connectionArrivalTime = (*connection).get().getArrivalTime();

footpathIndex = 0;
for (const NodeTimeDistance & transferableNode : nodeArrival.transferableNodes)
{
// Extract tentative time for current transferable node if found
Expand All @@ -295,18 +289,17 @@ namespace TrRouting
if (nodeArrival != transferableNode.node &&
currentTransferablenNodesTentativeTime < connectionArrivalTime)
{
footpathIndex++;
continue;
}

//TODO We should not do a direct == with float values
footpathTravelTime = parameters.getWalkingSpeedFactor() == 1.0 ? nodeArrival.transferableNodes[footpathIndex].time : (int)ceil((float)nodeArrival.transferableNodes[footpathIndex].time / parameters.getWalkingSpeedFactor());
footpathTravelTime = parameters.getWalkingSpeedFactor() == 1.0 ? transferableNode.time : (int)ceil((float)transferableNode.time / parameters.getWalkingSpeedFactor());

if (footpathTravelTime <= parameters.getMaxTransferWalkingTravelTimeSeconds())
{
if (footpathTravelTime + connectionArrivalTime < currentTransferablenNodesTentativeTime)
{
footpathDistance = nodeArrival.transferableNodes[footpathIndex].distance;
footpathDistance = transferableNode.distance;
nodesTentativeTime[transferableNode.node.uid] = footpathTravelTime + connectionArrivalTime;

//TODO DO we need a make_optional here??
Expand All @@ -324,11 +317,10 @@ namespace TrRouting
)
)
{
footpathDistance = nodeArrival.transferableNodes[footpathIndex].distance;
footpathDistance = transferableNode.distance;
forwardEgressJourneysSteps.insert_or_assign(transferableNode.node.uid, JourneyStep(currentTripQueryOverlay.enterConnection, *connection, std::cref(trip), footpathTravelTime, true, footpathDistance));
}
}
footpathIndex++;
}
}
reachableConnectionsCount++;
Expand Down
15 changes: 5 additions & 10 deletions connection_scan_algorithm/src/reverse_calculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace TrRouting
tentativeAccessNodeDepartureTime = connectionDepartureTime;

}
footpathIndex = 0;

for (const NodeTimeDistance & transferableNode : nodeDeparture.reverseTransferableNodes)
{

Expand All @@ -131,13 +131,13 @@ namespace TrRouting
}

//TODO We should not do a direct == with float values
footpathTravelTime = parameters.getWalkingSpeedFactor() == 1.0 ? nodeDeparture.reverseTransferableNodes[footpathIndex].time : (int)ceil((float)nodeDeparture.reverseTransferableNodes[footpathIndex].time / parameters.getWalkingSpeedFactor());
footpathTravelTime = parameters.getWalkingSpeedFactor() == 1.0 ? transferableNode.time : (int)ceil((float)transferableNode.time / parameters.getWalkingSpeedFactor());

if (footpathTravelTime <= parameters.getMaxTransferWalkingTravelTimeSeconds())
{
if (connectionDepartureTime - footpathTravelTime - connectionMinWaitingTimeSeconds >= nodesReverseTentativeTime.at(transferableNode.node.uid))
{
footpathDistance = nodeDeparture.reverseTransferableNodes.at(footpathIndex).distance;
footpathDistance = transferableNode.distance;
nodesReverseTentativeTime[transferableNode.node.uid] = connectionDepartureTime - footpathTravelTime - connectionMinWaitingTimeSeconds;
//TODO Do we need a make_optional<...>(connection) ??
reverseJourneysSteps.at(transferableNode.node.uid) = JourneyStep(*connection, currentTripQueryOverlay.exitConnection, std::cref(trip), footpathTravelTime, (nodeDeparture == transferableNode.node), footpathDistance);
Expand Down Expand Up @@ -173,7 +173,6 @@ namespace TrRouting
}
}
}
footpathIndex++;
}
}
reachableConnectionsCount++;
Expand Down Expand Up @@ -232,7 +231,6 @@ namespace TrRouting
short journeyConnectionMinWaitingTimeSeconds {-1};
//long long footpathsRangeStart {-1};
//long long footpathsRangeEnd {-1};
int footpathIndex {-1};
int footpathTravelTime {-1};
int footpathDistance {-1};

Expand Down Expand Up @@ -317,24 +315,22 @@ namespace TrRouting
connectionMinWaitingTimeSeconds = (*connection).get().getMinWaitingTimeOrDefault(parameters.getMinWaitingTimeSeconds());

auto nodeDepartureInNodesAccessIte = nodesAccess.find(nodeDeparture.uid);
footpathIndex = 0;
for (const NodeTimeDistance & transferableNode : nodeDeparture.reverseTransferableNodes)
{

if (nodeDeparture != transferableNode.node && nodesReverseTentativeTime.at(transferableNode.node.uid) > connectionDepartureTime - connectionMinWaitingTimeSeconds)
{
footpathIndex++;
continue;
}

//TODO We should not do a direct == with float values
footpathTravelTime = parameters.getWalkingSpeedFactor() == 1.0 ? nodeDeparture.reverseTransferableNodes[footpathIndex].time : (int)ceil((float)nodeDeparture.reverseTransferableNodes[footpathIndex].time / parameters.getWalkingSpeedFactor());
footpathTravelTime = parameters.getWalkingSpeedFactor() == 1.0 ? transferableNode.time : (int)ceil((float)transferableNode.time / parameters.getWalkingSpeedFactor());

if (footpathTravelTime <= parameters.getMaxTransferWalkingTravelTimeSeconds())
{
if (connectionDepartureTime - footpathTravelTime - connectionMinWaitingTimeSeconds >= nodesReverseTentativeTime.at(transferableNode.node.uid))
{
footpathDistance = nodeDeparture.reverseTransferableNodes.at(footpathIndex).distance;
footpathDistance = transferableNode.distance;
nodesReverseTentativeTime[transferableNode.node.uid] = connectionDepartureTime - footpathTravelTime - connectionMinWaitingTimeSeconds;
//TODO Do we need a make_optional<...>(connection) ??
reverseJourneysSteps.at(transferableNode.node.uid) = JourneyStep(*connection, currentTripQueryOverlay.exitConnection, std::cref(trip), footpathTravelTime, (nodeDeparture == transferableNode.node), footpathDistance);
Expand Down Expand Up @@ -370,7 +366,6 @@ namespace TrRouting
}
}
}
footpathIndex++;
}
}
reachableConnectionsCount++;
Expand Down
1 change: 1 addition & 0 deletions include/combinations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// from https://stackoverflow.com/a/25497877
// With later modifications to adapt for std::reference_wrapper
#include <vector>
#include <algorithm>

template<typename T> class Combinations {
// Combinations(std::vector<T> s, int m) iterate all Combinations without repetition
Expand Down
Loading