• Keine Ergebnisse gefunden

Discussion: Time-Expanded Vs. Time-Dependent Models

Edges e∈T are calledtrain edges and edgese∈A∪D∪Dˆ are calledtransfer edges.

The modeling with train routes is based on the following assumption.

Assumption 4.2. For any two nodespui,pvj connected by a train edge (pui, pvj)∈T and departure timesτd, τd0 from pui, for the respective arrival timesτa, τa0 atpvj it holds that

τd≤τd0⇒τa≤τa0.

In other words, there is no train t1 serving the same connection as t2 which departs later than t2, overtakes t2, and arrives earlier than t2 at the next station. In case the assumption is violated the train route concerned is split into two (or more) different train routes, for example by separating the trains into different speed classes.

Using a graph constructed in this way a fastest connection can be calculated by a time-dependent variant of Dijkstra’s algorithm.

Further Extending the Time-Dependent-Model For more steps towards a realis-tic scenario we refer to the description of our prototype of a time-dependent timetable information system in Chapter10.

4.4 Discussion: Time-Expanded

Chapter 5

The MOTIS Algorithm

The MOTIS-algorithm basically is a multi-criteria version of Dijkstra’s algorithm as intro-duced in Chapter3on a graph based on a time-expanded graph model from the previous chapter. In this chapter, we will present the algorithm itself and some issues affecting graph model and algorithm likewise.

5.1 The Graph Model of MOTIS

5.1.1 Realistic Interchange Rules

All interchange rules introduced in Section 1.1 can be modeled using only the station dependent interchange time and service to service transfers by adding service to service transfers for all interchanges defined by transfers between transfer classes or lines.

If boarding is permitted we have anentering edge from the change node copy to the original departure node. If leaving a train is possible, we have oneleaving edgeconnecting the arrival node to the appropriate change node. Namely the node at the time from which on all other events are reachable, i.e. the time difference of this node to the arrival is the maximum over the interchange times required by all change rules concerning this train at this station. For all trains reachable before this point in time we havespecial-interchange edges from the arrival to the departure nodes of the corresponding trains.

Example See Fig.5.1for an exemplary excerpt. It is easy to see that we have indeed covered all interchange rules. Arriving with train t we can either stay-in-train t (use stay-in-train edge e) or change to t which is possible due to some interchange rule e.g.

service to service transfer (special-interchange edgef). However, we can not take t0 (for example, if the minimum interchange time at the station does not allow this). Therefore, we needed the special interchange edge to reach t and not to reacht0 from t although enteringt0is allowed from the change level. Every event from timebon is again reachable (using leaving edgegto the change node at timeb), e.g., we can take traint00(via entering edgeh).

5.1.2 Traffic Days

Recall that not all trains operate on a daily basis, e.g. some only on workdays, others only on Sundays. To correctly model the traffic days of trains and still achieve a bearable

41

t*

t’

t’

t

t

t’’

change departure arrival

f

g e

h b a

time

Figure 5.1: Example for the time-expanded model with change nodes and special-interchange edges.

memory footprint, the days of operation are coded into the train edges only. All time values of nodes are taken modulo a single day (more precisely 1440 minutes, as the granularity of the schedule is one minute). During construction of the graph, an additional waiting edge from the last change node before to the first change node after midnight.

Let tu, tv be the time stamps of two nodes u, v, respectively. Then the length of edge (u, v)∈E istv−tu (mod 1440).

We maintain the exact time t throughout the execution of the algorithm (i.e. not only modulo a single day). Every time an edge is considered the exact departure time is known. The time of day is determined byt mod 1440 and the traffic day isbt/1440c.

A look-up in the traffic days of the involved train shows whether the edge is available at that day or can be ignored.

5.1.3 Footpaths

Inserting all the footpaths into the graph straightforwardly would result in a tremendous increase in the number of edges, as we would have to insert all footpaths of a station directly “behind” each arrival event. To avoid this problem the idea is to store the footpaths at the station and calculate the correct arrival node at the target stationS of the footpath with a search in the node list of stationS. Thus, the footpaths are inserted without time dependency. They are always available and have constant length.

We calculate the reflexive, transitive hull of the “footpath-relation” using a textbook version of Floyd-Warshall algorithm (Algorithm6). To this end we set the walking time from station SX to stationSX to zero and remove these loops afterwards. Using this modified “footpath-relation” we never need to consider more than one footpath in a row without traveling edges in between and still find all feasible connections containing any number of footpaths.

5.1 The Graph Model of MOTIS 43

