Skip to content

Commit

Permalink
Apply half of minTransferTime at every preboard and prealight event, …
Browse files Browse the repository at this point in the history
…independent of traversal direction. Avoids transit-specific schedule slack hack in reverse optimization. Addresses #409.
  • Loading branch information
abyrd committed Jul 30, 2011
1 parent e2e3118 commit d516166
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public State traverse(State s0){
* this stop.
*/
long t0 = s0.getTime();
long alight_before;
long alight_before = t0 - options.minTransferTime * 500;
long transfer_penalty = 0;
if (s0.getLastAlightedTime() != 0) {
/* this is a transfer rather than an initial boarding */
Expand All @@ -85,23 +85,21 @@ public State traverse(State s0){
int transfer_time = transferTable.getTransferTime(getFromVertex(), s0.getPreviousStop());
if (transfer_time == TransferTable.UNKNOWN_TRANSFER) {
// use min transfer time relative to arrival time at this stop
alight_before = t0 - options.minTransferTime * 1000;
} else if (transfer_time >= 0) {
// handle minimum time transfers (>0) and timed transfers (0)
// relative to alight time at last stop
alight_before = s0.getLastAlightedTime() - transfer_time * 1000;
long table_alight_before = s0.getLastAlightedTime() - transfer_time * 1000;
// do not let time run the wrong way
// this could make timed transfers fail if there is walking involved
if (alight_before > t0)
alight_before = t0;
if (table_alight_before < alight_before)
alight_before = table_alight_before;
} else if (transfer_time == TransferTable.FORBIDDEN_TRANSFER) {
return null;
} else if (transfer_time == TransferTable.PREFERRED_TRANSFER) {
// depenalize preferred transfers
// TODO: verify correctness of this method (AMB)
transfer_penalty = 0;
// use min transfer time relative to arrival time at this stop
alight_before = t0 - options.minTransferTime * 1000;
} else {
throw new IllegalStateException("Undefined value in transfer table.");
}
Expand All @@ -111,7 +109,6 @@ public State traverse(State s0){
}
} else {
/* this is a first boarding, not a transfer - divide minTransferTime in half */
alight_before = t0 - options.minTransferTime * 500;
}

// penalize transfers more heavily if requested by the user
Expand All @@ -134,6 +131,7 @@ public State traverse(State s0){
if (toVertex.isLocal()) {
s1.setAlightedLocal(true);
}
s1.incrementTimeMsec(options.minTransferTime * 500);
return s1.makeState();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public State traverse(State s0) {
if (fromVertex.isLocal()) {
s1.setAlightedLocal(true);
}

s1.incrementTimeMsec(options.minTransferTime * 500);
return s1.makeState();
} else {
/* Traverse forward: apply stop(pair)-specific costs */
Expand Down Expand Up @@ -80,7 +82,7 @@ public State traverse(State s0) {
* this stop.
*/
long t0 = s0.getTime();
long board_after;
long board_after = t0 + options.minTransferTime * 500;
long transfer_penalty = 0;
if (s0.getLastAlightedTime() != 0) {
/* this is a transfer rather than an initial boarding */
Expand All @@ -92,23 +94,21 @@ public State traverse(State s0) {
int transfer_time = transferTable.getTransferTime(s0.getPreviousStop(), getToVertex());
if (transfer_time == TransferTable.UNKNOWN_TRANSFER) {
// use min transfer time relative to arrival time at this stop
board_after = t0 + options.minTransferTime * 1000;
} else if (transfer_time >= 0) {
// handle minimum time transfers (>0) and timed transfers (0)
// relative to alight time at last stop
board_after = s0.getLastAlightedTime() + transfer_time * 1000;
long table_board_after = s0.getLastAlightedTime() + transfer_time * 1000;
// do not let time run backward
// this could make timed transfers fail if there is walking involved
if (board_after < t0)
board_after = t0;
if (table_board_after > board_after)
board_after = table_board_after;
} else if (transfer_time == TransferTable.FORBIDDEN_TRANSFER) {
return null;
} else if (transfer_time == TransferTable.PREFERRED_TRANSFER) {
// depenalize preferred transfers
// TODO: verify correctness of this method (AMB)
transfer_penalty = 0;
// use min transfer time relative to arrival time at this stop
board_after = t0 + options.minTransferTime * 1000;
} else {
throw new IllegalStateException("Undefined value in transfer table.");
}
Expand All @@ -118,7 +118,6 @@ public State traverse(State s0) {
}
} else {
/* this is a first boarding, not a transfer - divide minTransferTime in half */
board_after = t0 + options.minTransferTime * 500;
}

// penalize transfers more heavily if requested by the user
Expand Down

0 comments on commit d516166

Please sign in to comment.