Skip to content

Commit

Permalink
steps towards including initial transfers in traveltimes algorithm for
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Aug 16, 2022
1 parent cff8b6a commit 83f178d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: gtfsrouter
Title: Routing with GTFS (General Transit Feed Specification) Data
Version: 0.0.5.093
Version: 0.0.5.094
Authors@R: c(
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre")),
person("Marcin", "Stepniak", , "marcinstepniak@ucm.es", role = "aut",
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"codeRepository": "https://github.com/ATFutures/gtfs-router",
"issueTracker": "https://github.com/ATFutures/gtfs-router/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.0.5.093",
"version": "0.0.5.094",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
37 changes: 35 additions & 2 deletions src/traveltimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ void iso::trace_forward_iso (
trans_dest,
trans_duration,
minimise_transfers,
start_time,
false, // !is_start
iso);
}

Expand Down Expand Up @@ -285,6 +287,28 @@ void iso::trace_forward_traveltimes (
for (size_t a: arrival_station)
stations.emplace (std::make_pair (a, false));

// Fill initial transfers from start station:
for (auto s: start_stations_set)
{
for (auto t: transfer_map.at (s))
{
const size_t trans_dest = t.first;
const int trans_duration = t.second;

iso::fill_one_transfer (
INFINITE_INT, // departure_station param
s, // arrival_station param
start_time_min, // arrival_time param
trans_dest,
trans_duration,
minimise_transfers,
start_time_min,
true, // is_start
iso);

} // end for t over transfer map
} // end for s over start_stations_set

for (size_t i = 0; i < nrows; i++)
{
if (departure_time [i] < start_time_min)
Expand Down Expand Up @@ -328,6 +352,8 @@ void iso::trace_forward_traveltimes (
trans_dest,
trans_duration,
minimise_transfers,
start_time_min,
false, // !is_start
iso);

if (stations.find (trans_dest) !=
Expand Down Expand Up @@ -359,6 +385,8 @@ void iso::fill_one_transfer (
const size_t &trans_dest,
const int &trans_duration,
const bool &minimise_transfers,
const int &start_time,
const bool &is_start,
Iso &iso)
{
const int trans_time = arrival_time + trans_duration;
Expand All @@ -372,7 +400,7 @@ void iso::fill_one_transfer (
insert_transfer = iso::is_transfer_in_isochrone (
iso, arrival_station, trans_time);

if (!insert_transfer)
if (!insert_transfer && !is_start)
return;

if (iso.earliest_departure [trans_dest] == INFINITE_INT ||
Expand Down Expand Up @@ -417,14 +445,19 @@ void iso::fill_one_transfer (
}

iso.connections [trans_dest].convec [s].ntransfers = ntransfers + 1;
if (is_start)
{
latest_initial = start_time;
}
iso.connections [trans_dest].convec [s].initial_depart = latest_initial;

DEBUGMSGTR("---TR: (" << arrival_station << " -> " <<
trans_dest << "), time(" <<
arrival_time << " -> " <<
trans_time << ") - " << latest_initial <<
" = " << trans_time - latest_initial <<
"s with " << ntransfers << " transfers",
"s with " << ntransfers << " transfers" <<
"; INITIAL DEPART = " << latest_initial,
trans_dest, arrival_time);
}

Expand Down

0 comments on commit 83f178d

Please sign in to comment.