Input : DigraphG= (V ={1, ..., n}, E) with nonnegative edge weights 0< `ij <∞for all (i, j)∈E.

Output: A matrixD= (dij)1≤i,j≤n wheredij is the length of a shortest path from itoj if it exists anddij =∞otherwise.

fori, j∈V do dij:=

0 : i=j

`ij : (i, j)∈E

−∞ : otherwise

; forj:= 1 tondo

fori:= 1 tondo if i6=j then fork:= 1 tondo if k6=j then

dik= max{dik, dij+djk};

returnD;

Algorithm 6: Floyd-Warshall algorithm.

Masking in Iterators Footpaths virtually connect arrival nodes to change-departure nodes. The footpaths of a station are stored once per station. They are only considered when iterating over the leaving edges of an arrival node.

Start Labels after Footpaths Footpaths affect the creation of start labels, as well.

Consider the departure interval specified to be [τf irst, τlast] and the footpathsf1, . . . , fk, k >0 from the departure stationAto the stationsS1, . . . Skin timeτ1, . . . , τk. We collect all departure eventsdSji at stationSi with departure time in [τf irsti, τlasti]. Start labels for the eventsdSji need to be initialized with the durationτiof footpathfi and the footpath as first travel edge, whereas all other start labels do not have a first travel edge.

5.1.4 Edge Lengths for the Criteria

We associate component-wise non-negative cost vectors to the edges. Here we describe only the choice for forward search, the necessary modifications for backward search should be obvious.

travel time For the cost criterion travel time, the cost for edgee= (v, w) is the difference between the timestamps of the nodeswandv.

number of interchanges For the cost criterion number of train changes, all entering edges and all special-interchange edges get a cost value of 1, and all other edges a value of 0.

ticket cost Ticket costs are more difficult to handle:

Pricing systems of railway companies are very complex. Unfortunately, ticket costs are typically not proportional to the distance traveled. In distance-based fares the cost of the distance traveled in one train depends not only on the number of kilometers but also on its train class and other train classes used in the connection.

Additionally, there are relation-based fares for which origin-destination pairs and regional corridors determine the cost. Currently there are different supplementary fares for the different higher speed train classes. For more details see our discussion

of regular fares in Section6.2.2. Furthermore, the system undergoes rapid change.

In building timetable information systems it should not be the task to rebuild pricing components.

To be resistant to the changes in the pricing system (to some degree) we have a black-box pricing component (BPC) that can be used to calculate the ticket cost for some connection. Unfortunately, one call to this black-box routine is very costly:

The path information stored in labels has to be converted into structures for the BPC. Much additional information like attributes on the train edges has to be set to get a correct price. Therefore, it is not at all possible to calculate the correct price for every label and achieve a bearable runtime.

As a consequence we use price estimates in the labels that are updated during the search. The distance between the two stations of a train edge is taken as the straight line distance obtained from the coordinates of the stations. For every train edge the price estimate is increased by the distance times a factor depending on the train class used. The supplementary fare is paid once and only for the highest train class involved.

This simplified model provides helpful estimates for the search. After a search is completed, all connections are correctly priced by the BPC and advanced Pareto dominance can be applied to true fares.

Here another benefit of the Pareto relaxation (compare Section2.3.1) comes into play, enabling us to model some exceptions: For example, there might be a special offer (like

“Sch¨ones-Wochenende-Ticket” in Germany) for traveling on weekends for a fixed price independent of the distance but valid only on non-high speed trains. The relaxation allows us to make connections using no high speed trains and connections with high speed trains on weekends incomparable. We come back to the edge lengths regarding ticket cost in Section6.2when talking about special offers.

In Chapter6 we will introduce some additional criteria and how the edge lengths for these are defined and calculated.

5.1.5 Attributes NotIn/NotOut

Handling the special attributes forbidding boarding or disembarkment of a train at one of its stops during the execution of the algorithm calls for many exceptional rules:

1. We may not enter a train, if boarding is not allowed.

2. We may not leave a train, if disembarkment is not allowed.

3. If we reach our destination but may not leave the used train, we have to continue our journey until we reach the destination again (and are allowed to leave the train).

4. No start label is to be created for a departure event at stationAwhere boarding is not allowed.

The first two problems can be solved on the graph level: If boarding a train is not allowed, the corresponding departure event has no entering edge. Analogously, if disem-barkment is not allowed, the corresponding arrival event has no leaving edge.

The last two issues are treated in the algorithm itself: Whenever a label at (one of the) terminal station(s) is created, we only consider the terminal as “reached” (and thus

5.2 Algorithm Refinements 45