Skip to content

Commit

Permalink
move board slack constant, clarify comments
Browse files Browse the repository at this point in the history
  • Loading branch information
abyrd committed Oct 27, 2023
1 parent e9abaa9 commit 7062835
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
12 changes: 4 additions & 8 deletions src/main/java/com/conveyal/r5/profile/FastRaptorWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ public class FastRaptorWorker {
*/
public static final int UNREACHED = Integer.MAX_VALUE;

/**
* Minimum time between alighting from one vehicle and boarding another, in seconds.
* TODO make this configurable, and use loop-transfers from transfers.txt.
*/
public static final int BOARD_SLACK_SECONDS = 60;

public static final int SECONDS_PER_MINUTE = 60;

/**
Expand All @@ -70,8 +64,10 @@ public class FastRaptorWorker {
private static final int DEPARTURE_STEP_SEC = 60;

/**
* Minimum wait for boarding to account for schedule variation.
* FIXME clarify why this is separate from BOARD_SLACK. If it is not, merge the two constants into BOARD_SLACK_SEC.
* To be considered for boarding, a vehicle must depart at least this long after the rider arrives at the stop.
* Intuitively, "leave this long for transfers" to account for schedule variation or other unexpected variations.
* This is separate from BOARD_SLACK_SECONDS used in McRaptor and point-to-point searches, in case someone needs
* to set them independently.
*/
private static final int MINIMUM_BOARD_WAIT_SEC = 60;

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/conveyal/r5/profile/PathWithTimes.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
* A path that also includes itineraries and bounds for all possible trips on the paths (even those which may not be optimal)
*/
public class PathWithTimes extends Path {
/**
* Minimum time between alighting from one vehicle and boarding another, in seconds.
* Appears to be used only in McRaptor and point-to-point searches.
* TODO make this configurable, and use loop-transfers from transfers.txt.
*/
public static final int BOARD_SLACK_SECONDS = 60;
/** Stats for the entire path */
public Stats stats;

Expand Down Expand Up @@ -92,7 +98,7 @@ private void computeTimes (TransportNetwork network, ProfileRequest req, TIntInt
// loop over departures within the time window
// firstTrip is the trip on the first pattern
int firstTrip = 0;
while (times[0][firstTrip][0] < req.fromTime + accessTime + FastRaptorWorker.BOARD_SLACK_SECONDS) firstTrip++;
while (times[0][firstTrip][0] < req.fromTime + accessTime + BOARD_SLACK_SECONDS) firstTrip++;

// now interleave times
double walkSpeedMillimetersPerSecond = req.walkSpeed * 1000;
Expand Down Expand Up @@ -137,7 +143,7 @@ private void computeTimes (TransportNetwork network, ProfileRequest req, TIntInt

// TODO should board slack be applied at the origin stop? Is this done in RaptorWorker?
// See also below in computeStatistics
time = times[patIdx][trip][1] + transferTime + FastRaptorWorker.BOARD_SLACK_SECONDS;
time = times[patIdx][trip][1] + transferTime + BOARD_SLACK_SECONDS;
itin.arriveAtBoardStopTimes[patIdx + 1] = time;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/conveyal/r5/profile/StatsCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static StatsCollection computeStatistics (ProfileRequest req, int accessT

for (int start = req.fromTime; start < req.toTime; start += 60) {
// TODO should board slack be applied at the origin stop? Is this done in RaptorWorker?
int timeAtOriginStop = start + accessTime + FastRaptorWorker.BOARD_SLACK_SECONDS;
int timeAtOriginStop = start + accessTime + PathWithTimes.BOARD_SLACK_SECONDS;
int bestTimeAtDestinationStop = Integer.MAX_VALUE;

PathWithTimes.Itinerary bestItinerary = null;
Expand Down

0 comments on commit 7062835

Please sign in to comment.