3.1. Query Algorithm
We shall now present our query algorithm, named MDTM-QH, for solving EAP on a MDTM graph, G. An EA query is answered by executing a modified Dijkstra’s algorithm on G, starting from the switch node of stop S.
Before discussing the details of our algorithm, we first describe the additional data structures used by MDTM-QH with respect to the classic Dijkstra’s algorithm. In particular, for each switch node of a stop, algorithm MDTM-QH maintains a set of earliest arrival index tables, whose construction and contents are described below.
Each departure node d is associated with a departure time and an arrival time . In general, all the departure nodes with the same departure stop can be ordered either by departure time or arrival time at an arrival stop. The first ordering favors an efficient search on the departure nodes to get the valid routes which have a valid departure time, i.e., a departure time greater than or equal to at which time the traveler is at . The second ordering favors an efficient search on the departure nodes on the optimal routes which provide the earliest arrival times to their adjacent stops. The second ordering is already applied within the existing ( and ) departure groups of G. However, we would also like to have the advantage of the first ordering. Therefore, for the purpose of effectively searching the departure nodes that both have valid departure times from stop and earliest arrival times to an adjacent arrival stop , we introduce the earliest arrival index tables.
Let denote an earliest arrival index table, consisting of departure nodes with departure stop , arrival stop , and transport mode M. is constructed as follows: Let be the sequence of the departure nodes, ordered by arrival time at , for a trip departing from stop and arriving at stop with transport mode M. Initially, is empty. Node is inserted in and is the current max departure time. Afterwards, for , if , then and is inserted at the end of the table; otherwise, is skipped. If the table contains the departure nodes , , and for some i, , then is the first departure node to start the search of the earliest arrival time at . This allows us to bypass the departure nodes, before in the arrival ordered sequence, with departure times less than .
Table 1 shows the contents of table
, for the example shown in
Figure 2. If a traveler has arrived or has started their journey from stop
at time
, then to continue at the adjacent stop
, the search of valid and optimal path-solutions can start after the departure node 20.
To reduce the size and the operations in the priority queue of the query algorithm, we inserted in it only the switch nodes and changed the arc relaxation as described below (iteration step). The MDTM-QH algorithm works as follows.
Initialization. The switch node of the origin stop is inserted in the priority queue, with distance and time . During the algorithm execution, provided that the traveler is already at at time the minimum transfer time of is set to .
Iteration. At each step, a switch node is extracted from the priority queue. The node is settled, having got the earliest arrival time for the optimal journey departing from at time and arriving to at time . Then, the algorithm relaxes the outgoing arcs of following a node filtering and blocking process:
- (i)
Using the existing grouping of departure nodes ( and ), the departure node groups corresponding to non-selected transportation modes are skipped.
- (ii)
Using the earliest arrival index tables, the algorithm can skip the departure nodes of stop that have an earlier than departure time, or they provide non-optimal arrival times to the next adjacent stops. In particular, after is extracted, then for each adjacent arrival stop of stop and for each enabled transport mode :
- (1)
A binary search is performed on the index table for getting the first departure node with that provides the earliest arrival time at stop .
- (2)
An arc relaxation step is performed based on those departure nodes.
Let the sequence of the outgoing switch arcs of be , which corresponds to travel using the transport mode M and arriving at the stop . Let , , and let the node be the departure node that is returned by . Within the current time period , arcs can be safely skipped, because they provide earlier departures or non-optimal arrival paths from to . The first arc that is relaxed is . Provided that the next switch arcs and their departure node heads are ordered by arrival time, the algorithm relaxes the arcs (relaxation of arcs after might be required, since the journey may continue on the next day) and it stops as soon as it falls over a departure node with (a) and (b) . The first condition ensures the minimum transfer time for the traveler in using a different vehicle to continue his/her travel. The second condition ensures that we will not miss optimal paths in with no transfer.
In all cases, if the departure node head of the switch arc is visited for the first time, or it has a greater distance assigned during a previous step, then we set and . When the distance is updated, the algorithm also relaxes the outgoing arcs of the departure node . For its outgoing arc , if is visited for the first time or it has, from a previous step, a greater distance, then we set . If there is also a vehicle (departure-departure) arc , then for the associated vehicle we also relax the outgoing arcs of the departure nodes at the next stops at which the vehicle passes along the same route. In that case, we can stop if we fall over a departure which has an outgoing arc to a switch node which has not yet been visited or extracted from the priority queue. The algorithm finishes when the switch node of the destination stop is settled.
The MDTM-QH algorithm can be adapted to answer MNT queries by setting the weight of all switch-departure arcs to 1 (representing a transfer between vehicles) and the weight of the rest of the arcs to 0.
3.2. Improved Query Algorithm
In order to boost the performance of the query algorithm
MDTM-QH, we adapted the ALT heuristic [
17]. The combined algorithm is named
MDTM-QH-ALT. ALT is a goal-directed technique—that is, its main aim is that of pushing the shortest-path search faster towards the target stop
t. This is achieved by adding a
feasible potential to the priority-key of each node in the priority queue. The feasible potentials are computed as follows. Given a set of nodes
called
landmarks, the feasible potential of a node
towards a target
t is computed as
. By the triangle inequality, it follows that
is a lower bound to the distance
and this is enough to prove the correctness of the shortest path algorithm (see [
17] for more details). Now, the exploration and settlement of the nodes when running Dijkstra’s algorithm to compute a shortest path from a source node
s to a target node
t is done using the priority
for a node
u, instead of
which is used in the classical Dijkstra’s algorithm. It is easy to see that the tighter the lower bounds are, the more narrow the search space becomes—that is, the faster the query algorithm finds the shortest path. Therefore, choosing good landmarks that provide tight lower bounds is a fundamental part of the preprocessing phase of ALT.
As in [
10], we apply in MDTM an approach similar to that proposed in [
18]. In particular, we select as landmarks the switch nodes, each of which represents the arrival node group of a station. Therefore the lower bound distance,
, between two switch nodes,
and
, denotes the minimum travel time among connections traveling from station
A to station
B. These lower bound distances can be computed during a preprocessing phase by running single-source queries from each switch node. The tightest lower bounds can be obtained by storing all pair station distances
and by computing all-pairs shortest paths on the condensed version of the input graph (see [
18]). This makes sense, particularly when the stations are relatively few in number.
We combined ALT along with our query algorithm in
Section 3.1. This combination (
MDTM-QH-ALT) considerably reduces the search space and leads to a more efficient algorithm.
3.3. The Multicriteria Multimodal Query Algorithm
In order to provide best journeys for a vector of cost functions over the multimodal transport options, we introduce the
multicriteria extensions of
MDTM-QH and
MDTM-QH-ALT. In this case, in addition to computing journeys with a variety of transport modes, the optimal Pareto set of journeys is computed on the EA and MNT criteria (a set of pairwise non-dominating journeys, each of them being better to at least one objective criterion and no worse in all other criteria). Since it is possible that all Pareto-optimal journeys be exponential in number, we focus on finding a solution that minimizes MNT, while retaining the EA below a given threshold
P (a variant also considered in [
2]). Our multicriteria algorithm
McMDTM-QH is described below. Its combination with ALT will be called
McMDTM-QH-ALT.
Let be a multicriteria (EA, MNT) query, starting from the switch node of stop S. The number of transfers is taken into account by setting the weight of all switch-departure arcs to 1 (representing a transfer between vehicles) and the weight of the rest of the arcs to 0. Due to the modeling, every single switch node in MDTM can have at least as many Pareto-optimal solutions as its incoming arcs. Initially, the cost minimization is on EA. Therefore, when the target switch node is settled, we have found the first (EA,MNT) Pareto optimal journey of vector distance , with the minimum travel time , and the maximum number of transfers , which is an upper bound on the number of transfers for the rest of the Pareto-optimal solutions having travel times greater than . We then let Dijkstra’s algorithm continue; and whenever the target switch node is explored again with a smaller number of transfers then a new Pareto-optimal journey is found. The algorithm stops when all journey solutions with the shortest travel time to the target stop less than or equal to and transfers less than or equal to , have been found.
3.4. The Profile Query Algorithm
Let be a profile query, where we need to compute all Pareto-optimal journeys from S to T, given a departure time interval , departing from S within the time interval D and arriving at T, using any chosen transport mode, including walking (with free departure) or/and public transit (with non-free departures/arrivals). The domination rule is in relation to the earliest arrival time and latest departure time. The output solution is a set of departing time subintervals and their corresponding journeys that provide the minimum travel time.
Our algorithm, called PrMDTM-QH-ALT, consists of two phases.
In the first phase, the shortest path tree from S, using the slowest transport mode, i.e., walking, is computed. To achieve this, we run the MDTM-QH-ALT algorithm with root S and destination T, using only walking, skipping any boarding, and stopping when all switch nodes with are explored and settled, where denotes the walking distance metric, and . Let be the set of the candidate shortest path stops for the requested profile query.
In the second phase, the size of J is being considered. If J is empty, it means that there is no candidate stop for any departure time-point, and thus the shortest path by walk in the computed is the dominated solution in D. Otherwise, the shortest journeys may include at least one of the candidate stops in J. Starting with departure time , the MDTM-QH-ALT algorithm is executed, having the following preceding initialization step: the distances of the nodes are updated with respect to the departure time t, obtaining the corresponding arrival times. Those nodes are marked as already visited by the algorithm, and each candidate stop node in J is inserted into the priority queue.
The iteration steps of the algorithm are as follows. If the computed shortest journey from
S at
t towards
T has at least one boarding, then a public transit itinerary has been used. Let
be the earliest arrival time computed. In order to determine the latest departure
,
, that the traveler can reach
T at the earliest arrival time
, a backward query algorithm has to be performed [
19]. Specifically, the latest departure time at
S is computed by running a backward
MDTM-QH-ALT algorithm, where the root is
T, the incoming arcs of each settled node are traversed, and the stopping condition is the settlement of
S. The computed journey
provides a fixed minimum arrival time
in
, with
being the maximum waiting time in
S departing at
and the waiting time in
S becoming zero if the departing time is at
. Subsequently, we continue in the remaining interval
, where
denotes that the traveler cannot use the previously computed
path because it is invalid—that is, at least one boarding is past, and thus the next reachable boardings in
need to be found. The next departure time-point
t is set to
, and the process is repeated until
t reaches the last time-point,
. Finally, any computed journeys having travel times greater than
are discarded and replaced by the first-phase-computed shortest
path by walking.